]> git.ipfire.org Git - thirdparty/unbound.git/commitdiff
Specify port number in interface lines.
authorWouter Wijngaards <wouter@nlnetlabs.nl>
Tue, 8 Dec 2009 16:31:56 +0000 (16:31 +0000)
committerWouter Wijngaards <wouter@nlnetlabs.nl>
Tue, 8 Dec 2009 16:31:56 +0000 (16:31 +0000)
git-svn-id: file:///svn/unbound/trunk@1930 be551aaa-1e26-0410-a405-d3ace91eadb9

doc/Changelog
doc/example.conf.in
doc/unbound.conf.5.in
services/listen_dnsport.c

index 14cb1c981d962f205161d37fe5eab7b19f1bfcb5..2dea61dd12f1aeac3006cd3c3255f0f982cbfb3d 100644 (file)
@@ -2,6 +2,8 @@
        - Fix for lookup of parent-child disagreement domains, where the
          parent-side glue works but it does not provide proper NS, A or AAAA
          for itself, fixing domains such as motorcaravanners.eu.
+       - Feature: you can specify a port number in the interface: line, so
+         you can bind the same interface multiple times at different ports.
 
 7 December 2009: Wouter
        - Bug#287: Fix segfault when unbound-control remove nonexistent local
index d4ed1e3321fd473ba1b1e4f1a7560726cd6e66fe..484ea1c8aacd12fc75fa6f6c19b8484ee205beef 100644 (file)
@@ -32,7 +32,7 @@ server:
        # specify the interfaces to answer queries from by ip-address.
        # The default is to listen to localhost (127.0.0.1 and ::1).
        # specify 0.0.0.0 and ::0 to bind to all available interfaces.
-       # specify every interface on a new 'interface:' labelled line.
+       # specify every interface[@port] on a new 'interface:' labelled line.
        # The listen interfaces are not changed on reload, only on restart.
        # interface: 192.0.2.153
        # interface: 192.0.2.154
index dea7023f42d33b460e1a1a915962224343a33fe0..6c7fba7eacec3eb5d64219fd45981ec7f90d21ce 100644 (file)
@@ -108,12 +108,15 @@ The number of threads to create to serve clients. Use 1 for no threading.
 .B port: \fI<port number>
 The port number, default 53, on which the server responds to queries.
 .TP
-.B interface: \fI<ip address>
+.B interface: \fI<ip address[@port]>
 Interface to use to connect to the network. This interface is listened to
 for queries from clients, and answers to clients are given from it.
 Can be given multiple times to work on several interfaces. If none are 
 given the default is to listen to localhost.
 The interfaces are not changed on a reload (kill \-HUP) but only on restart.
+A port number can be specified with @port (without spaces between
+interface and port number), if not specified the default port (from
+\fBport\fR) is used.
 .TP
 .B interface\-automatic: \fI<yes or no>
 Detect source interface on UDP queries and copy them to replies.  This 
index 92ba88431678f86ac21fd89152da7a05f55d2f69..5ec2462b0771a00274a205b6ba7ed96b41f186cc 100644 (file)
@@ -417,6 +417,35 @@ make_sock(int stype, const char* ifname, const char* port,
        return s;
 }
 
+/** make socket and first see if ifname contains port override info */
+static int
+make_sock_port(int stype, const char* ifname, const char* port, 
+       struct addrinfo *hints, int v6only, int* noip6, size_t rcv)
+{
+       char* s = strchr(ifname, '@');
+       if(s) {
+               /* override port with ifspec@port */
+               char p[16];
+               char newif[128];
+               if((size_t)(s-ifname) >= sizeof(newif)) {
+                       log_err("ifname too long: %s", ifname);
+                       *noip6 = 0;
+                       return -1;
+               }
+               if(strlen(s+1) >= sizeof(p)) {
+                       log_err("portnumber too long: %s", ifname);
+                       *noip6 = 0;
+                       return -1;
+               }
+               strncpy(newif, ifname, sizeof(newif));
+               newif[s-ifname] = 0;
+               strncpy(p, s+1, sizeof(p));
+               p[strlen(s+1)]=0;
+               return make_sock(stype, newif, p, hints, v6only, noip6, rcv);
+       }
+       return make_sock(stype, ifname, port, hints, v6only, noip6, rcv);
+}
+
 /**
  * Add port to open ports list.
  * @param list: list head. changed.
@@ -515,7 +544,7 @@ ports_create_if(const char* ifname, int do_auto, int do_udp, int do_tcp,
        if(!do_udp && !do_tcp)
                return 0;
        if(do_auto) {
-               if((s = make_sock(SOCK_DGRAM, ifname, port, hints, 1, 
+               if((s = make_sock_port(SOCK_DGRAM, ifname, port, hints, 1, 
                        &noip6, rcv)) == -1) {
                        if(noip6) {
                                log_warn("IPv6 protocol not available");
@@ -536,7 +565,7 @@ ports_create_if(const char* ifname, int do_auto, int do_udp, int do_tcp,
                }
        } else if(do_udp) {
                /* regular udp socket */
-               if((s = make_sock(SOCK_DGRAM, ifname, port, hints, 1, 
+               if((s = make_sock_port(SOCK_DGRAM, ifname, port, hints, 1, 
                        &noip6, rcv)) == -1) {
                        if(noip6) {
                                log_warn("IPv6 protocol not available");
@@ -554,7 +583,7 @@ ports_create_if(const char* ifname, int do_auto, int do_udp, int do_tcp,
                }
        }
        if(do_tcp) {
-               if((s = make_sock(SOCK_STREAM, ifname, port, hints, 1, 
+               if((s = make_sock_port(SOCK_STREAM, ifname, port, hints, 1, 
                        &noip6, 0)) == -1) {
                        if(noip6) {
                                /*log_warn("IPv6 protocol not available");*/