mirror of
https://github.com/fosrl/olm.git
synced 2026-02-08 05:56:41 +00:00
Starting and stopping working
This commit is contained in:
2
main.go
2
main.go
@@ -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,
|
||||||
|
|||||||
57
olm/olm.go
57
olm/olm.go
@@ -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 {
|
||||||
|
|||||||
Reference in New Issue
Block a user