Starting and stopping working

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

View File

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