1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20 package org.apache.directory.server.dns;
21
22
23 import org.apache.directory.server.core.DefaultDirectoryService;
24 import org.apache.directory.server.core.api.DirectoryService;
25 import org.apache.directory.server.protocol.shared.transport.TcpTransport;
26 import org.apache.directory.server.protocol.shared.transport.UdpTransport;
27 import org.slf4j.Logger;
28 import org.slf4j.LoggerFactory;
29
30
31
32
33
34 public class Main
35 {
36
37 private static final Logger LOG = LoggerFactory.getLogger( Main.class );
38
39 private static DnsServer dnsConfiguration;
40
41
42
43
44
45
46
47
48 public static void main( String[] args ) throws Exception
49 {
50 new Main().go();
51 }
52
53
54
55
56
57 public void go() throws Exception
58 {
59 LOG.debug( "Starting the DNS server" );
60
61 DirectoryService directoryService = new DefaultDirectoryService();
62 dnsConfiguration = new DnsServer();
63 dnsConfiguration.setDirectoryService( directoryService );
64 dnsConfiguration.setEnabled( true );
65 dnsConfiguration.setTransports( new TcpTransport( 10053 ), new UdpTransport( 10053 ) );
66 dnsConfiguration.start();
67 }
68
69
70 protected void shutdown()
71 {
72 LOG.debug( "Stopping the DNS server" );
73 dnsConfiguration.stop();
74 }
75 }