char *origin;
char *idxfile;
bool retry;
+ bool prefv6;
} cfg = {
"8837",
"*",
"http://localhost",
"index.html",
false,
+ false
};
static volatile struct telemetry_state_t *telemetry;
pthread_t tid;
pthread_attr_t attr;
- ss = tcp_open_server( cfg.iface, cfg.port );
+ ss = cfg.prefv6 ? tcp6_open_server( cfg.iface, cfg.port ) : -1;
+ if ( ss < 0 )
+ ss = tcp_open_server( cfg.iface, cfg.port );
if ( ss < 0 ) {
char ebuf[200];
net_strerror( ss, ebuf, sizeof ebuf );
" Options:\n"
" -b str bind interface; default: * (all)\n"
" -h str host name; default: localhost\n"
+ " -6 prefer TCP over IPv6, if available\n"
" -i file file to serve as index file; default: index.html\n"
" -o str origin; default: http://localhost\n"
" -p N TCP listen port; default: 8837\n"
static int config( int argc, char *argv[] ) {
int opt;
- const char *ostr = "+rb:h:i:o:p:";
+ const char *ostr = "+6rb:h:i:o:p:";
while ( -1 != ( opt = getopt( argc, argv, ostr ) ) ) {
switch ( opt ) {
case 'r':
cfg.retry = true;
break;
+ case '6':
+ cfg.prefv6 = true;
+ break;
case ':':
EPRINT( "Missing argument for option '%c'\n", optopt );
usage( argv[0] );