mirror of
https://github.com/netchx/netch.git
synced 2026-03-18 18:13:21 +08:00
Update NetRoute.GetBestRouteTemplate()
This commit is contained in:
@@ -39,11 +39,11 @@ namespace Netch.Controllers
|
||||
if (_serverRemoteAddress != null && IPAddress.IsLoopback(_serverRemoteAddress))
|
||||
_serverRemoteAddress = null;
|
||||
|
||||
_outbound = NetRoute.GetBestRouteTemplate(out var address);
|
||||
_outbound = NetRoute.GetBestRouteTemplate();
|
||||
CheckDriver();
|
||||
|
||||
Dial(NameList.TYPE_ADAPMTU, "1500");
|
||||
Dial(NameList.TYPE_BYPBIND, address.ToString());
|
||||
Dial(NameList.TYPE_BYPBIND, _outbound.Gateway);
|
||||
Dial(NameList.TYPE_BYPLIST, "disabled");
|
||||
|
||||
#region Server
|
||||
|
||||
@@ -16,12 +16,11 @@ namespace Netch.Models
|
||||
};
|
||||
}
|
||||
|
||||
public static NetRoute GetBestRouteTemplate(out IPAddress address)
|
||||
public static NetRoute GetBestRouteTemplate()
|
||||
{
|
||||
if (IpHlpApi.GetBestRoute(BitConverter.ToUInt32(IPAddress.Parse("114.114.114.114").GetAddressBytes(), 0), 0, out var route) != 0)
|
||||
throw new MessageException("GetBestRoute 搜索失败");
|
||||
|
||||
address = new IPAddress(route.dwForwardNextHop.S_addr);
|
||||
var gateway = new IPAddress(route.dwForwardNextHop.S_un_b);
|
||||
return TemplateBuilder(gateway.ToString(), (int)route.dwForwardIfIndex);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user