diff --git a/client/internal/engine.go b/client/internal/engine.go index d80d1f235..ee0974a45 100644 --- a/client/internal/engine.go +++ b/client/internal/engine.go @@ -97,7 +97,7 @@ type EngineConfig struct { type Engine struct { // signal is a Signal Service client signal signal.Client - signaler *Signaler + signaler *peer.Signaler // mgmClient is a Management Service client mgmClient mgm.Client // peerConns is a map that holds all the peers that are known to this peer diff --git a/client/internal/peer/conn.go b/client/internal/peer/conn.go index 16daf492e..609e4d739 100644 --- a/client/internal/peer/conn.go +++ b/client/internal/peer/conn.go @@ -12,7 +12,6 @@ import ( log "github.com/sirupsen/logrus" "golang.zx2c4.com/wireguard/wgctrl/wgtypes" - "github.com/netbirdio/netbird/client/internal" "github.com/netbirdio/netbird/client/internal/stdnet" "github.com/netbirdio/netbird/client/internal/wgproxy" "github.com/netbirdio/netbird/iface" @@ -73,7 +72,7 @@ type Conn struct { statusRecorder *Status wgProxyFactory *wgproxy.Factory wgProxy wgproxy.Proxy - signaler *internal.Signaler + signaler *Signaler allowedIPsIP string handshaker *Handshaker closeCh chan struct{} @@ -95,7 +94,7 @@ type Conn struct { // NewConn creates a new not opened Conn to the remote peer. // To establish a connection run Conn.Open -func NewConn(engineCtx context.Context, config ConnConfig, statusRecorder *Status, wgProxyFactory *wgproxy.Factory, signaler *internal.Signaler, iFaceDiscover stdnet.ExternalIFaceDiscover, relayManager *relayClient.Manager) (*Conn, error) { +func NewConn(engineCtx context.Context, config ConnConfig, statusRecorder *Status, wgProxyFactory *wgproxy.Factory, signaler *Signaler, iFaceDiscover stdnet.ExternalIFaceDiscover, relayManager *relayClient.Manager) (*Conn, error) { _, allowedIPsIP, err := net.ParseCIDR(config.WgConfig.AllowedIps) if err != nil { log.Errorf("failed to parse allowedIPS: %v", err) diff --git a/client/internal/peer/conn_ice.go b/client/internal/peer/conn_ice.go index e3d33a4d7..baf7be4f8 100644 --- a/client/internal/peer/conn_ice.go +++ b/client/internal/peer/conn_ice.go @@ -15,7 +15,6 @@ import ( "github.com/pion/stun/v2" log "github.com/sirupsen/logrus" - "github.com/netbirdio/netbird/client/internal" "github.com/netbirdio/netbird/client/internal/stdnet" "github.com/netbirdio/netbird/iface" "github.com/netbirdio/netbird/iface/bind" @@ -64,7 +63,7 @@ type ConnectorICE struct { log *log.Entry config ConnConfig configICE ICEConfig - signaler *internal.Signaler + signaler *Signaler iFaceDiscover stdnet.ExternalIFaceDiscover statusRecorder *Status onICEConnReady OnICEConnReadyCallback @@ -79,7 +78,7 @@ type ConnectorICE struct { sentExtraSrflx bool } -func NewConnectorICE(ctx context.Context, log *log.Entry, config ConnConfig, configICE ICEConfig, signaler *internal.Signaler, ifaceDiscover stdnet.ExternalIFaceDiscover, statusRecorder *Status, onICEConnReady OnICEConnReadyCallback, doHandshakeFn DoHandshake) *ConnectorICE { +func NewConnectorICE(ctx context.Context, log *log.Entry, config ConnConfig, configICE ICEConfig, signaler *Signaler, ifaceDiscover stdnet.ExternalIFaceDiscover, statusRecorder *Status, onICEConnReady OnICEConnReadyCallback, doHandshakeFn DoHandshake) *ConnectorICE { cice := &ConnectorICE{ ctx: ctx, log: log, diff --git a/client/internal/peer/handshaker.go b/client/internal/peer/handshaker.go index 6562c12e7..f2f2cff59 100644 --- a/client/internal/peer/handshaker.go +++ b/client/internal/peer/handshaker.go @@ -9,7 +9,6 @@ import ( log "github.com/sirupsen/logrus" "golang.zx2c4.com/wireguard/conn" - "github.com/netbirdio/netbird/client/internal" "github.com/netbirdio/netbird/version" ) @@ -60,7 +59,7 @@ type Handshaker struct { mu sync.Mutex ctx context.Context config ConnConfig - signaler *internal.Signaler + signaler *Signaler // remoteOffersCh is a channel used to wait for remote credentials to proceed with the connection remoteOffersCh chan OfferAnswer @@ -71,7 +70,7 @@ type Handshaker struct { remoteOfferAnswerCreated time.Time } -func NewHandshaker(ctx context.Context, config ConnConfig, signaler *internal.Signaler) *Handshaker { +func NewHandshaker(ctx context.Context, config ConnConfig, signaler *Signaler) *Handshaker { return &Handshaker{ ctx: ctx, config: config, diff --git a/client/internal/signaler.go b/client/internal/peer/signaler.go similarity index 80% rename from client/internal/signaler.go rename to client/internal/peer/signaler.go index cd466784d..713123e5d 100644 --- a/client/internal/signaler.go +++ b/client/internal/peer/signaler.go @@ -1,10 +1,9 @@ -package internal +package peer import ( "github.com/pion/ice/v3" "golang.zx2c4.com/wireguard/wgctrl/wgtypes" - "github.com/netbirdio/netbird/client/internal/peer" signal "github.com/netbirdio/netbird/signal/client" sProto "github.com/netbirdio/netbird/signal/proto" ) @@ -21,11 +20,11 @@ func NewSignaler(signal signal.Client, wgPrivateKey wgtypes.Key) *Signaler { } } -func (s *Signaler) SignalOffer(offer peer.OfferAnswer, remoteKey string) error { +func (s *Signaler) SignalOffer(offer OfferAnswer, remoteKey string) error { return s.signalOfferAnswer(offer, remoteKey, sProto.Body_OFFER) } -func (s *Signaler) SignalAnswer(offer peer.OfferAnswer, remoteKey string) error { +func (s *Signaler) SignalAnswer(offer OfferAnswer, remoteKey string) error { return s.signalOfferAnswer(offer, remoteKey, sProto.Body_ANSWER) } @@ -45,7 +44,7 @@ func (s *Signaler) Ready() bool { } // SignalOfferAnswer signals either an offer or an answer to remote peer -func (s *Signaler) signalOfferAnswer(offerAnswer peer.OfferAnswer, remoteKey string, bodyType sProto.Body_Type) error { +func (s *Signaler) signalOfferAnswer(offerAnswer OfferAnswer, remoteKey string, bodyType sProto.Body_Type) error { msg, err := signal.MarshalCredential( s.wgPrivateKey, offerAnswer.WgListenPort,