mirror of
https://github.com/GeyserMC/MCProtocolLib.git
synced 2024-12-04 12:51:09 -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 {
|
||||
/**
|
||||
* When set to true, prints exceptions that occur when attempting
|
||||
* to resolve DNS SRV records, rather than silently ignoring them.
|
||||
* When set to true, enables printing internal debug messages.
|
||||
*/
|
||||
public static final String PRINT_DNS_ERRORS = "print-dns-errors";
|
||||
public static final String PRINT_DEBUG = "print-packetlib-debug";
|
||||
|
||||
private BuiltinFlags() {
|
||||
}
|
||||
|
|
|
@ -102,6 +102,8 @@ public class TcpClientSession extends TcpSession {
|
|||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
boolean debug = getFlag(BuiltinFlags.PRINT_DEBUG, false);
|
||||
|
||||
String host = getHost();
|
||||
int port = getPort();
|
||||
|
||||
|
@ -112,9 +114,16 @@ public class TcpClientSession extends TcpSession {
|
|||
|
||||
host = srv.getTarget().toString().replaceFirst("\\.$", "");
|
||||
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) {
|
||||
if(getFlag(BuiltinFlags.PRINT_DNS_ERRORS, false)) {
|
||||
if(debug) {
|
||||
System.out.println("[PacketLib] Failed to resolve SRV record.");
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue