udp-port can now be unset, and that will disable listening to UDP.

This commit is contained in:
Nikos Mavrogiannopoulos
2013-12-07 17:44:31 +01:00
parent a53c4dba8e
commit 8a919d236f
3 changed files with 21 additions and 20 deletions

2
NEWS
View File

@@ -4,6 +4,8 @@
compatibility. Patch by Kevin Cernekee.
- When a new connection presents a cookie of an existing session
the previous session is disconnected (and its IP is hijacked).
- If udp-port is unset or set to zero then the server will not listen
for UDP sessions.
* Version 0.2.2 (released 2013-11-23)

View File

@@ -452,9 +452,6 @@ static void check_cfg( struct cfg_st *config)
if (config->dpd == 0)
config->keepalive = 60;
if (config->udp_port == 0)
config->udp_port = config->port;
if (config->priorities == NULL)
config->priorities = "NORMAL:%SERVER_PRECEDENCE:%COMPAT";
}

View File

@@ -209,29 +209,31 @@ listen_ports(struct cfg_st* config, struct listen_list_st *list, const char *nod
exit(1);
}
snprintf(portname, sizeof(portname), "%d", config->udp_port);
if (config->udp_port) {
snprintf(portname, sizeof(portname), "%d", config->udp_port);
memset(&hints, 0, sizeof(hints));
hints.ai_socktype = SOCK_DGRAM;
hints.ai_flags = AI_PASSIVE
memset(&hints, 0, sizeof(hints));
hints.ai_socktype = SOCK_DGRAM;
hints.ai_flags = AI_PASSIVE
#ifdef AI_ADDRCONFIG
| AI_ADDRCONFIG
| AI_ADDRCONFIG
#endif
;
;
ret = getaddrinfo(node, portname, &hints, &res);
if (ret != 0) {
fprintf(stderr, "getaddrinfo() failed: %s\n",
gai_strerror(ret));
return -1;
}
ret = getaddrinfo(node, portname, &hints, &res);
if (ret != 0) {
fprintf(stderr, "getaddrinfo() failed: %s\n",
gai_strerror(ret));
return -1;
}
ret = _listen_ports(config, res, list);
if (ret < 0) {
return -1;
}
ret = _listen_ports(config, res, list);
if (ret < 0) {
return -1;
}
freeaddrinfo(res);
freeaddrinfo(res);
}
return 0;
}