Starting and stopping working

Former-commit-id: f23f2fb9aa
This commit is contained in:
Owen
2025-11-07 14:20:36 -08:00
parent ce3c585514
commit a274b4b38f
2 changed files with 27 additions and 32 deletions

View File

@@ -202,8 +202,6 @@ func main() {
EnableAPI: config.EnableAPI,
HTTPAddr: config.HTTPAddr,
SocketPath: config.SocketPath,
PingInterval: config.PingInterval,
PingTimeout: config.PingTimeout,
Holepunch: config.Holepunch,
TlsClientCert: config.TlsClientCert,
PingIntervalDuration: config.PingIntervalDuration,

View File

@@ -674,17 +674,10 @@ func TunnelProcess(ctx context.Context, config Config, id string, secret string,
olm.RegisterHandler("olm/register/no-sites", func(msg websocket.WSMessage) {
logger.Info("Received no-sites message - no sites available for connection")
// if stopRegister != nil {
// stopRegister()
// stopRegister = nil
// }
// select {
// case <-stopHolepunch:
// // Channel already closed, do nothing
// default:
// close(stopHolepunch)
// }
if stopRegister != nil {
stopRegister()
stopRegister = nil
}
logger.Info("No sites available - stopped registration and holepunch processes")
})
@@ -706,18 +699,18 @@ func TunnelProcess(ctx context.Context, config Config, id string, secret string,
publicKey := privateKey.PublicKey()
logger.Debug("Sending registration message to server with public key: %s and relay: %v", publicKey, !config.Holepunch)
stopRegister = olm.SendMessageInterval("olm/wg/register", map[string]interface{}{
"publicKey": publicKey.String(),
"relay": !config.Holepunch,
"olmVersion": config.Version,
"orgId": config.OrgID,
}, 1*time.Second)
if stopRegister == nil {
logger.Debug("Sending registration message to server with public key: %s and relay: %v", publicKey, !config.Holepunch)
stopRegister = olm.SendMessageInterval("olm/wg/register", map[string]interface{}{
"publicKey": publicKey.String(),
"relay": !config.Holepunch,
"olmVersion": config.Version,
"orgId": config.OrgID,
}, 1*time.Second)
}
go keepSendingPing(olm)
logger.Info("Sent registration message")
return nil
})
@@ -769,18 +762,22 @@ func TunnelProcess(ctx context.Context, config Config, id string, secret string,
}
func Stop() {
select {
case <-stopHolepunch:
// Channel already closed, do nothing
default:
close(stopHolepunch)
if stopHolepunch != nil {
select {
case <-stopHolepunch:
// Channel already closed, do nothing
default:
close(stopHolepunch)
}
}
select {
case <-stopPing:
// Channel already closed
default:
close(stopPing)
if stopPing != nil {
select {
case <-stopPing:
// Channel already closed
default:
close(stopPing)
}
}
if stopRegister != nil {