mirror of
https://github.com/fosrl/olm.git
synced 2026-02-08 05:56:41 +00:00
Rename and clear network settings
This commit is contained in:
2
main.go
2
main.go
@@ -226,5 +226,5 @@ func runOlmMainWithArgs(ctx context.Context, args []string) {
|
||||
// DoNotCreateNewClient: config.DoNotCreateNewClient,
|
||||
}
|
||||
|
||||
olm.Run(ctx, olmConfig)
|
||||
olm.Init(ctx, olmConfig)
|
||||
}
|
||||
|
||||
18
olm/olm.go
18
olm/olm.go
@@ -78,7 +78,7 @@ var (
|
||||
stopPing chan struct{}
|
||||
)
|
||||
|
||||
func Run(ctx context.Context, config Config) {
|
||||
func Init(ctx context.Context, config Config) {
|
||||
// Create a cancellable context for internal shutdown control
|
||||
ctx, cancel := context.WithCancel(ctx)
|
||||
defer cancel()
|
||||
@@ -144,7 +144,7 @@ func Run(ctx context.Context, config Config) {
|
||||
if id != "" && secret != "" && endpoint != "" {
|
||||
logger.Info("Starting tunnel with new credentials")
|
||||
tunnelRunning = true
|
||||
go TunnelProcess(ctx, config, id, secret, userToken, endpoint)
|
||||
go StartTunnel(ctx, config, id, secret, userToken, endpoint)
|
||||
}
|
||||
|
||||
case <-apiServer.GetDisconnectChannel():
|
||||
@@ -161,7 +161,7 @@ func Run(ctx context.Context, config Config) {
|
||||
if id != "" && secret != "" && endpoint != "" && !tunnelRunning {
|
||||
logger.Info("Starting tunnel process with initial credentials")
|
||||
tunnelRunning = true
|
||||
go TunnelProcess(ctx, config, id, secret, userToken, endpoint)
|
||||
go StartTunnel(ctx, config, id, secret, userToken, endpoint)
|
||||
} else if id == "" || secret == "" || endpoint == "" {
|
||||
// If we don't have credentials, check if API is enabled
|
||||
if !config.EnableAPI {
|
||||
@@ -187,12 +187,12 @@ func Run(ctx context.Context, config Config) {
|
||||
}
|
||||
|
||||
shutdown:
|
||||
Stop()
|
||||
Close()
|
||||
apiServer.Stop()
|
||||
logger.Info("Olm service shutting down")
|
||||
}
|
||||
|
||||
func TunnelProcess(ctx context.Context, config Config, id string, secret string, userToken string, endpoint string) {
|
||||
func StartTunnel(ctx context.Context, config Config, id string, secret string, userToken string, endpoint string) {
|
||||
// Create a cancellable context for this tunnel process
|
||||
tunnelCtx, cancel := context.WithCancel(ctx)
|
||||
tunnelCancel = cancel
|
||||
@@ -788,7 +788,7 @@ func TunnelProcess(ctx context.Context, config Config, id string, secret string,
|
||||
// Mark as not connected to trigger re-registration
|
||||
connected = false
|
||||
|
||||
Stop()
|
||||
Close()
|
||||
|
||||
// Clear peer statuses in API
|
||||
apiServer.SetRegistered(false)
|
||||
@@ -812,7 +812,7 @@ func TunnelProcess(ctx context.Context, config Config, id string, secret string,
|
||||
logger.Info("Tunnel process context cancelled, cleaning up")
|
||||
}
|
||||
|
||||
func Stop() {
|
||||
func Close() {
|
||||
// Stop hole punch manager
|
||||
if holePunchManager != nil {
|
||||
holePunchManager.Stop()
|
||||
@@ -881,7 +881,7 @@ func StopTunnel() {
|
||||
olmClient = nil
|
||||
}
|
||||
|
||||
Stop()
|
||||
Close()
|
||||
|
||||
// Reset the connected state
|
||||
connected = false
|
||||
@@ -892,5 +892,7 @@ func StopTunnel() {
|
||||
apiServer.SetRegistered(false)
|
||||
apiServer.SetTunnelIP("")
|
||||
|
||||
network.ClearNetworkSettings()
|
||||
|
||||
logger.Info("Tunnel process stopped")
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user