Problem
The server currently binds to all interfaces (in6addr_any / 0.0.0.0). On a VPS with multiple IP addresses, there's no way to bind sendrawtx to a specific IP while other services use a different IP.
Current workaround
Use iptables PREROUTING REDIRECT to forward traffic from a specific IP:port to the server's port. This works perfectly (kernel-level, zero overhead, no URL size issues) but requires external firewall rules.
Proposed solution
Add an optional listen_address config option:
[server]
port = 8080
listen_address = 203.0.113.20
The server already uses dual-stack IPv6 sockets, so this would support:
- IPv4 addresses (
203.0.113.20)
- IPv6 addresses (
2001:db8::1)
- All interfaces (
0.0.0.0 or ::, current default when omitted)
Implementation notes
- Change is ~10 lines in
worker.c (replace in6addr_any with parsed address) and config.c/config.h (add field + parser)
- Use
inet_pton() to parse the address, try IPv4 first then IPv6
- Default to current behavior (all interfaces) when omitted
- The iptables workaround is fine for now — this is a nice-to-have for self-documenting configs
Problem
The server currently binds to all interfaces (
in6addr_any/0.0.0.0). On a VPS with multiple IP addresses, there's no way to bind sendrawtx to a specific IP while other services use a different IP.Current workaround
Use iptables PREROUTING REDIRECT to forward traffic from a specific IP:port to the server's port. This works perfectly (kernel-level, zero overhead, no URL size issues) but requires external firewall rules.
Proposed solution
Add an optional
listen_addressconfig option:The server already uses dual-stack IPv6 sockets, so this would support:
203.0.113.20)2001:db8::1)0.0.0.0or::, current default when omitted)Implementation notes
worker.c(replacein6addr_anywith parsed address) andconfig.c/config.h(add field + parser)inet_pton()to parse the address, try IPv4 first then IPv6