Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Release v0.22.0 #2792

Merged
merged 47 commits into from
Jan 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
47 commits
Select commit Hold shift + click to select a range
4dd9d35
cleanup script
abhishek9686 Jan 18, 2024
abe7f4c
upgrade flag
abhishek9686 Jan 18, 2024
6749fb4
add trial license logic
abhishek9686 Jan 19, 2024
5b7d170
remvove license input on pro in script
abhishek9686 Jan 19, 2024
c674929
invoke trial from main
abhishek9686 Jan 19, 2024
040e700
revamp pro trial invocation
abhishek9686 Jan 19, 2024
34e6140
fix build
abhishek9686 Jan 19, 2024
ffb9790
store trial as bytes
abhishek9686 Jan 19, 2024
e390398
conv key pair to bytes
abhishek9686 Jan 19, 2024
7a39ef3
add trial end date to server status api
abhishek9686 Jan 19, 2024
17980cc
get trial end date only if license key is missing
abhishek9686 Jan 19, 2024
dbc48b1
check if trial table is empty
abhishek9686 Jan 22, 2024
5b335fb
add upgrade and downgrade options
abhishek9686 Jan 22, 2024
49641df
fix script args
abhishek9686 Jan 22, 2024
49c64ef
save config only if values are not empty
abhishek9686 Jan 22, 2024
cf9febb
fix script args
abhishek9686 Jan 22, 2024
dc953c7
fix script args
abhishek9686 Jan 22, 2024
c16ea48
fix script args
abhishek9686 Jan 22, 2024
ce34a3f
more info log
abhishek9686 Jan 22, 2024
96c6495
check if netclient exists
abhishek9686 Jan 23, 2024
1f44817
add tenantid check
abhishek9686 Jan 23, 2024
487c3f5
addtional logs in script
abhishek9686 Jan 23, 2024
32974e2
skip trial end date check on err
abhishek9686 Jan 23, 2024
1d25096
add license logs
abhishek9686 Jan 23, 2024
2a4d04c
limit api handler if trail has ended
abhishek9686 Jan 23, 2024
4fe282d
add trial license status to server status api
abhishek9686 Jan 23, 2024
13caec2
get pro override compose only on upgrade
abhishek9686 Jan 23, 2024
a57c669
turn of exporter only on upgrade
abhishek9686 Jan 23, 2024
b7e900f
turn of exporter only on upgrade
abhishek9686 Jan 23, 2024
c2eb662
rm overeride file if present
abhishek9686 Jan 23, 2024
1e90772
rm overide file if present
abhishek9686 Jan 23, 2024
1a17f4e
script fixes
abhishek9686 Jan 23, 2024
17a6392
image tag for testing
abhishek9686 Jan 23, 2024
a446c50
check for pro, if host is getting relayed
abhishek9686 Jan 23, 2024
c690eb1
mover failOver func to pro pkg
abhishek9686 Jan 23, 2024
baaba59
check for pro, if host is getting relayed
abhishek9686 Jan 23, 2024
c67571e
on upgrade and downgrade of tier perisist image tag
abhishek9686 Jan 24, 2024
f535722
avoid pull new config on upgrade and downgrade
abhishek9686 Jan 24, 2024
4a0ec26
get override files on upgrade
abhishek9686 Jan 24, 2024
2164797
copy build tag
abhishek9686 Jan 24, 2024
69dd212
fix upgrade and downgrade
abhishek9686 Jan 24, 2024
dc6ffe1
fix upgrade and downgrade
abhishek9686 Jan 24, 2024
0298532
fix upgrade and downgrade
abhishek9686 Jan 24, 2024
330c230
fix upgrade and downgrade
abhishek9686 Jan 24, 2024
5f20383
replace readthedocs url
abhishek9686 Jan 24, 2024
7a36b93
change trial period to 14 days
abhishek9686 Jan 24, 2024
1d1b9bb
Merge pull request #2786 from gravitl/NET-898
abhishek9686 Jan 24, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ If you're just looking to use Netmaker, you can create an account for free at [n

# Self-Hosted Quick Start

