Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 15 additions & 8 deletions client/internal/engine.go
Original file line number Diff line number Diff line change
Expand Up @@ -1442,16 +1442,9 @@ func (e *Engine) receiveSignalEvents() {

switch msg.GetBody().Type {
case sProto.Body_OFFER, sProto.Body_ANSWER:
offerAnswer, err := convertToOfferAnswer(msg)
if err != nil {
if err := e.handleOfferAnswer(msg, conn); err != nil {
return err
}

if msg.Body.Type == sProto.Body_OFFER {
conn.OnRemoteOffer(*offerAnswer)
} else {
conn.OnRemoteAnswer(*offerAnswer)
}
case sProto.Body_CANDIDATE:
candidate, err := ice.UnmarshalCandidate(msg.GetBody().Payload)
if err != nil {
Expand Down Expand Up @@ -1479,6 +1472,20 @@ func (e *Engine) receiveSignalEvents() {
e.signal.WaitStreamConnected()
}

func (e *Engine) handleOfferAnswer(msg *sProto.Message, conn *peer.Conn) error {
offerAnswer, err := convertToOfferAnswer(msg)
if err != nil {
return err
}

if msg.Body.Type == sProto.Body_OFFER {
conn.OnRemoteOffer(*offerAnswer)
} else {
conn.OnRemoteAnswer(*offerAnswer)
}
return nil
}

func (e *Engine) parseNATExternalIPMappings() []string {
var mappedIPs []string
var ignoredIFaces = make(map[string]interface{})
Expand Down
4 changes: 3 additions & 1 deletion client/internal/updatemanager/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,9 @@ type UpdateManager struct {

// updateMutex protect update and expectedVersion fields
updateMutex sync.Mutex

// updateFunc is used for testing to mock the triggerUpdate behavior
updateFunc func(ctx context.Context, targetVersion string) error
}

func NewUpdateManager(statusRecorder *peer.Status, stateManager *statemanager.Manager) *UpdateManager {
Expand All @@ -79,7 +82,6 @@ func NewUpdateManager(statusRecorder *peer.Status, stateManager *statemanager.Ma
// CheckUpdateSuccess checks if the update was successful. It works without to start the update manager.
func (u *UpdateManager) CheckUpdateSuccess(ctx context.Context) {
u.updateStateManager(ctx)
return
}

func (u *UpdateManager) Start(ctx context.Context) {
Expand Down
5 changes: 5 additions & 0 deletions client/internal/updatemanager/update_darwin.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,11 @@ const (
)

func (u *UpdateManager) triggerUpdate(ctx context.Context, targetVersion string) error {
// Use test function if set (for testing only)
if u.updateFunc != nil {
return u.updateFunc(ctx, targetVersion)
}

cmd := exec.CommandContext(ctx, "pkgutil", "--pkg-info", "io.netbird.client")
outBytes, err := cmd.Output()
if err != nil && cmd.ProcessState.ExitCode() == 1 {
Expand Down
5 changes: 5 additions & 0 deletions client/internal/updatemanager/update_freebsd.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@ package updatemanager
import "context"

func (u *UpdateManager) triggerUpdate(ctx context.Context, targetVersion string) error {
// Use test function if set (for testing purposes)
if u.updateFunc != nil {
return u.updateFunc(ctx, targetVersion)
}

// TODO: Implement
return nil
}
5 changes: 5 additions & 0 deletions client/internal/updatemanager/update_js.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@ package updatemanager
import "context"

func (u *UpdateManager) triggerUpdate(ctx context.Context, targetVersion string) error {
// Use test function if set (for testing purposes)
if u.updateFunc != nil {
return u.updateFunc(ctx, targetVersion)
}

// TODO: Implement
return nil
}
5 changes: 5 additions & 0 deletions client/internal/updatemanager/update_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@ package updatemanager
import "context"

func (u *UpdateManager) triggerUpdate(ctx context.Context, targetVersion string) error {
// Use test function if set (for testing purposes)
if u.updateFunc != nil {
return u.updateFunc(ctx, targetVersion)
}

// TODO: Implement
return nil
}
5 changes: 5 additions & 0 deletions client/internal/updatemanager/update_windows.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,11 @@ const (
type installerType string

func (u *UpdateManager) triggerUpdate(ctx context.Context, targetVersion string) error {
// Use test function if set (for testing purposes)
if u.updateFunc != nil {
return u.updateFunc(ctx, targetVersion)
}

method := installation()
return install(ctx, method, targetVersion)
}
Expand Down
Loading