mirror of
https://github.com/fosrl/olm.git
synced 2026-02-08 05:56:41 +00:00
@@ -216,15 +216,15 @@ func (o *Olm) handleSync(msg websocket.WSMessage) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
var wgData WgData
|
var syncData SyncData
|
||||||
if err := json.Unmarshal(jsonData, &wgData); err != nil {
|
if err := json.Unmarshal(jsonData, &syncData); err != nil {
|
||||||
logger.Error("Error unmarshaling sync data: %v", err)
|
logger.Error("Error unmarshaling sync data: %v", err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
// Build a map of expected peers from the incoming data
|
// Build a map of expected peers from the incoming data
|
||||||
expectedPeers := make(map[int]peers.SiteConfig)
|
expectedPeers := make(map[int]peers.SiteConfig)
|
||||||
for _, site := range wgData.Sites {
|
for _, site := range syncData.Sites {
|
||||||
expectedPeers[site.SiteId] = site
|
expectedPeers[site.SiteId] = site
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
15
olm/olm.go
15
olm/olm.go
@@ -60,8 +60,6 @@ type Olm struct {
|
|||||||
stopRegister func()
|
stopRegister func()
|
||||||
updateRegister func(newData any)
|
updateRegister func(newData any)
|
||||||
|
|
||||||
stopServerPing func()
|
|
||||||
|
|
||||||
stopPeerSend func()
|
stopPeerSend func()
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -332,14 +330,6 @@ func (o *Olm) StartTunnel(config TunnelConfig) {
|
|||||||
|
|
||||||
o.apiServer.SetConnectionStatus(true)
|
o.apiServer.SetConnectionStatus(true)
|
||||||
|
|
||||||
// restart the ping if we need to
|
|
||||||
if o.stopServerPing == nil {
|
|
||||||
o.stopServerPing, _ = olmClient.SendMessageInterval("olm/ping", map[string]any{
|
|
||||||
"timestamp": time.Now().Unix(),
|
|
||||||
"userToken": olmClient.GetConfig().UserToken,
|
|
||||||
}, 30*time.Second, -1) // -1 means dont time out with the max attempts
|
|
||||||
}
|
|
||||||
|
|
||||||
if o.connected {
|
if o.connected {
|
||||||
logger.Debug("Already connected, skipping registration")
|
logger.Debug("Already connected, skipping registration")
|
||||||
return nil
|
return nil
|
||||||
@@ -445,11 +435,6 @@ func (o *Olm) Close() {
|
|||||||
o.holePunchManager = nil
|
o.holePunchManager = nil
|
||||||
}
|
}
|
||||||
|
|
||||||
if o.stopServerPing != nil {
|
|
||||||
o.stopServerPing()
|
|
||||||
o.stopServerPing = nil
|
|
||||||
}
|
|
||||||
|
|
||||||
if o.stopRegister != nil {
|
if o.stopRegister != nil {
|
||||||
o.stopRegister()
|
o.stopRegister()
|
||||||
o.stopRegister = nil
|
o.stopRegister = nil
|
||||||
|
|||||||
@@ -12,6 +12,10 @@ type WgData struct {
|
|||||||
UtilitySubnet string `json:"utilitySubnet"` // this is for things like the DNS server, and alias addresses
|
UtilitySubnet string `json:"utilitySubnet"` // this is for things like the DNS server, and alias addresses
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type SyncData struct {
|
||||||
|
Sites []peers.SiteConfig `json:"sites"`
|
||||||
|
}
|
||||||
|
|
||||||
type OlmConfig struct {
|
type OlmConfig struct {
|
||||||
// Logging
|
// Logging
|
||||||
LogLevel string
|
LogLevel string
|
||||||
|
|||||||
@@ -657,8 +657,11 @@ func (c *Client) pingMonitor() {
|
|||||||
c.configVersionMux.RUnlock()
|
c.configVersionMux.RUnlock()
|
||||||
|
|
||||||
pingMsg := WSMessage{
|
pingMsg := WSMessage{
|
||||||
Type: "ping",
|
Type: "olm/ping",
|
||||||
Data: map[string]interface{}{},
|
Data: map[string]any{
|
||||||
|
"timestamp": time.Now().Unix(),
|
||||||
|
"userToken": c.config.UserToken,
|
||||||
|
},
|
||||||
ConfigVersion: configVersion,
|
ConfigVersion: configVersion,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user