ICE bullshit

This commit is contained in:
LAX1DUDE 2022-08-23 18:28:46 -07:00
parent b2868af8b6
commit 4470365d6c
7 changed files with 18030 additions and 18045 deletions

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -139,9 +139,8 @@ public class EaglerSPRelayConfigRelayList {
} }
private static void add(String filename, Collection<RelayServer> loading, RelayType type, String url, String user, String pass) { private static void add(String filename, Collection<RelayServer> loading, RelayType type, String url, String user, String pass) {
if(url == null) { if(url == null) {
EaglerSPRelay.logger.error("Error: Invalid [STUN] in {}, missing 'url'", filename); EaglerSPRelay.logger.error("Error: Invalid relay in {}, missing 'url'", filename);
}else { }else {
loading.add(new RelayServer(type, url, user, pass)); loading.add(new RelayServer(type, url, user, pass));
} }

View File

@ -24,15 +24,14 @@ public class IPacket01ICEServers extends IPacket {
RelayServer srv = itr.next(); RelayServer srv = itr.next();
if(srv.type == RelayType.STUN) { if(srv.type == RelayType.STUN) {
output.write('S'); output.write('S');
writeASCII16(output, srv.address);
}else if(srv.type == RelayType.TURN) { }else if(srv.type == RelayType.TURN) {
output.write('T'); output.write('T');
writeASCII16(output, srv.address);
writeASCII8(output, srv.username);
writeASCII8(output, srv.password);
}else { }else {
throw new IOException("Unknown/Unsupported Relay Type: " + srv.type.name()); throw new IOException("Unknown/Unsupported Relay Type: " + srv.type.name());
} }
writeASCII16(output, srv.address);
writeASCII8(output, srv.username);
writeASCII8(output, srv.password);
} }
} }

View File

@ -71,7 +71,7 @@ public class GuiScreenLANConnecting extends GuiScreen {
LANClientNetworkManager netMgr = LANClientNetworkManager.connectToWorld(sock, code, sock.getURI()); LANClientNetworkManager netMgr = LANClientNetworkManager.connectToWorld(sock, code, sock.getURI());
if(netMgr == null) { if(netMgr == null) {
this.mc.displayGuiScreen(new GuiDisconnected(parent, "connect.failed", "disconnect.genericReason", "noRelay.worldFail", "")); this.mc.displayGuiScreen(new GuiDisconnected(parent, "connect.failed", "disconnect.genericReason", st.translateKey("noRelay.worldFail"), ""));
return; return;
} }

View File

@ -28,12 +28,10 @@ public class ICEServerSet {
} }
public String getICEString() { public String getICEString() {
if(type == RelayType.STUN) { if(username == null) {
return address; return address;
}else if(type == RelayType.TURN) {
return address + ";" + username + ";" + password;
}else { }else {
throw new IllegalStateException("Unknown relay type: " + (type == null ? "null" : type.name())); return address + ";" + username + ";" + password;
} }
} }

View File

@ -18,22 +18,20 @@ public class IPacket01ICEServers extends IPacket {
int l = input.readUnsignedShort(); int l = input.readUnsignedShort();
for(int i = 0; i < l; ++i) { for(int i = 0; i < l; ++i) {
char type = (char)input.read(); char type = (char)input.read();
ICEServerSet.RelayType typeEnum;
if(type == 'S') { if(type == 'S') {
servers.add(new ICEServerSet.RelayServer( typeEnum = ICEServerSet.RelayType.STUN;
ICEServerSet.RelayType.STUN,
readASCII16(input),
null, null
));
}else if(type == 'T') { }else if(type == 'T') {
typeEnum = ICEServerSet.RelayType.TURN;
}else {
throw new IOException("Unknown/Unsupported Relay Type: '" + type + "'");
}
servers.add(new ICEServerSet.RelayServer( servers.add(new ICEServerSet.RelayServer(
ICEServerSet.RelayType.TURN, typeEnum,
readASCII16(input), readASCII16(input),
readASCII8(input), readASCII8(input),
readASCII8(input) readASCII8(input)
)); ));
}else {
throw new IOException("Unknown/Unsupported Relay Type: '" + type + "'");
}
} }
} }