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

v0.20.3 #2435

Merged
merged 54 commits into from
Jul 3, 2023
Merged

v0.20.3 #2435

Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
54 commits
Select commit Hold shift + click to select a range
b9a18cf
remove stun
afeiszli Jun 13, 2023
637f840
Update common.go
Jun 16, 2023
59da269
Update common.go
Jun 16, 2023
4ea0991
Merge branch 'develop' into NET-341/dont-panic
Jun 20, 2023
9787ce6
fix(NET-312): increase log levels for verbose logs (#2403)
Aceix Jun 20, 2023
161e1d3
Bump golang.org/x/crypto from 0.9.0 to 0.10.0 (#2406)
dependabot[bot] Jun 21, 2023
52221fe
Bump alpine from 3.18.0 to 3.18.2 (#2408)
dependabot[bot] Jun 21, 2023
2cc0da3
update develop to v0.20.3 (#2412)
theguy951357 Jun 21, 2023
5950ded
Bump golang.org/x/oauth2 from 0.8.0 to 0.9.0 (#2407)
dependabot[bot] Jun 21, 2023
6e39ae4
add domain flag to nm-quick (#2416)
mattkasun Jun 22, 2023
11933fc
Don't expose user hashed password (#2419)
gabrielseibel1 Jun 26, 2023
aca65cf
Net 374 (#2420)
mattkasun Jun 26, 2023
34c56d5
Revert "prevent ingress creation on NATed host (#2395)" (#2422)
Aceix Jun 27, 2023
4071bb2
db cache nodes and hosts
abhishek9686 Jun 25, 2023
3072031
unexport cache funcs
abhishek9686 Jun 26, 2023
27ac920
cache acls
abhishek9686 Jun 26, 2023
0c06e2b
Merge branch 'NET-341/dont-panic' of https://github.com/gravitl/netma…
abhishek9686 Jun 27, 2023
50e093b
cache ext clients
abhishek9686 Jun 27, 2023
845bb33
unlock mutex
abhishek9686 Jun 27, 2023
65a683a
rm return
abhishek9686 Jun 27, 2023
cfdc15f
fix integration tests
abhishek9686 Jun 27, 2023
243cc74
remove endpoint detection from host model
abhishek9686 Jun 27, 2023
8d874b8
set mq order matters to false
abhishek9686 Jun 28, 2023
b4081f4
use mutex for accessing acl container
abhishek9686 Jun 28, 2023
8461735
fix(NET-379): send host NAT type over api (#2423)
Aceix Jun 28, 2023
230e062
GRA-1298: License check changes, free tier limits for saas (#2418)
abhishek9686 Jun 28, 2023
4efbe62
stop context cancel on peer updates
abhishek9686 Jun 28, 2023
1a67b4e
Merge branch 'NET-390-endpointdetection-config-fix' of https://github…
abhishek9686 Jun 28, 2023
38454ec
IOT-66: Single Peer update for IOT client (#2424)
abhishek9686 Jun 28, 2023
eca3a16
broadcast port changes
abhishek9686 Jun 28, 2023
b64cef3
fix merge conflicts
abhishek9686 Jun 28, 2023
a7acb5d
Merge pull request #2426 from gravitl/NET-390-endpointdetection-confi…
afeiszli Jun 28, 2023
950a303
Merge branch 'develop' of https://github.com/gravitl/netmaker into NE…
abhishek9686 Jun 28, 2023
e4895ae
Merge branch 'develop' into remove-stun
afeiszli Jun 28, 2023
2db6004
Update docker-compose.yml
afeiszli Jun 28, 2023
ae92499
Merge pull request #2427 from gravitl/NET-390-acl-panic-fix
afeiszli Jun 28, 2023
5857ff4
Merge branch 'develop' into remove-stun
afeiszli Jun 28, 2023
c53386d
Merge branch 'develop' of https://github.com/gravitl/netmaker into NE…
abhishek9686 Jun 28, 2023
086ef25
remove peer update context
abhishek9686 Jun 28, 2023
0046bae
Merge pull request #2396 from gravitl/remove-stun
afeiszli Jun 28, 2023
68c7b20
additional mutex locks for acls
abhishek9686 Jun 28, 2023
5015da3
rm commented code
abhishek9686 Jun 28, 2023
ef6e66f
acl mutex on ISAllowed
abhishek9686 Jun 28, 2023
ae1cd94
remove stun refs
mattkasun Jun 28, 2023
d5ed8ec
Merge branch 'develop' into remove-stun
mattkasun Jun 28, 2023
f68158f
Merge pull request #2429 from gravitl/remove-stun
afeiszli Jun 29, 2023
70a8d0e
Merge pull request #2428 from gravitl/NET-390-scale-latest
afeiszli Jun 29, 2023
5809118
unset all relayed node when relay node is deleted
abhishek9686 Jun 30, 2023
90c372b
unset relay fields before node deletion
abhishek9686 Jun 30, 2023
25bc108
Merge pull request #2433 from gravitl/relay_bug
afeiszli Jun 30, 2023
818fabd
removed egress range twice bug.
theguy951357 Jul 3, 2023
c94a6f6
Update release.md
afeiszli Jul 3, 2023
cd4bd58
Merge pull request #2434 from gravitl/v0.20.3_release_notes
afeiszli Jul 3, 2023
c6ca393
Merge branch 'master' into release-v0.20.3
theguy951357 Jul 3, 2023
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
1 change: 1 addition & 0 deletions .github/ISSUE_TEMPLATE/bug-report.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ body:
label: Version
description: What version are you running?
options:
- v0.20.3
- v0.20.2
- v0.20.1
- v0.20.0
Expand Down
4 changes: 3 additions & 1 deletion .github/workflows/branchtest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,9 @@ jobs:
if [ "$result" == "pass" ]
then
server=$arg
echo server >> /tmp/server

echo $server >> /tmp/server

break
fi
done
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ COPY . .

RUN GOOS=linux CGO_ENABLED=1 go build -ldflags="-s -w " -tags ${tags} .
# RUN go build -tags=ee . -o netmaker main.go
FROM alpine:3.18.0
FROM alpine:3.18.2

# add a c lib
# set the working directory
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile-quick
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#first stage - builder
FROM alpine:3.18.0
FROM alpine:3.18.2
ARG version
WORKDIR /app
COPY ./netmaker /root/netmaker
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

<p align="center">
<a href="https://github.com/gravitl/netmaker/releases">
<img src="https://img.shields.io/badge/Version-0.20.2-informational?style=flat-square" />
<img src="https://img.shields.io/badge/Version-0.20.3-informational?style=flat-square" />
</a>
<a href="https://hub.docker.com/r/gravitl/netmaker/tags">
<img src="https://img.shields.io/docker/pulls/gravitl/netmaker?label=downloads" />
Expand Down
2 changes: 1 addition & 1 deletion compose/docker-compose.netclient.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ version: "3.4"
services:
netclient:
container_name: netclient
image: 'gravitl/netclient:v0.20.2'
image: 'gravitl/netclient:v0.20.3'
hostname: netmaker-1
network_mode: host
restart: on-failure
Expand Down
4 changes: 1 addition & 3 deletions compose/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ services:
- sqldata:/root/data
environment:
# config-dependant vars
- STUN_LIST=stun.${NM_DOMAIN}:${STUN_PORT},stun1.netmaker.io:3478,stun2.netmaker.io:3478,stun1.l.google.com:19302,stun2.l.google.com:19302
- STUN_LIST=stun1.netmaker.io:3478,stun2.netmaker.io:3478,stun1.l.google.com:19302,stun2.l.google.com:19302
# The domain/host IP indicating the mq broker address
- BROKER_ENDPOINT=wss://broker.${NM_DOMAIN}
# The base domain of netmaker
Expand All @@ -26,8 +26,6 @@ services:
- TURN_SERVER_HOST=turn.${NM_DOMAIN}
# domain of the turn api server
- TURN_SERVER_API_HOST=https://turnapi.${NM_DOMAIN}
ports:
- "3478:3478/udp"

netmaker-ui:
container_name: netmaker-ui
Expand Down
5 changes: 5 additions & 0 deletions config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,11 @@ type ServerConfig struct {
TurnUserName string `yaml:"turn_username"`
TurnPassword string `yaml:"turn_password"`
UseTurn bool `yaml:"use_turn"`
UsersLimit int `yaml:"user_limit"`
ClientsLimit int `yaml:"client_limit"`
NetworksLimit int `yaml:"network_limit"`
HostsLimit int `yaml:"host_limit"`
DeployedByOperator bool `yaml:"deployed_by_operator"`
}

// ProxyMode - default proxy mode for server
Expand Down
3 changes: 1 addition & 2 deletions controllers/dns_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,7 @@ func TestGetNodeDNS(t *testing.T) {
createNet()
createHost()
t.Run("NoNodes", func(t *testing.T) {
dns, err := logic.GetNodeDNS("skynet")
assert.EqualError(t, err, "could not find any records")
dns, _ := logic.GetNodeDNS("skynet")
assert.Equal(t, []models.DNSEntry(nil), dns)
})
t.Run("NodeExists", func(t *testing.T) {
Expand Down
2 changes: 1 addition & 1 deletion controllers/docs.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
//
// Schemes: https
// BasePath: /
// Version: 0.20.2
// Version: 0.20.3
// Host: netmaker.io
//
// Consumes:
Expand Down
3 changes: 1 addition & 2 deletions controllers/ext_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import (

"github.com/gorilla/mux"
"github.com/gravitl/netmaker/database"
"github.com/gravitl/netmaker/functions"
"github.com/gravitl/netmaker/logger"
"github.com/gravitl/netmaker/logic"
"github.com/gravitl/netmaker/logic/pro"
Expand Down Expand Up @@ -102,7 +101,7 @@ func getAllExtClients(w http.ResponseWriter, r *http.Request) {
clients := []models.ExtClient{}
var err error
if len(networksSlice) > 0 && networksSlice[0] == logic.ALL_NETWORK_ACCESS {
clients, err = functions.GetAllExtClients()
clients, err = logic.GetAllExtClients()
if err != nil && !database.IsEmptyRecord(err) {
logger.Log(0, "failed to get all extclients: ", err.Error())
logic.ReturnErrorResponse(w, r, logic.FormatError(err, "internal"))
Expand Down
39 changes: 7 additions & 32 deletions controllers/hosts.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package controller

import (
"context"
"encoding/json"
"errors"
"fmt"
Expand Down Expand Up @@ -49,38 +48,8 @@ func getHosts(w http.ResponseWriter, r *http.Request) {
logic.ReturnErrorResponse(w, r, logic.FormatError(err, "internal"))
return
}
//isMasterAdmin := r.Header.Get("ismaster") == "yes"
//user, err := logic.GetUser(r.Header.Get("user"))
//if err != nil && !isMasterAdmin {
// logger.Log(0, r.Header.Get("user"), "failed to fetch user: ", err.Error())
// logic.ReturnErrorResponse(w, r, logic.FormatError(err, "internal"))
// return
//}
// return JSON/API formatted hosts
//ret := []models.ApiHost{}
apiHosts := logic.GetAllHostsAPI(currentHosts[:])
logger.Log(2, r.Header.Get("user"), "fetched all hosts")
//for _, host := range apiHosts {
// nodes := host.Nodes
// // work on the copy
// host.Nodes = []string{}
// for _, nid := range nodes {
// node, err := logic.GetNodeByID(nid)
// if err != nil {
// logger.Log(0, r.Header.Get("user"), "failed to fetch node: ", err.Error())
// // TODO find the reason for the DB error, skip this node for now
// continue
// }
// if !isMasterAdmin && !logic.UserHasNetworksAccess([]string{node.Network}, user) {
// continue
// }
// host.Nodes = append(host.Nodes, nid)
// }
// // add to the response only if has perms to some nodes / networks
// if len(host.Nodes) > 0 {
// ret = append(ret, host)
// }
//}
logic.SortApiHosts(apiHosts[:])
w.WriteHeader(http.StatusOK)
json.NewEncoder(w).Encode(apiHosts)
Expand Down Expand Up @@ -111,7 +80,13 @@ func pull(w http.ResponseWriter, r *http.Request) {
logic.ReturnErrorResponse(w, r, logic.FormatError(err, "internal"))
return
}
hPU, err := logic.GetPeerUpdateForHost(context.Background(), "", host, nil, nil)
allNodes, err := logic.GetAllNodes()
if err != nil {
logger.Log(0, "could not pull peers for host", hostID)
logic.ReturnErrorResponse(w, r, logic.FormatError(err, "internal"))
return
}
hPU, err := logic.GetPeerUpdateForHost("", host, allNodes, nil, nil)
if err != nil {
logger.Log(0, "could not pull peers for host", hostID)
logic.ReturnErrorResponse(w, r, logic.FormatError(err, "internal"))
Expand Down
10 changes: 1 addition & 9 deletions controllers/limits.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import (
"github.com/gravitl/netmaker/database"
"github.com/gravitl/netmaker/logic"
"github.com/gravitl/netmaker/models"
"github.com/gravitl/netmaker/servercfg"
)

// limit consts
Expand All @@ -23,20 +22,13 @@ func checkFreeTierLimits(limit_choice int, next http.Handler) http.HandlerFunc {
Code: http.StatusForbidden, Message: "free tier limits exceeded on networks",
}

if logic.Free_Tier && servercfg.Is_EE { // check that free tier limits not exceeded
if logic.Free_Tier { // check that free tier limits not exceeded
if limit_choice == networks_l {
currentNetworks, err := logic.GetNetworks()
if (err != nil && !database.IsEmptyRecord(err)) || len(currentNetworks) >= logic.Networks_Limit {
logic.ReturnErrorResponse(w, r, errorResponse)
return
}
} else if limit_choice == node_l {
nodes, err := logic.GetAllNodes()
if (err != nil && !database.IsEmptyRecord(err)) || len(nodes) >= logic.Node_Limit {
errorResponse.Message = "free tier limits exceeded on nodes"
logic.ReturnErrorResponse(w, r, errorResponse)
return
}
} else if limit_choice == users_l {
users, err := logic.GetUsers()
if (err != nil && !database.IsEmptyRecord(err)) || len(users) >= logic.Users_Limit {
Expand Down
29 changes: 22 additions & 7 deletions controllers/node.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package controller

import (
"context"
"encoding/json"
"fmt"
"net/http"
Expand Down Expand Up @@ -388,7 +387,14 @@ func getNode(w http.ResponseWriter, r *http.Request) {
logic.ReturnErrorResponse(w, r, logic.FormatError(err, "internal"))
return
}
hostPeerUpdate, err := logic.GetPeerUpdateForHost(context.Background(), node.Network, host, nil, nil)
allNodes, err := logic.GetAllNodes()
if err != nil {
logger.Log(0, r.Header.Get("user"),
fmt.Sprintf("error fetching wg peers config for host [ %s ]: %v", host.ID.String(), err))
logic.ReturnErrorResponse(w, r, logic.FormatError(err, "internal"))
return
}
hostPeerUpdate, err := logic.GetPeerUpdateForHost(node.Network, host, allNodes, nil, nil)
if err != nil && !database.IsEmptyRecord(err) {
logger.Log(0, r.Header.Get("user"),
fmt.Sprintf("error fetching wg peers config for host [ %s ]: %v", host.ID.String(), err))
Expand Down Expand Up @@ -583,9 +589,13 @@ func deleteIngressGateway(w http.ResponseWriter, r *http.Request) {
if len(removedClients) > 0 {
host, err := logic.GetHost(node.HostID.String())
if err == nil {
allNodes, err := logic.GetAllNodes()
if err != nil {
return
}
go mq.PublishSingleHostPeerUpdate(
context.Background(),
host,
allNodes,
nil,
removedClients[:],
)
Expand Down Expand Up @@ -730,10 +740,6 @@ func deleteNode(w http.ResponseWriter, r *http.Request) {
return
}
}
if err := logic.DeleteNode(&node, fromNode); err != nil {
logic.ReturnErrorResponse(w, r, logic.FormatError(fmt.Errorf("failed to delete node"), "internal"))
return
}
if node.IsRelayed {
// cleanup node from relayednodes on relay node
relayNode, err := logic.GetNodeByID(node.RelayedBy)
Expand All @@ -750,6 +756,15 @@ func deleteNode(w http.ResponseWriter, r *http.Request) {
}

}
if node.IsRelay {
// unset all the relayed nodes
logic.SetRelayedNodes(false, node.ID.String(), node.RelayedNodes)
}
if err := logic.DeleteNode(&node, fromNode); err != nil {
logic.ReturnErrorResponse(w, r, logic.FormatError(fmt.Errorf("failed to delete node"), "internal"))
return
}

logic.ReturnSuccessResponse(w, r, nodeid+" deleted.")
logger.Log(1, r.Header.Get("user"), "Deleted node", nodeid, "from network", params["network"])
if !fromNode { // notify node change
Expand Down
1 change: 1 addition & 0 deletions controllers/node_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,7 @@ func TestNodeACLs(t *testing.T) {
}

func deleteAllNodes() {
logic.ClearNodeCache()
database.DeleteAllRecords(database.NODES_TABLE_NAME)
}

Expand Down
38 changes: 38 additions & 0 deletions controllers/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,38 @@ func serverHandlers(r *mux.Router) {
r.HandleFunc("/api/server/getconfig", allowUsers(http.HandlerFunc(getConfig))).Methods(http.MethodGet)
r.HandleFunc("/api/server/getserverinfo", Authorize(true, false, "node", http.HandlerFunc(getServerInfo))).Methods(http.MethodGet)
r.HandleFunc("/api/server/status", http.HandlerFunc(getStatus)).Methods(http.MethodGet)
r.HandleFunc("/api/server/usage", Authorize(true, false, "user", http.HandlerFunc(getUsage))).Methods(http.MethodGet)
}
func getUsage(w http.ResponseWriter, r *http.Request) {
type usage struct {
Hosts int `json:"hosts"`
Clients int `json:"clients"`
Networks int `json:"networks"`
Users int `json:"users"`
}
var serverUsage usage
hosts, err := logic.GetAllHosts()
if err == nil {
serverUsage.Hosts = len(hosts)
}
clients, err := logic.GetAllExtClients()
if err == nil {
serverUsage.Clients = len(clients)
}
users, err := logic.GetUsers()
if err == nil {
serverUsage.Users = len(users)
}
networks, err := logic.GetNetworks()
if err == nil {
serverUsage.Networks = len(networks)
}
w.Header().Set("Content-Type", "application/json")
json.NewEncoder(w).Encode(models.SuccessResponse{
Code: http.StatusOK,
Response: serverUsage,
})

}

// swagger:route GET /api/server/status server getStatus
Expand All @@ -41,6 +73,12 @@ func getStatus(w http.ResponseWriter, r *http.Request) {
type status struct {
DB bool `json:"db_connected"`
Broker bool `json:"broker_connected"`
Usage struct {
Hosts int `json:"hosts"`
Clients int `json:"clients"`
Networks int `json:"networks"`
Users int `json:"users"`
} `json:"usage"`
}

currentServerStatus := status{
Expand Down
Loading