diff --git a/src/svxlink/reflector/SatelliteLink.cpp b/src/svxlink/reflector/SatelliteLink.cpp index 2c775c9..6112a4f 100644 --- a/src/svxlink/reflector/SatelliteLink.cpp +++ b/src/svxlink/reflector/SatelliteLink.cpp @@ -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 */ diff --git a/tests/TESTS.md b/tests/TESTS.md index c85b0ba..87131c4 100644 --- a/tests/TESTS.md +++ b/tests/TESTS.md @@ -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 diff --git a/tests/test_trunk.py b/tests/test_trunk.py index 8c7e1a7..bc09b8e 100644 --- a/tests/test_trunk.py +++ b/tests/test_trunk.py @@ -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}" # ---------------------------------------------------------------------------