Skip to content

Commit

Permalink
resolve merge conflicts
Browse files Browse the repository at this point in the history
  • Loading branch information
abhishek9686 committed Dec 11, 2024
2 parents 0c4f7eb + 94cc853 commit 411d5a5
Show file tree
Hide file tree
Showing 49 changed files with 1,936 additions and 312 deletions.
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.30.0
- v0.26.0
- v0.25.0
- v0.24.3
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.20.3
FROM alpine:3.21.0

# 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.20.3
FROM alpine:3.21.0
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.26.0-informational?style=flat-square" />
<img src="https://img.shields.io/badge/Version-0.30.0-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
4 changes: 2 additions & 2 deletions auth/host_session.go
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,7 @@ func CheckNetRegAndHostUpdate(networks []string, h *models.Host, relayNodeId uui
if relayNodeId != uuid.Nil && !newNode.IsRelayed {
// check if relay node exists and acting as relay
relaynode, err := logic.GetNodeByID(relayNodeId.String())
if err == nil && relaynode.IsRelay {
if err == nil && relaynode.IsRelay && relaynode.Network == newNode.Network {
slog.Info(fmt.Sprintf("adding relayed node %s to relay %s on network %s", newNode.ID.String(), relayNodeId.String(), network))
newNode.IsRelayed = true
newNode.RelayedBy = relayNodeId.String()
Expand All @@ -271,7 +271,7 @@ func CheckNetRegAndHostUpdate(networks []string, h *models.Host, relayNodeId uui
slog.Error("failed to update node", "nodeid", relayNodeId.String())
}
} else {
slog.Error("failed to relay node. maybe specified relay node is actually not a relay?", "err", err)
slog.Error("failed to relay node. maybe specified relay node is actually not a relay? Or the relayed node is not in the same network with relay?", "err", err)
}
}
logger.Log(1, "added new node", newNode.ID.String(), "to host", h.Name)
Expand Down
3 changes: 2 additions & 1 deletion compose/docker-compose-emqx.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ version: "3.4"
services:
mq:
container_name: mq
image: emqx/emqx:5.0.9
image: emqx/emqx:5.8.2
env_file: ./netmaker.env
restart: unless-stopped
environment:
Expand All @@ -20,6 +20,7 @@ services:
- emqx_data:/opt/emqx/data
- emqx_etc:/opt/emqx/etc
- emqx_logs:/opt/emqx/log
- ./emqx.conf:/opt/emqx/data/configs/cluster.hocon
volumes:
emqx_data: { } # storage for emqx data
emqx_etc: { } # storage for emqx etc
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.26.0'
image: 'gravitl/netclient:v0.30.0'
hostname: netmaker-1
network_mode: host
restart: on-failure
Expand Down
1 change: 1 addition & 0 deletions config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ type ServerConfig struct {
Stun bool `yaml:"stun"`
StunServers string `yaml:"stun_servers"`
DefaultDomain string `yaml:"default_domain"`
PublicIp string `yaml:"public_ip"`
}

// SQLConfig - Generic SQL Config
Expand Down
88 changes: 79 additions & 9 deletions controllers/acls.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,81 @@ func aclPolicyTypes(w http.ResponseWriter, r *http.Request) {
// models.NetmakerIPAclID,
// models.NetmakerSubNetRangeAClID,
},
ProtocolTypes: []models.ProtocolType{
{
Name: models.Any,
AllowedProtocols: []models.Protocol{
models.ALL,
},
PortRange: "All ports",
AllowPortSetting: false,
},
{
Name: models.Http,
AllowedProtocols: []models.Protocol{
models.TCP,
},
PortRange: "80",
},
{
Name: models.Https,
AllowedProtocols: []models.Protocol{
models.TCP,
},
PortRange: "443",
},
// {
// Name: "MySQL",
// AllowedProtocols: []models.Protocol{
// models.TCP,
// },
// PortRange: "3306",
// },
// {
// Name: "DNS TCP",
// AllowedProtocols: []models.Protocol{
// models.TCP,
// },
// PortRange: "53",
// },
// {
// Name: "DNS UDP",
// AllowedProtocols: []models.Protocol{
// models.UDP,
// },
// PortRange: "53",
// },
{
Name: models.AllTCP,
AllowedProtocols: []models.Protocol{
models.TCP,
},
PortRange: "All ports",
},
{
Name: models.AllUDP,
AllowedProtocols: []models.Protocol{
models.UDP,
},
PortRange: "All ports",
},
{
Name: models.ICMPService,
AllowedProtocols: []models.Protocol{
models.ICMP,
},
PortRange: "",
},
{
Name: models.Custom,
AllowedProtocols: []models.Protocol{
models.UDP,
models.TCP,
},
PortRange: "All ports",
AllowPortSetting: true,
},
},
}
logic.ReturnSuccessResponseWithJson(w, r, resp, "fetched acls types")
}
Expand All @@ -69,7 +144,7 @@ func aclDebug(w http.ResponseWriter, r *http.Request) {
logic.ReturnErrorResponse(w, r, logic.FormatError(err, "badrequest"))
return
}
allowed := logic.IsNodeAllowedToCommunicate(node, peer)
allowed, _ := logic.IsNodeAllowedToCommunicate(node, peer, true)
logic.ReturnSuccessResponseWithJson(w, r, allowed, "fetched all acls in the network ")
}

