Rename and clear network settings

Former-commit-id: e7be7fb281
This commit is contained in:
Owen
2025-11-18 16:23:36 -05:00
committed by miloschwartz
parent d4c5292e8f
commit 3e2cb70d58
2 changed files with 11 additions and 9 deletions

View File

@@ -226,5 +226,5 @@ func runOlmMainWithArgs(ctx context.Context, args []string) {
// DoNotCreateNewClient: config.DoNotCreateNewClient, // DoNotCreateNewClient: config.DoNotCreateNewClient,
} }
olm.Run(ctx, olmConfig) olm.Init(ctx, olmConfig)
} }

View File

@@ -78,7 +78,7 @@ var (
stopPing chan struct{} 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 // Create a cancellable context for internal shutdown control
ctx, cancel := context.WithCancel(ctx) ctx, cancel := context.WithCancel(ctx)
defer cancel() defer cancel()
@@ -144,7 +144,7 @@ func Run(ctx context.Context, config Config) {
if id != "" && secret != "" && endpoint != "" { if id != "" && secret != "" && endpoint != "" {
logger.Info("Starting tunnel with new credentials") logger.Info("Starting tunnel with new credentials")
tunnelRunning = true tunnelRunning = true
go TunnelProcess(ctx, config, id, secret, userToken, endpoint) go StartTunnel(ctx, config, id, secret, userToken, endpoint)
} }
case <-apiServer.GetDisconnectChannel(): case <-apiServer.GetDisconnectChannel():
@@ -161,7 +161,7 @@ func Run(ctx context.Context, config Config) {
if id != "" && secret != "" && endpoint != "" && !tunnelRunning { if id != "" && secret != "" && endpoint != "" && !tunnelRunning {
logger.Info("Starting tunnel process with initial credentials") logger.Info("Starting tunnel process with initial credentials")
tunnelRunning = true tunnelRunning = true
go TunnelProcess(ctx, config, id, secret, userToken, endpoint) go StartTunnel(ctx, config, id, secret, userToken, endpoint)
} else if id == "" || secret == "" || endpoint == "" { } else if id == "" || secret == "" || endpoint == "" {
// If we don't have credentials, check if API is enabled // If we don't have credentials, check if API is enabled
if !config.EnableAPI { if !config.EnableAPI {
@@ -187,12 +187,12 @@ func Run(ctx context.Context, config Config) {
} }
shutdown: shutdown:
Stop() Close()
apiServer.Stop() apiServer.Stop()
logger.Info("Olm service shutting down") 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 // Create a cancellable context for this tunnel process
tunnelCtx, cancel := context.WithCancel(ctx) tunnelCtx, cancel := context.WithCancel(ctx)
tunnelCancel = cancel 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 // Mark as not connected to trigger re-registration
connected = false connected = false
Stop() Close()
// Clear peer statuses in API // Clear peer statuses in API
apiServer.SetRegistered(false) 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") logger.Info("Tunnel process context cancelled, cleaning up")
} }
func Stop() { func Close() {
// Stop hole punch manager // Stop hole punch manager
if holePunchManager != nil { if holePunchManager != nil {
holePunchManager.Stop() holePunchManager.Stop()
@@ -881,7 +881,7 @@ func StopTunnel() {
olmClient = nil olmClient = nil
} }
Stop() Close()
// Reset the connected state // Reset the connected state
connected = false connected = false
@@ -892,5 +892,7 @@ func StopTunnel() {
apiServer.SetRegistered(false) apiServer.SetRegistered(false)
apiServer.SetTunnelIP("") apiServer.SetTunnelIP("")
network.ClearNetworkSettings()
logger.Info("Tunnel process stopped") logger.Info("Tunnel process stopped")
} }