applied some fixes ayunami suggested

This commit is contained in:
LAX1DUDE 2022-08-18 13:42:48 -07:00
parent 8111b7f756
commit 1e7c5a7493
11 changed files with 54 additions and 39 deletions

View File

@ -35,13 +35,13 @@ public class EaglerSPClient {
try { try {
this.socket.send(IPacket.writePacket(packet)); this.socket.send(IPacket.writePacket(packet));
}catch(IOException ex) { }catch(IOException ex) {
EaglerSPRelay.logger.debug("Error sending data to {}", this.socket.getAttachment()); EaglerSPRelay.logger.debug("Error sending data to {}", (String) this.socket.getAttachment());
EaglerSPRelay.logger.debug(ex); EaglerSPRelay.logger.debug(ex);
disconnect(IPacketFEDisconnectClient.TYPE_INTERNAL_ERROR, "Internal Server Error"); disconnect(IPacketFEDisconnectClient.TYPE_INTERNAL_ERROR, "Internal Server Error");
this.socket.close(); this.socket.close();
} }
}else { }else {
EaglerSPRelay.logger.debug("WARNING: Tried to send data to {} after the connection closed.", this.socket.getAttachment()); EaglerSPRelay.logger.debug("WARNING: Tried to send data to {} after the connection closed.", (String) this.socket.getAttachment());
} }
} }
@ -50,21 +50,21 @@ public class EaglerSPClient {
if(LoginState.assertEquals(this, LoginState.INIT)) { if(LoginState.assertEquals(this, LoginState.INIT)) {
state = LoginState.SENT_ICE_CANDIDATE; state = LoginState.SENT_ICE_CANDIDATE;
server.handleClientICECandidate(this, (IPacket03ICECandidate)packet); server.handleClientICECandidate(this, (IPacket03ICECandidate)packet);
EaglerSPRelay.logger.debug("[{}][Client -> Relay -> Server] PKT 0x03: ICECandidate", socket.getAttachment()); EaglerSPRelay.logger.debug("[{}][Client -> Relay -> Server] PKT 0x03: ICECandidate", (String) socket.getAttachment());
} }
return true; return true;
}else if(packet instanceof IPacket04Description) { }else if(packet instanceof IPacket04Description) {
if(LoginState.assertEquals(this, LoginState.RECIEVED_ICE_CANIDATE)) { if(LoginState.assertEquals(this, LoginState.RECIEVED_ICE_CANIDATE)) {
state = LoginState.SENT_DESCRIPTION; state = LoginState.SENT_DESCRIPTION;
server.handleClientDescription(this, (IPacket04Description)packet); server.handleClientDescription(this, (IPacket04Description)packet);
EaglerSPRelay.logger.debug("[{}][Client -> Relay -> Server] PKT 0x04: Description", socket.getAttachment()); EaglerSPRelay.logger.debug("[{}][Client -> Relay -> Server] PKT 0x04: Description", (String) socket.getAttachment());
} }
return true; return true;
}else if(packet instanceof IPacket05ClientSuccess) { }else if(packet instanceof IPacket05ClientSuccess) {
if(LoginState.assertEquals(this, LoginState.RECIEVED_DESCRIPTION)) { if(LoginState.assertEquals(this, LoginState.RECIEVED_DESCRIPTION)) {
state = LoginState.FINISHED; state = LoginState.FINISHED;
server.handleClientSuccess(this, (IPacket05ClientSuccess)packet); server.handleClientSuccess(this, (IPacket05ClientSuccess)packet);
EaglerSPRelay.logger.debug("[{}][Client -> Relay -> Server] PKT 0x05: ClientSuccess", socket.getAttachment()); EaglerSPRelay.logger.debug("[{}][Client -> Relay -> Server] PKT 0x05: ClientSuccess", (String) socket.getAttachment());
disconnect(IPacketFEDisconnectClient.TYPE_FINISHED_SUCCESS, "Successful connection"); disconnect(IPacketFEDisconnectClient.TYPE_FINISHED_SUCCESS, "Successful connection");
} }
return true; return true;
@ -72,7 +72,7 @@ public class EaglerSPClient {
if(LoginState.assertEquals(this, LoginState.RECIEVED_DESCRIPTION)) { if(LoginState.assertEquals(this, LoginState.RECIEVED_DESCRIPTION)) {
state = LoginState.FINISHED; state = LoginState.FINISHED;
server.handleClientFailure(this, (IPacket06ClientFailure)packet); server.handleClientFailure(this, (IPacket06ClientFailure)packet);
EaglerSPRelay.logger.debug("[{}][Client -> Relay -> Server] PKT 0x05: ClientFailure", socket.getAttachment()); EaglerSPRelay.logger.debug("[{}][Client -> Relay -> Server] PKT 0x05: ClientFailure", (String) socket.getAttachment());
disconnect(IPacketFEDisconnectClient.TYPE_FINISHED_FAILED, "Failed connection"); disconnect(IPacketFEDisconnectClient.TYPE_FINISHED_FAILED, "Failed connection");
} }
return true; return true;
@ -103,7 +103,7 @@ public class EaglerSPClient {
send(pkt); send(pkt);
socket.close(); socket.close();
} }
EaglerSPRelay.logger.debug("[{}][Relay -> Client] PKT 0xFE: #{} {}", socket.getAttachment(), code, reason); EaglerSPRelay.logger.debug("[{}][Relay -> Client] PKT 0xFE: #{} {}", (String) socket.getAttachment(), code, reason);
} }
public static final int clientCodeLength = 16; public static final int clientCodeLength = 16;

