Remote socket address correctly passed

This commit is contained in:
Manevolent
2019-11-26 11:34:30 -07:00
parent 614b3d9d69
commit 28c570f253
2 changed files with 8 additions and 7 deletions
@@ -17,6 +17,7 @@ import org.bouncycastle.math.ec.ECPoint;
import java.io.IOException; import java.io.IOException;
import java.math.BigInteger; import java.math.BigInteger;
import java.net.*;
import java.nio.ByteBuffer; import java.nio.ByteBuffer;
import java.nio.charset.Charset; import java.nio.charset.Charset;
import java.util.Base64; import java.util.Base64;
@@ -220,13 +221,9 @@ public class LocalClientHandlerConnecting extends LocalClientHandler {
initiv.add(new CommandSingleParameter("omega", getClient().getIdentity().getPublicKeyString())); initiv.add(new CommandSingleParameter("omega", getClient().getIdentity().getPublicKeyString()));
initiv.add(new CommandSingleParameter("ot", "1")); // constant, set to 1 initiv.add(new CommandSingleParameter("ot", "1")); // constant, set to 1
Random r = new Random(); InetAddress address = getClient().getRemoteSocketAddress().getAddress();
initiv.add( if (address != null)
new CommandSingleParameter( initiv.add(new CommandSingleParameter("ip", address.getHostAddress().substring(1)));
"ip",
r.nextInt(255) + "." + r.nextInt(255) + "." + r.nextInt(255) + "." +r.nextInt(255)
)
);
return initiv; return initiv;
} }
@@ -415,6 +415,10 @@ public class LocalTeamspeakClientSocket
return (InetSocketAddress) socket.getLocalSocketAddress(); return (InetSocketAddress) socket.getLocalSocketAddress();
} }
public InetSocketAddress getRemoteSocketAddress() {
return remote;
}
@Override @Override
public void close() throws IOException { public void close() throws IOException {
socket.close(); socket.close();