Fix satellite disconnect loop: parent now sends hello reply

The parent SatelliteLink never sent a hello reply after authenticating
the satellite client. This caused two problems:

1. The satellite client's m_hello_received stayed false, preventing it
   from forwarding any local events to the parent.
2. No parent→satellite traffic until the first heartbeat at ~10s,
   allowing intermediate firewalls/NAT to kill the idle connection
   (observed as ~7s disconnect-after-auth loops).

Send a MsgTrunkHello reply from the parent, matching what TrunkLink
already does for trunk peers. Update tests for two-way handshake.
This commit is contained in:
Audric committed 2026-04-10 10:59:39 +02:00
1 parent 76c2afc084
commit 8b6148a678
3 files changed
+15 -4

No files matched your search

+7
View File
@@ -182,6 +182,13 @@ void SatelliteLink::handleMsgTrunkHello(std::istream& is)
cout << "SAT: Satellite '" << m_satellite_id
<< "' authenticated" << endl;
// Send hello reply so the satellite client can set m_hello_received
// and start forwarding local events. This also generates early
// parent→satellite traffic, keeping the connection alive through
// firewalls / NAT devices that drop idle TCP sessions.
sendMsg(MsgTrunkHello("PARENT", "", 0, m_secret,
MsgTrunkHello::ROLE_PEER));
} /* SatelliteLink::handleMsgTrunkHello */
+1 -1
View File
@@ -81,7 +81,7 @@ Simulates a trunk peer connection. Connects via TCP, performs HMAC handshake, an
### SatellitePeer
Extends `TrunkPeer` with satellite-specific behavior: connects to the satellite port and sends a hello with `role=SATELLITE`. Authentication is one-way (satellite proves identity to parent; parent does not send a hello back).
Extends `TrunkPeer` with satellite-specific behavior: connects to the satellite port and sends a hello with `role=SATELLITE`. Authentication is two-way: the satellite proves identity to the parent, then the parent sends a hello reply back so the satellite can verify the parent and enable event forwarding.
### ClientPeer
+7 -3
View File
@@ -272,16 +272,20 @@ class SatellitePeer(TrunkPeer):
def handshake(self, sat_id=SAT_ID, secret=SAT_SECRET, priority=None,
**kwargs):
"""Send MsgTrunkHello with ROLE_SATELLITE.
"""Send MsgTrunkHello with ROLE_SATELLITE and read parent reply.
Unlike trunk peers, the parent does NOT send a hello back —
authentication is one-way (satellite proves identity to parent).
Two-way authentication: satellite proves identity, parent replies
with its own hello so the satellite can verify and start forwarding.
"""
if priority is None:
priority = struct.unpack("!I", os.urandom(4))[0]
hello = build_trunk_hello(sat_id, "", priority, secret,
role=ROLE_SATELLITE)
send_frame(self.sock, hello)
# Read the parent's hello reply
msg_type, _fields = self.recv_msg(timeout=5.0)
assert msg_type == MSG_TRUNK_HELLO, \
f"Expected hello reply, got type={msg_type}"
# ---------------------------------------------------------------------------