diff options
| author | Pugmatt <pugmatt@gmail.com> | 2020-08-18 11:51:30 -0400 |
|---|---|---|
| committer | Pugmatt <pugmatt@gmail.com> | 2020-08-18 11:51:30 -0400 |
| commit | 78517302103941fd974cce22cc575e19821437da (patch) | |
| tree | d30e56321c6cde7e737f7113ef31347749d3a629 | |
| parent | 9b468c1d5ec1d5273c9485c05e58fc0bb5da7146 (diff) | |
| download | BedrockConnect-78517302103941fd974cce22cc575e19821437da.tar.gz BedrockConnect-78517302103941fd974cce22cc575e19821437da.tar.bz2 BedrockConnect-78517302103941fd974cce22cc575e19821437da.zip | |
Revert unfinished DNS server1.5.3
3 files changed, 1 insertions, 165 deletions
diff --git a/serverlist-server/pom.xml b/serverlist-server/pom.xml index 2b04c21..33def55 100644 --- a/serverlist-server/pom.xml +++ b/serverlist-server/pom.xml @@ -155,21 +155,11 @@ <scope>compile</scope> </dependency> <dependency> - <groupId>dnsjava</groupId> - <artifactId>dnsjava</artifactId> - <version>3.0.2</version> - </dependency> - <dependency> <groupId>org.slf4j</groupId> <artifactId>slf4j-simple</artifactId> <version>1.7.21</version> </dependency> - <dependency> - <groupId>io.netty</groupId> - <artifactId>netty-resolver-dns</artifactId> - <version>4.1.43.Final</version> - <scope>compile</scope> - </dependency> + <!-- Proxy Stuff --> diff --git a/serverlist-server/src/main/com/pyratron/pugmatt/bedrockconnect/BedrockConnect.java b/serverlist-server/src/main/com/pyratron/pugmatt/bedrockconnect/BedrockConnect.java index 3c72590..1949331 100644 --- a/serverlist-server/src/main/com/pyratron/pugmatt/bedrockconnect/BedrockConnect.java +++ b/serverlist-server/src/main/com/pyratron/pugmatt/bedrockconnect/BedrockConnect.java @@ -1,16 +1,11 @@ package main.com.pyratron.pugmatt.bedrockconnect; -import main.com.pyratron.pugmatt.bedrockconnect.dns.DNS; import main.com.pyratron.pugmatt.bedrockconnect.sql.Data; import main.com.pyratron.pugmatt.bedrockconnect.sql.MySQL; import main.com.pyratron.pugmatt.bedrockconnect.utils.PaletteManager; -import org.json.simple.JSONArray; -import org.json.simple.JSONObject; import java.io.*; import java.net.*; -import java.nio.file.Files; -import java.nio.file.Paths; import java.sql.Connection; import java.sql.ResultSet; import java.sql.SQLException; @@ -119,56 +114,6 @@ public class BedrockConnect { if(str.startsWith("publicipv6=")) { publicIPV6 = getArgValue(str, "publicipv6"); } - if(str.startsWith("enabledns=")) { - enableDNS = true; - } - } - - if(enableDNS) { - if(localIP == null) { - String ip; - - try { - Enumeration<NetworkInterface> interfaces = NetworkInterface.getNetworkInterfaces(); - - System.out.println("Local IPv4 IPs:"); - while (interfaces.hasMoreElements()) { - NetworkInterface iface = interfaces.nextElement(); - - if (iface.isLoopback() || !iface.isUp() || iface.isVirtual() || iface.isPointToPoint()) - continue; - - Enumeration<InetAddress> addresses = iface.getInetAddresses(); - while (addresses.hasMoreElements()) { - InetAddress addr = addresses.nextElement(); - - if (!(addr instanceof Inet4Address)) continue; - - ip = addr.getHostAddress(); - System.out.println(iface.getDisplayName() + ": " + ip); - } - } - - Scanner reader = new Scanner(System.in); // Reading from System.in - System.out.print("\nEnter the local IPv4 that players inside your WiFi network will connect to: "); - localIP = reader.next().replaceAll("\\s+", ""); - reader.close(); - } catch (SocketException e) { - throw new RuntimeException(e); - } - - } - - if(publicIP == null) { - URL whatismyip = new URL("http://checkip.amazonaws.com"); - BufferedReader in = new BufferedReader(new InputStreamReader( - whatismyip.openStream())); - - publicIP = in.readLine(); - } - - DNS dnsServer = new DNS(localIP, publicIP, localIPV6, publicIPV6, 53); - dnsServer.start(); } if(!noDB) diff --git a/serverlist-server/src/main/com/pyratron/pugmatt/bedrockconnect/dns/DNS.java b/serverlist-server/src/main/com/pyratron/pugmatt/bedrockconnect/dns/DNS.java deleted file mode 100644 index 7e65c7f..0000000 --- a/serverlist-server/src/main/com/pyratron/pugmatt/bedrockconnect/dns/DNS.java +++ /dev/null @@ -1,99 +0,0 @@ -package main.com.pyratron.pugmatt.bedrockconnect.dns; - -import org.xbill.DNS.*; - -import java.io.IOException; -import java.net.DatagramPacket; -import java.net.DatagramSocket; -import java.util.Arrays; -import java.util.List; - -// Referenced code from: https://medium.com/swlh/mock-a-dns-server-in-java-a810b9338872 - -public class DNS { - private Thread thread = null; - private volatile boolean running = false; - private static final int UDP_SIZE = 512; - private final int port; - private int requestCount = 0; - - private String localIP; - private String publicIP; - - private String localIPV6; - private String publicIPV6; - - public DNS(String localIP, String publicIP, String localIPV6, String publicIPV6, int port) { - this.port = port; - this.localIP = localIP; - this.publicIP = publicIP; - - this.localIPV6 = localIPV6; - this.publicIPV6 = publicIPV6; - } - - public void start() { - running = true; - thread = new Thread(() -> { - try { - serve(); - } catch (IOException ex) { - stop(); - throw new RuntimeException(ex); - } - }); - thread.start(); - System.out.println("BedrockConnect DNS server now running ( Local IPv4: " + localIP + " ; Public IPv4: " + publicIP + " )"); - } - - public void stop() { - running = false; - thread.interrupt(); - thread = null; - } - - public int getRequestCount() { - return requestCount; - } - - private void serve() throws IOException { - DatagramSocket socket = new DatagramSocket(port); - while (running) { - process(socket); - } - } - - private void process(DatagramSocket socket) throws IOException { - byte[] in = new byte[UDP_SIZE]; - - DatagramPacket indp = new DatagramPacket(in, UDP_SIZE); - socket.receive(indp); - ++requestCount; - - Message request = new Message(in); - Message response = new Message(request.getHeader().getID()); - - response.addRecord(request.getQuestion(), Section.QUESTION); - System.out.println(request.getQuestion().getName().toString()); - List<String> featuredServers = Arrays.asList("receive-lp1.dg.srv.nintendo.net", "www.facebook.com.", "mobile.twitter.com.", "geo.hivebedrock.network.", "hivebedrock.network.", "mco.mineplex.com.", "play.inpvp.net.", "mco.lbsg.net.", "mco.cubecraft.net."); - if(featuredServers.contains(request.getQuestion().getName().toString())) { - if (indp.getAddress().getHostAddress().startsWith("192.168")) { - System.out.println(localIP); - response.addRecord(Record.fromString(Name.root, Type.A, DClass.ANY, 86400, "192.168.0.140", Name.root), Section.ANSWER); - //if(localIPV6 != null) { - // response.addRecord(Record.fromString(Name.root, Type.AAAA, DClass.IN, 86400, localIPV6, Name.root), Section.ANSWER); - //} - } - else { - response.addRecord(Record.fromString(Name.root, Type.A, DClass.IN, 86400, publicIP, Name.root), Section.ANSWER); - if(publicIPV6 != null) { - response.addRecord(Record.fromString(Name.root, Type.AAAA, DClass.IN, 86400, publicIPV6, Name.root), Section.ANSWER); - } - } - - byte[] resp = response.toWire(); - DatagramPacket outdp = new DatagramPacket(resp, resp.length, indp.getAddress(), indp.getPort()); - socket.send(outdp); - } - } -} |
