Skip to content

Commit 7d44061

Browse files
authored
Merge pull request #2 from Outfit8TSB/patch-1
update to latest 3.3.4.
2 parents 092a9c6 + e6fa1c0 commit 7d44061

4 files changed

Lines changed: 61 additions & 12 deletions

File tree

README.MD

Lines changed: 19 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,24 +4,33 @@ This plugin is only needed if you want to host a public SRV mode proxy instance.
44

55
## SRV ViaProxy
66
### Running ViaProxy in SRV mode
7-
To use the SRV mode in ViaProxy you have to start it through the command line.\
8-
The command line arguments are as follows:
9-
````bash
10-
java -jar ViaProxy.jar -ba 0.0.0.0 -bp <bind port> -srv -oam_auth -a0 -v1.8.x
11-
````
12-
13-
You have to replace ``<bind port>`` with the port you want ViaProxy to run on.\
14-
The ``-oam_auth`` argument is optional and enables the [OpenAuthMod](https://github.com/RaphiMC/OpenAuthMod) authentication.\
15-
The ``-a0`` and ``-v1.8.x`` arguments are required for ViaProxy to start but don't do anything in SRV mode.
167

8+
To use the SRV mode in ViaProxy you have to start it through the config.\
9+
Here are The config options require to make a Public SRV mode.
10+
```
11+
bind-address: 0.0.0.0:25568 # will translate to viaproxy.0-0-0-0.nip.io:25568
12+
target-address: 127.0.0.1 # unused on srv mode.
13+
target-version: 1.8.x # unused on srv mode.
14+
auth-method: OpenAuthMod
15+
wildcard-domain-handling: PUBLIC
16+
```
17+
18+
You have to replace ``0.0.0.0:<bind port>`` with the port you want ViaProxy to run on.\
19+
The ``auth-method: openauthmod`` is optional and enables the [OpenAuthMod](https://github.com/RaphiMC/OpenAuthMod) authentication. for 1.19.4 users, see the caution below.\
20+
The ``target-address`` and ``target-version`` are required for ViaProxy to start but don't do anything in SRV mode.
21+
> [!CAUTION]
22+
> warning: auth-method: openauthmod will be not functional for 1.7-1.7.10, Vanilla 1.8-1.19.3, 1.19.4-1.21.1, and Bedrock Edition.\
23+
> Reason: 1.7-1.7.10: OpenAuthMod is only available for 1.8.
24+
> Bedrock: Forge or Fabric don't support Bedrock Edition.\
25+
> 1.19.4+: OpenAuthMod discontinued before release of 1.19.4. use this option if you want to.
1726
### Connecting to ViaProxy in SRV mode
1827
To connect to ViaProxy in SRV mode you need a domain pointing to the IP of the server running ViaProxy.\
1928
The subdomain ``viaproxy.`` is required for it to work.\
2029
For local connections you can use ``viaproxy.127-0-0-1.nip.io``.
2130

2231
To connect to a server through ViaProxy you have to prepend the ``server ip``, ``server port`` and ``version`` to your domain:
2332
````
24-
<ip>_<port>_<version>.viaproxy.<domain>
33+
address_port_version.viaproxy.hostname
2534
````
2635

2736
For example to connect to ``lenni0451.net:39999`` with the version ``C0.30-CPE`` you can use:

build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,5 +17,5 @@ repositories {
1717
}
1818

1919
dependencies {
20-
implementation "net.raphimc:ViaProxy:3.2.2"
20+
implementation "net.raphimc:ViaProxy:3.3.4-SNAPSHOT"
2121
}
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
package net.lenni0451.nolocalconnections;
2+
3+
import net.lenni0451.optconfig.ConfigLoader;
4+
import net.lenni0451.optconfig.annotations.Description;
5+
import net.lenni0451.optconfig.annotations.OptConfig;
6+
import net.lenni0451.optconfig.annotations.Option;
7+
import net.lenni0451.optconfig.provider.ConfigProvider;
8+
import net.raphimc.viaproxy.util.logging.Logger;
9+
10+
import java.io.File;
11+
import java.util.List;
12+
13+
@OptConfig(header = {
14+
"Configuration for the NoLocalConnections ViaProxy plugin.",
15+
"Used to block a Connection for Local Address Connections through ViaProxy(useful for address_port_version.viaproxy.hostname).",
16+
"",
17+
"Made by Lenni0451",
18+
"Source: https://github.com/ViaVersionAddons/NoLocalConnections"
19+
})
20+
public class KickMessageConfig {
21+
22+
@Option("kick")
23+
@Description({
24+
"kick message when the user tries to join using local address such as 192.168.35.1. you can use the Decoration Codes here using Section Symbol(§)."
25+
})
26+
public static String kick = "§cYou can't connect to any local address.";
27+
28+
public static void load() {
29+
try {
30+
ConfigLoader<KickMessageConfig> configLoader = new ConfigLoader<>(KickMessageConfig.class);
31+
configLoader.getConfigOptions().setResetInvalidOptions(true); //Reset invalid options to their default value
32+
configLoader.loadStatic(ConfigProvider.file(new File("kickmessage.yml")));
33+
} catch (Throwable t) {
34+
Logger.LOGGER.error("Unable to load kick message! turning off viaproxy...", t);
35+
System.exit(-1);
36+
}
37+
}
38+
}

src/main/java/net/lenni0451/nolocalconnections/Main.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package net.lenni0451.nolocalconnections;
22

3+
import net.lenni0451.nolocalconnections.KickMessageConfig;
34
import net.lenni0451.lambdaevents.EventHandler;
45
import net.raphimc.viaproxy.ViaProxy;
56
import net.raphimc.viaproxy.plugins.ViaProxyPlugin;
@@ -12,13 +13,14 @@ public class Main extends ViaProxyPlugin {
1213

1314
@Override
1415
public void onEnable() {
16+
KickMessageConfig.load();
1517
ViaProxy.EVENT_MANAGER.register(this);
1618
}
1719

1820
@EventHandler
1921
public void onEvent(PreConnectEvent event) {
2022
if (!(event.getServerAddress() instanceof InetSocketAddress socketAddress)) return;
21-
if (this.isLocal(socketAddress.getAddress())) event.setCancelMessage("§cYou can't connect to any local address");
23+
if (this.isLocal(socketAddress.getAddress())) event.setCancelMessage(KickMessageConfig.kick);
2224
}
2325

2426
private boolean isLocal(final InetAddress address) {

0 commit comments

Comments
 (0)