]> git.ipfire.org Git - thirdparty/knot-resolver.git/commitdiff
command line: specify ports via @ but remain compatible
authorVladimír Čunát <vladimir.cunat@nic.cz>
Wed, 17 May 2017 14:17:32 +0000 (16:17 +0200)
committerVladimír Čunát <vladimir.cunat@nic.cz>
Wed, 17 May 2017 14:40:46 +0000 (16:40 +0200)
.travis.yml
NEWS
daemon/bindings.c
daemon/lua/config.lua
daemon/main.c
doc/kresd.8.in
modules/graphite/graphite.lua
modules/http/http.lua
scripts/supervisor.py

index 439f3903a81ded564cec21ec5ea53eb2e0700e73..ad7835d416f80f600e2cec6877fe8865c512279a 100644 (file)
@@ -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
diff --git a/NEWS b/NEWS
index fab3ecfbb497eb3d5a078d7009c440bad3f8a86a..a5c1fec6aba10470a88366a8b0f810d1e7d61cbc 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -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)
index aa2d41ca1c62aeea1326a7fe07a561eb0945856c..14fd548cd549186b9ec3d05ec37cfd11ab390f8c 100644 (file)
@@ -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;
index dd31cd3b41e6a7d131c048f3b666350fc909a8ac..877b553ab5c1ad3a00f19704ffd89c58beda6517 100644 (file)
@@ -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
index e1e7320a2d16c4bbe943de641c16ca253f626b38..2ebbf6ad427104cda25383a6eef2b9804bcdd6ba 100644 (file)
@@ -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;
                        }
index 29a648d39f34135835da0f8dca820311018ba592..620e2f9dc14144a5e532c76ac39821ae3cdc496a 100644 (file)
@@ -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.
index aa4354e0456d8de9413f8ef5ce95e7b3a29f79eb..f7c3a4ca04a99a641fbad1d42f47c94c75f58a3e 100644 (file)
@@ -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
index 4e0143dbfe600e8e3f37462cfcfa5587232529dd..f064ba98b573044d24273677933e6d2e63116316 100644 (file)
@@ -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
index c585c53dce73c45f1318c68094c1135a7d3518dc..218eb522394b6a2f3f119391802fc37d025f6c68 100755 (executable)
@@ -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)