Skip to content

Commit

Permalink
v0.20.1 (#443)
Browse files Browse the repository at this point in the history
* Bump golang.org/x/term from 0.7.0 to 0.8.0

Bumps [golang.org/x/term](https://github.com/golang/term) from 0.7.0 to 0.8.0.
- [Commits](golang/term@v0.7.0...v0.8.0)

---
updated-dependencies:
- dependency-name: golang.org/x/term
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <[email protected]>

* workflow refactor

* limit gui builds

* txeh updates

* Bump github.com/guumaster/hostctl from 1.1.3 to 1.1.4

Bumps [github.com/guumaster/hostctl](https://github.com/guumaster/hostctl) from 1.1.3 to 1.1.4.
- [Release notes](https://github.com/guumaster/hostctl/releases)
- [Changelog](https://github.com/guumaster/hostctl/blob/master/.goreleaser.yml)
- [Commits](guumaster/hostctl@v1.1.3...v1.1.4)

---
updated-dependencies:
- dependency-name: github.com/guumaster/hostctl
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <[email protected]>

* Bump golang.org/x/net from 0.9.0 to 0.10.0 (#402)

Bumps [golang.org/x/net](https://github.com/golang/net) from 0.9.0 to 0.10.0.
- [Commits](golang/net@v0.9.0...v0.10.0)

---
updated-dependencies:
- dependency-name: golang.org/x/net
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* fixed data endcoding (#400)

* fixed data endcoding

* remove redundant casting

* Bump golang.org/x/crypto from 0.8.0 to 0.9.0 (#403)

Bumps [golang.org/x/crypto](https://github.com/golang/crypto) from 0.8.0 to 0.9.0.
- [Commits](golang/crypto@v0.8.0...v0.9.0)

---
updated-dependencies:
- dependency-name: golang.org/x/crypto
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* NET-89:  TURN reactive Implementation (#398)

* initialize turn client always, irrespective of nat type

* run background thread to resolve peer connection using turn

* update go mod

* add read lock for turncfg

* use conn negotitation action at required locations

* use lasthandshake for connection status

* use a separate wait group for proxy threads

* comments fix

* typo fix

* add additional logging for errors

* update go mod

* update action var name

* update go mod

* use relevant func name

* pr comments

* Bump github.com/wailsapp/wails/v2 from 2.2.0 to 2.5.0 (#404)

Bumps [github.com/wailsapp/wails/v2](https://github.com/wailsapp/wails) from 2.2.0 to 2.5.0.
- [Release notes](https://github.com/wailsapp/wails/releases)
- [Commits](wailsapp/wails@v2.2.0...v2.5.0)

---
updated-dependencies:
- dependency-name: github.com/wailsapp/wails/v2
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* Bump alpine from 3.17.3 to 3.18.0 (#401)

Bumps alpine from 3.17.3 to 3.18.0.

---
updated-dependencies:
- dependency-name: alpine
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* update versions (#406)

* Bump github.com/wailsapp/wails/v2 from 2.5.0 to 2.5.1 (#414)

Bumps [github.com/wailsapp/wails/v2](https://github.com/wailsapp/wails) from 2.5.0 to 2.5.1.
- [Release notes](https://github.com/wailsapp/wails/releases)
- [Commits](wailsapp/wails@v2.5.0...v2.5.1)

---
updated-dependencies:
- dependency-name: github.com/wailsapp/wails/v2
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* discord message after branch test run (#419)

* discord message after branch test run

* add repo to discord message

* ripping out netmaker.conf (#415)

* add ip6tabels support to docker netclient (#421)

* prevent updates to host params that should not be changed (#417)

* NET-10: Refactor Peer update Phase-1 (#407)

* singleton peer update mq handler

* process adding and removing single peer

* avoid restarting daemon on join to network host update

* handle peer list on singleton update

* support multiple peer removal

* use map for peer data

* init peer map

* don't retrun if wg file update fails

* add debug comment

* add debug comment

* add func comments

* add comment

* rm ununsed funcs

* prevent server overwriting immutable host parameters

* Revert "NET-10: Refactor Peer update Phase-1 (#407)"

This reverts commit 627b924.

---------

Co-authored-by: Abhishek K <[email protected]>

* NET-186: hole punch wg port, start proxy on free port available (#420)

* report wg public listen port

* save the proxy port

* debug log

* checkin with servers on broker connection

* start proxy on freeport

* revert proxy autoswitch removal

* use natinfo for proxy port

* pr comments

* Net 202  (#422)

* join endpoint

* sso endpoint for gui

* review comments

* sso registration with gui (#389)

* Revert "fix(GRA-1387): remove join by sso/basic auth"

This reverts commit ec8630d.

* feat(NET-20): add join by basic auth for nc-gui

* fix(NET-20): wip - join by oauth/basic auth

* join endpoint

* sso endpoint for gui

* review comments

* fix(NET-20): wip - join by oauth/basic auth

* fix(NET-20):  join by oauth/basic auth

* Revert "join endpoint"

This reverts commit 5f2351f.

* fix(NET-20): only join via enrollment key option

---------

Co-authored-by: Matthew R Kasun <[email protected]>

* version and release note updates (#423)

* Net 12 (#427)

* discord message after branch test run

* add repo to discord message

* .goreleaser update

* NET-185 Dont re-use the Config struct (#432)

* - dont re-use the Config struct- gitignore for idea

* test for yaml config merging

* NET-287: get host public IP using stun (#431)

* get host public IP using stun

* check if ip is not specified

* check if ip is not specified

* update go mod for release

---------

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Matthew R Kasun <[email protected]>
Co-authored-by: Alex Feiszli <[email protected]>
Co-authored-by: Abhishek K <[email protected]>
Co-authored-by: Aceix <[email protected]>
Co-authored-by: Tobias Cudnik <[email protected]>
Co-authored-by: Gravitl <[email protected]>
  • Loading branch information
8 people authored Jun 7, 2023
1 parent ca49f99 commit 1a6cefd
Show file tree
Hide file tree
Showing 9 changed files with 64 additions and 73 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,4 @@ gui/build/
gui/**/dist/
backup/*
dist/*
/.idea
3 changes: 3 additions & 0 deletions config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@ var (
GW6Addr net.IPNet
// WgPublicListenPort - host's wireguard public listen port
WgPublicListenPort int
// HostPublicIP - host's public endpoint
HostPublicIP net.IP
)

// Config configuration for netclient and host as a whole
Expand Down Expand Up @@ -210,6 +212,7 @@ func ReadNetclientConfig() (*Config, error) {
return nil, err
}
defer f.Close()
netclient = Config{}
if err := yaml.NewDecoder(f).Decode(&netclient); err != nil {
return nil, err
}
Expand Down
41 changes: 41 additions & 0 deletions config/config_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
package config

import (
"strings"
"testing"

"github.com/stretchr/testify/assert"
"gopkg.in/yaml.v3"
)

func TestReadNetclientConfig(t *testing.T) {
var err error
type ConfigMin struct {
Test bool `yaml:"test"`
HostPeers map[string][]struct{ UpdateOnly bool } `yaml:"peers"`
}
empty := ConfigMin{}
existing := ConfigMin{
HostPeers: map[string][]struct{ UpdateOnly bool }{
"foo1": {
{UpdateOnly: true},
},
},
}
data := "test: true\npeers:\n foo2:\n - UpdateOnly: false"

// test empty config
err = yaml.NewDecoder(strings.NewReader(data)).Decode(&empty)
assert.NoError(t, err)
assert.True(t, empty.Test)
assert.NotEmpty(t, empty.HostPeers["foo2"])

// test existing config
assert.NotEmpty(t, existing.HostPeers["foo1"], "foo1 existing before Decode")
err = yaml.NewDecoder(strings.NewReader(data)).Decode(&existing)
assert.NoError(t, err)
assert.True(t, existing.Test)
// "foo1" tags along from before `Decode`
assert.NotEmpty(t, existing.HostPeers["foo1"], "foo1 exists after Decode")
assert.NotEmpty(t, existing.HostPeers["foo2"])
}
12 changes: 7 additions & 5 deletions functions/daemon.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"context"
"errors"
"fmt"
"net"
"os"
"os/signal"
"sync"
Expand Down Expand Up @@ -131,7 +132,7 @@ func startGoRoutines(wg *sync.WaitGroup) context.CancelFunc {
if err := config.ReadServerConf(); err != nil {
logger.Log(0, "errors reading server map from disk", err.Error())
}
config.WgPublicListenPort = holePunchWgPort()
config.HostPublicIP, config.WgPublicListenPort = holePunchWgPort()
logger.Log(0, fmt.Sprint("wireguard public listen port: ", config.WgPublicListenPort))
setNatInfo()
logger.Log(3, "configuring netmaker wireguard interface")
Expand Down Expand Up @@ -447,13 +448,14 @@ func RemoveServer(node *config.Node) {
delete(ServerSet, node.Server)
}

func holePunchWgPort() (pubPort int) {
func holePunchWgPort() (pubIP net.IP, pubPort int) {
for _, server := range config.Servers {
portToStun := config.Netclient().ListenPort
_, pubPort = stun.HolePunch(server.StunList, portToStun)
if pubPort != 0 {
break
pubIP, pubPort = stun.HolePunch(server.StunList, portToStun)
if pubPort == 0 || pubIP == nil || pubIP.IsUnspecified() {
continue
}
break
}
return
}
Expand Down
18 changes: 8 additions & 10 deletions functions/mqpublish.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import (
"encoding/json"
"errors"
"fmt"
"net"
"net/http"
"strconv"
"sync"
Expand Down Expand Up @@ -240,21 +239,20 @@ func UpdateHostSettings() error {
_ = config.ReadServerConf()
logger.Log(3, "checkin with server(s)")
var (
publicIP string
err error
publishMsg bool
)
for _, serverName := range config.GetServers() {
server := config.GetServer(serverName)
if !config.Netclient().IsStatic {
publicIP, err = ncutils.GetPublicIP(server.API)
if err != nil {
logger.Log(1, "error encountered checking public ip addresses: ", err.Error())
}
if len(publicIP) > 0 && config.Netclient().EndpointIP.String() != publicIP {
logger.Log(0, "endpoint has changed from", config.Netclient().EndpointIP.String(), "to", publicIP)
config.Netclient().EndpointIP = net.ParseIP(publicIP)
publishMsg = true
if config.Netclient().EndpointIP == nil {
config.Netclient().EndpointIP = config.HostPublicIP
} else {
if config.HostPublicIP != nil && !config.HostPublicIP.IsUnspecified() && !config.Netclient().EndpointIP.Equal(config.HostPublicIP) {
logger.Log(0, "endpoint has changed from", config.Netclient().EndpointIP.String(), "to", config.HostPublicIP.String())
config.Netclient().EndpointIP = config.HostPublicIP
publishMsg = true
}
}
}
if config.WgPublicListenPort != 0 && config.Netclient().WgPublicListenPort != config.WgPublicListenPort {
Expand Down
15 changes: 0 additions & 15 deletions functions/register.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import (
"encoding/json"
"errors"
"fmt"
"net"
"net/http"
"os"
"strconv"
Expand Down Expand Up @@ -98,20 +97,6 @@ func doubleCheck(host *config.Config, apiServer string) (shouldUpdate bool, err
host.HostPass = logic.RandomString(32)
shouldUpdateHost = true
}
if host.EndpointIP == nil {
ip, err := ncutils.GetPublicIP(apiServer)
if err != nil {
return false, err
}
host.EndpointIP = net.ParseIP(ip)
if err != nil {
return false, fmt.Errorf("error setting public ip %w", err)
}
if host.EndpointIP == nil {
return false, fmt.Errorf("error setting public endpoint for host - %v", err)
}
shouldUpdateHost = true
}
if shouldUpdateHost {
config.UpdateNetclient(*host)
config.WriteNetclientConfig()
Expand Down
3 changes: 3 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ require (
github.com/rhysd/go-github-selfupdate v1.2.3
github.com/spf13/cobra v1.7.0
github.com/spf13/viper v1.15.0
github.com/stretchr/testify v1.8.3
github.com/vishvananda/netlink v1.1.0
github.com/wailsapp/wails/v2 v2.5.1
golang.design/x/clipboard v0.7.0
Expand All @@ -43,6 +44,7 @@ require (
github.com/bep/debounce v1.2.1 // indirect
github.com/bytedance/sonic v1.8.0 // indirect; indirectvar peerUpdate models.HostPeerUpdate
github.com/chenzhuoyu/base64x v0.0.0-20221115062448-fe3a3abad311 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/docker/distribution v2.8.1+incompatible // indirect
github.com/docker/docker v23.0.5+incompatible // indirect
github.com/docker/go-connections v0.4.0 // indirect
Expand Down Expand Up @@ -95,6 +97,7 @@ require (
github.com/pion/transport/v2 v2.2.0 // indirect
github.com/pkg/browser v0.0.0-20210706143420-7d21f8c997e2 // indirect
github.com/pkg/errors v0.9.1 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/posthog/posthog-go v0.0.0-20211028072449-93c17c49e2b0 // indirect
github.com/rogpeppe/go-internal v1.9.0 // indirect
github.com/rqlite/gorqlite v0.0.0-20210514125552-08ff1e76b22f // indirect
Expand Down
1 change: 1 addition & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -350,6 +350,7 @@ github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO
github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4=
github.com/stretchr/testify v1.8.2/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4=
github.com/stretchr/testify v1.8.3 h1:RP3t2pwF7cMEbC1dqtB6poj3niw/9gnV4Cjg5oW5gtY=
github.com/stretchr/testify v1.8.3/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo=
github.com/subosito/gotenv v1.4.2 h1:X1TuBLAMDFbaTAChgCBLu3DU3UPyELpnF2jjJ2cz/S8=
github.com/subosito/gotenv v1.4.2/go.mod h1:ayKnFf/c6rvx/2iiLrJUk1e6plDbT3edrFNGqEflhK0=
github.com/tcnksm/go-gitconfig v0.1.2 h1:iiDhRitByXAEyjgBqsKi9QU4o2TNtv9kPP3RgPgXBPw=
Expand Down
43 changes: 0 additions & 43 deletions ncutils/netclientutils.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import (
"io"
"log"
"net"
"net/http"
"os"
"os/exec"
"regexp"
Expand Down Expand Up @@ -118,48 +117,6 @@ func IsEmptyRecord(err error) bool {
return strings.Contains(err.Error(), NoDBRecord) || strings.Contains(err.Error(), NoDBRecords)
}

// GetPublicIP - gets public ip
func GetPublicIP(api string) (string, error) {

iplist := []string{"https://ip.client.gravitl.com", "https://ifconfig.me", "https://api.ipify.org", "https://ipinfo.io/ip"}

//for network, ipService := range global_settings.PublicIPServices {
//logger.Log(3, "User provided public IP service defined for network", network, "is", ipService)

// prepend the user-specified service so it's checked first
// iplist = append([]string{ipService}, iplist...)
//}
if api != "" {
api = "https://" + api + "/api/getip"
iplist = append([]string{api}, iplist...)
}

endpoint := ""
var err error
for _, ipserver := range iplist {
client := &http.Client{
Timeout: time.Second * 10,
}
resp, err := client.Get(ipserver)
if err != nil {
continue
}
defer resp.Body.Close()
if resp.StatusCode == http.StatusOK {
bodyBytes, err := io.ReadAll(resp.Body)
if err != nil {
continue
}
endpoint = string(bodyBytes)
break
}
}
if err == nil && endpoint == "" {
err = errors.New("public address not found")
}
return endpoint, err
}

// GetMacAddr - get's mac address
func GetMacAddr() ([]net.HardwareAddr, error) {
ifas, err := net.Interfaces()
Expand Down

0 comments on commit 1a6cefd

Please sign in to comment.