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 java.io.IOException;
24
25 import javax.naming.NamingException;
26
27 import org.apache.directory.server.core.DefaultDirectoryService;
28 import org.apache.directory.server.core.DirectoryService;
29 import org.apache.directory.server.protocol.shared.DatagramAcceptor;
30 import org.apache.directory.server.protocol.shared.SocketAcceptor;
31 import org.slf4j.Logger;
32 import org.slf4j.LoggerFactory;
33
34
35
36
37
38
39 public class Main
40 {
41
42 private static final Logger LOG = LoggerFactory.getLogger( Main.class );
43
44 private static DnsServer dnsConfiguration;
45
46
47
48
49
50
51
52 public static void main( String[] args ) throws Exception
53 {
54 new Main().go();
55 }
56
57
58
59
60
61 public void go() throws IOException, NamingException
62 {
63 LOG.debug( "Starting the DNS server" );
64
65 DatagramAcceptor datagramAcceptor = new DatagramAcceptor( null );
66 SocketAcceptor socketAcceptor = new SocketAcceptor( null );
67 DirectoryService directoryService = new DefaultDirectoryService();
68 dnsConfiguration = new DnsServer();
69 dnsConfiguration.setDatagramAcceptor( datagramAcceptor );
70 dnsConfiguration.setSocketAcceptor( socketAcceptor );
71 dnsConfiguration.setDirectoryService( directoryService );
72 dnsConfiguration.setEnabled( true );
73 dnsConfiguration.setIpPort( 10053 );
74 dnsConfiguration.start();
75 }
76
77
78 protected void shutdown()
79 {
80 LOG.debug( "Stopping the DNS server" );
81 dnsConfiguration.stop();
82 }
83 }