From 5291bea6a03f9b97ae49f37bc91241ee7f7ce29a Mon Sep 17 00:00:00 2001 From: Steveice10 Date: Sat, 30 May 2020 10:49:39 -0700 Subject: [PATCH] Add flag for printing DNS resolution errors. --- .../com/github/steveice10/packetlib/BuiltinFlags.java | 8 ++++++++ .../github/steveice10/packetlib/tcp/TcpClientSession.java | 4 ++++ 2 files changed, 12 insertions(+) create mode 100644 src/main/java/com/github/steveice10/packetlib/BuiltinFlags.java diff --git a/src/main/java/com/github/steveice10/packetlib/BuiltinFlags.java b/src/main/java/com/github/steveice10/packetlib/BuiltinFlags.java new file mode 100644 index 00000000..e433e82f --- /dev/null +++ b/src/main/java/com/github/steveice10/packetlib/BuiltinFlags.java @@ -0,0 +1,8 @@ +package com.github.steveice10.packetlib; + +public class BuiltinFlags { + public static final String PRINT_DNS_ERRORS = "print-dns-errors"; + + 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 a67a19d0..a87288be 100644 --- a/src/main/java/com/github/steveice10/packetlib/tcp/TcpClientSession.java +++ b/src/main/java/com/github/steveice10/packetlib/tcp/TcpClientSession.java @@ -1,5 +1,6 @@ package com.github.steveice10.packetlib.tcp; +import com.github.steveice10.packetlib.BuiltinFlags; import com.github.steveice10.packetlib.Client; import com.github.steveice10.packetlib.ProxyInfo; import com.github.steveice10.packetlib.packet.PacketProtocol; @@ -113,6 +114,9 @@ public class TcpClientSession extends TcpSession { port = srv.getPort(); } } catch(TextParseException e) { + if(getFlag(BuiltinFlags.PRINT_DNS_ERRORS, false)) { + e.printStackTrace(); + } } bootstrap.remoteAddress(host, port);