Preserve cold NAT trials in the real network fixture
This commit is contained in:
1 parent
391059c967
commit
c7be1ebbbe
4 files changed
+9
-4
No files matched your search
@@ -14,6 +14,9 @@ def check_profiles(scenario):
|
||||
public = [node for node in NODES if not node.nat]
|
||||
transport = "tcp" if scenario.args.tcp_only else "udp"
|
||||
connected = set()
|
||||
# Первый профиль измеряется при появлении маршрутов, до фонового обхода всех NODEINFO.
|
||||
for agent in agents.values():
|
||||
agent.rpc("nat_auto", enabled=1)
|
||||
|
||||
def connect(source, target):
|
||||
pair = (source.name, target.name)
|
||||
@@ -56,13 +59,13 @@ def check_profiles(scenario):
|
||||
actual = profile(data[first.name], "udp")
|
||||
if actual["helper"] != agents[private_helper.name].identity or agents[private_helper.name].identity in data[first.name]["direct_up"]:
|
||||
raise RuntimeError(f"NAT indirect private helper was not used: {actual}")
|
||||
agents[first.name].rpc("nat_auto", enabled=0)
|
||||
print(f"NAT routed private helper: {private_helper.name} through {second.name}, group={actual['group']}", flush=True)
|
||||
|
||||
verified = {}
|
||||
for owner in public + [node for node in NODES if node.nat]:
|
||||
observer = second if owner.name == first.name else first
|
||||
agents[owner.name].rpc("nat_auto", enabled=1)
|
||||
if not scenario.args.tcp_only:
|
||||
agents[owner.name].rpc("nat_check", socket="udp", observer=agents[observer.name].identity)
|
||||
if not scenario.args.tcp_only:
|
||||
contacts = set(profile(agents[owner.name].rpc("stats"), "udp")["contacts"])
|
||||
helper = next((node for node in public if node.name not in {owner.name, observer.name} and node.ip not in contacts), None)
|
||||
@@ -104,7 +107,6 @@ def check_profiles(scenario):
|
||||
print(f"NAT {owner.name}/{protocol}: {actual['mapping']} / {actual['inbound']}"
|
||||
f" external={actual['external'] or '-'} reason={actual['reason']}", flush=True)
|
||||
verified[owner.name] = observed
|
||||
agents[owner.name].rpc("nat_auto", enabled=0)
|
||||
(scenario.network.directory / "nat-profiles.json").write_text(json.dumps(verified, indent=2) + "\n")
|
||||
|
||||
# Повтор на использовавшемся порту сохраняет mapping, но не обновляет OPEN
|
||||
|
||||
Reference in new issue
Block a user