mirror of
https://github.com/gravitl/netmaker.git
synced 2025-09-10 23:24:32 +08:00
docker compose update, add stun to caddyfile
This commit is contained in:
parent
4b1a85a3ee
commit
80c7d46ec6
12 changed files with 53 additions and 33 deletions
10
Dockerfile
10
Dockerfile
|
@ -4,19 +4,21 @@ ARG version
|
||||||
ARG tags
|
ARG tags
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
COPY . .
|
COPY . .
|
||||||
|
# RUN mkdir -p /Users/abhishekk/go/src/github.com/gravitl
|
||||||
|
# ADD ../netclient /Users/abhishekk/go/src/github.com/gravitl
|
||||||
ENV GO111MODULE=auto
|
ENV GO111MODULE=auto
|
||||||
|
|
||||||
RUN apk add git libpcap-dev
|
# RUN apk add git
|
||||||
RUN GOOS=linux CGO_ENABLED=1 go build ${tags} -ldflags="-s -X 'main.version=${version}'" .
|
# RUN GOOS=linux CGO_ENABLED=1 go build ${tags} -ldflags="-s -X 'main.version=${version}'" .
|
||||||
# RUN go build -tags=ee . -o netmaker main.go
|
# RUN go build -tags=ee . -o netmaker main.go
|
||||||
FROM alpine:3.16.2
|
FROM alpine:3.16.2
|
||||||
|
|
||||||
# add a c lib
|
# add a c lib
|
||||||
RUN apk add gcompat iptables wireguard-tools libpcap-dev
|
RUN apk add gcompat iptables wireguard-tools
|
||||||
# set the working directory
|
# set the working directory
|
||||||
WORKDIR /root/
|
WORKDIR /root/
|
||||||
RUN mkdir -p /etc/netclient/config
|
RUN mkdir -p /etc/netclient/config
|
||||||
COPY --from=builder /app/netmaker .
|
COPY --from=builder /app/bin/netmaker .
|
||||||
COPY --from=builder /app/config config
|
COPY --from=builder /app/config config
|
||||||
EXPOSE 8081
|
EXPOSE 8081
|
||||||
ENTRYPOINT ["./netmaker"]
|
ENTRYPOINT ["./netmaker"]
|
||||||
|
|
|
@ -21,6 +21,7 @@ services:
|
||||||
environment:
|
environment:
|
||||||
BROKER_NAME: "broker.NETMAKER_BASE_DOMAIN"
|
BROKER_NAME: "broker.NETMAKER_BASE_DOMAIN"
|
||||||
SERVER_NAME: "NETMAKER_BASE_DOMAIN"
|
SERVER_NAME: "NETMAKER_BASE_DOMAIN"
|
||||||
|
STUN_DOMAIN: "stun.NETMAKER_BASE_DOMAIN"
|
||||||
SERVER_HOST: "SERVER_PUBLIC_IP"
|
SERVER_HOST: "SERVER_PUBLIC_IP"
|
||||||
SERVER_API_CONN_STRING: "api.NETMAKER_BASE_DOMAIN:443"
|
SERVER_API_CONN_STRING: "api.NETMAKER_BASE_DOMAIN:443"
|
||||||
COREDNS_ADDR: "SERVER_PUBLIC_IP"
|
COREDNS_ADDR: "SERVER_PUBLIC_IP"
|
||||||
|
@ -45,6 +46,7 @@ services:
|
||||||
PROXY: "on"
|
PROXY: "on"
|
||||||
ports:
|
ports:
|
||||||
- "51821-51830:51821-51830/udp"
|
- "51821-51830:51821-51830/udp"
|
||||||
|
- "3478:3478/udp"
|
||||||
netmaker-ui:
|
netmaker-ui:
|
||||||
container_name: netmaker-ui
|
container_name: netmaker-ui
|
||||||
image: gravitl/netmaker-ui:v0.17.0
|
image: gravitl/netmaker-ui:v0.17.0
|
||||||
|
|
|
@ -78,6 +78,7 @@ type ServerConfig struct {
|
||||||
NetmakerAccountID string `yaml:"netmaker_account_id"`
|
NetmakerAccountID string `yaml:"netmaker_account_id"`
|
||||||
IsEE string `yaml:"is_ee"`
|
IsEE string `yaml:"is_ee"`
|
||||||
StunPort string `yaml:"stun_port"`
|
StunPort string `yaml:"stun_port"`
|
||||||
|
StunHost string `yaml:"stun_host"`
|
||||||
Proxy string `yaml:"proxy"`
|
Proxy string `yaml:"proxy"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -8,6 +8,7 @@ import (
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/gorilla/mux"
|
"github.com/gorilla/mux"
|
||||||
|
"github.com/gravitl/netclient/nm-proxy/manager"
|
||||||
"github.com/gravitl/netmaker/database"
|
"github.com/gravitl/netmaker/database"
|
||||||
"github.com/gravitl/netmaker/logger"
|
"github.com/gravitl/netmaker/logger"
|
||||||
"github.com/gravitl/netmaker/logic"
|
"github.com/gravitl/netmaker/logic"
|
||||||
|
@ -115,7 +116,7 @@ func authenticate(response http.ResponseWriter, request *http.Request) {
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
Command: mq.CreateClientCmd,
|
Command: mq.CreateClientCmd,
|
||||||
Username: result.ID,
|
Username: result.HostID,
|
||||||
Password: authRequest.Password,
|
Password: authRequest.Password,
|
||||||
Textname: result.Name,
|
Textname: result.Name,
|
||||||
Roles: []mq.MqDynSecRole{
|
Roles: []mq.MqDynSecRole{
|
||||||
|
@ -618,6 +619,7 @@ func createNode(w http.ResponseWriter, r *http.Request) {
|
||||||
}
|
}
|
||||||
// consume password before hashing for mq client creation
|
// consume password before hashing for mq client creation
|
||||||
nodePassword := node.Password
|
nodePassword := node.Password
|
||||||
|
node.Server = servercfg.GetServer()
|
||||||
err = logic.CreateNode(&node)
|
err = logic.CreateNode(&node)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logger.Log(0, r.Header.Get("user"),
|
logger.Log(0, r.Header.Get("user"),
|
||||||
|
@ -1046,6 +1048,12 @@ func deleteNode(w http.ResponseWriter, r *http.Request) {
|
||||||
logic.ReturnErrorResponse(w, r, logic.FormatError(fmt.Errorf("failed to delete node"), "internal"))
|
logic.ReturnErrorResponse(w, r, logic.FormatError(fmt.Errorf("failed to delete node"), "internal"))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
if node.Proxy {
|
||||||
|
mq.ProxyUpdate(&manager.ProxyManagerPayload{
|
||||||
|
Action: manager.DeleteNetwork,
|
||||||
|
Network: node.Network,
|
||||||
|
}, &node)
|
||||||
|
}
|
||||||
if fromNode {
|
if fromNode {
|
||||||
//check if server should be removed from mq
|
//check if server should be removed from mq
|
||||||
found := false
|
found := false
|
||||||
|
|
|
@ -29,6 +29,12 @@ https://api.NETMAKER_BASE_DOMAIN {
|
||||||
reverse_proxy http://netmaker:8081
|
reverse_proxy http://netmaker:8081
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# STUN
|
||||||
|
https://stun.NETMAKER_BASE_DOMAIN {
|
||||||
|
reverse_proxy netmaker:3478
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
# MQ
|
# MQ
|
||||||
wss://broker.NETMAKER_BASE_DOMAIN {
|
wss://broker.NETMAKER_BASE_DOMAIN {
|
||||||
reverse_proxy ws://mq:8883
|
reverse_proxy ws://mq:8883
|
||||||
|
|
|
@ -44,6 +44,11 @@ https://api.NETMAKER_BASE_DOMAIN {
|
||||||
reverse_proxy http://netmaker:8081
|
reverse_proxy http://netmaker:8081
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# STUN
|
||||||
|
https://stun.NETMAKER_BASE_DOMAIN {
|
||||||
|
reverse_proxy netmaker:3478
|
||||||
|
}
|
||||||
|
|
||||||
# MQ
|
# MQ
|
||||||
wss://broker.NETMAKER_BASE_DOMAIN {
|
wss://broker.NETMAKER_BASE_DOMAIN {
|
||||||
reverse_proxy ws://mq:8883
|
reverse_proxy ws://mq:8883
|
||||||
|
|
22
go.mod
22
go.mod
|
@ -53,30 +53,10 @@ require (
|
||||||
)
|
)
|
||||||
|
|
||||||
require (
|
require (
|
||||||
github.com/gravitl/netclient v0.0.0-20221130181441-8e24c4c15dec
|
github.com/gravitl/netclient v0.0.0-20221205113827-847146e217b3
|
||||||
github.com/matryer/is v1.4.0
|
github.com/matryer/is v1.4.0
|
||||||
)
|
)
|
||||||
|
|
||||||
require (
|
|
||||||
github.com/devilcove/httpclient v0.6.0 // indirect
|
|
||||||
github.com/hashicorp/hcl v1.0.0 // indirect
|
|
||||||
github.com/inconshreveable/mousetrap v1.0.1 // indirect
|
|
||||||
github.com/magiconair/properties v1.8.6 // indirect
|
|
||||||
github.com/mitchellh/mapstructure v1.5.0 // indirect
|
|
||||||
github.com/pelletier/go-toml v1.9.5 // indirect
|
|
||||||
github.com/pelletier/go-toml/v2 v2.0.5 // indirect
|
|
||||||
github.com/spf13/cast v1.5.0 // indirect
|
|
||||||
github.com/spf13/cobra v1.6.0 // indirect
|
|
||||||
github.com/spf13/jwalterweatherman v1.1.0 // indirect
|
|
||||||
github.com/spf13/pflag v1.0.5 // indirect
|
|
||||||
github.com/spf13/viper v1.13.0 // indirect
|
|
||||||
github.com/subosito/gotenv v1.4.1 // indirect
|
|
||||||
github.com/vishvananda/netlink v1.1.0 // indirect
|
|
||||||
github.com/vishvananda/netns v0.0.0-20191106174202-0a2b9b5464df // indirect
|
|
||||||
golang.zx2c4.com/wintun v0.0.0-20211104114900-415007cec224 // indirect
|
|
||||||
golang.zx2c4.com/wireguard/windows v0.5.3 // indirect
|
|
||||||
)
|
|
||||||
|
|
||||||
require (
|
require (
|
||||||
cloud.google.com/go/compute v1.7.0 // indirect
|
cloud.google.com/go/compute v1.7.0 // indirect
|
||||||
fyne.io/systray v1.10.1-0.20220621085403-9a2652634e93 // indirect
|
fyne.io/systray v1.10.1-0.20220621085403-9a2652634e93 // indirect
|
||||||
|
|
|
@ -161,6 +161,7 @@ func GetPeersForProxy(node *models.Node, onlyPeers bool) (manager.ProxyManagerPa
|
||||||
proxyPayload.WgAddr = addr
|
proxyPayload.WgAddr = addr
|
||||||
proxyPayload.Peers = peers
|
proxyPayload.Peers = peers
|
||||||
proxyPayload.PeerMap = peerConfMap
|
proxyPayload.PeerMap = peerConfMap
|
||||||
|
proxyPayload.Network = node.Network
|
||||||
proxyPayload.InterfaceName = node.Interface
|
proxyPayload.InterfaceName = node.Interface
|
||||||
return proxyPayload, nil
|
return proxyPayload, nil
|
||||||
}
|
}
|
||||||
|
|
|
@ -475,7 +475,7 @@ func (newNode *Node) Fill(currentNode *Node) { // TODO add new field for nftable
|
||||||
if newNode.Failover == "" {
|
if newNode.Failover == "" {
|
||||||
newNode.Failover = currentNode.Failover
|
newNode.Failover = currentNode.Failover
|
||||||
}
|
}
|
||||||
|
newNode.Proxy = currentNode.Proxy
|
||||||
newNode.TrafficKeys = currentNode.TrafficKeys
|
newNode.TrafficKeys = currentNode.TrafficKeys
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -223,6 +223,7 @@ type ServerConfig struct {
|
||||||
Broker string `yaml:"broker"`
|
Broker string `yaml:"broker"`
|
||||||
Is_EE bool `yaml:"isee"`
|
Is_EE bool `yaml:"isee"`
|
||||||
StunPort string `yaml:"stun_port"`
|
StunPort string `yaml:"stun_port"`
|
||||||
|
StunHost string `yaml:"stun_host"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// User.NameInCharset - returns if name is in charset below or not
|
// User.NameInCharset - returns if name is in charset below or not
|
||||||
|
|
|
@ -29,7 +29,7 @@ func PublishPeerUpdate(newNode *models.Node, publishToSelf bool) error {
|
||||||
|
|
||||||
if node.IsServer == "yes" {
|
if node.IsServer == "yes" {
|
||||||
if servercfg.IsProxyEnabled() {
|
if servercfg.IsProxyEnabled() {
|
||||||
err := PublishProxyUpdate(&node)
|
err := PublishProxyPeerUpdate(&node)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logger.Log(0, "failed to send proxy update for server: ", err.Error())
|
logger.Log(0, "failed to send proxy update for server: ", err.Error())
|
||||||
}
|
}
|
||||||
|
@ -50,12 +50,13 @@ func PublishPeerUpdate(newNode *models.Node, publishToSelf bool) error {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
func PublishProxyUpdate(node *models.Node) error {
|
func PublishProxyPeerUpdate(node *models.Node) error {
|
||||||
peerUpdates, err := logic.GetPeersForProxy(node, false)
|
proxyUpdate, err := logic.GetPeersForProxy(node, false)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
err = ProxyUpdate(&peerUpdates, node)
|
proxyUpdate.Action = manager.AddNetwork
|
||||||
|
err = ProxyUpdate(&proxyUpdate, node)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logger.Log(1, "failed to send proxy update: ", err.Error())
|
logger.Log(1, "failed to send proxy update: ", err.Error())
|
||||||
return err
|
return err
|
||||||
|
@ -75,6 +76,7 @@ func PublishSinglePeerUpdate(node *models.Node) error {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
proxyUpdate.Action = manager.AddNetwork
|
||||||
peerUpdate.ProxyUpdate = proxyUpdate
|
peerUpdate.ProxyUpdate = proxyUpdate
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -138,7 +140,7 @@ func NodeUpdate(node *models.Node) error {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
if node.Proxy {
|
if node.Proxy {
|
||||||
err = PublishProxyUpdate(node)
|
err = PublishProxyPeerUpdate(node)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logger.Log(1, "failed to publish proxy update to node", node.Name, "on network", node.Network, ":", err.Error())
|
logger.Log(1, "failed to publish proxy update to node", node.Name, "on network", node.Network, ":", err.Error())
|
||||||
}
|
}
|
||||||
|
@ -149,7 +151,7 @@ func NodeUpdate(node *models.Node) error {
|
||||||
|
|
||||||
// ProxyUpdate -- publishes updates to peers related to proxy
|
// ProxyUpdate -- publishes updates to peers related to proxy
|
||||||
func ProxyUpdate(proxyPayload *manager.ProxyManagerPayload, node *models.Node) error {
|
func ProxyUpdate(proxyPayload *manager.ProxyManagerPayload, node *models.Node) error {
|
||||||
if !servercfg.IsMessageQueueBackend() {
|
if !servercfg.IsMessageQueueBackend() || !node.Proxy {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
if node.IsServer == "yes" {
|
if node.IsServer == "yes" {
|
||||||
|
|
|
@ -108,6 +108,7 @@ func GetServerInfo() models.ServerConfig {
|
||||||
}
|
}
|
||||||
cfg.Version = GetVersion()
|
cfg.Version = GetVersion()
|
||||||
cfg.Is_EE = Is_EE
|
cfg.Is_EE = Is_EE
|
||||||
|
cfg.StunHost = GetStunAddr()
|
||||||
cfg.StunPort = GetStunPort()
|
cfg.StunPort = GetStunPort()
|
||||||
|
|
||||||
return cfg
|
return cfg
|
||||||
|
@ -194,6 +195,17 @@ func GetAPIPort() string {
|
||||||
return apiport
|
return apiport
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// GetStunAddr - gets the stun host address
|
||||||
|
func GetStunAddr() string {
|
||||||
|
stunAddr := ""
|
||||||
|
if os.Getenv("STUN_DOMAIN") != "" {
|
||||||
|
stunAddr = os.Getenv("STUN_DOMAIN")
|
||||||
|
} else if config.Config.Server.StunHost != "" {
|
||||||
|
stunAddr = config.Config.Server.StunHost
|
||||||
|
}
|
||||||
|
return stunAddr
|
||||||
|
}
|
||||||
|
|
||||||
// GetDefaultNodeLimit - get node limit if one is set
|
// GetDefaultNodeLimit - get node limit if one is set
|
||||||
func GetDefaultNodeLimit() int32 {
|
func GetDefaultNodeLimit() int32 {
|
||||||
var limit int32
|
var limit int32
|
||||||
|
|
Loading…
Add table
Reference in a new issue