mirror of
https://github.com/fosrl/olm.git
synced 2026-03-27 04:56:43 +00:00
Add api endpoints to jit
This commit is contained in:
@@ -220,6 +220,7 @@ func (o *Olm) handleSync(msg websocket.WSMessage) {
|
||||
logger.Info("Sync: Adding new peer for site %d", siteId)
|
||||
|
||||
o.holePunchManager.TriggerHolePunch()
|
||||
o.holePunchManager.ResetServerHolepunchInterval() // start sending immediately again so we fill in the endpoint on the cloud
|
||||
|
||||
// // TODO: do we need to send the message to the cloud to add the peer that way?
|
||||
// if err := o.peerManager.AddPeer(expectedSite); err != nil {
|
||||
|
||||
11
olm/olm.go
11
olm/olm.go
@@ -66,6 +66,7 @@ type Olm struct {
|
||||
updateRegister func(newData any)
|
||||
|
||||
stopPeerSend func()
|
||||
stopPeerInit func()
|
||||
|
||||
// WaitGroup to track tunnel lifecycle
|
||||
tunnelWg sync.WaitGroup
|
||||
@@ -284,6 +285,16 @@ func (o *Olm) registerAPICallbacks() {
|
||||
logger.Info("Processing power mode change request via API: mode=%s", req.Mode)
|
||||
return o.SetPowerMode(req.Mode)
|
||||
},
|
||||
func(req api.JITConnectionRequest) error {
|
||||
logger.Info("Processing JIT connect request via API: site=%s resource=%s", req.Site, req.Resource)
|
||||
|
||||
o.stopPeerInit, _ = o.websocket.SendMessageInterval("olm/wg/server/peer/init", map[string]interface{}{
|
||||
"siteId": req.Site,
|
||||
"resourceId": req.Resource,
|
||||
}, 2*time.Second, 10)
|
||||
|
||||
return nil
|
||||
},
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user