@@ -124,17 +124,17 @@ private void handleHandshake(final C2SHandshakingClientIntentionPacket packet) {
124124 }
125125
126126 final String [] handshakeParts ;
127- if (ViaProxy .getConfig ().shouldPassthroughBungeecordPlayerInfo ()) {
127+ if (ViaProxy .getConfig ().getProxy (). shouldPassthroughBungeecordPlayerInfo ()) {
128128 handshakeParts = packet .address .split ("\0 " );
129129 } else {
130130 handshakeParts = new String []{packet .address };
131131 }
132132
133- SocketAddress serverAddress = ViaProxy .getConfig ().getTargetAddress ();
134- ProtocolVersion serverVersion = ViaProxy .getConfig ().getTargetVersion ();
135- String classicMpPass = ViaProxy .getConfig ().getAccount () instanceof ClassicAccount classicAccount ? classicAccount .getMppass () : null ;
133+ SocketAddress serverAddress = ViaProxy .getConfig ().getBackend (). getAddress ();
134+ ProtocolVersion serverVersion = ViaProxy .getConfig ().getBackend (). getVersion ();
135+ String classicMpPass = ViaProxy .getConfig ().getBackend (). getAccount () instanceof ClassicAccount classicAccount ? classicAccount .getMppass () : null ;
136136
137- if (ViaProxy .getConfig ().getWildcardDomainHandling () == ViaProxyConfig .WildcardDomainHandling .PUBLIC ) {
137+ if (ViaProxy .getConfig ().getFrontend (). getWildcardDomainHandling () == ViaProxyConfig .WildcardDomainHandling .PUBLIC ) {
138138 if (handshakeParts [0 ].toLowerCase ().contains ("f2.viaproxy." )) { // Format 2: address.<address>.port.<port>.version.<version>.f2.viaproxy.hostname
139139 WildcardDomainParser .ParsedDomain parsedDomain = WildcardDomainParser .parseFormat2 (handshakeParts [0 ]);
140140 if (parsedDomain == null ) {
@@ -158,7 +158,7 @@ private void handleHandshake(final C2SHandshakingClientIntentionPacket packet) {
158158 } else {
159159 this .proxyConnection .kickClient ("§cWrong domain syntax! §6Please use:\n §7address_port_version.viaproxy.hostname" );
160160 }
161- } else if (ViaProxy .getConfig ().getWildcardDomainHandling () == ViaProxyConfig .WildcardDomainHandling .INTERNAL ) {
161+ } else if (ViaProxy .getConfig ().getFrontend (). getWildcardDomainHandling () == ViaProxyConfig .WildcardDomainHandling .INTERNAL ) {
162162 final ArrayHelper arrayHelper = ArrayHelper .instanceOf (handshakeParts [0 ].split ("\7 " ));
163163 handshakeParts [0 ] = arrayHelper .get (0 ); // Restore the original address
164164 final String versionString = arrayHelper .get (2 );
@@ -191,16 +191,16 @@ private void handleHandshake(final C2SHandshakingClientIntentionPacket packet) {
191191 serverAddress = preConnectEvent .getServerAddress ();
192192 serverVersion = preConnectEvent .getServerVersion ();
193193
194- final boolean isJavaBetaPing = packet .intendedState .getConnectionState () == ConnectionState .STATUS && serverVersion .olderThanOrEqualTo (LegacyProtocolVersion .b1_7tob1_7_3 ) && !ViaProxy .getConfig ().shouldAllowBetaPinging ();
194+ final boolean isJavaBetaPing = packet .intendedState .getConnectionState () == ConnectionState .STATUS && serverVersion .olderThanOrEqualTo (LegacyProtocolVersion .b1_7tob1_7_3 ) && !ViaProxy .getConfig ().getBackend (). shouldAllowBetaPinging ();
195195 final boolean isBedrockNetherNetPing = packet .intendedState .getConnectionState () == ConnectionState .STATUS && serverVersion .equals (BedrockProtocolVersion .bedrockLatest ) && serverAddress instanceof NetherNetAddress ;
196196 if (isJavaBetaPing || isBedrockNetherNetPing ) {
197- if (!ViaProxy .getConfig ().getCustomMotd ().isBlank ()) {
198- this .proxyConnection .kickClient (ViaProxy .getConfig ().getCustomMotd ());
197+ if (!ViaProxy .getConfig ().getFrontend ().getMotd (). isEnabled ()) {
198+ this .proxyConnection .kickClient (ViaProxy .getConfig ().getFrontend (). getMotd (). getDescription ());
199199 }
200200 this .proxyConnection .kickClient ("§7ViaProxy is working!\n §7Connect to join the configured server" );
201201 }
202202
203- final UserOptions userOptions = new UserOptions (classicMpPass , ViaProxy .getConfig ().getAccount ());
203+ final UserOptions userOptions = new UserOptions (classicMpPass , ViaProxy .getConfig ().getBackend (). getAccount ());
204204 ChannelUtil .disableAutoRead (this .proxyConnection .getC2P ());
205205
206206 if (packet .intendedState .getConnectionState () == ConnectionState .LOGIN && serverVersion .equals (ProtocolTranslator .AUTO_DETECT_PROTOCOL )) {
@@ -236,14 +236,16 @@ private void connect(final SocketAddress serverAddress, final ProtocolVersion se
236236 this .proxyConnection .setClientHandshakeAddress (clientHandshakeAddress );
237237 this .proxyConnection .setUserOptions (userOptions );
238238 this .proxyConnection .setC2pConnectionState (intendedState .getConnectionState ());
239- this .proxyConnection .getPacketHandlers ().add (new StatusPacketHandler (this .proxyConnection ));
240- if (ViaProxy .getConfig ().shouldSupportSimpleVoiceChat () && serverVersion .newerThan (ProtocolVersion .v1_14 ) && clientVersion .newerThan (ProtocolVersion .v1_14 )) {
239+ if (ViaProxy .getConfig ().getFrontend ().getMotd ().isEnabled ()) {
240+ this .proxyConnection .getPacketHandlers ().add (new StatusPacketHandler (this .proxyConnection ));
241+ }
242+ if (ViaProxy .getConfig ().getProxy ().shouldSupportSimpleVoiceChat () && serverVersion .newerThan (ProtocolVersion .v1_14 ) && clientVersion .newerThan (ProtocolVersion .v1_14 )) {
241243 this .proxyConnection .getPacketHandlers ().add (new SimpleVoiceChatPacketHandler (this .proxyConnection ));
242244 }
243- if (ViaProxy .getConfig ().shouldFixFabricParticleApi () && serverVersion .newerThanOrEqualTo (ProtocolVersion .v1_21_5 ) && clientVersion .newerThanOrEqualTo (ProtocolVersion .v1_21_5 ) && !serverVersion .equals (clientVersion )) {
245+ if (ViaProxy .getConfig ().getProxy (). shouldFixFabricParticleApi () && serverVersion .newerThanOrEqualTo (ProtocolVersion .v1_21_5 ) && clientVersion .newerThanOrEqualTo (ProtocolVersion .v1_21_5 ) && !serverVersion .equals (clientVersion )) {
244246 this .proxyConnection .getPacketHandlers ().add (new FabricParticleApiFixPacketHandler (this .proxyConnection ));
245247 }
246- if (ViaProxy .getConfig ().shouldFakeAcceptResourcePacks () && serverVersion .newerThanOrEqualTo (LegacyProtocolVersion .r1_3_1tor1_3_2 )) {
248+ if (ViaProxy .getConfig ().getProxy (). shouldFakeAcceptResourcePacks () && serverVersion .newerThanOrEqualTo (LegacyProtocolVersion .r1_3_1tor1_3_2 )) {
247249 this .proxyConnection .getPacketHandlers ().add (new ResourcePackSpooferPacketHandler (this .proxyConnection ));
248250 }
249251 if (clientVersion .newerThanOrEqualTo (ProtocolVersion .v1_8 )) {
@@ -252,7 +254,7 @@ private void connect(final SocketAddress serverAddress, final ProtocolVersion se
252254 this .proxyConnection .getPacketHandlers ().add (new CompressionPacketHandler (this .proxyConnection ));
253255 this .proxyConnection .getPacketHandlers ().add (new LoginPacketHandler (this .proxyConnection ));
254256 this .proxyConnection .getPacketHandlers ().add (new DisconnectPacketHandler (this .proxyConnection ));
255- if (ViaProxy .getConfig ().shouldRewriteTransferPackets () && clientVersion .newerThanOrEqualTo (ProtocolVersion .v1_20_5 )) {
257+ if (ViaProxy .getConfig ().getProxy (). shouldRewriteTransferPackets () && clientVersion .newerThanOrEqualTo (ProtocolVersion .v1_20_5 )) {
256258 this .proxyConnection .getPacketHandlers ().add (new TransferPacketHandler (this .proxyConnection ));
257259 }
258260 if (clientVersion .newerThanOrEqualTo (ProtocolVersion .v1_20_2 ) || serverVersion .newerThanOrEqualTo (ProtocolVersion .v1_20_2 )) {
@@ -261,21 +263,21 @@ private void connect(final SocketAddress serverAddress, final ProtocolVersion se
261263 if (clientVersion .newerThanOrEqualTo (ProtocolVersion .v1_19_3 ) && serverVersion .newerThanOrEqualTo (ProtocolVersion .v1_19_3 )) {
262264 this .proxyConnection .getPacketHandlers ().add (new ChatSignaturePacketHandler (this .proxyConnection ));
263265 }
264- if (!ViaProxy .getConfig ().getResourcePackUrl ().isBlank ()) {
266+ if (!ViaProxy .getConfig ().getFrontend (). getResourcePackUrl ().isBlank ()) {
265267 this .proxyConnection .getPacketHandlers ().add (new ResourcePackPacketHandler (this .proxyConnection ));
266268 }
267269 if (Via .getConfig ().sendPlayerDetails () || Via .getConfig ().sendServerDetails ()) {
268270 this .proxyConnection .getPacketHandlers ().add (new ViaVersionConnectionDetailsPacketHandler (this .proxyConnection ));
269271 }
270272 this .proxyConnection .getPacketHandlers ().add (new UnexpectedPacketHandler (this .proxyConnection ));
271273
272- if (ViaProxy .getConfig ().shouldLogClientStatusRequests () || intendedState != IntendedState .STATUS ) {
274+ if (ViaProxy .getConfig ().getFrontend (). shouldLogClientStatusRequests () || intendedState != IntendedState .STATUS ) {
273275 Logger .u_info ("connect" , this .proxyConnection , "[" + clientVersion .getName () + " <-> " + serverVersion .getName () + "] Connecting to " + AddressUtil .toString (serverAddress ));
274276 }
275277 ViaProxy .EVENT_MANAGER .call (new ConnectEvent (this .proxyConnection ));
276278
277279 final int handshakePort ;
278- if (ViaProxy .getConfig ().shouldRewriteHandshakePacket ()) {
280+ if (ViaProxy .getConfig ().getProxy (). shouldRewriteHandshakePacket ()) {
279281 if (serverAddress instanceof InetSocketAddress inetSocketAddress ) {
280282 handshakeParts [0 ] = inetSocketAddress .getHostString ();
281283 handshakePort = inetSocketAddress .getPort ();
@@ -290,7 +292,7 @@ private void connect(final SocketAddress serverAddress, final ProtocolVersion se
290292 this .proxyConnection .connectToServer (serverAddress , serverVersion ).addListeners ((ThrowingChannelFutureListener ) f -> {
291293 if (f .isSuccess ()) {
292294 f .channel ().eventLoop ().submit (() -> { // Reschedule so the packets get sent after the channel is fully initialized and active
293- if (ViaProxy .getConfig ().useBackendHaProxy ()) {
295+ if (ViaProxy .getConfig ().getBackend (). useHaProxy ()) {
294296 this .proxyConnection .getChannel ().writeAndFlush (HAProxyUtil .createMessage (this .proxyConnection .getC2P (), this .proxyConnection .getChannel (), clientVersion )).addListener (ChannelFutureListener .FIRE_EXCEPTION_ON_FAILURE );
295297 }
296298
0 commit comments