GSMTAP: --gsmtap-bind to listen beyond loopback (containers)
A container's 127.0.0.1 is its own loopback, so a GSMTAP feed sent to the container's bridge address never reached the listener: it was hard-bound to 127.0.0.1. - `simtrace-analyser-server --gsmtap-bind ADDR` (default 127.0.0.1) is passed through GsmtapListener to GsmtapReceiver (whose bind_ip already existed), including the receiver re-created by a start() after close. The startup banner prints the effective bind address next to the port. - READMEs (EN/RU) document the option, naming the container case. - tests: the listener forwards the address on construction and on start(), binds 0.0.0.0, and keeps the loopback default. Verified end-to-end: with --gsmtap-bind 0.0.0.0 the socket listens on 0.0.0.0:14732 and an ATR + APDU sent to 127.0.0.1:14732 landed in the capture session (2 messages); without the flag it listens on 127.0.0.1. 557 Python + 80 Node tests.
This commit is contained in:
1 parent
c810ff50cf
commit
903ead9791
5 files changed
+51
-5
No files matched your search
@@ -206,6 +206,41 @@ class TestGsmtapListenerRobustness(unittest.TestCase):
|
||||
self.assertEqual(listener.dropped, 1)
|
||||
|
||||
|
||||
class TestGsmtapListenerBind(unittest.TestCase):
|
||||
def test_bind_ip_reaches_the_receiver(self):
|
||||
from simtrace_analyser import capture
|
||||
calls = []
|
||||
|
||||
class _FakeReceiver:
|
||||
def __init__(self, bind_ip='127.0.0.1', bind_port=4729):
|
||||
calls.append((bind_ip, bind_port))
|
||||
|
||||
def close(self):
|
||||
pass
|
||||
|
||||
real = capture.GsmtapReceiver
|
||||
capture.GsmtapReceiver = _FakeReceiver
|
||||
try:
|
||||
listener = capture.GsmtapListener(bind_ip='0.0.0.0', bind_port=4729)
|
||||
listener._receiver._closed = True # force start() to re-create it
|
||||
listener.start()
|
||||
finally:
|
||||
capture.GsmtapReceiver = real
|
||||
self.assertEqual(calls, [('0.0.0.0', 4729), ('0.0.0.0', 4729)])
|
||||
|
||||
def test_all_interfaces_bind(self):
|
||||
from simtrace_analyser.capture import GsmtapListener
|
||||
listener = GsmtapListener(bind_ip='0.0.0.0', bind_port=0)
|
||||
self.addCleanup(listener.stop)
|
||||
self.assertEqual(listener._receiver._sock.getsockname()[0], '0.0.0.0')
|
||||
|
||||
def test_default_bind_is_loopback(self):
|
||||
from simtrace_analyser.capture import GsmtapListener
|
||||
listener = GsmtapListener(bind_port=0)
|
||||
self.addCleanup(listener.stop)
|
||||
self.assertEqual(listener._receiver._sock.getsockname()[0], '127.0.0.1')
|
||||
|
||||
|
||||
class TestCaptureLoopRobustness(unittest.TestCase):
|
||||
def test_capture_loop_survives_insert_error(self):
|
||||
mgr = CaptureManager(_OneShotBackend(), _NullDb())
|
||||
|
||||
Reference in new issue
Block a user