Changing players connection address

Discussion in 'BungeeCord Plugin Development' started by Whada, Jan 14, 2022.

  1. Hey! So I run a network in which players are able to host their own servers, in an optimal world, they would not be able to find the bungee network that is hosting their server, or any individual players IP. I have bypassed people able to get players IPs by the following;


    Code (Java):
                      final Object channelWrapper = ReflectionUtils.getObjectInPrivateField(this.pendingConnection, "ch");
                      final Object channel = ReflectionUtils.getObjectInPrivateField(channelWrapper, "ch");
                      try {
                            final Field socketAddressField = ReflectionUtils.searchFieldByClass(channelWrapper.getClass(), SocketAddress.class);
                            ReflectionUtils.setFinalField(channelWrapper, socketAddressField, ip);
                      }
                      catch (Exception ex) {}
                      ReflectionUtils.setFinalField(channel, ReflectionUtils.getPrivateField(AbstractChannel.class, "remoteAddress"), ip);
                      ReflectionUtils.setFinalField(channel, ReflectionUtils.getPrivateField(AbstractChannel.class, "localAddress"), ip);
    Which just about spoofs everything, except for PlayerLoginEvents .getRealAddress method. How would I go about changing the return of .getRealAddress from a bungeecord plugin.

    Note; I've tried

    Code (Java):
                final InetSocketAddress virtualHost = InetSocketAddress.createUnresolved(hostname, this.handshake.getPort());
                try {
                      ReflectionUtils.setFinalField(this.pendingConnection, "virtualHost", virtualHost);
                }
                catch (Exception ex) {
                      ReflectionUtils.setFinalField(this.pendingConnection, "vHost", virtualHost);
                }
                ReflectionUtils.setField(this.handshake, "host", hostname);
    but it doesn't change anything.
     
  2. 1) Why would you do this?
    2) I would say that the player's IP address is stored in the player's Channel.
     
  3. I stated in the original post why I would need this. The result of .getRealAddress is not in the players channel