mirror of
https://github.com/netchx/netch.git
synced 2026-05-07 22:44:03 +08:00
fix: lookup server hostname before start
This commit is contained in:
@@ -40,6 +40,12 @@ namespace Netch.Controllers
|
||||
return false;
|
||||
}
|
||||
|
||||
if (DNS.Lookup(server.Hostname) == null)
|
||||
{
|
||||
MessageBoxX.Show("Lookup Server hostname failed");
|
||||
return false;
|
||||
}
|
||||
|
||||
_ = Task.Run(Firewall.AddNetchFwRules);
|
||||
|
||||
try
|
||||
|
||||
@@ -86,7 +86,7 @@ namespace Netch.Controllers
|
||||
|
||||
var argument = new StringBuilder();
|
||||
if (s.IsSocks5())
|
||||
argument.Append($"-proxyServer {s.Hostname}:{s.Port} ");
|
||||
argument.Append($"-proxyServer {_serverAddresses}:{s.Port} ");
|
||||
else
|
||||
argument.Append($"-proxyServer 127.0.0.1:{Global.Settings.Socks5LocalPort} ");
|
||||
|
||||
|
||||
@@ -27,7 +27,7 @@ namespace Netch.Servers.Shadowsocks
|
||||
{
|
||||
State = State.Starting;
|
||||
var client = Encoding.UTF8.GetBytes($"{LocalAddress}:{Socks5LocalPort}");
|
||||
var remote = Encoding.UTF8.GetBytes($"{server.Hostname}:{server.Port}");
|
||||
var remote = Encoding.UTF8.GetBytes($"{DNS.Lookup(server.Hostname)}:{server.Port}");
|
||||
var passwd = Encoding.UTF8.GetBytes($"{server.Password}");
|
||||
var method = Encoding.UTF8.GetBytes($"{server.EncryptMethod}");
|
||||
if (!ShadowsocksDLL.Info(client, remote, passwd, method))
|
||||
@@ -55,7 +55,7 @@ namespace Netch.Servers.Shadowsocks
|
||||
|
||||
var argument = new StringBuilder();
|
||||
argument.Append(
|
||||
$"-s {server.Hostname} " +
|
||||
$"-s {DNS.Lookup(server.Hostname)} " +
|
||||
$"-p {server.Port} " +
|
||||
$"-b {LocalAddress ?? Global.Settings.LocalAddress} " +
|
||||
$"-l {Socks5LocalPort ?? Global.Settings.Socks5LocalPort} " +
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
using System.Text;
|
||||
using Netch.Controllers;
|
||||
using Netch.Models;
|
||||
using Netch.Utils;
|
||||
|
||||
namespace Netch.Servers.ShadowsocksR
|
||||
{
|
||||
@@ -20,7 +21,7 @@ namespace Netch.Servers.ShadowsocksR
|
||||
#region Argument
|
||||
|
||||
var argument = new StringBuilder();
|
||||
argument.Append($"-s {server.Hostname} -p {server.Port} -k \"{server.Password}\" -m {server.EncryptMethod} -t 120");
|
||||
argument.Append($"-s {DNS.Lookup(server.Hostname)} -p {server.Port} -k \"{server.Password}\" -m {server.EncryptMethod} -t 120");
|
||||
if (!string.IsNullOrEmpty(server.Protocol))
|
||||
{
|
||||
argument.Append($" -O {server.Protocol}");
|
||||
|
||||
@@ -3,6 +3,7 @@ using System.IO;
|
||||
using Netch.Controllers;
|
||||
using Netch.Models;
|
||||
using Netch.Servers.Trojan.Models;
|
||||
using Netch.Utils;
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace Netch.Servers.Trojan
|
||||
@@ -28,7 +29,7 @@ namespace Netch.Servers.Trojan
|
||||
{
|
||||
local_addr = LocalAddress ?? Global.Settings.LocalAddress,
|
||||
local_port = Socks5LocalPort ?? Global.Settings.Socks5LocalPort,
|
||||
remote_addr = server.Hostname,
|
||||
remote_addr = DNS.Lookup(server.Hostname).ToString(),
|
||||
remote_port = server.Port,
|
||||
password = new List<string>
|
||||
{
|
||||
|
||||
@@ -3,6 +3,7 @@ using System.IO;
|
||||
using Netch.Controllers;
|
||||
using Netch.Models;
|
||||
using Netch.Servers.VMess.Models;
|
||||
using Netch.Utils;
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace Netch.Servers.VMess
|
||||
@@ -46,7 +47,7 @@ namespace Netch.Servers.VMess
|
||||
{
|
||||
new VMessConfig.VNext
|
||||
{
|
||||
address = server.Hostname,
|
||||
address = DNS.Lookup(server.Hostname).ToString(),
|
||||
port = server.Port,
|
||||
users = new List<VMessConfig.User>
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user