Skip to content

Conversation

@MayCXC
Copy link
Contributor

@MayCXC MayCXC commented Nov 6, 2025

Assistance Disclosure

No AI was used.

Adds an interfaces subdirective to bind to implement #7256 without changing how addresses are parsed:

example.com {
    bind 10.0.0.1 tcp4/127.0.0.1 tcp6/[::1] {
        interfaces eth0 tcp4/eth1 tcp6/eth2
        protocols h1 h2
    }
}

in the example above, the site is bound to at least six addresses and served with two protocols. This way the tcp6/ udp6/ and ip6: networks can be used instead of a new version mode syntax, and the port is read from the site block again instead of the directive arguments.

Only one address is bound per prefix for interfaces assigned a cidr. This is preferable to composing or selecting multiple addresses to emulate a bind to device syscall; a socket manager can do that natively without the overhead of opening 2^n listeners at once, or the unreliability of trying to open the first one available iteratively. e.g. for linux, the user could apply #7342 with systemd.socket and BindToDevice/FreeBind.

Tests are todo, ideally we will mock the value of net.InterfaceByName and parse a caddyfile.

@MayCXC MayCXC changed the title Bind interfaces bind interfaces Nov 6, 2025
@MayCXC MayCXC marked this pull request as draft November 6, 2025 10:28
@MayCXC
Copy link
Contributor Author

MayCXC commented Nov 6, 2025

converted to draft because it shares some diffs with #7342

@MayCXC MayCXC changed the title bind interfaces bind interfaces subdirective Nov 6, 2025
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.

1 participant