Skip to content

Commit

Permalink
Allow using unixdomainsockets as proxies
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexProgrammerDE committed May 15, 2024
1 parent 8fbf574 commit 4cb49c1
Show file tree
Hide file tree
Showing 6 changed files with 9 additions and 8 deletions.
3 changes: 3 additions & 0 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@ allprojects {
maven("https://repo.spring.io/milestone") {
name = "Spring Milestone Repository"
}
maven("https://repo.spring.io/snapshot") {
name = "Spring Snapshot Repository"
}
mavenCentral()
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@
import java.awt.GridBagLayout;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.net.InetSocketAddress;
import java.util.ArrayList;
import javax.inject.Inject;
import javax.swing.BorderFactory;
Expand Down Expand Up @@ -134,7 +133,7 @@ public Class<?> getColumnClass(int columnIndex) {
var enabled = (boolean) rowData[4];

proxies.add(
new EnabledWrapper<>(enabled, new SFProxy(type, (InetSocketAddress) SocketAddressHelper.deserialize(address), username, password)));
new EnabledWrapper<>(enabled, new SFProxy(type, SocketAddressHelper.deserialize(address), username, password)));
}

proxyRegistry.setProxies(proxies);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,13 @@

import com.soulfiremc.grpc.generated.ProxyProto;
import com.soulfiremc.util.SocketAddressHelper;
import java.net.InetSocketAddress;
import java.net.SocketAddress;
import lombok.NonNull;
import org.jetbrains.annotations.Nullable;

public record SFProxy(
@NonNull ProxyType type,
@NonNull InetSocketAddress address,
@NonNull SocketAddress address,
@Nullable String username,
@Nullable String password) {
public SFProxy {
Expand All @@ -48,7 +47,7 @@ public record SFProxy(
public static SFProxy fromProto(ProxyProto proto) {
return new SFProxy(
ProxyType.valueOf(proto.getType().name()),
(InetSocketAddress) SocketAddressHelper.deserialize(proto.getAddress()),
SocketAddressHelper.deserialize(proto.getAddress()),
proto.hasUsername() ? proto.getUsername() : null,
proto.hasPassword() ? proto.getPassword() : null);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ public static HttpClient createReactorClient(
case SOCKS4 -> ProxyProvider.Proxy.SOCKS4;
case SOCKS5 -> ProxyProvider.Proxy.SOCKS5;
})
.address(proxyData.address())
.socketAddress(proxyData.address())
.nonProxyHosts("localhost")
.connectTimeoutMillis(20_000);

Expand Down
2 changes: 1 addition & 1 deletion gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ flatlaf = "3.4.1"
flatlaf-inter-version = "4.0"
flatlaf-jetbrains-mono-version = "2.304"
kyori = "4.17.0"
reactor = "1.1.19"
reactor = "1.2.0-SNAPSHOT"
armeria = "1.28.4"

[plugins]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,7 @@ public MinecraftCodecHelper getCodecHelper() {
}

private void addHAProxySupport(ChannelPipeline pipeline) {
InetSocketAddress clientAddress = getFlag(BuiltinFlags.CLIENT_PROXIED_ADDRESS);
var clientAddress = getFlag(BuiltinFlags.CLIENT_PROXIED_ADDRESS);
if (getFlag(BuiltinFlags.ENABLE_CLIENT_PROXY_PROTOCOL, false) && clientAddress != null) {
pipeline.addFirst(
"proxy-protocol-packet-sender",
Expand Down

0 comments on commit 4cb49c1

Please sign in to comment.