Expand Down Expand Up @@ -132,11 +207,6 @@ func createAcl(w http.ResponseWriter, r *http.Request) {
acl.CreatedBy = user.UserName
acl.CreatedAt = time.Now().UTC()
acl.Default = false
if acl.RuleType == models.DevicePolicy {
acl.AllowedDirection = models.TrafficDirectionBi
} else {
acl.AllowedDirection = models.TrafficDirectionUni
}
// validate create acl policy
if !logic.IsAclPolicyValid(acl) {
logic.ReturnErrorResponse(w, r, logic.FormatError(errors.New("invalid policy"), "badrequest"))
Expand All @@ -152,7 +222,7 @@ func createAcl(w http.ResponseWriter, r *http.Request) {
logic.ReturnErrorResponse(w, r, logic.FormatError(err, "internal"))
return
}
go mq.PublishPeerUpdate(false)
go mq.PublishPeerUpdate(true)
logic.ReturnSuccessResponseWithJson(w, r, acl, "created acl successfully")
}

Expand Down Expand Up @@ -194,7 +264,7 @@ func updateAcl(w http.ResponseWriter, r *http.Request) {
logic.ReturnErrorResponse(w, r, logic.FormatError(err, "badrequest"))
return
}
go mq.PublishPeerUpdate(false)
go mq.PublishPeerUpdate(true)
logic.ReturnSuccessResponse(w, r, "updated acl "+acl.Name)
}

Expand Down Expand Up @@ -225,6 +295,6 @@ func deleteAcl(w http.ResponseWriter, r *http.Request) {
logic.FormatError(errors.New("cannot delete default policy"), "internal"))
return
}
go mq.PublishPeerUpdate(false)
go mq.PublishPeerUpdate(true)
logic.ReturnSuccessResponse(w, r, "deleted acl "+acl.Name)
}
4 changes: 3 additions & 1 deletion controllers/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -326,8 +326,9 @@ func getNetworkNodes(w http.ResponseWriter, r *http.Request) {
if len(filteredNodes) > 0 {
nodes = filteredNodes
}
nodes = logic.AddStaticNodestoList(nodes)

nodes = logic.AddStaticNodestoList(nodes)
nodes = logic.AddStatusToNodes(nodes)
// returns all the nodes in JSON/API format
apiNodes := logic.GetAllNodesAPI(nodes[:])
logger.Log(2, r.Header.Get("user"), "fetched nodes on network", networkName)
Expand Down Expand Up @@ -367,6 +368,7 @@ func getAllNodes(w http.ResponseWriter, r *http.Request) {

}
nodes = logic.AddStaticNodestoList(nodes)
nodes = logic.AddStatusToNodes(nodes)
// return all the nodes in JSON/API format
apiNodes := logic.GetAllNodesAPI(nodes[:])
logger.Log(3, r.Header.Get("user"), "fetched all nodes they have access to")
Expand Down
6 changes: 6 additions & 0 deletions controllers/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@ func serverHandlers(r *mux.Router) {
Methods(http.MethodGet)
r.HandleFunc("/api/server/cpu_profile", logic.SecurityCheck(false, http.HandlerFunc(cpuProfile))).
Methods(http.MethodPost)
r.HandleFunc("/api/server/mem_profile", logic.SecurityCheck(false, http.HandlerFunc(memProfile))).
Methods(http.MethodPost)
}

func cpuProfile(w http.ResponseWriter, r *http.Request) {
Expand All @@ -62,6 +64,10 @@ func cpuProfile(w http.ResponseWriter, r *http.Request) {
}
}
}
func memProfile(w http.ResponseWriter, r *http.Request) {
os.Remove("/root/data/mem.prof")
logic.StartMemProfiling()
}

