mirror of
https://github.com/GeyserMC/MCProtocolLib.git
synced 2024-12-04 21:01:02 -05:00
Change DNS error printing to a debug printing flag.
This commit is contained in:
parent
8eaefa9cfc
commit
d82b1b688d
2 changed files with 12 additions and 4 deletions
|
@ -5,10 +5,9 @@ package com.github.steveice10.packetlib;
|
||||||
*/
|
*/
|
||||||
public class BuiltinFlags {
|
public class BuiltinFlags {
|
||||||
/**
|
/**
|
||||||
* When set to true, prints exceptions that occur when attempting
|
* When set to true, enables printing internal debug messages.
|
||||||
* to resolve DNS SRV records, rather than silently ignoring them.
|
|
||||||
*/
|
*/
|
||||||
public static final String PRINT_DNS_ERRORS = "print-dns-errors";
|
public static final String PRINT_DEBUG = "print-packetlib-debug";
|
||||||
|
|
||||||
private BuiltinFlags() {
|
private BuiltinFlags() {
|
||||||
}
|
}
|
||||||
|
|
|
@ -102,6 +102,8 @@ public class TcpClientSession extends TcpSession {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
try {
|
try {
|
||||||
|
boolean debug = getFlag(BuiltinFlags.PRINT_DEBUG, false);
|
||||||
|
|
||||||
String host = getHost();
|
String host = getHost();
|
||||||
int port = getPort();
|
int port = getPort();
|
||||||
|
|
||||||
|
@ -112,9 +114,16 @@ public class TcpClientSession extends TcpSession {
|
||||||
|
|
||||||
host = srv.getTarget().toString().replaceFirst("\\.$", "");
|
host = srv.getTarget().toString().replaceFirst("\\.$", "");
|
||||||
port = srv.getPort();
|
port = srv.getPort();
|
||||||
|
|
||||||
|
if(debug) {
|
||||||
|
System.out.println("[PacketLib] Found SRV record for \"" + host + ":" + port + "\".");
|
||||||
|
}
|
||||||
|
} else if(debug) {
|
||||||
|
System.out.println("[PacketLib] No SRV records found.");
|
||||||
}
|
}
|
||||||
} catch(TextParseException e) {
|
} catch(TextParseException e) {
|
||||||
if(getFlag(BuiltinFlags.PRINT_DNS_ERRORS, false)) {
|
if(debug) {
|
||||||
|
System.out.println("[PacketLib] Failed to resolve SRV record.");
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue