Skip to content

Commit

Permalink
feat: notifying about actual ip update through protobuf
Browse files Browse the repository at this point in the history
  • Loading branch information
gbaranski committed Jan 16, 2025
1 parent 8425660 commit a7d425b
Show file tree
Hide file tree
Showing 6 changed files with 31 additions and 10 deletions.
7 changes: 6 additions & 1 deletion daemon/job_actual_ip.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,12 @@ func updateActualIP(dm *DataManager, api core.InsightsAPI, ctx context.Context,
func JobActualIP(statePublisher *state.StatePublisher, dm *DataManager, api core.InsightsAPI) {
call := func(ctx context.Context, isConnected bool) {
err := updateActualIP(dm, api, ctx, isConnected)
if err != nil {
if err == nil {
err := statePublisher.NotifyActualIPUpdate()
if err != nil {
log.Println(internal.ErrorPrefix, "notify about actual ip update failed: ", err)
}
} else {
if err == context.Canceled {
return
}
Expand Down
16 changes: 10 additions & 6 deletions daemon/pb/state.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 10 additions & 0 deletions daemon/state/state.go
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,16 @@ func (s *StatePublisher) NotifyServersListUpdate(any) error {
return nil
}

func (s *StatePublisher) NotifyActualIPUpdate() error {
s.mu.Lock()
defer s.mu.Unlock()

log.Println(internal.DebugPrefix, "notifying actual ip update")
s.notify(pb.UpdateEvent_ACTUAL_IP_UPDATE)

return nil
}

func (s *StatePublisher) NotifySubscriptionChanged(e *pb.AccountModification) error {
s.mu.Lock()
defer s.mu.Unlock()
Expand Down
2 changes: 1 addition & 1 deletion protobuf/daemon/state.proto
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ enum LoginEventType {

enum UpdateEvent {
SERVERS_LIST_UPDATE = 0;
ACTUAL_IP_UPDATE = 1;
}

message AccountModification {
Expand All @@ -54,4 +55,3 @@ message AppState {
AccountModification account_modification = 6;
}
}

4 changes: 2 additions & 2 deletions test/qa/lib/protobuf/daemon/state_pb2.py

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions test/qa/lib/protobuf/daemon/state_pb2.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,15 @@ class LoginEventType(int, metaclass=_enum_type_wrapper.EnumTypeWrapper):
class UpdateEvent(int, metaclass=_enum_type_wrapper.EnumTypeWrapper):
__slots__ = ()
SERVERS_LIST_UPDATE: _ClassVar[UpdateEvent]
ACTUAL_IP_UPDATE: _ClassVar[UpdateEvent]
FAILED_TO_GET_UID: AppStateError
DISCONNECTED: ConnectionState
CONNECTING: ConnectionState
CONNECTED: ConnectionState
LOGIN: LoginEventType
LOGOUT: LoginEventType
SERVERS_LIST_UPDATE: UpdateEvent
ACTUAL_IP_UPDATE: UpdateEvent

class ConnectionStatus(_message.Message):
__slots__ = ("state", "server_ip", "server_country", "server_city", "server_hostname", "server_name", "is_mesh_peer", "by_user")
Expand Down

0 comments on commit a7d425b

Please sign in to comment.