Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 15 additions & 5 deletions src/main/java/org/cloudburstmc/proxypass/ProxyPass.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,11 @@
import com.google.gson.JsonObject;
import com.google.gson.JsonParser;
import dev.kastle.netty.channel.nethernet.NetherNetChannelFactory;
import dev.kastle.netty.channel.nethernet.config.NetherChannelOption;
import dev.kastle.netty.channel.nethernet.config.NetherNetAddress;
import dev.kastle.netty.channel.nethernet.signaling.NetherNetClientSignaling;
import dev.kastle.netty.channel.nethernet.signaling.NetherNetDiscoverySignaling;
import dev.kastle.netty.channel.nethernet.signaling.NetherNetXboxRpcSignaling;
import dev.kastle.netty.channel.nethernet.signaling.NetherNetServerSignaling;
import dev.kastle.netty.channel.nethernet.signaling.NetherNetXboxSignaling;
import dev.kastle.webrtc.PeerConnectionFactory;
Expand Down Expand Up @@ -160,6 +162,7 @@ public void writeObjectFieldValueSeparator(JsonGenerator generator) throws IOExc
private SocketAddress targetAddress;
private InetSocketAddress proxyAddress;
private Configuration configuration;
private ServerAddress serverAddress;
private Path baseDir;
private Path sessionsDir;
private Path dataDir;
Expand Down Expand Up @@ -230,8 +233,8 @@ public void boot() throws IOException {
}
}

ServerAddress serverAddress = new ServerAddress(configuration.getDestination(), account, client);
targetAddress = serverAddress.getAddress();
this.serverAddress = new ServerAddress(configuration.getDestination(), account, client);
this.targetAddress = serverAddress.getAddress();

Object object = this.loadGzipNBT("block_palette.nbt");

Expand Down Expand Up @@ -360,9 +363,15 @@ public void newClient(SocketAddress socketAddress, Consumer<ProxyClientSession>
NetherNetClientSignaling signaling;

if (socketAddress instanceof NetherNetAddress) {
signaling = new NetherNetXboxSignaling(
account.authManager().getMinecraftSession().getCached().getAuthorizationHeader()
);
if (this.serverAddress.getNetworkProtocol().equalsIgnoreCase("NETHERNET_JSONRPC")) {
signaling = new NetherNetXboxRpcSignaling(
account.authManager().getMinecraftSession().getCached().getAuthorizationHeader()
);
} else {
signaling = new NetherNetXboxSignaling(
account.authManager().getMinecraftSession().getCached().getAuthorizationHeader()
);
}
} else {
signaling = new NetherNetDiscoverySignaling();
}
Expand Down Expand Up @@ -398,6 +407,7 @@ protected void initSession(ProxyClientSession session) {
});
} else {
bootstrap
.option(NetherChannelOption.NETHER_CLIENT_HANDSHAKE_TIMEOUT_MS, 6000)
.handler(new NetherNetBedrockChannelInitializer<ProxyClientSession>() {
@Override
protected ProxyClientSession createSession0(BedrockPeer peer, int subClientId) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@
public class ServerAddress {
@Getter
private SocketAddress address;
@Getter
private String networkProtocol;
private String host;
private int port;

Expand Down Expand Up @@ -125,19 +127,19 @@ public ServerAddress(Destination destination, Account account, HttpClient client
throw new IllegalArgumentException("Realms API provided no server address!");
}

this.networkProtocol = protocol;

if (protocol.equalsIgnoreCase("NETHERNET")) {
this.address = new NetherNetAddress(fullAddress);
return;
} else {
String[] parts = fullAddress.split(":");
this.host = parts[0];
if (parts.length > 1) {
this.port = Integer.parseInt(parts[1]);
} else {
this.port = 19132;
}
log.info("Resolved Realm '{}' to {}:{}", realmName, this.host, this.port);
}

if (protocol.equalsIgnoreCase("NETHERNET_JSONRPC")) {
this.address = new NetherNetAddress(fullAddress);
return;
}

throw new IllegalArgumentException("Unsupported Realms network protocol: " + protocol);
} else {
log.warn("Could not find Realm with name: {}", realmName);
}
Expand Down Expand Up @@ -181,6 +183,7 @@ public ServerAddress(Destination destination, Account account, HttpClient client
}
this.host = experience.getResult().getIpV4Address();
this.port = experience.getResult().getPort();
this.networkProtocol = experience.getResult().getNetworkProtocol();
log.info("Resolved experience ID {} to {}:{}", experienceId, this.host, this.port);
} catch (IOException e) {
log.error("Failed to fetch experience", e);
Expand Down