These are the instructions for deploying a Netmaker server on your own cloud VM as quickly as possible. For more detailed instructions, visit the [Install Docs](https://netmaker.readthedocs.io/en/master/install.html).
These are the instructions for deploying a Netmaker server on your own cloud VM as quickly as possible. For more detailed instructions, visit the [Install Docs](https://docs.netmaker.io/install.html).

1. Get a cloud VM with Ubuntu 22.04 and a public IP.
2. Open ports 443, 80, 3479, 8089 and 51821-51830/udp on the VM firewall and in cloud security settings.
Expand All @@ -68,7 +68,7 @@ This script gives you the option to deploy the Community or Enterprise version o
<img src="https://raw.githubusercontent.com/gravitl/netmaker-docs/master/images/netmaker-github/readme.gif" />
</p>

After installing Netmaker, check out the [Walkthrough](https://itnext.io/getting-started-with-netmaker-a-wireguard-virtual-networking-platform-3d563fbd87f0) and [Getting Started](https://netmaker.readthedocs.io/en/master/getting-started.html) guides to learn more about configuring networks. Or, check out some of our other [Tutorials](https://www.netmaker.io/blog) for different use cases, including Kubernetes.
After installing Netmaker, check out the [Walkthrough](https://itnext.io/getting-started-with-netmaker-a-wireguard-virtual-networking-platform-3d563fbd87f0) and [Getting Started](https://docs.netmaker.io/getting-started.html) guides to learn more about configuring networks. Or, check out some of our other [Tutorials](https://www.netmaker.io/blog) for different use cases, including Kubernetes.

# Get Support

Expand Down
33 changes: 24 additions & 9 deletions controllers/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"net/http"
"strings"
"syscall"
"time"

"github.com/gorilla/mux"
"golang.org/x/exp/slog"
Expand Down Expand Up @@ -109,22 +110,36 @@ func getUsage(w http.ResponseWriter, _ *http.Request) {
// 200: serverConfigResponse
func getStatus(w http.ResponseWriter, r *http.Request) {
type status struct {
DB bool `json:"db_connected"`
Broker bool `json:"broker_connected"`
LicenseError string `json:"license_error"`
IsPro bool `json:"is_pro"`
DB bool `json:"db_connected"`
Broker bool `json:"broker_connected"`
LicenseError string `json:"license_error"`
IsPro bool `json:"is_pro"`
TrialEndDate time.Time `json:"trial_end_date"`
IsOnTrialLicense bool `json:"is_on_trial_license"`
}

licenseErr := ""
if servercfg.ErrLicenseValidation != nil {
licenseErr = servercfg.ErrLicenseValidation.Error()
}

var trialEndDate time.Time
var err error
isOnTrial := false
if servercfg.IsPro && (servercfg.GetLicenseKey() == "" || servercfg.GetNetmakerTenantID() == "") {
trialEndDate, err = logic.GetTrialEndDate()
if err != nil {
slog.Error("failed to get trial end date", "error", err)
} else {
isOnTrial = true
}
}
currentServerStatus := status{
DB: database.IsConnected(),
Broker: mq.IsConnected(),
LicenseError: licenseErr,
IsPro: servercfg.IsPro,
DB: database.IsConnected(),
Broker: mq.IsConnected(),
LicenseError: licenseErr,
IsPro: servercfg.IsPro,
TrialEndDate: trialEndDate,
IsOnTrialLicense: isOnTrial,
}

w.Header().Set("Content-Type", "application/json")
Expand Down
44 changes: 22 additions & 22 deletions database/database.go
Original file line number Diff line number Diff line change
Expand Up @@ -124,29 +124,29 @@ func InitializeDatabase() error {
}

func createTables() {
createTable(NETWORKS_TABLE_NAME)
createTable(NODES_TABLE_NAME)
createTable(CERTS_TABLE_NAME)
createTable(DELETED_NODES_TABLE_NAME)
createTable(USERS_TABLE_NAME)
createTable(DNS_TABLE_NAME)
createTable(EXT_CLIENT_TABLE_NAME)
createTable(PEERS_TABLE_NAME)
createTable(SERVERCONF_TABLE_NAME)
createTable(SERVER_UUID_TABLE_NAME)
createTable(GENERATED_TABLE_NAME)
createTable(NODE_ACLS_TABLE_NAME)
createTable(SSO_STATE_CACHE)
createTable(METRICS_TABLE_NAME)
createTable(NETWORK_USER_TABLE_NAME)
createTable(USER_GROUPS_TABLE_NAME)
createTable(CACHE_TABLE_NAME)
createTable(HOSTS_TABLE_NAME)
createTable(ENROLLMENT_KEYS_TABLE_NAME)
createTable(HOST_ACTIONS_TABLE_NAME)
CreateTable(NETWORKS_TABLE_NAME)
CreateTable(NODES_TABLE_NAME)
CreateTable(CERTS_TABLE_NAME)
CreateTable(DELETED_NODES_TABLE_NAME)
CreateTable(USERS_TABLE_NAME)
CreateTable(DNS_TABLE_NAME)
CreateTable(EXT_CLIENT_TABLE_NAME)
CreateTable(PEERS_TABLE_NAME)
CreateTable(SERVERCONF_TABLE_NAME)
CreateTable(SERVER_UUID_TABLE_NAME)
CreateTable(GENERATED_TABLE_NAME)
CreateTable(NODE_ACLS_TABLE_NAME)
CreateTable(SSO_STATE_CACHE)
CreateTable(METRICS_TABLE_NAME)
CreateTable(NETWORK_USER_TABLE_NAME)
CreateTable(USER_GROUPS_TABLE_NAME)
CreateTable(CACHE_TABLE_NAME)
CreateTable(HOSTS_TABLE_NAME)
CreateTable(ENROLLMENT_KEYS_TABLE_NAME)
CreateTable(HOST_ACTIONS_TABLE_NAME)
}

func createTable(tableName string) error {
func CreateTable(tableName string) error {
return getCurrentDB()[CREATE_TABLE].(func(string) error)(tableName)
}

Expand Down Expand Up @@ -194,7 +194,7 @@ func DeleteAllRecords(tableName string) error {
if err != nil {
return err
}
err = createTable(tableName)
err = CreateTable(tableName)
if err != nil {
return err
}
Expand Down
47 changes: 14 additions & 33 deletions logic/peers.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@ var (
ResetFailedOverPeer = func(failedOverNode *models.Node) error {
return nil
}
// GetFailOverPeerIps - gets failover peerips
GetFailOverPeerIps = func(peer, node *models.Node) []net.IPNet {
return []net.IPNet{}
}
)

// GetPeerUpdateForHost - gets the consolidated peer update for the host from all networks
Expand Down Expand Up @@ -144,16 +148,18 @@ func GetPeerUpdateForHost(network string, host *models.Host, allNodes []models.N
hostPeerUpdate.EgressRoutes = append(hostPeerUpdate.EgressRoutes, getExtpeersExtraRoutes(peer.Network)...)
}
_, isFailOverPeer := node.FailOverPeers[peer.ID.String()]
if (node.IsRelayed && node.RelayedBy != peer.ID.String()) ||
(peer.IsRelayed && peer.RelayedBy != node.ID.String()) || isFailOverPeer {
// if node is relayed and peer is not the relay, set remove to true
if _, ok := peerIndexMap[peerHost.PublicKey.String()]; ok {
if servercfg.IsPro {
if (node.IsRelayed && node.RelayedBy != peer.ID.String()) ||
(peer.IsRelayed && peer.RelayedBy != node.ID.String()) || isFailOverPeer {
// if node is relayed and peer is not the relay, set remove to true
if _, ok := peerIndexMap[peerHost.PublicKey.String()]; ok {
continue
}
peerConfig.Remove = true
hostPeerUpdate.Peers = append(hostPeerUpdate.Peers, peerConfig)
peerIndexMap[peerHost.PublicKey.String()] = len(hostPeerUpdate.Peers) - 1
continue
}
peerConfig.Remove = true
hostPeerUpdate.Peers = append(hostPeerUpdate.Peers, peerConfig)
peerIndexMap[peerHost.PublicKey.String()] = len(hostPeerUpdate.Peers) - 1
continue
}

uselocal := false
Expand Down Expand Up @@ -362,31 +368,6 @@ func GetAllowedIPs(node, peer *models.Node, metrics *models.Metrics) []net.IPNet
return allowedips
}

func GetFailOverPeerIps(peer, node *models.Node) []net.IPNet {
allowedips := []net.IPNet{}
for failOverpeerID := range node.FailOverPeers {
failOverpeer, err := GetNodeByID(failOverpeerID)
if err == nil && failOverpeer.FailedOverBy == peer.ID {
if failOverpeer.Address.IP != nil {
allowed := net.IPNet{
IP: failOverpeer.Address.IP,
Mask: net.CIDRMask(32, 32),
}
allowedips = append(allowedips, allowed)
}
if failOverpeer.Address6.IP != nil {
allowed := net.IPNet{
IP: failOverpeer.Address6.IP,
Mask: net.CIDRMask(128, 128),
}
allowedips = append(allowedips, allowed)
}

}
}
return allowedips
}

func GetEgressIPs(peer *models.Node) []net.IPNet {

peerHost, err := GetHost(peer.HostID.String())
Expand Down
40 changes: 6 additions & 34 deletions logic/serverconf.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ package logic

import (
"encoding/json"
"time"

"github.com/gravitl/netmaker/database"
"github.com/gravitl/netmaker/servercfg"
)
Expand All @@ -19,46 +21,16 @@ var (
EgressesLimit = 1000000000
// FreeTier - specifies if free tier
FreeTier = false

GetTrialEndDate = func() (time.Time, error) {
return time.Time{}, nil
}
)

type serverData struct {
PrivateKey string `json:"privatekey,omitempty" bson:"privatekey,omitempty"`
}

// StorePrivKey - stores server client WireGuard privatekey if needed
func StorePrivKey(serverID string, privateKey string) error {
var newData = serverData{}
var err error
var data []byte
newData.PrivateKey = privateKey
data, err = json.Marshal(&newData)
if err != nil {
return err
}
return database.Insert(serverID, string(data), database.SERVERCONF_TABLE_NAME)
}

// FetchPrivKey - fetches private key
func FetchPrivKey(serverID string) (string, error) {
var dbData string
var err error
var fetchedData = serverData{}
dbData, err = database.FetchRecord(database.SERVERCONF_TABLE_NAME, serverID)
if err != nil {
return "", err
}
err = json.Unmarshal([]byte(dbData), &fetchedData)
if err != nil {
return "", err
}
return fetchedData.PrivateKey, nil
}

// RemovePrivKey - removes a private key
func RemovePrivKey(serverID string) error {
return database.DeleteRecord(database.SERVERCONF_TABLE_NAME, serverID)
}

// FetchJWTSecret - fetches jwt secret from db
func FetchJWTSecret() (string, error) {
var dbData string
Expand Down
12 changes: 6 additions & 6 deletions logic/telemetry.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,12 @@ func sendTelemetry() error {
return nil
}

var telRecord, err = fetchTelemetryRecord()
var telRecord, err = FetchTelemetryRecord()
if err != nil {
return err
}
// get telemetry data
d, err := fetchTelemetryData()
d, err := FetchTelemetryData()
if err != nil {
return err
}
Expand Down Expand Up @@ -71,8 +71,8 @@ func sendTelemetry() error {
})
}

// fetchTelemetry - fetches telemetry data: count of various object types in DB
func fetchTelemetryData() (telemetryData, error) {
// FetchTelemetryData - fetches telemetry data: count of various object types in DB
func FetchTelemetryData() (telemetryData, error) {
var data telemetryData

data.IsPro = servercfg.IsPro
Expand Down Expand Up @@ -138,8 +138,8 @@ func getClientCount(nodes []models.Node) clientCount {
return count
}

// fetchTelemetryRecord - get the existing UUID and Timestamp from the DB
func fetchTelemetryRecord() (models.Telemetry, error) {
// FetchTelemetryRecord - get the existing UUID and Timestamp from the DB
func FetchTelemetryRecord() (models.Telemetry, error) {
var rawData string
var telObj models.Telemetry
var err error
Expand Down
7 changes: 4 additions & 3 deletions logic/timer.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,12 @@ package logic
import (
"context"
"fmt"
"github.com/gravitl/netmaker/logger"
"golang.org/x/exp/slog"
"sync"
"time"

"github.com/gravitl/netmaker/logger"
"golang.org/x/exp/slog"

"github.com/gravitl/netmaker/models"
)

Expand All @@ -24,7 +25,7 @@ var HookManagerCh = make(chan models.HookDetails, 3)
// TimerCheckpoint - Checks if 24 hours has passed since telemetry was last sent. If so, sends telemetry data to posthog
func TimerCheckpoint() error {
// get the telemetry record in the DB, which contains a timestamp
telRecord, err := fetchTelemetryRecord()
telRecord, err := FetchTelemetryRecord()
if err != nil {
return err
}
Expand Down
4 changes: 2 additions & 2 deletions logic/traffic.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package logic

// RetrievePrivateTrafficKey - retrieves private key of server
func RetrievePrivateTrafficKey() ([]byte, error) {
var telRecord, err = fetchTelemetryRecord()
var telRecord, err = FetchTelemetryRecord()
if err != nil {
return nil, err
}
Expand All @@ -12,7 +12,7 @@ func RetrievePrivateTrafficKey() ([]byte, error) {

// RetrievePublicTrafficKey - retrieves public key of server
func RetrievePublicTrafficKey() ([]byte, error) {
var telRecord, err = fetchTelemetryRecord()
var telRecord, err = FetchTelemetryRecord()
if err != nil {
return nil, err
}
Expand Down
Loading