mirror of
https://github.com/samba-team/samba.git
synced 2025-01-26 10:04:02 +03:00
libcli/dns.c: dns forwarder port test changes
Test harness for the dns fowarder setting in smb.conf. Adds IPv6 forwarder as second target DNS forwarder, listening on port 54. Signed-off-by: Matthew Grant <grantma@mattgrant.net.nz> Reviewed-by: Uri Simchoni <uri@samba.org> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
This commit is contained in:
parent
617a5a1d35
commit
2a09803097
@ -31,6 +31,8 @@ import samba.getopt as options
|
||||
import optparse
|
||||
import subprocess
|
||||
|
||||
DNS_PORT2 = 54
|
||||
|
||||
parser = optparse.OptionParser("dns_forwarder.py <server name> <server ip> (dns forwarder)+ [options]")
|
||||
sambaopts = options.SambaOptions(parser)
|
||||
parser.add_option_group(sambaopts)
|
||||
@ -173,7 +175,10 @@ class TestDnsForwarding(DNSTest):
|
||||
'dns_forwarder_helpers/server.py'),
|
||||
host, str(port), id])
|
||||
self.subprocesses.append(p)
|
||||
s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM, 0)
|
||||
if (host.find(':') != -1):
|
||||
s = socket.socket(socket.AF_INET6, socket.SOCK_DGRAM, 0)
|
||||
else:
|
||||
s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM, 0)
|
||||
for i in range(300):
|
||||
time.sleep(0.05)
|
||||
s.connect((host, port))
|
||||
@ -349,7 +354,7 @@ class TestDnsForwarding(DNSTest):
|
||||
print("Ignoring test_double_forwarder_first_frozen")
|
||||
return
|
||||
s1 = self.start_toy_server(dns_servers[0], 53, 'forwarder1')
|
||||
s2 = self.start_toy_server(dns_servers[1], 53, 'forwarder2')
|
||||
s2 = self.start_toy_server(dns_servers[1], DNS_PORT2, 'forwarder2')
|
||||
s1.send(b'timeout 1000', 0)
|
||||
ad = contact_real_server(server_ip, 53)
|
||||
name = "dsfsfds.dsfsdfs"
|
||||
@ -378,7 +383,7 @@ class TestDnsForwarding(DNSTest):
|
||||
if len(dns_servers) < 2:
|
||||
print("Ignoring test_double_forwarder_first_down")
|
||||
return
|
||||
s2 = self.start_toy_server(dns_servers[1], 53, 'forwarder2')
|
||||
s2 = self.start_toy_server(dns_servers[1], DNS_PORT2, 'forwarder2')
|
||||
ad = contact_real_server(server_ip, 53)
|
||||
name = "dsfsfds.dsfsdfs"
|
||||
p = self.make_name_packet(dns.DNS_OPCODE_QUERY)
|
||||
@ -407,7 +412,7 @@ class TestDnsForwarding(DNSTest):
|
||||
print("Ignoring test_double_forwarder_both_slow")
|
||||
return
|
||||
s1 = self.start_toy_server(dns_servers[0], 53, 'forwarder1')
|
||||
s2 = self.start_toy_server(dns_servers[1], 53, 'forwarder2')
|
||||
s2 = self.start_toy_server(dns_servers[1], DNS_PORT2, 'forwarder2')
|
||||
s1.send(b'timeout 1.5', 0)
|
||||
s2.send(b'timeout 1.5', 0)
|
||||
ad = contact_real_server(server_ip, 53)
|
||||
@ -493,7 +498,7 @@ class TestDnsForwarding(DNSTest):
|
||||
print("Ignoring test_cname_forwarding_with_slow_server")
|
||||
return
|
||||
s1 = self.start_toy_server(dns_servers[0], 53, 'forwarder1')
|
||||
s2 = self.start_toy_server(dns_servers[1], 53, 'forwarder2')
|
||||
s2 = self.start_toy_server(dns_servers[1], DNS_PORT2, 'forwarder2')
|
||||
s1.send(b'timeout 10000', 0)
|
||||
|
||||
name = 'resolve.cname.%s' % self.get_dns_domain()
|
||||
@ -525,7 +530,7 @@ class TestDnsForwarding(DNSTest):
|
||||
if len(dns_servers) < 2:
|
||||
print("Ignoring test_cname_forwarding_with_server_down")
|
||||
return
|
||||
s2 = self.start_toy_server(dns_servers[1], 53, 'forwarder2')
|
||||
s2 = self.start_toy_server(dns_servers[1], DNS_PORT2, 'forwarder2')
|
||||
|
||||
name1 = 'resolve1.cname.%s' % self.get_dns_domain()
|
||||
name2 = 'resolve2.cname.%s' % self.get_dns_domain()
|
||||
|
@ -19,6 +19,7 @@
|
||||
# Based on the EchoServer example from python docs
|
||||
|
||||
import socketserver as SocketServer
|
||||
import socket
|
||||
import sys
|
||||
from threading import Timer
|
||||
from samba.dcerpc import dns
|
||||
@ -85,11 +86,18 @@ class DnsHandler(SocketServer.BaseRequestHandler):
|
||||
t = Timer(timeout, self.really_handle, [data, socket])
|
||||
t.start()
|
||||
|
||||
class TestUDPServer(SocketServer.UDPServer):
|
||||
def __init__(self, server_address, RequestHandlerClass):
|
||||
if server_address[0].find(':') != -1:
|
||||
self.address_family = socket.AF_INET6
|
||||
else:
|
||||
self.address_family = socket.AF_INET
|
||||
super(SocketServer.UDPServer, self).__init__(server_address, RequestHandlerClass)
|
||||
|
||||
def main():
|
||||
global SERVER_ID
|
||||
host, port, SERVER_ID = sys.argv[1:]
|
||||
server = SocketServer.UDPServer((host, int(port)), DnsHandler)
|
||||
server = TestUDPServer((host, int(port)), DnsHandler)
|
||||
server.serve_forever()
|
||||
|
||||
|
||||
|
@ -1675,13 +1675,13 @@ sub provision_fl2003dc($$$)
|
||||
{
|
||||
my ($self, $prefix, $dcvars) = @_;
|
||||
my $ip_addr1 = Samba::get_ipv4_addr("fakednsforwarder1");
|
||||
my $ip_addr2 = Samba::get_ipv4_addr("fakednsforwarder2");
|
||||
my $ip_addr2 = Samba::get_ipv6_addr("fakednsforwarder2");
|
||||
|
||||
print "PROVISIONING DC WITH FOREST LEVEL 2003...\n";
|
||||
my $extra_conf_options = "allow dns updates = nonsecure and secure
|
||||
dcesrv:header signing = no
|
||||
dcesrv:max auth states = 0
|
||||
dns forwarder = $ip_addr1 $ip_addr2";
|
||||
dns forwarder = $ip_addr1 [$ip_addr2]:54";
|
||||
my $extra_provision_options = ["--base-schema=2008_R2"];
|
||||
my $ret = $self->provision($prefix,
|
||||
"domain controller",
|
||||
|
Loading…
x
Reference in New Issue
Block a user