mirror of
https://github.com/netchx/netch.git
synced 2026-05-09 22:54:03 +08:00
Cleanup code
This commit is contained in:
@@ -31,32 +31,32 @@ namespace Netch.Controllers
|
||||
return false;
|
||||
}
|
||||
|
||||
File.WriteAllText("data\\last.json", Newtonsoft.Json.JsonConvert.SerializeObject(new Models.Information.VMess.Config()
|
||||
File.WriteAllText("data\\last.json", Newtonsoft.Json.JsonConvert.SerializeObject(new Models.Information.VMess.Config
|
||||
{
|
||||
inbounds = new List<Models.Information.VMess.Inbounds>()
|
||||
inbounds = new List<Models.Information.VMess.Inbounds>
|
||||
{
|
||||
new Models.Information.VMess.Inbounds()
|
||||
new Models.Information.VMess.Inbounds
|
||||
{
|
||||
settings = new Models.Information.VMess.InboundSettings(),
|
||||
port = Global.Settings.Socks5LocalPort,
|
||||
listen = Global.Settings.LocalAddress
|
||||
}
|
||||
},
|
||||
outbounds = new List<Models.Information.VMess.Outbounds>()
|
||||
outbounds = new List<Models.Information.VMess.Outbounds>
|
||||
{
|
||||
new Models.Information.VMess.Outbounds()
|
||||
new Models.Information.VMess.Outbounds
|
||||
{
|
||||
settings = new Models.Information.VMess.OutboundSettings()
|
||||
settings = new Models.Information.VMess.OutboundSettings
|
||||
{
|
||||
vnext = new List<Models.Information.VMess.VNext>()
|
||||
vnext = new List<Models.Information.VMess.VNext>
|
||||
{
|
||||
new Models.Information.VMess.VNext()
|
||||
new Models.Information.VMess.VNext
|
||||
{
|
||||
address = server.Hostname,
|
||||
port = server.Port,
|
||||
users = new List<Models.Information.VMess.User>
|
||||
{
|
||||
new Models.Information.VMess.User()
|
||||
new Models.Information.VMess.User
|
||||
{
|
||||
id = server.UserID,
|
||||
alterId = server.AlterID,
|
||||
@@ -66,66 +66,66 @@ namespace Netch.Controllers
|
||||
}
|
||||
}
|
||||
},
|
||||
streamSettings = new Models.Information.VMess.StreamSettings()
|
||||
streamSettings = new Models.Information.VMess.StreamSettings
|
||||
{
|
||||
network = server.TransferProtocol,
|
||||
security = server.TLSSecure == true ? "tls" : "",
|
||||
wsSettings = server.TransferProtocol == "ws" ? new Models.Information.VMess.WebSocketSettings()
|
||||
security = server.TLSSecure ? "tls" : "",
|
||||
wsSettings = server.TransferProtocol == "ws" ? new Models.Information.VMess.WebSocketSettings
|
||||
{
|
||||
path = server.Path == "" ? "/" : server.Path,
|
||||
headers = new Models.Information.VMess.WSHeaders()
|
||||
headers = new Models.Information.VMess.WSHeaders
|
||||
{
|
||||
Host = server.Host == "" ? server.Hostname : server.Host
|
||||
}
|
||||
} : null,
|
||||
tcpSettings = server.FakeType == "http" ? new Models.Information.VMess.TCPSettings()
|
||||
tcpSettings = server.FakeType == "http" ? new Models.Information.VMess.TCPSettings
|
||||
{
|
||||
header = new Models.Information.VMess.TCPHeaders()
|
||||
header = new Models.Information.VMess.TCPHeaders
|
||||
{
|
||||
type = server.FakeType,
|
||||
request = new Models.Information.VMess.TCPRequest()
|
||||
request = new Models.Information.VMess.TCPRequest
|
||||
{
|
||||
path = server.Path == "" ? "/" : server.Path,
|
||||
headers = new Models.Information.VMess.TCPRequestHeaders()
|
||||
headers = new Models.Information.VMess.TCPRequestHeaders
|
||||
{
|
||||
Host = server.Host == "" ? server.Hostname : server.Host
|
||||
}
|
||||
}
|
||||
}
|
||||
} : null,
|
||||
kcpSettings = server.TransferProtocol == "kcp" ? new Models.Information.VMess.KCPSettings()
|
||||
kcpSettings = server.TransferProtocol == "kcp" ? new Models.Information.VMess.KCPSettings
|
||||
{
|
||||
header = new Models.Information.VMess.TCPHeaders()
|
||||
header = new Models.Information.VMess.TCPHeaders
|
||||
{
|
||||
type = server.FakeType
|
||||
}
|
||||
} : null,
|
||||
quicSettings = server.TransferProtocol == "quic" ? new Models.Information.VMess.QUICSettings()
|
||||
quicSettings = server.TransferProtocol == "quic" ? new Models.Information.VMess.QUICSettings
|
||||
{
|
||||
security = server.QUICSecure,
|
||||
key = server.QUICSecret,
|
||||
header = new Models.Information.VMess.TCPHeaders()
|
||||
header = new Models.Information.VMess.TCPHeaders
|
||||
{
|
||||
type = server.FakeType
|
||||
}
|
||||
} : null,
|
||||
httpSettings = server.TransferProtocol == "h2" ? new Models.Information.VMess.HTTPSettings()
|
||||
httpSettings = server.TransferProtocol == "h2" ? new Models.Information.VMess.HTTPSettings
|
||||
{
|
||||
host = server.Host == "" ? server.Hostname : server.Host,
|
||||
path = server.Path == "" ? "/" : server.Path
|
||||
} : null,
|
||||
tlsSettings = new Models.Information.VMess.TLSSettings()
|
||||
tlsSettings = new Models.Information.VMess.TLSSettings
|
||||
{
|
||||
allowInsecure = true,
|
||||
serverName = server.Host == "" ? server.Hostname : server.Host
|
||||
}
|
||||
},
|
||||
mux = new Models.Information.VMess.OutboundMux()
|
||||
mux = new Models.Information.VMess.OutboundMux
|
||||
{
|
||||
enabled = server.UseMux
|
||||
}
|
||||
},
|
||||
new Models.Information.VMess.Outbounds()
|
||||
new Models.Information.VMess.Outbounds
|
||||
{
|
||||
tag = "direct",
|
||||
protocol = "freedom",
|
||||
@@ -134,11 +134,11 @@ namespace Netch.Controllers
|
||||
mux = null
|
||||
}
|
||||
},
|
||||
routing = new Models.Information.VMess.Routing()
|
||||
routing = new Models.Information.VMess.Routing
|
||||
{
|
||||
rules = new List<Models.Information.VMess.RoutingRules>()
|
||||
rules = new List<Models.Information.VMess.RoutingRules>
|
||||
{
|
||||
mode.BypassChina == true ? new Models.Information.VMess.RoutingRules()
|
||||
mode.BypassChina ? new Models.Information.VMess.RoutingRules
|
||||
{
|
||||
type = "field",
|
||||
ip = new List<string>
|
||||
@@ -152,7 +152,7 @@ namespace Netch.Controllers
|
||||
"geosite:cn"
|
||||
},
|
||||
outboundTag = "direct"
|
||||
} : new Models.Information.VMess.RoutingRules()
|
||||
} : new Models.Information.VMess.RoutingRules
|
||||
{
|
||||
type = "field",
|
||||
ip = new List<string>
|
||||
@@ -185,7 +185,7 @@ namespace Netch.Controllers
|
||||
Instance.Start();
|
||||
Instance.BeginOutputReadLine();
|
||||
Instance.BeginErrorReadLine();
|
||||
for (int i = 0; i < 1000; i++)
|
||||
for (var i = 0; i < 1000; i++)
|
||||
{
|
||||
Thread.Sleep(10);
|
||||
|
||||
@@ -232,7 +232,7 @@ namespace Netch.Controllers
|
||||
|
||||
public void OnOutputDataReceived(object sender, DataReceivedEventArgs e)
|
||||
{
|
||||
if (!String.IsNullOrWhiteSpace(e.Data))
|
||||
if (!string.IsNullOrWhiteSpace(e.Data))
|
||||
{
|
||||
File.AppendAllText("logging\\v2ray.log", $"{e.Data}\r\n");
|
||||
|
||||
|
||||
Reference in New Issue
Block a user