| 75 | |
| 76 | |
| 77 | def write_config(config_dir: str, port: int) -> None: |
| 78 | config_path = os.path.join(config_dir, "config") |
| 79 | # Point-to-point loopback on a non-default port (avoids the user's |
| 80 | # RNS desktop apps on 4242). macOS doesn't reliably loop 255.255.255.255 |
| 81 | # broadcast between two localhost processes, so use 127.0.0.1 explicitly. |
| 82 | forward_port = port + 1 |
| 83 | cfg = f""" |
| 84 | [reticulum] |
| 85 | enable_transport = No |
| 86 | share_instance = No |
| 87 | shared_instance_port = 37428 |
| 88 | instance_control_port = 37429 |
| 89 | panic_on_interface_error = No |
| 90 | |
| 91 | [logging] |
| 92 | loglevel = 7 |
| 93 | |
| 94 | [interfaces] |
| 95 | |
| 96 | [[UDPInterop]] |
| 97 | type = UDPInterface |
| 98 | interface_enabled = True |
| 99 | listen_ip = 127.0.0.1 |
| 100 | listen_port = {port} |
| 101 | forward_ip = 127.0.0.1 |
| 102 | forward_port = {forward_port} |
| 103 | """ |
| 104 | with open(config_path, "w") as f: |
| 105 | f.write(cfg) |
| 106 | |
| 107 | |
| 108 | def main(): |