Skip to content

Add listen_address config for IP binding #25

Description

@8144225309

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions