Skip to content

Commit

Permalink
HevConf: Add support for IP address values in -i parameter.
Browse files Browse the repository at this point in the history
Fixes #66
  • Loading branch information
heiher committed Jun 30, 2024
1 parent 3327bc0 commit 20861df
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ Options:
-6 use IPv6
-u UDP mode
-d run as daemon
-i <interface> network interface
-i <interface> network interface or IP address
-k <interval> seconds between each keep-alive
-s <addr>[:port] domain name or address of STUN server
-h <addr>[:port] domain name or address of HTTP server
Expand Down
14 changes: 11 additions & 3 deletions src/hev-conf.c
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,16 @@
#include <stdio.h>
#include <unistd.h>
#include <stdlib.h>
#include <arpa/inet.h>
#include <netinet/in.h>
#include <sys/socket.h>

#include "hev-misc.h"

#include "hev-conf.h"

static int mode = SOCK_STREAM;
static int type = AF_UNSPEC;
static int type = AF_INET;
static int keep;
static int dmon;
static int tmsec;
Expand Down Expand Up @@ -48,7 +50,7 @@ hev_conf_help (void)
" -6 use IPv6\n"
" -u UDP mode\n"
" -d run as daemon\n"
" -i <interface> network interface\n"
" -i <interface> network interface or IP address\n"
" -k <interval> seconds between each keep-alive\n"
" -s <addr>[:port] domain name or address of STUN server\n"
" -h <addr>[:port] domain name or address of HTTP server\n"
Expand All @@ -70,6 +72,7 @@ int
hev_conf_init (int argc, char *argv[])
{
int opt;
struct sockaddr_in6 sa;

while ((opt = getopt (argc, argv, "46udk:s:h:e:f:b:T:t:p:i:")) != -1) {
switch (opt) {
Expand Down Expand Up @@ -141,7 +144,12 @@ hev_conf_init (int argc, char *argv[])
bport = "0";
}

baddr = (type == AF_INET6) ? "::" : "0.0.0.0";
if (iface && inet_pton (type, iface, &sa)) {
baddr = iface;
iface = NULL;
} else {
baddr = (type == AF_INET6) ? "::" : "0.0.0.0";
}

if (tmsec <= 0) {
tmsec = 120000;
Expand Down

0 comments on commit 20861df

Please sign in to comment.