Commit 3e66e9ee authored by Daniel Salzman's avatar Daniel Salzman

Merge branch 'tcp-freebind' into 'master'

Allow binding to non-local adresses for TCP

See merge request !740
parents 8db6beba 25ef187e
......@@ -211,7 +211,16 @@ static int server_init_iface(iface_t *new_if, struct sockaddr_storage *addr, int
}
/* Create bound TCP socket. */
int sock = net_bound_socket(SOCK_STREAM, (struct sockaddr *)addr, 0);
int tcp_bind_flags = 0;
int sock = net_bound_socket(SOCK_STREAM, (struct sockaddr *)addr, tcp_bind_flags);
if (sock == KNOT_EADDRNOTAVAIL) {
tcp_bind_flags |= NET_BIND_NONLOCAL;
sock = net_bound_socket(SOCK_STREAM, (struct sockaddr *)addr, tcp_bind_flags);
if (sock >= 0) {
log_warning("address '%s' bound, but required nonlocal bind", addr_str);
}
}
if (sock < 0) {
log_error("cannot bind address '%s' (%s)", addr_str,
knot_strerror(sock));
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment