Merge Socks5LocalServer with Sock5Server

This commit is contained in:
ChsBuffer
2021-11-13 22:52:57 +08:00
parent 222ad80b37
commit 86475a4ea2
13 changed files with 63 additions and 47 deletions

View File

@@ -44,8 +44,8 @@ public class TUNController : Guard, IModeController
_mode = tunMode;
_tunConfig = Global.Settings.TUNTAP;
if (server is Socks5LocalServer socks5Bridge)
_serverRemoteAddress = await DnsUtils.LookupAsync(socks5Bridge.RemoteHostname);
if (server.RemoteHostname.ValueOrDefault() != null)
_serverRemoteAddress = await DnsUtils.LookupAsync(server.RemoteHostname!);
else
_serverRemoteAddress = await DnsUtils.LookupAsync(server.Hostname);
@@ -93,10 +93,9 @@ public class TUNController : Guard, IModeController
Global.MainForm.StatusText(i18N.Translate("Assigning unicast IP"));
if (!await Task.Run(() => RouteHelper.CreateUnicastIP(AddressFamily.InterNetwork,
_tunConfig.Address,
(byte)Utils.Utils.SubnetToCidr(_tunConfig.Netmask),
(ulong)tunIndex))
)
_tunConfig.Address,
(byte)Utils.Utils.SubnetToCidr(_tunConfig.Netmask),
(ulong)tunIndex)))
{
Log.Error("Create unicast IP failed");
throw new MessageException("Create unicast IP failed");