mirror of
https://github.com/fosrl/olm.git
synced 2026-02-28 15:56:43 +00:00
feat(ping): send fingerprint and posture checks as part of ping/register
This commit is contained in:
committed by
Owen Schwartz
parent
566084683a
commit
70a7e83291
14
olm/olm.go
14
olm/olm.go
@@ -356,12 +356,14 @@ func (o *Olm) StartTunnel(config TunnelConfig) {
|
|||||||
if o.stopRegister == nil {
|
if o.stopRegister == nil {
|
||||||
logger.Debug("Sending registration message to server with public key: %s and relay: %v", publicKey, !config.Holepunch)
|
logger.Debug("Sending registration message to server with public key: %s and relay: %v", publicKey, !config.Holepunch)
|
||||||
o.stopRegister, o.updateRegister = olmClient.SendMessageInterval("olm/wg/register", map[string]any{
|
o.stopRegister, o.updateRegister = olmClient.SendMessageInterval("olm/wg/register", map[string]any{
|
||||||
"publicKey": publicKey.String(),
|
"publicKey": publicKey.String(),
|
||||||
"relay": !config.Holepunch,
|
"relay": !config.Holepunch,
|
||||||
"olmVersion": o.olmConfig.Version,
|
"olmVersion": o.olmConfig.Version,
|
||||||
"olmAgent": o.olmConfig.Agent,
|
"olmAgent": o.olmConfig.Agent,
|
||||||
"orgId": config.OrgID,
|
"orgId": config.OrgID,
|
||||||
"userToken": userToken,
|
"userToken": userToken,
|
||||||
|
"fingerprint": o.fingerprint,
|
||||||
|
"postures": o.postures,
|
||||||
}, 1*time.Second)
|
}, 1*time.Second)
|
||||||
|
|
||||||
// Invoke onRegistered callback if configured
|
// Invoke onRegistered callback if configured
|
||||||
|
|||||||
12
olm/ping.go
12
olm/ping.go
@@ -8,10 +8,12 @@ import (
|
|||||||
"github.com/fosrl/olm/websocket"
|
"github.com/fosrl/olm/websocket"
|
||||||
)
|
)
|
||||||
|
|
||||||
func sendPing(olm *websocket.Client) error {
|
func (o *Olm) sendPing(olm *websocket.Client) error {
|
||||||
err := olm.SendMessage("olm/ping", map[string]any{
|
err := olm.SendMessage("olm/ping", map[string]any{
|
||||||
"timestamp": time.Now().Unix(),
|
"timestamp": time.Now().Unix(),
|
||||||
"userToken": olm.GetConfig().UserToken,
|
"userToken": olm.GetConfig().UserToken,
|
||||||
|
"fingerprint": o.fingerprint,
|
||||||
|
"postures": o.postures,
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logger.Error("Failed to send ping message: %v", err)
|
logger.Error("Failed to send ping message: %v", err)
|
||||||
@@ -23,7 +25,7 @@ func sendPing(olm *websocket.Client) error {
|
|||||||
|
|
||||||
func (o *Olm) keepSendingPing(olm *websocket.Client) {
|
func (o *Olm) keepSendingPing(olm *websocket.Client) {
|
||||||
// Send ping immediately on startup
|
// Send ping immediately on startup
|
||||||
if err := sendPing(olm); err != nil {
|
if err := o.sendPing(olm); err != nil {
|
||||||
logger.Error("Failed to send initial ping: %v", err)
|
logger.Error("Failed to send initial ping: %v", err)
|
||||||
} else {
|
} else {
|
||||||
logger.Info("Sent initial ping message")
|
logger.Info("Sent initial ping message")
|
||||||
@@ -39,7 +41,7 @@ func (o *Olm) keepSendingPing(olm *websocket.Client) {
|
|||||||
logger.Info("Stopping ping messages")
|
logger.Info("Stopping ping messages")
|
||||||
return
|
return
|
||||||
case <-ticker.C:
|
case <-ticker.C:
|
||||||
if err := sendPing(olm); err != nil {
|
if err := o.sendPing(olm); err != nil {
|
||||||
logger.Error("Failed to send periodic ping: %v", err)
|
logger.Error("Failed to send periodic ping: %v", err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user