mirror of
https://github.com/fosrl/olm.git
synced 2026-02-19 03:16:46 +00:00
18
olm/olm.go
18
olm/olm.go
@@ -799,6 +799,24 @@ func StartTunnel(config TunnelConfig) {
|
||||
}
|
||||
})
|
||||
|
||||
olm.OnAuthError(func(statusCode int, message string) {
|
||||
logger.Error("Authentication error (status %d): %s. Terminating tunnel.", statusCode, message)
|
||||
apiServer.SetTerminated(true)
|
||||
apiServer.SetConnectionStatus(false)
|
||||
apiServer.SetRegistered(false)
|
||||
apiServer.ClearPeerStatuses()
|
||||
network.ClearNetworkSettings()
|
||||
Close()
|
||||
|
||||
if globalConfig.OnAuthError != nil {
|
||||
go globalConfig.OnAuthError(statusCode, message)
|
||||
}
|
||||
|
||||
if globalConfig.OnTerminated != nil {
|
||||
go globalConfig.OnTerminated()
|
||||
}
|
||||
})
|
||||
|
||||
// Connect to the WebSocket server
|
||||
if err := olm.Connect(); err != nil {
|
||||
logger.Error("Failed to connect to server: %v", err)
|
||||
|
||||
@@ -45,6 +45,7 @@ type GlobalConfig struct {
|
||||
OnRegistered func()
|
||||
OnConnected func()
|
||||
OnTerminated func()
|
||||
OnAuthError func(statusCode int, message string) // Called when auth fails (401/403)
|
||||
|
||||
// Source tracking (not in JSON)
|
||||
sources map[string]string
|
||||
|
||||
Reference in New Issue
Block a user