Browse Source

* source/portknock : enable SO_REUSEADDR

master
Alex 'AdUser' Z 8 years ago
parent
commit
0c52552aca
  1. 2
      src/sources/portknock.c

2
src/sources/portknock.c

@ -144,6 +144,7 @@ start(cfg_t *cfg) {
for (f2b_port_t *port = cfg->ports; port != 0; port = port->next) {
port->sock = -1;
int ret = getaddrinfo(port->host, port->port, &hints, &result);
int opt = 1;
if (ret != 0) {
snprintf(cfg->error, sizeof(cfg->error), "getaddrinfo: %s", gai_strerror(ret));
cfg->errcb(cfg->error);
@ -153,6 +154,7 @@ start(cfg_t *cfg) {
port->sock = socket(rp->ai_family, rp->ai_socktype, rp->ai_protocol);
if (port->sock == -1)
continue;
setsockopt(port->sock, SOL_SOCKET, SO_REUSEADDR, &opt, sizeof(opt));
if (bind(port->sock, rp->ai_addr, rp->ai_addrlen) == 0) {
if (listen(port->sock, 5) == 0) /* TODO: hardcoded */
break; /* success */

Loading…
Cancel
Save