Skip to content

Added commandline arguments and functionality usefull to run behind a NAT#7

Open
pvagner wants to merge 1 commit intochatmail:mainfrom
pvagner:nat
Open

Added commandline arguments and functionality usefull to run behind a NAT#7
pvagner wants to merge 1 commit intochatmail:mainfrom
pvagner:nat

Conversation

@pvagner
Copy link
Copy Markdown

@pvagner pvagner commented Oct 31, 2025

This turn server enumerates all the interfaces found on the system, identifies globally addressable addresses and creates an UDP listen socket on the default port. Relay connections for this scenario is not restricted and the whole port range should be allowed in the firewall. This setup will work when the public addresses are configured on the system. For home setups where the server is behind a NAT this won't work.
There fore I have added ability to specify local listen address and a public relay address for listening connections and additional minimum and maximum port for the relay connections. Both the listen port and the relay port range have to be forwarded in the gateway providing network address translation so incoming UDP connections will end up reaching running instance of this turn server.

While testing run

chatmail-turn --help

to discover the commandline arguments.

Copy link
Copy Markdown
Contributor

@hpk42 hpk42 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i think it makes sense to support manual tweaking, but don't like the multitude of new options. What about

  --net "listen=192.168.1.10:3478,external=203.0.113.7,relay-ports=49152-65535"

which would disable auto-discovery, and you need to provide all neccessary settings in the --net directive?
also, some addition to README.md is needed, not just a code change.

@pvagner
Copy link
Copy Markdown
Author

pvagner commented Mar 3, 2026

@hpk42 Thanks for looking into it.
Doing it like this allowed me to just use the existing libraries and I've got parsing of commandline arguments for free without doing anything.

These days I can't work on it further but hopefully I will figure it out sooner rather than later.

Greetings

Peter

@DarkCat09
Copy link
Copy Markdown

@hpk42
Maybe smth like this? Looks more readable, in my opinion

--listen 192.168.1.10:3478 --relay-addr 203.0.113.7:49152-65535

@DarkCat09
Copy link
Copy Markdown

DarkCat09 commented Mar 4, 2026

Also, for convenience, we can allow specifying only port(s), without an IP, like this:

--listen :3478 --relay-addr :49152-65535

which defaults to the all-zero host for the listen address and an automatic IP detection for the relay address.

@DarkCat09
Copy link
Copy Markdown

Would you mind if i send a PR?

@pvagner
Copy link
Copy Markdown
Author

pvagner commented Mar 4, 2026

@DarkCat09 It would be awesome if you can make a PR that supersedes this one.

Thanks for thinking about it and working more on it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants