Commit 8bbeab09 authored by Vladimír Čunát's avatar Vladimír Čunát

command line: specify ports via @ but remain compatible

parent ccafba8e
......@@ -33,7 +33,7 @@ script:
- CFLAGS="-O2 -g -fno-omit-frame-pointer -DDEBUG" make -j2 install check V=1 COVERAGE=1 PREFIX=${HOME}/.local DYLD_LIBRARY_PATH=${DYLD_LIBRARY_PATH}
- ./daemon/kresd -h
- ./daemon/kresd -V
- echo "quit()" | ./daemon/kresd -a 127.0.0.1#53535 .
- echo "quit()" | ./daemon/kresd -a 127.0.0.1@53535 .
- CFLAGS="-O2 -g -fno-omit-frame-pointer -DDEBUG" make -j2 check-integration COVERAGE=1 PREFIX=${HOME}/.local DYLD_LIBRARY_PATH=${DYLD_LIBRARY_PATH}
after_success:
- if test $TRAVIS_OS_NAME = linux; then coveralls -i lib -i daemon -x ".c" --gcov-options '\-lp'; fi
......
......@@ -11,6 +11,7 @@ Security
Improvements
------------
- allow answering from cache in non-iterative modes (#122)
- command line: specify ports via @ but still support # for compatibility
Knot Resolver 1.2.6 (2017-04-24)
......
......@@ -189,7 +189,7 @@ static int net_listen_addrs(lua_State *L, int port, int flags)
struct engine *engine = engine_luaget(L);
int ret = network_listen(&engine->net, str, port, flags);
if (ret != 0) {
kr_log_info("[system] bind to '%s#%d' %s\n",
kr_log_info("[system] bind to '%s@%d' %s\n",
str, port, kr_strerror(ret));
}
return ret == 0;
......
......@@ -2,15 +2,15 @@
if not next(net.list()) then
local ok, err = pcall(net.listen, '127.0.0.1')
if not ok then
error('bind to 127.0.0.1#53 '..err)
error('bind to 127.0.0.1@53 '..err)
end
-- IPv6 loopback may fail
ok, err = pcall(net.listen, '::1')
if not ok and verbose() then
print('bind to ::1#53 '..err)
print('bind to ::1@53 '..err)
end
end
-- Open cache if not set/disabled
if not cache.current_size then
cache.size = 100 * MB
end
\ No newline at end of file
end
......@@ -289,7 +289,10 @@ static void signal_handler(uv_signal_t *handle, int signum)
/** Split away port from the address. */
static const char *set_addr(char *addr, int *port)
{
char *p = strchr(addr, '#');
char *p = strchr(addr, '@');
if (!p) {
p = strchr(addr, '#');
}
if (p) {
*port = atoi(p + 1);
*p = '\0';
......@@ -338,7 +341,7 @@ static void help(int argc, char *argv[])
{
printf("Usage: %s [parameters] [rundir]\n", argv[0]);
printf("\nParameters:\n"
" -a, --addr=[addr] Server address (default: localhost#53).\n"
" -a, --addr=[addr] Server address (default: localhost@53).\n"
" -t, --tls=[addr] Server address for TLS (default: off).\n"
" -S, --fd=[fd] Listen on given fd (handed out by supervisor).\n"
" -T, --tlsfd=[fd] Listen using TLS on given fd (handed out by supervisor).\n"
......@@ -609,7 +612,7 @@ int main(int argc, char **argv)
const char *addr = set_addr(addr_set.at[i], &port);
ret = network_listen(&engine.net, addr, (uint16_t)port, NET_UDP|NET_TCP);
if (ret != 0) {
kr_log_error("[system] bind to '%s#%d' %s\n", addr, port, kr_strerror(ret));
kr_log_error("[system] bind to '%s@%d' %s\n", addr, port, kr_strerror(ret));
ret = EXIT_FAILURE;
break;
}
......@@ -622,7 +625,7 @@ int main(int argc, char **argv)
const char *addr = set_addr(tls_set.at[i], &port);
ret = network_listen(&engine.net, addr, (uint16_t)port, NET_TCP|NET_TLS);
if (ret != 0) {
kr_log_error("[system] bind to '%s#%d' (TLS) %s\n", addr, port, kr_strerror(ret));
kr_log_error("[system] bind to '%s@%d' (TLS) %s\n", addr, port, kr_strerror(ret));
ret = EXIT_FAILURE;
break;
}
......
......@@ -13,7 +13,7 @@
.SH "SYNOPSIS"
.B kresd
.RB [ \-a | \-\-addr
.IR addr[#port] ]
.IR addr[@port] ]
.RB [ \-S | \-\-fd
.IR fd ]
.RB [ \-c | \-\-config
......@@ -92,11 +92,11 @@ EOF
.P
The available CLI options are:
.TP
.B \-a\fI addr[#port]\fR, \fB\-\-addr=\fI<addr[#port]>
.B \-a\fI addr[@port]\fR, \fB\-\-addr=\fI<addr[@port]>
Listen on given address (and port) pair. If no port is given, \fI53\fR is used as a default.
Option may be passed multiple times to listen on more addresses.
.TP
.B \-t\fI addr[#port]\fR, \fB\-\-tls=\fI<addr[#port]>
.B \-t\fI addr[@port]\fR, \fB\-\-tls=\fI<addr[@port]>
Listen using TLS on given address (and port) pair. If no port is
given, \fI853\fR is used as a default. Option may be passed multiple
times to listen on more addresses.
......
......@@ -66,7 +66,7 @@ local function publish_table(metrics, prefix, now)
local tcp = M.cli[i]['connect'] ~= nil
local host = M.info[i]
if tcp and host.seen + 2 * M.interval / 1000 <= now then
print(string.format('[graphite] reconnecting: %s#%d reason: %s',
print(string.format('[graphite] reconnecting: %s@%d reason: %s',
host.addr, host.port, err))
M.cli[i] = make_tcp(host.addr, host.port)
host.seen = now
......
......@@ -303,7 +303,7 @@ function M.interface(host, port, endpoints, crtfile, keyfile)
onstream = routes;
}
if not s then
panic('failed to listen on %s#%d: %s', host, port, err)
panic('failed to listen on %s@%d: %s', host, port, err)
end
table.insert(M.servers, s)
-- Create certificate renewal timer if ephemeral
......
......@@ -27,7 +27,10 @@ while len(unparsed) > 0:
# Parse address
addr = unparsed.pop(0)
try:
if '#' in addr:
if '@' in addr:
addr, port = addr.split('@')
port = int(port)
elif '#' in addr:
addr, port = addr.split('#')
port = int(port)
else:
......@@ -56,4 +59,4 @@ while True: # Fork forever
end = datetime.datetime.now()
print('[%s] process finished, pid = %d, status = %d, uptime = %s' % \
(start, pid, status, end - start))
time.sleep(0.5)
\ No newline at end of file
time.sleep(0.5)
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