mirror of
https://github.com/fosrl/olm.git
synced 2026-02-08 05:56:41 +00:00
feat(ping): send fingerprint and posture checks as part of ping/register
Former-commit-id: 70a7e83291
This commit is contained in:
committed by
Owen Schwartz
parent
69952ee5c5
commit
4b6999e06a
14
olm/olm.go
14
olm/olm.go
@@ -356,12 +356,14 @@ func (o *Olm) StartTunnel(config TunnelConfig) {
|
||||
if o.stopRegister == nil {
|
||||
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{
|
||||
"publicKey": publicKey.String(),
|
||||
"relay": !config.Holepunch,
|
||||
"olmVersion": o.olmConfig.Version,
|
||||
"olmAgent": o.olmConfig.Agent,
|
||||
"orgId": config.OrgID,
|
||||
"userToken": userToken,
|
||||
"publicKey": publicKey.String(),
|
||||
"relay": !config.Holepunch,
|
||||
"olmVersion": o.olmConfig.Version,
|
||||
"olmAgent": o.olmConfig.Agent,
|
||||
"orgId": config.OrgID,
|
||||
"userToken": userToken,
|
||||
"fingerprint": o.fingerprint,
|
||||
"postures": o.postures,
|
||||
}, 1*time.Second)
|
||||
|
||||
// Invoke onRegistered callback if configured
|
||||
|
||||
12
olm/ping.go
12
olm/ping.go
@@ -8,10 +8,12 @@ import (
|
||||
"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{
|
||||
"timestamp": time.Now().Unix(),
|
||||
"userToken": olm.GetConfig().UserToken,
|
||||
"timestamp": time.Now().Unix(),
|
||||
"userToken": olm.GetConfig().UserToken,
|
||||
"fingerprint": o.fingerprint,
|
||||
"postures": o.postures,
|
||||
})
|
||||
if err != nil {
|
||||
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) {
|
||||
// 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)
|
||||
} else {
|
||||
logger.Info("Sent initial ping message")
|
||||
@@ -39,7 +41,7 @@ func (o *Olm) keepSendingPing(olm *websocket.Client) {
|
||||
logger.Info("Stopping ping messages")
|
||||
return
|
||||
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)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user