func getUsage(w http.ResponseWriter, _ *http.Request) {
type usage struct {
Expand Down
2 changes: 1 addition & 1 deletion controllers/user.go
Original file line number Diff line number Diff line change
Expand Up @@ -722,7 +722,7 @@ func socketHandler(w http.ResponseWriter, r *http.Request) {
// @Summary lists all user roles.
// @Router /api/v1/user/roles [get]
// @Tags Users
// @Param role_id param string true "roleid required to get the role details"
// @Param role_id query string true "roleid required to get the role details"
// @Success 200 {object} []models.UserRolePermissionTemplate
// @Failure 500 {object} models.ErrorResponse
func listRoles(w http.ResponseWriter, r *http.Request) {
Expand Down
21 changes: 21 additions & 0 deletions docker/emqx.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
authentication = [
{
backend = "built_in_database"
mechanism = "password_based"
password_hash_algorithm {
name = "sha256",
salt_position = "suffix"
}
user_id_type = "username"
}
]
authorization {
deny_action = ignore
no_match = allow
sources = [
{
type = built_in_database
enable = true
}
]
}
13 changes: 8 additions & 5 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ module github.com/gravitl/netmaker
go 1.23

require (
github.com/blang/semver v3.5.1+incompatible
github.com/eclipse/paho.mqtt.golang v1.4.3
github.com/go-playground/validator/v10 v10.23.0
github.com/golang-jwt/jwt/v4 v4.5.1
Expand All @@ -14,13 +15,14 @@ require (
github.com/rqlite/gorqlite v0.0.0-20240122221808-a8a425b1a6aa
github.com/seancfoley/ipaddress-go v1.7.0
github.com/skip2/go-qrcode v0.0.0-20200617195104-da1b6568686e
github.com/stretchr/testify v1.9.0
github.com/stretchr/testify v1.10.0
github.com/txn2/txeh v1.5.5
golang.org/x/crypto v0.29.0
go.uber.org/automaxprocs v1.6.0
golang.org/x/crypto v0.30.0
golang.org/x/net v0.27.0 // indirect
golang.org/x/oauth2 v0.24.0
golang.org/x/sys v0.27.0 // indirect
golang.org/x/text v0.20.0 // indirect
golang.org/x/sys v0.28.0 // indirect
golang.org/x/text v0.21.0 // indirect
golang.zx2c4.com/wireguard/wgctrl v0.0.0-20221104135756-97bc4ad4a1cb
gopkg.in/yaml.v3 v3.0.1
)
Expand Down Expand Up @@ -51,6 +53,7 @@ require (
github.com/gabriel-vasile/mimetype v1.4.3 // indirect
github.com/go-jose/go-jose/v3 v3.0.3 // indirect
github.com/inconshreveable/mousetrap v1.1.0 // indirect
github.com/kr/text v0.2.0 // indirect
github.com/rivo/uniseg v0.2.0 // indirect
github.com/seancfoley/bintree v1.3.1 // indirect
github.com/spf13/pflag v1.0.5 // indirect
Expand All @@ -66,5 +69,5 @@ require (
github.com/leodido/go-urn v1.4.0 // indirect
github.com/mattn/go-runewidth v0.0.13 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
golang.org/x/sync v0.9.0 // indirect
golang.org/x/sync v0.10.0 // indirect
)
Loading

0 comments on commit 411d5a5

Please sign in to comment.