From e3c8998773abdb60ef46f0665e588e54bca1c60f Mon Sep 17 00:00:00 2001 From: sirjonasxx <36828922+sirjonasxx@users.noreply.github.com> Date: Wed, 3 Jun 2020 16:24:00 +0200 Subject: [PATCH] attempt for mac raw ip support --- .../protocol/connection/proxy/ProxyProviderFactory.java | 2 +- .../protocol/hostreplacer/ipmapping/IpMapperFactory.java | 3 +-- .../ipmapping/{EmptyIpMapper.java => MacIpMapper.java} | 7 +++---- 3 files changed, 5 insertions(+), 7 deletions(-) rename G-Earth/src/main/java/gearth/protocol/hostreplacer/ipmapping/{EmptyIpMapper.java => MacIpMapper.java} (70%) diff --git a/G-Earth/src/main/java/gearth/protocol/connection/proxy/ProxyProviderFactory.java b/G-Earth/src/main/java/gearth/protocol/connection/proxy/ProxyProviderFactory.java index 1266061..9cbe29e 100644 --- a/G-Earth/src/main/java/gearth/protocol/connection/proxy/ProxyProviderFactory.java +++ b/G-Earth/src/main/java/gearth/protocol/connection/proxy/ProxyProviderFactory.java @@ -111,7 +111,7 @@ public class ProxyProviderFactory { return null; } - else if (OSValidator.isUnix()) { + else if (OSValidator.isUnix() || OSValidator.isMac()) { return new LinuxRawIpProxyProvider(proxySetter, stateSetter, hConnection, domain, port, socksConfig.useSocks() && !socksConfig.onlyUseIfNeeded()); } return null; diff --git a/G-Earth/src/main/java/gearth/protocol/hostreplacer/ipmapping/IpMapperFactory.java b/G-Earth/src/main/java/gearth/protocol/hostreplacer/ipmapping/IpMapperFactory.java index 319ef86..957d3cf 100644 --- a/G-Earth/src/main/java/gearth/protocol/hostreplacer/ipmapping/IpMapperFactory.java +++ b/G-Earth/src/main/java/gearth/protocol/hostreplacer/ipmapping/IpMapperFactory.java @@ -8,8 +8,7 @@ public class IpMapperFactory { if (OSValidator.isWindows()) return new WindowsIpMapper(); if (OSValidator.isUnix()) return new LinuxIpMapper(); - - return new EmptyIpMapper(); + else return new MacIpMapper(); } } diff --git a/G-Earth/src/main/java/gearth/protocol/hostreplacer/ipmapping/EmptyIpMapper.java b/G-Earth/src/main/java/gearth/protocol/hostreplacer/ipmapping/MacIpMapper.java similarity index 70% rename from G-Earth/src/main/java/gearth/protocol/hostreplacer/ipmapping/EmptyIpMapper.java rename to G-Earth/src/main/java/gearth/protocol/hostreplacer/ipmapping/MacIpMapper.java index 1017b92..b22c4bf 100644 --- a/G-Earth/src/main/java/gearth/protocol/hostreplacer/ipmapping/EmptyIpMapper.java +++ b/G-Earth/src/main/java/gearth/protocol/hostreplacer/ipmapping/MacIpMapper.java @@ -3,8 +3,7 @@ package gearth.protocol.hostreplacer.ipmapping; import java.util.ArrayList; import java.util.List; -// Temporary class for the sake of not getting nullpointers on linux&mac until they have an IpMapper as well -public class EmptyIpMapper extends IpMapper { +public class MacIpMapper extends IpMapper { @Override public void enable() { @@ -12,12 +11,12 @@ public class EmptyIpMapper extends IpMapper { @Override public void addMapping(String ip) { - + runCommand("ifconfig", "lo0", "alias", ip); } @Override public void deleteMapping(String ip) { - + runCommand("ifconfig", "lo0", "-alias", ip); } @Override