View File

@ -179,7 +179,7 @@ public class EaglerSPRelay extends WebSocketServer {
} }
if(totalCons >= config.getConnectionsPerIP()) { if(totalCons >= config.getConnectionsPerIP()) {
logger.debug("[{}]: Too many connections are open on this address", arg0.getAttachment()); logger.debug("[{}]: Too many connections are open on this address", (String) arg0.getAttachment());
arg0.send(IPacketFEDisconnectClient.ratelimitPacketTooMany); arg0.send(IPacketFEDisconnectClient.ratelimitPacketTooMany);
arg0.close(); arg0.close();
return; return;
@ -208,7 +208,7 @@ public class EaglerSPRelay extends WebSocketServer {
IPacket00Handshake ipkt = (IPacket00Handshake)pkt; IPacket00Handshake ipkt = (IPacket00Handshake)pkt;
if(ipkt.connectionVersion != Constants.protocolVersion) { if(ipkt.connectionVersion != Constants.protocolVersion) {
logger.debug("[{}]: Connected with unsupported protocol version: {} (supported " logger.debug("[{}]: Connected with unsupported protocol version: {} (supported "
+ "version: {})", arg0.getAttachment(), ipkt.connectionVersion, Constants.protocolVersion); + "version: {})", (String) arg0.getAttachment(), ipkt.connectionVersion, Constants.protocolVersion);
if(ipkt.connectionVersion < Constants.protocolVersion) { if(ipkt.connectionVersion < Constants.protocolVersion) {
arg0.send(IPacket.writePacket(new IPacketFFErrorCode(IPacketFFErrorCode.TYPE_PROTOCOL_VERSION, arg0.send(IPacket.writePacket(new IPacketFFErrorCode(IPacketFFErrorCode.TYPE_PROTOCOL_VERSION,
"Outdated Client! (v" + Constants.protocolVersion + " req)"))); "Outdated Client! (v" + Constants.protocolVersion + " req)")));
@ -221,21 +221,21 @@ public class EaglerSPRelay extends WebSocketServer {
} }
if(ipkt.connectionType == 0x01) { if(ipkt.connectionType == 0x01) {
if(!rateLimit(worldRateLimiter, arg0, waiting.address)) { if(!rateLimit(worldRateLimiter, arg0, waiting.address)) {
logger.debug("[{}]: Got world ratelimited", arg0.getAttachment()); logger.debug("[{}]: Got world ratelimited", (String) arg0.getAttachment());
return; return;
} }
synchronized(serverAddressSets) { synchronized(serverAddressSets) {
List<EaglerSPServer> lst = serverAddressSets.get(waiting.address); List<EaglerSPServer> lst = serverAddressSets.get(waiting.address);
if(lst != null) { if(lst != null) {
if(lst.size() >= config.getWorldsPerIP()) { if(lst.size() >= config.getWorldsPerIP()) {
logger.debug("[{}]: Too many worlds are open on this address", arg0.getAttachment()); logger.debug("[{}]: Too many worlds are open on this address", (String) arg0.getAttachment());
arg0.send(IPacketFEDisconnectClient.ratelimitPacketTooMany); arg0.send(IPacketFEDisconnectClient.ratelimitPacketTooMany);
arg0.close(); arg0.close();
return; return;
} }
} }
} }
logger.debug("[{}]: Connected as a server", arg0.getAttachment()); logger.debug("[{}]: Connected as a server", (String) arg0.getAttachment());
EaglerSPServer srv; EaglerSPServer srv;
synchronized(serverCodes) { synchronized(serverCodes) {
int j = 0; int j = 0;
@ -243,7 +243,7 @@ public class EaglerSPRelay extends WebSocketServer {
do { do {
if(++j > 100) { if(++j > 100) {
logger.error("Error: relay is running out of codes!"); logger.error("Error: relay is running out of codes!");
logger.error("Closing connection to {}", arg0.getAttachment()); logger.error("Closing connection to {}", (String) arg0.getAttachment());
arg0.send(IPacket.writePacket(new IPacketFFErrorCode(IPacketFFErrorCode.TYPE_INTERNAL_ERROR, arg0.send(IPacket.writePacket(new IPacketFFErrorCode(IPacketFFErrorCode.TYPE_INTERNAL_ERROR,
"Internal Server Error"))); "Internal Server Error")));
arg0.close(); arg0.close();
@ -255,7 +255,7 @@ public class EaglerSPRelay extends WebSocketServer {
serverCodes.put(code, srv); serverCodes.put(code, srv);
ipkt.connectionCode = code; ipkt.connectionCode = code;
arg0.send(IPacket.writePacket(ipkt)); arg0.send(IPacket.writePacket(ipkt));
logger.debug("[{}][Relay -> Server] PKT 0x00: Assign join code: {}", arg0.getAttachment(), code); logger.debug("[{}][Relay -> Server] PKT 0x00: Assign join code: {}", (String) arg0.getAttachment(), code);
} }
synchronized(serverConnections) { synchronized(serverConnections) {
serverConnections.put(arg0, srv); serverConnections.put(arg0, srv);
@ -269,15 +269,15 @@ public class EaglerSPRelay extends WebSocketServer {
lst.add(srv); lst.add(srv);
} }
srv.send(new IPacket01ICEServers(EaglerSPRelayConfigRelayList.relayServers)); srv.send(new IPacket01ICEServers(EaglerSPRelayConfigRelayList.relayServers));
logger.debug("[{}][Relay -> Server] PKT 0x01: Send ICE server list to server", arg0.getAttachment()); logger.debug("[{}][Relay -> Server] PKT 0x01: Send ICE server list to server", (String) arg0.getAttachment());
}else { }else {
if(!rateLimit(pingRateLimiter, arg0, waiting.address)) { if(!rateLimit(pingRateLimiter, arg0, waiting.address)) {
logger.debug("[{}]: Got ping ratelimited", arg0.getAttachment()); logger.debug("[{}]: Got ping ratelimited", (String) arg0.getAttachment());
return; return;
} }
if(ipkt.connectionType == 0x02) { if(ipkt.connectionType == 0x02) {
String code = ipkt.connectionCode; String code = ipkt.connectionCode;
logger.debug("[{}]: Connected as a client, requested server code: {}", arg0.getAttachment(), code); logger.debug("[{}]: Connected as a client, requested server code: {}", (String) arg0.getAttachment(), code);
if(code.length() != config.getCodeLength()) { if(code.length() != config.getCodeLength()) {
logger.debug("The code '{}' is invalid because it's the wrong length, disconnecting"); logger.debug("The code '{}' is invalid because it's the wrong length, disconnecting");
arg0.send(IPacket.writePacket(new IPacketFFErrorCode(IPacketFFErrorCode.TYPE_CODE_LENGTH, arg0.send(IPacket.writePacket(new IPacketFFErrorCode(IPacketFFErrorCode.TYPE_CODE_LENGTH,
@ -319,18 +319,18 @@ public class EaglerSPRelay extends WebSocketServer {
lst.add(cl); lst.add(cl);
} }
cl.send(new IPacket01ICEServers(EaglerSPRelayConfigRelayList.relayServers)); cl.send(new IPacket01ICEServers(EaglerSPRelayConfigRelayList.relayServers));
logger.debug("[{}][Relay -> Client] PKT 0x01: Send ICE server list to client", arg0.getAttachment()); logger.debug("[{}][Relay -> Client] PKT 0x01: Send ICE server list to client", (String) arg0.getAttachment());
} }
}else if(ipkt.connectionType == 0x03) { }else if(ipkt.connectionType == 0x03) {
logger.debug("[{}]: Pinging the server", arg0.getAttachment()); logger.debug("[{}]: Pinging the server", (String) arg0.getAttachment());
arg0.send(IPacket.writePacket(new IPacket69Pong(Constants.protocolVersion, config.getComment(), Constants.versionBrand))); arg0.send(IPacket.writePacket(new IPacket69Pong(Constants.protocolVersion, config.getComment(), Constants.versionBrand)));
arg0.close(); arg0.close();
}else if(ipkt.connectionType == 0x04) { }else if(ipkt.connectionType == 0x04) {
logger.debug("[{}]: Polling the server for other worlds", arg0.getAttachment()); logger.debug("[{}]: Polling the server for other worlds", (String) arg0.getAttachment());
arg0.send(IPacket.writePacket(new IPacket07LocalWorlds(getLocalWorlds(waiting.address)))); arg0.send(IPacket.writePacket(new IPacket07LocalWorlds(getLocalWorlds(waiting.address))));
arg0.close(); arg0.close();
}else { }else {
logger.debug("[{}]: Unknown connection type: {}", arg0.getAttachment(), ipkt.connectionType); logger.debug("[{}]: Unknown connection type: {}", (String) arg0.getAttachment(), ipkt.connectionType);
arg0.send(IPacket.writePacket(new IPacketFFErrorCode(IPacketFFErrorCode.TYPE_ILLEGAL_OPERATION, arg0.send(IPacket.writePacket(new IPacketFFErrorCode(IPacketFFErrorCode.TYPE_ILLEGAL_OPERATION,
"Unexpected Init Packet"))); "Unexpected Init Packet")));
arg0.close(); arg0.close();
@ -338,7 +338,7 @@ public class EaglerSPRelay extends WebSocketServer {
} }
}else { }else {
logger.debug("[{}]: Pending connection did not send a 0x00 packet to identify " logger.debug("[{}]: Pending connection did not send a 0x00 packet to identify "
+ "as a client or server", arg0.getAttachment()); + "as a client or server", (String) arg0.getAttachment());
arg0.send(IPacket.writePacket(new IPacketFFErrorCode(IPacketFFErrorCode.TYPE_ILLEGAL_OPERATION, arg0.send(IPacket.writePacket(new IPacketFFErrorCode(IPacketFFErrorCode.TYPE_ILLEGAL_OPERATION,
"Unexpected Init Packet"))); "Unexpected Init Packet")));
arg0.close(); arg0.close();
@ -350,7 +350,7 @@ public class EaglerSPRelay extends WebSocketServer {
} }
if(srv != null) { if(srv != null) {
if(!srv.handle(pkt)) { if(!srv.handle(pkt)) {
logger.debug("[{}]: Server sent invalid packet: {}", arg0.getAttachment(), pkt.getClass().getSimpleName()); logger.debug("[{}]: Server sent invalid packet: {}", (String) arg0.getAttachment(), pkt.getClass().getSimpleName());
arg0.send(IPacket.writePacket(new IPacketFFErrorCode(IPacketFFErrorCode.TYPE_INVALID_PACKET, arg0.send(IPacket.writePacket(new IPacketFFErrorCode(IPacketFFErrorCode.TYPE_INVALID_PACKET,
"Invalid Packet Recieved"))); "Invalid Packet Recieved")));
arg0.close(); arg0.close();
@ -362,13 +362,13 @@ public class EaglerSPRelay extends WebSocketServer {
} }
if(cl != null) { if(cl != null) {
if(cl.handle(pkt)) { if(cl.handle(pkt)) {
logger.debug("[{}]: Client sent invalid packet: {}", arg0.getAttachment(), pkt.getClass().getSimpleName()); logger.debug("[{}]: Client sent invalid packet: {}", (String) arg0.getAttachment(), pkt.getClass().getSimpleName());
arg0.send(IPacket.writePacket(new IPacketFFErrorCode(IPacketFFErrorCode.TYPE_INVALID_PACKET, arg0.send(IPacket.writePacket(new IPacketFFErrorCode(IPacketFFErrorCode.TYPE_INVALID_PACKET,
"Invalid Packet Recieved"))); "Invalid Packet Recieved")));
arg0.close(); arg0.close();
} }
}else { }else {
logger.debug("[{}]: Connection has no client/server attached to it!", arg0.getAttachment()); logger.debug("[{}]: Connection has no client/server attached to it!", (String) arg0.getAttachment());
arg0.send(IPacket.writePacket(new IPacketFFErrorCode(IPacketFFErrorCode.TYPE_ILLEGAL_OPERATION, arg0.send(IPacket.writePacket(new IPacketFFErrorCode(IPacketFFErrorCode.TYPE_ILLEGAL_OPERATION,
"Internal Server Error"))); "Internal Server Error")));
arg0.close(); arg0.close();
@ -376,14 +376,14 @@ public class EaglerSPRelay extends WebSocketServer {
} }
} }
}catch(Throwable t) { }catch(Throwable t) {
logger.error("[{}]: Failed to handle binary frame: {}", arg0.getAttachment(), t); logger.error("[{}]: Failed to handle binary frame: {}", (String) arg0.getAttachment(), t);
arg0.close(); arg0.close();
} }
} }
@Override @Override
public void onMessage(WebSocket arg0, String arg1) { public void onMessage(WebSocket arg0, String arg1) {
logger.debug("[{}]: Sent a text frame, disconnecting", arg0.getAttachment()); logger.debug("[{}]: Sent a text frame, disconnecting", (String) arg0.getAttachment());
arg0.close(); arg0.close();
} }
@ -394,7 +394,7 @@ public class EaglerSPRelay extends WebSocketServer {
srv = serverConnections.remove(arg0); srv = serverConnections.remove(arg0);
} }
if(srv != null) { if(srv != null) {
logger.debug("[{}]: Server closed, code: {}", arg0.getAttachment(), srv.code); logger.debug("[{}]: Server closed, code: {}", (String) arg0.getAttachment(), srv.code);
synchronized(serverCodes) { synchronized(serverCodes) {
serverCodes.remove(srv.code); serverCodes.remove(srv.code);
} }
@ -415,7 +415,7 @@ public class EaglerSPRelay extends WebSocketServer {
while(itr.hasNext()) { while(itr.hasNext()) {
EaglerSPClient cl = itr.next(); EaglerSPClient cl = itr.next();
if(cl.server == srv) { if(cl.server == srv) {
logger.debug("[{}]: Disconnecting client: {} (id: ", cl.socket.getAttachment(), cl.id); logger.debug("[{}]: Disconnecting client: {} (id: ", (String) cl.socket.getAttachment(), cl.id);
cl.socket.close(); cl.socket.close();
} }
} }
@ -434,20 +434,20 @@ public class EaglerSPRelay extends WebSocketServer {
} }
} }
if(cl != null) { if(cl != null) {
logger.debug("[{}]: Client closed, id: {}", arg0.getAttachment(), cl.id); logger.debug("[{}]: Client closed, id: {}", (String) arg0.getAttachment(), cl.id);
synchronized(clientIds) { synchronized(clientIds) {
clientIds.remove(cl.id); clientIds.remove(cl.id);
} }
cl.server.handleClientDisconnect(cl); cl.server.handleClientDisconnect(cl);
}else { }else {
logger.debug("[{}]: Connection Closed: {} ", arg0.getAttachment()); logger.debug("[{}]: Connection Closed: {} ", (String) arg0.getAttachment());
} }
} }
} }
@Override @Override
public void onError(WebSocket arg0, Exception arg1) { public void onError(WebSocket arg0, Exception arg1) {
logger.error("[{}]: Exception thrown: {}", arg0.getAttachment(), arg1.toString()); logger.error("[{}]: Exception thrown: {}", (String) arg0.getAttachment(), arg1.toString());
logger.debug(arg1); logger.debug(arg1);
arg0.close(); arg0.close();
} }

View File

@ -70,7 +70,7 @@ public class EaglerSPServer {
if(LoginState.assertEquals(cl, LoginState.SENT_ICE_CANDIDATE)) { if(LoginState.assertEquals(cl, LoginState.SENT_ICE_CANDIDATE)) {
cl.state = LoginState.RECIEVED_ICE_CANIDATE; cl.state = LoginState.RECIEVED_ICE_CANIDATE;
cl.handleServerICECandidate(packet); cl.handleServerICECandidate(packet);
EaglerSPRelay.logger.debug("[{}][Server -> Relay -> Client] PKT 0x03: ICECandidate", cl.socket.getAttachment()); EaglerSPRelay.logger.debug("[{}][Server -> Relay -> Client] PKT 0x03: ICECandidate", (String) cl.socket.getAttachment());
} }
}else { }else {
this.socket.send(IPacket.writePacket(new IPacketFFErrorCode(IPacketFFErrorCode.TYPE_UNKNOWN_CLIENT, this.socket.send(IPacket.writePacket(new IPacketFFErrorCode(IPacketFFErrorCode.TYPE_UNKNOWN_CLIENT,
@ -84,7 +84,7 @@ public class EaglerSPServer {
if(LoginState.assertEquals(cl, LoginState.SENT_DESCRIPTION)) { if(LoginState.assertEquals(cl, LoginState.SENT_DESCRIPTION)) {
cl.state = LoginState.RECIEVED_DESCRIPTION; cl.state = LoginState.RECIEVED_DESCRIPTION;
cl.handleServerDescription(packet); cl.handleServerDescription(packet);
EaglerSPRelay.logger.debug("[{}][Server -> Relay -> Client] PKT 0x04: Description", cl.socket.getAttachment()); EaglerSPRelay.logger.debug("[{}][Server -> Relay -> Client] PKT 0x04: Description", (String) cl.socket.getAttachment());
} }
}else { }else {
this.socket.send(IPacket.writePacket(new IPacketFFErrorCode(IPacketFFErrorCode.TYPE_UNKNOWN_CLIENT, this.socket.send(IPacket.writePacket(new IPacketFFErrorCode(IPacketFFErrorCode.TYPE_UNKNOWN_CLIENT,
@ -96,7 +96,7 @@ public class EaglerSPServer {
EaglerSPClient cl = clients.get(packet.clientId); EaglerSPClient cl = clients.get(packet.clientId);
if(cl != null) { if(cl != null) {
cl.handleServerDisconnectClient(packet); cl.handleServerDisconnectClient(packet);
EaglerSPRelay.logger.debug("[{}][Server -> Relay -> Client] PKT 0xFE: Disconnect: {}: {}", cl.socket.getAttachment(), EaglerSPRelay.logger.debug("[{}][Server -> Relay -> Client] PKT 0xFE: Disconnect: {}: {}", (String) cl.socket.getAttachment(),
packet.code, packet.reason); packet.code, packet.reason);
}else { }else {
this.socket.send(IPacket.writePacket(new IPacketFFErrorCode(IPacketFFErrorCode.TYPE_UNKNOWN_CLIENT, this.socket.send(IPacket.writePacket(new IPacketFFErrorCode(IPacketFFErrorCode.TYPE_UNKNOWN_CLIENT,

View File

@ -14,7 +14,7 @@ public enum LoginState {
if(client.state != state) { if(client.state != state) {
String msg = "client is in state " + client.state.name() + " when it was supposed to be " + state.name(); String msg = "client is in state " + client.state.name() + " when it was supposed to be " + state.name();
client.disconnect(IPacketFEDisconnectClient.TYPE_INVALID_OPERATION, msg); client.disconnect(IPacketFEDisconnectClient.TYPE_INVALID_OPERATION, msg);
EaglerSPRelay.logger.debug("[{}][Relay -> Client] PKT 0xFE: TYPE_INVALID_OPERATION: {}", client.socket.getAttachment(), msg); EaglerSPRelay.logger.debug("[{}][Relay -> Client] PKT 0xFE: TYPE_INVALID_OPERATION: {}", (String) client.socket.getAttachment(), msg);
return false; return false;
}else { }else {
return true; return true;

View File

@ -30,12 +30,13 @@ public class IPacket00Handshake extends IPacket {
@Override @Override
public void write(DataOutputStream output) throws IOException { public void write(DataOutputStream output) throws IOException {
output.write(connectionType); output.write(connectionType);
output.write(connectionVersion);
IPacket.writeASCII8(output, connectionCode); IPacket.writeASCII8(output, connectionCode);
} }
@Override @Override
public int packetLength() { public int packetLength() {
return 1 + (connectionCode != null ? 1 + connectionCode.length() : 0); return 1 + 1 + (connectionCode != null ? 1 + connectionCode.length() : 0);
} }
} }

View File

@ -11,6 +11,9 @@ public class IPacket02NewClient extends IPacket {
this.clientId = clientId; this.clientId = clientId;
} }
public IPacket02NewClient() {
}
public void write(DataOutputStream output) throws IOException { public void write(DataOutputStream output) throws IOException {
writeASCII8(output, clientId); writeASCII8(output, clientId);
} }

View File

@ -17,6 +17,9 @@ public class IPacket69Pong extends IPacket {
this.comment = comment; this.comment = comment;
this.brand = brand; this.brand = brand;
} }
public IPacket69Pong() {
}
public void write(DataOutputStream output) throws IOException { public void write(DataOutputStream output) throws IOException {
output.write(protcolVersion); output.write(protcolVersion);

View File

@ -48,11 +48,11 @@ public class RelayServer {
} }
public String getPingComment() { public String getPingComment() {
return queriedComment; return queriedComment == null ? "" : queriedComment;
} }
public String getPingVendor() { public String getPingVendor() {
return queriedVendor; return queriedVendor == null ? "" : queriedVendor;
} }
public VersionMismatch getPingCompatible() { public VersionMismatch getPingCompatible() {

View File

@ -30,6 +30,7 @@ public class IPacket00Handshake extends IPacket {
@Override @Override
public void write(DataOutputStream output) throws IOException { public void write(DataOutputStream output) throws IOException {
output.write(connectionType); output.write(connectionType);
output.write(connectionVersion);
IPacket.writeASCII8(output, connectionCode); IPacket.writeASCII8(output, connectionCode);
} }

View File

@ -8,6 +8,10 @@ public class IPacket02NewClient extends IPacket {
public String clientId; public String clientId;
public IPacket02NewClient(String clientId) { public IPacket02NewClient(String clientId) {
this.clientId = clientId;
}
public IPacket02NewClient() {
} }
public void read(DataInputStream input) throws IOException { public void read(DataInputStream input) throws IOException {

View File

@ -17,6 +17,9 @@ public class IPacket69Pong extends IPacket {
this.comment = comment; this.comment = comment;
this.brand = brand; this.brand = brand;
} }
public IPacket69Pong() {
}
public void read(DataInputStream output) throws IOException { public void read(DataInputStream output) throws IOException {
protcolVersion = output.read(); protcolVersion = output.read();