mirror of
https://github.com/GeyserMC/MCProtocolLib.git
synced 2024-12-12 08:41:00 -05:00
Replace session host and port with resolved SRV record, bump version to 1.7.
This commit is contained in:
parent
9a11ceddd5
commit
42e417fc50
3 changed files with 8 additions and 9 deletions
2
pom.xml
2
pom.xml
|
@ -5,7 +5,7 @@
|
||||||
|
|
||||||
<groupId>com.github.steveice10</groupId>
|
<groupId>com.github.steveice10</groupId>
|
||||||
<artifactId>packetlib</artifactId>
|
<artifactId>packetlib</artifactId>
|
||||||
<version>1.7-SNAPSHOT</version>
|
<version>1.7</version>
|
||||||
<packaging>jar</packaging>
|
<packaging>jar</packaging>
|
||||||
|
|
||||||
<name>PacketLib</name>
|
<name>PacketLib</name>
|
||||||
|
|
|
@ -29,7 +29,6 @@ import io.netty.resolver.dns.DnsNameResolver;
|
||||||
import io.netty.resolver.dns.DnsNameResolverBuilder;
|
import io.netty.resolver.dns.DnsNameResolverBuilder;
|
||||||
|
|
||||||
import java.net.InetSocketAddress;
|
import java.net.InetSocketAddress;
|
||||||
import java.net.SocketAddress;
|
|
||||||
|
|
||||||
public class TcpClientSession extends TcpSession {
|
public class TcpClientSession extends TcpSession {
|
||||||
private Client client;
|
private Client client;
|
||||||
|
@ -111,7 +110,8 @@ public class TcpClientSession extends TcpSession {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
try {
|
try {
|
||||||
bootstrap.remoteAddress(resolveAddress());
|
resolveAddress();
|
||||||
|
bootstrap.remoteAddress(getHost(), getPort());
|
||||||
|
|
||||||
ChannelFuture future = bootstrap.connect().sync();
|
ChannelFuture future = bootstrap.connect().sync();
|
||||||
if(future.isSuccess()) {
|
if(future.isSuccess()) {
|
||||||
|
@ -138,7 +138,7 @@ public class TcpClientSession extends TcpSession {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private SocketAddress resolveAddress() {
|
private void resolveAddress() {
|
||||||
boolean debug = getFlag(BuiltinFlags.PRINT_DEBUG, false);
|
boolean debug = getFlag(BuiltinFlags.PRINT_DEBUG, false);
|
||||||
|
|
||||||
String name = this.getPacketProtocol().getSRVRecordPrefix() + "._tcp." + this.getHost();
|
String name = this.getPacketProtocol().getSRVRecordPrefix() + "._tcp." + this.getHost();
|
||||||
|
@ -168,7 +168,8 @@ public class TcpClientSession extends TcpSession {
|
||||||
System.out.println("[PacketLib] Found SRV record containing \"" + host + ":" + port + "\".");
|
System.out.println("[PacketLib] Found SRV record containing \"" + host + ":" + port + "\".");
|
||||||
}
|
}
|
||||||
|
|
||||||
return new InetSocketAddress(host, port);
|
this.host = host;
|
||||||
|
this.port = port;
|
||||||
} else if(debug) {
|
} else if(debug) {
|
||||||
System.out.println("[PacketLib] Received non-SRV record in response.");
|
System.out.println("[PacketLib] Received non-SRV record in response.");
|
||||||
}
|
}
|
||||||
|
@ -185,8 +186,6 @@ public class TcpClientSession extends TcpSession {
|
||||||
envelope.release();
|
envelope.release();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return new InetSocketAddress(this.getHost(), this.getPort());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -34,8 +34,8 @@ import java.util.concurrent.CopyOnWriteArrayList;
|
||||||
import java.util.concurrent.LinkedBlockingQueue;
|
import java.util.concurrent.LinkedBlockingQueue;
|
||||||
|
|
||||||
public abstract class TcpSession extends SimpleChannelInboundHandler<Packet> implements Session {
|
public abstract class TcpSession extends SimpleChannelInboundHandler<Packet> implements Session {
|
||||||
private String host;
|
protected String host;
|
||||||
private int port;
|
protected int port;
|
||||||
private PacketProtocol protocol;
|
private PacketProtocol protocol;
|
||||||
|
|
||||||
private int compressionThreshold = -1;
|
private int compressionThreshold = -1;
|
||||||
|
|
Loading…
Reference in a new issue