From 0413aa5aae10b2d61cab3f48d08fe2ffd061311d Mon Sep 17 00:00:00 2001 From: Pavel Shramov Date: Fri, 6 Dec 2024 14:51:47 +0300 Subject: [PATCH] control: Replace host parameters in exported clients --- python/test/test_logic_control.py | 6 +++--- src/logic/control.cc | 6 ++++++ 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/python/test/test_logic_control.py b/python/test/test_logic_control.py index d780cfb6..d5709ee1 100644 --- a/python/test/test_logic_control.py +++ b/python/test/test_logic_control.py @@ -193,7 +193,7 @@ async def test_resolve(asyncloop, path_srcdir): channel: url: control://;tll.channel.processor=processor;tll.channel.resolve=resolve;name=logic service: test - hostname: host + hostname: ::1 service-tags: 'a,b' ''') @@ -202,11 +202,11 @@ async def test_resolve(asyncloop, path_srcdir): tproc, tinput = mock.io('processor', 'resolve') - tcp = asyncloop.Channel(f'child-export+tcp://::1:{ports.TCP6};mode=server;name=tcp;tll.resolve.export=yes') + tcp = asyncloop.Channel(f'child-export+tcp://*:{ports.TCP6};mode=server;name=tcp;tll.resolve.export=yes') tcp.open() m = await tinput.recv() - assert tinput.unpack(m).as_dict() == {'service': 'test', 'tags': ['a', 'b'], 'host': 'host'} + assert tinput.unpack(m).as_dict() == {'service': 'test', 'tags': ['a', 'b'], 'host': '::1'} tproc.post({'channel': 'tcp', 'state': 'Active'}, name='StateUpdate') for name in ('tcp', 'tcp/first', 'tcp/first/second'): diff --git a/src/logic/control.cc b/src/logic/control.cc index b2d1568f..3b4d898c 100644 --- a/src/logic/control.cc +++ b/src/logic/control.cc @@ -472,10 +472,16 @@ int Control::_post_export(ChannelExport &channel, std::string_view name, const t data.set_service(_service); data.set_channel(name); std::map curl; + for (auto & [name, cfg] : client.browse("**")) { if (name.substr(0, strlen("children.")) != "children.") curl.emplace(name, cfg); } + tll::Config hostname; + hostname.set(_hostname); + for (auto & [k, _]: client.browse("replace.host.**")) + curl[std::string(k.substr(strlen("replace.host.")))] = hostname; + data.get_config().resize(curl.size()); auto di = data.get_config().begin(); for (auto & [name, cfg] : curl) {