Skip to content

Commit

Permalink
Fix lints
Browse files Browse the repository at this point in the history
  • Loading branch information
pappz committed Dec 18, 2023
1 parent 471ee41 commit b3ed5b1
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 14 deletions.
21 changes: 11 additions & 10 deletions client/internal/engine.go
Expand Up @@ -14,6 +14,7 @@ import (
"time"

"github.com/pion/ice/v3"
"github.com/pion/stun/v2"
log "github.com/sirupsen/logrus"
"golang.zx2c4.com/wireguard/wgctrl/wgtypes"

Expand Down Expand Up @@ -95,9 +96,9 @@ type Engine struct {
mobileDep MobileDependency

// STUNs is a list of STUN servers used by ICE
STUNs []*ice.URL
STUNs []*stun.URI
// TURNs is a list of STUN servers used by ICE
TURNs []*ice.URL
TURNs []*stun.URI

cancel context.CancelFunc

Expand Down Expand Up @@ -146,8 +147,8 @@ func NewEngine(
syncMsgMux: &sync.Mutex{},
config: config,
mobileDep: mobileDep,
STUNs: []*ice.URL{},
TURNs: []*ice.URL{},
STUNs: []*stun.URI{},
TURNs: []*stun.URI{},
networkSerial: 0,
sshServerFunc: nbssh.DefaultSSHServer,
statusRecorder: statusRecorder,
Expand Down Expand Up @@ -565,10 +566,10 @@ func (e *Engine) updateSTUNs(stuns []*mgmProto.HostConfig) error {
if len(stuns) == 0 {
return nil
}
var newSTUNs []*ice.URL
var newSTUNs []*stun.URI
log.Debugf("got STUNs update from Management Service, updating")
for _, stun := range stuns {
url, err := ice.ParseURL(stun.Uri)
for _, s := range stuns {
url, err := stun.ParseURI(s.Uri)
if err != nil {
return err
}
Expand All @@ -583,10 +584,10 @@ func (e *Engine) updateTURNs(turns []*mgmProto.ProtectedHostConfig) error {
if len(turns) == 0 {
return nil
}
var newTURNs []*ice.URL
var newTURNs []*stun.URI
log.Debugf("got TURNs update from Management Service, updating")
for _, turn := range turns {
url, err := ice.ParseURL(turn.HostConfig.Uri)
url, err := stun.ParseURI(turn.HostConfig.Uri)
if err != nil {
return err
}
Expand Down Expand Up @@ -836,7 +837,7 @@ func (e *Engine) peerExists(peerKey string) bool {

func (e *Engine) createPeerConn(pubKey string, allowedIPs string) (*peer.Conn, error) {
log.Debugf("creating peer connection %s", pubKey)
var stunTurn []*ice.URL
var stunTurn []*stun.URI
stunTurn = append(stunTurn, e.STUNs...)
stunTurn = append(stunTurn, e.TURNs...)

Expand Down
5 changes: 3 additions & 2 deletions client/internal/peer/conn.go
Expand Up @@ -9,6 +9,7 @@ import (
"time"

"github.com/pion/ice/v3"
"github.com/pion/stun/v2"
log "github.com/sirupsen/logrus"
"golang.zx2c4.com/wireguard/wgctrl/wgtypes"

Expand Down Expand Up @@ -45,7 +46,7 @@ type ConnConfig struct {
LocalKey string

// StunTurn is a list of STUN and TURN URLs
StunTurn []*ice.URL
StunTurn []*stun.URI

// InterfaceBlackList is a list of machine interfaces that should be filtered out by ICE Candidate gathering
// (e.g. if eth0 is in the list, host candidate of this interface won't be used)
Expand Down Expand Up @@ -141,7 +142,7 @@ func (conn *Conn) WgConfig() WgConfig {
}

// UpdateStunTurn update the turn and stun addresses
func (conn *Conn) UpdateStunTurn(turnStun []*ice.URL) {
func (conn *Conn) UpdateStunTurn(turnStun []*stun.URI) {
conn.config.StunTurn = turnStun
}

Expand Down
4 changes: 2 additions & 2 deletions client/internal/peer/conn_test.go
Expand Up @@ -6,7 +6,7 @@ import (
"time"

"github.com/magiconair/properties/assert"
"github.com/pion/ice/v3"
"github.com/pion/stun/v2"

"github.com/netbirdio/netbird/client/internal/stdnet"
"github.com/netbirdio/netbird/client/internal/wgproxy"
Expand All @@ -16,7 +16,7 @@ import (
var connConf = ConnConfig{
Key: "LLHf3Ma6z6mdLbriAJbqhX7+nM/B71lgw2+91q3LfhU=",
LocalKey: "RRHf3Ma6z6mdLbriAJbqhX7+nM/B71lgw2+91q3LfhU=",
StunTurn: []*ice.URL{},
StunTurn: []*stun.URI{},
InterfaceBlackList: nil,
Timeout: time.Second,
LocalWgPort: 51820,
Expand Down
1 change: 1 addition & 0 deletions sharedsock/sock_linux_test.go
Expand Up @@ -11,6 +11,7 @@ import (
"testing"
"time"

"github.com/pion/stun/v2"
log "github.com/sirupsen/logrus"
"github.com/stretchr/testify/require"
"golang.org/x/sync/errgroup"
Expand Down

0 comments on commit b3ed5b1

Please sign in to comment.