Commit 25ef187e authored by Julian Brost's avatar Julian Brost
Browse files

Allow binding to non-local adresses for TCP

The UDP code already allows binding to non-local addresses using the
IP_FREEBIND or IP_BINDANY socket options, but the TCP code is missing
this so far.
parent cc8bab04
......@@ -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);
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,
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