diff --git a/src/main/java/com/github/steveice10/packetlib/BuiltinFlags.java b/src/main/java/com/github/steveice10/packetlib/BuiltinFlags.java index f81c505b..9937bd31 100644 --- a/src/main/java/com/github/steveice10/packetlib/BuiltinFlags.java +++ b/src/main/java/com/github/steveice10/packetlib/BuiltinFlags.java @@ -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() { } diff --git a/src/main/java/com/github/steveice10/packetlib/tcp/TcpClientSession.java b/src/main/java/com/github/steveice10/packetlib/tcp/TcpClientSession.java index a87288be..b796468f 100644 --- a/src/main/java/com/github/steveice10/packetlib/tcp/TcpClientSession.java +++ b/src/main/java/com/github/steveice10/packetlib/tcp/TcpClientSession.java @@ -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(); } }