mirror of https://github.com/2dust/v2rayN
IDE0017-简化对象初始化
parent
8b68ecb891
commit
d8d8346d45
|
@ -17,8 +17,10 @@ namespace v2rayN.Base
|
|||
this.port = port;
|
||||
this._responderMethod = method;
|
||||
|
||||
Thread thread = new Thread(StartListen);
|
||||
thread.IsBackground = true;
|
||||
Thread thread = new Thread(StartListen)
|
||||
{
|
||||
IsBackground = true
|
||||
};
|
||||
thread.Start();
|
||||
}
|
||||
|
||||
|
@ -46,8 +48,10 @@ namespace v2rayN.Base
|
|||
}
|
||||
|
||||
TcpClient socket = listener.AcceptTcpClient();
|
||||
Thread thread = new Thread(new ParameterizedThreadStart(ProcessThread));
|
||||
thread.IsBackground = true;
|
||||
Thread thread = new Thread(new ParameterizedThreadStart(ProcessThread))
|
||||
{
|
||||
IsBackground = true
|
||||
};
|
||||
thread.Start(socket);
|
||||
Thread.Sleep(1);
|
||||
}
|
||||
|
|
|
@ -207,9 +207,11 @@ namespace v2rayN.Forms
|
|||
{
|
||||
ClearServer();
|
||||
|
||||
OpenFileDialog fileDialog = new OpenFileDialog();
|
||||
fileDialog.Multiselect = false;
|
||||
fileDialog.Filter = "Config|*.json|All|*.*";
|
||||
OpenFileDialog fileDialog = new OpenFileDialog
|
||||
{
|
||||
Multiselect = false,
|
||||
Filter = "Config|*.json|All|*.*"
|
||||
};
|
||||
if (fileDialog.ShowDialog() != DialogResult.OK)
|
||||
{
|
||||
return;
|
||||
|
|
|
@ -271,8 +271,10 @@ namespace v2rayN.Forms
|
|||
VmessItem item = config.vmess[k];
|
||||
string name = item.getSummary();
|
||||
|
||||
ToolStripMenuItem ts = new ToolStripMenuItem(name);
|
||||
ts.Tag = k;
|
||||
ToolStripMenuItem ts = new ToolStripMenuItem(name)
|
||||
{
|
||||
Tag = k
|
||||
};
|
||||
if (config.index.Equals(k))
|
||||
{
|
||||
ts.Checked = true;
|
||||
|
@ -422,8 +424,10 @@ namespace v2rayN.Forms
|
|||
|
||||
if (config.vmess[index].configType == (int)EConfigType.Vmess)
|
||||
{
|
||||
var fm = new AddServerForm();
|
||||
fm.EditIndex = index;
|
||||
var fm = new AddServerForm
|
||||
{
|
||||
EditIndex = index
|
||||
};
|
||||
if (fm.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
//刷新
|
||||
|
@ -433,8 +437,10 @@ namespace v2rayN.Forms
|
|||
}
|
||||
else if (config.vmess[index].configType == (int)EConfigType.Shadowsocks)
|
||||
{
|
||||
var fm = new AddServer3Form();
|
||||
fm.EditIndex = index;
|
||||
var fm = new AddServer3Form
|
||||
{
|
||||
EditIndex = index
|
||||
};
|
||||
if (fm.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
RefreshServers();
|
||||
|
@ -443,8 +449,10 @@ namespace v2rayN.Forms
|
|||
}
|
||||
else if (config.vmess[index].configType == (int)EConfigType.Socks)
|
||||
{
|
||||
var fm = new AddServer4Form();
|
||||
fm.EditIndex = index;
|
||||
var fm = new AddServer4Form
|
||||
{
|
||||
EditIndex = index
|
||||
};
|
||||
if (fm.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
RefreshServers();
|
||||
|
@ -453,8 +461,10 @@ namespace v2rayN.Forms
|
|||
}
|
||||
else
|
||||
{
|
||||
var fm2 = new AddServer2Form();
|
||||
fm2.EditIndex = index;
|
||||
var fm2 = new AddServer2Form
|
||||
{
|
||||
EditIndex = index
|
||||
};
|
||||
if (fm2.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
//刷新
|
||||
|
@ -524,8 +534,10 @@ namespace v2rayN.Forms
|
|||
|
||||
private void menuAddVmessServer_Click(object sender, EventArgs e)
|
||||
{
|
||||
AddServerForm fm = new AddServerForm();
|
||||
fm.EditIndex = -1;
|
||||
AddServerForm fm = new AddServerForm
|
||||
{
|
||||
EditIndex = -1
|
||||
};
|
||||
if (fm.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
//刷新
|
||||
|
@ -772,9 +784,11 @@ namespace v2rayN.Forms
|
|||
{
|
||||
UI.Show(UIRes.I18N("CustomServerTips"));
|
||||
|
||||
OpenFileDialog fileDialog = new OpenFileDialog();
|
||||
fileDialog.Multiselect = false;
|
||||
fileDialog.Filter = "Config|*.json|All|*.*";
|
||||
OpenFileDialog fileDialog = new OpenFileDialog
|
||||
{
|
||||
Multiselect = false,
|
||||
Filter = "Config|*.json|All|*.*"
|
||||
};
|
||||
if (fileDialog.ShowDialog() != DialogResult.OK)
|
||||
{
|
||||
return;
|
||||
|
@ -800,8 +814,10 @@ namespace v2rayN.Forms
|
|||
|
||||
private void menuAddShadowsocksServer_Click(object sender, EventArgs e)
|
||||
{
|
||||
var fm = new AddServer3Form();
|
||||
fm.EditIndex = -1;
|
||||
var fm = new AddServer3Form
|
||||
{
|
||||
EditIndex = -1
|
||||
};
|
||||
if (fm.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
//刷新
|
||||
|
@ -813,8 +829,10 @@ namespace v2rayN.Forms
|
|||
|
||||
private void menuAddSocksServer_Click(object sender, EventArgs e)
|
||||
{
|
||||
var fm = new AddServer4Form();
|
||||
fm.EditIndex = -1;
|
||||
var fm = new AddServer4Form
|
||||
{
|
||||
EditIndex = -1
|
||||
};
|
||||
if (fm.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
//刷新
|
||||
|
|
|
@ -98,10 +98,12 @@ namespace v2rayN.Forms
|
|||
|
||||
private void AddSub()
|
||||
{
|
||||
var subItem = new SubItem();
|
||||
subItem.id = string.Empty;
|
||||
subItem.remarks = "remarks";
|
||||
subItem.url = "url";
|
||||
var subItem = new SubItem
|
||||
{
|
||||
id = string.Empty,
|
||||
remarks = "remarks",
|
||||
url = "url"
|
||||
};
|
||||
config.subItem.Add(subItem);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -30,34 +30,38 @@ namespace v2rayN.Handler
|
|||
}
|
||||
if (config == null)
|
||||
{
|
||||
config = new Config();
|
||||
config.index = -1;
|
||||
config.logEnabled = false;
|
||||
config.loglevel = "warning";
|
||||
config.vmess = new List<VmessItem>();
|
||||
config = new Config
|
||||
{
|
||||
index = -1,
|
||||
logEnabled = false,
|
||||
loglevel = "warning",
|
||||
vmess = new List<VmessItem>(),
|
||||
|
||||
//Mux
|
||||
config.muxEnabled = true;
|
||||
//Mux
|
||||
muxEnabled = true,
|
||||
|
||||
////默认监听端口
|
||||
//config.pacPort = 8888;
|
||||
|
||||
// 默认不开启统计
|
||||
config.enableStatistics = false;
|
||||
////默认监听端口
|
||||
//config.pacPort = 8888;
|
||||
|
||||
// 默认中等刷新率
|
||||
config.statisticsFreshRate = (int)Global.StatisticsFreshRate.medium;
|
||||
// 默认不开启统计
|
||||
enableStatistics = false,
|
||||
|
||||
// 默认中等刷新率
|
||||
statisticsFreshRate = (int)Global.StatisticsFreshRate.medium
|
||||
};
|
||||
}
|
||||
|
||||
//本地监听
|
||||
if (config.inbound == null)
|
||||
{
|
||||
config.inbound = new List<InItem>();
|
||||
InItem inItem = new InItem();
|
||||
inItem.protocol = Global.InboundSocks;
|
||||
inItem.localPort = 10808;
|
||||
inItem.udpEnabled = true;
|
||||
inItem.sniffingEnabled = true;
|
||||
InItem inItem = new InItem
|
||||
{
|
||||
protocol = Global.InboundSocks,
|
||||
localPort = 10808,
|
||||
udpEnabled = true,
|
||||
sniffingEnabled = true
|
||||
};
|
||||
|
||||
config.inbound.Add(inItem);
|
||||
|
||||
|
@ -100,14 +104,16 @@ namespace v2rayN.Handler
|
|||
//kcp
|
||||
if (config.kcpItem == null)
|
||||
{
|
||||
config.kcpItem = new KcpItem();
|
||||
config.kcpItem.mtu = 1350;
|
||||
config.kcpItem.tti = 50;
|
||||
config.kcpItem.uplinkCapacity = 12;
|
||||
config.kcpItem.downlinkCapacity = 100;
|
||||
config.kcpItem.readBufferSize = 2;
|
||||
config.kcpItem.writeBufferSize = 2;
|
||||
config.kcpItem.congestion = false;
|
||||
config.kcpItem = new KcpItem
|
||||
{
|
||||
mtu = 1350,
|
||||
tti = 50,
|
||||
uplinkCapacity = 12,
|
||||
downlinkCapacity = 100,
|
||||
readBufferSize = 2,
|
||||
writeBufferSize = 2,
|
||||
congestion = false
|
||||
};
|
||||
}
|
||||
if (config.uiItem == null)
|
||||
{
|
||||
|
@ -259,20 +265,22 @@ namespace v2rayN.Handler
|
|||
return -1;
|
||||
}
|
||||
|
||||
VmessItem vmessItem = new VmessItem();
|
||||
vmessItem.configVersion = config.vmess[index].configVersion;
|
||||
vmessItem.configType = config.vmess[index].configType;
|
||||
vmessItem.address = config.vmess[index].address;
|
||||
vmessItem.port = config.vmess[index].port;
|
||||
vmessItem.id = config.vmess[index].id;
|
||||
vmessItem.alterId = config.vmess[index].alterId;
|
||||
vmessItem.security = config.vmess[index].security;
|
||||
vmessItem.network = config.vmess[index].network;
|
||||
vmessItem.headerType = config.vmess[index].headerType;
|
||||
vmessItem.requestHost = config.vmess[index].requestHost;
|
||||
vmessItem.path = config.vmess[index].path;
|
||||
vmessItem.streamSecurity = config.vmess[index].streamSecurity;
|
||||
vmessItem.remarks = string.Format("{0}-clone", config.vmess[index].remarks);
|
||||
VmessItem vmessItem = new VmessItem
|
||||
{
|
||||
configVersion = config.vmess[index].configVersion,
|
||||
configType = config.vmess[index].configType,
|
||||
address = config.vmess[index].address,
|
||||
port = config.vmess[index].port,
|
||||
id = config.vmess[index].id,
|
||||
alterId = config.vmess[index].alterId,
|
||||
security = config.vmess[index].security,
|
||||
network = config.vmess[index].network,
|
||||
headerType = config.vmess[index].headerType,
|
||||
requestHost = config.vmess[index].requestHost,
|
||||
path = config.vmess[index].path,
|
||||
streamSecurity = config.vmess[index].streamSecurity,
|
||||
remarks = string.Format("{0}-clone", config.vmess[index].remarks)
|
||||
};
|
||||
|
||||
config.vmess.Insert(index + 1, vmessItem); // 插入到下一项
|
||||
|
||||
|
@ -345,18 +353,20 @@ namespace v2rayN.Handler
|
|||
VmessItem vmessItem = config.vmess[index];
|
||||
if (vmessItem.configType == (int)EConfigType.Vmess)
|
||||
{
|
||||
VmessQRCode vmessQRCode = new VmessQRCode();
|
||||
vmessQRCode.v = vmessItem.configVersion.ToString();
|
||||
vmessQRCode.ps = vmessItem.remarks.TrimEx(); //备注也许很长 ;
|
||||
vmessQRCode.add = vmessItem.address;
|
||||
vmessQRCode.port = vmessItem.port.ToString();
|
||||
vmessQRCode.id = vmessItem.id;
|
||||
vmessQRCode.aid = vmessItem.alterId.ToString();
|
||||
vmessQRCode.net = vmessItem.network;
|
||||
vmessQRCode.type = vmessItem.headerType;
|
||||
vmessQRCode.host = vmessItem.requestHost;
|
||||
vmessQRCode.path = vmessItem.path;
|
||||
vmessQRCode.tls = vmessItem.streamSecurity;
|
||||
VmessQRCode vmessQRCode = new VmessQRCode
|
||||
{
|
||||
v = vmessItem.configVersion.ToString(),
|
||||
ps = vmessItem.remarks.TrimEx(), //备注也许很长 ;
|
||||
add = vmessItem.address,
|
||||
port = vmessItem.port.ToString(),
|
||||
id = vmessItem.id,
|
||||
aid = vmessItem.alterId.ToString(),
|
||||
net = vmessItem.network,
|
||||
type = vmessItem.headerType,
|
||||
host = vmessItem.requestHost,
|
||||
path = vmessItem.path,
|
||||
tls = vmessItem.streamSecurity
|
||||
};
|
||||
|
||||
url = Utils.ToJson(vmessQRCode);
|
||||
url = Utils.Base64Encode(url);
|
||||
|
@ -535,10 +545,12 @@ namespace v2rayN.Handler
|
|||
return -1;
|
||||
}
|
||||
|
||||
VmessItem vmessItem = new VmessItem();
|
||||
vmessItem.address = newFileName;
|
||||
vmessItem.configType = (int)EConfigType.Custom;
|
||||
vmessItem.remarks = string.Format("import custom@{0}", DateTime.Now.ToShortDateString());
|
||||
VmessItem vmessItem = new VmessItem
|
||||
{
|
||||
address = newFileName,
|
||||
configType = (int)EConfigType.Custom,
|
||||
remarks = string.Format("import custom@{0}", DateTime.Now.ToShortDateString())
|
||||
};
|
||||
|
||||
config.vmess.Add(vmessItem);
|
||||
if (config.vmess.Count == 1)
|
||||
|
@ -799,10 +811,12 @@ namespace v2rayN.Handler
|
|||
}
|
||||
}
|
||||
|
||||
var subItem = new SubItem();
|
||||
subItem.id = string.Empty;
|
||||
subItem.remarks = "import sub";
|
||||
subItem.url = url;
|
||||
var subItem = new SubItem
|
||||
{
|
||||
id = string.Empty,
|
||||
remarks = "import sub",
|
||||
url = url
|
||||
};
|
||||
config.subItem.Add(subItem);
|
||||
|
||||
return SaveSubItem(ref config);
|
||||
|
|
|
@ -60,8 +60,10 @@ namespace v2rayN.Handler
|
|||
public async Task CheckUpdateAsync(string type)
|
||||
{
|
||||
Utils.SetSecurityProtocol();
|
||||
WebRequestHandler webRequestHandler = new WebRequestHandler();
|
||||
webRequestHandler.AllowAutoRedirect = false;
|
||||
WebRequestHandler webRequestHandler = new WebRequestHandler
|
||||
{
|
||||
AllowAutoRedirect = false
|
||||
};
|
||||
HttpClient httpClient = new HttpClient(webRequestHandler);
|
||||
|
||||
string url;
|
||||
|
|
|
@ -85,10 +85,12 @@ namespace v2rayN.Handler
|
|||
return;
|
||||
}
|
||||
|
||||
SaveFileDialog fileDialog = new SaveFileDialog();
|
||||
fileDialog.Filter = "Config|*.json";
|
||||
fileDialog.FilterIndex = 2;
|
||||
fileDialog.RestoreDirectory = true;
|
||||
SaveFileDialog fileDialog = new SaveFileDialog
|
||||
{
|
||||
Filter = "Config|*.json",
|
||||
FilterIndex = 2,
|
||||
RestoreDirectory = true
|
||||
};
|
||||
if (fileDialog.ShowDialog() != DialogResult.OK)
|
||||
{
|
||||
return;
|
||||
|
@ -124,10 +126,12 @@ namespace v2rayN.Handler
|
|||
return;
|
||||
}
|
||||
|
||||
SaveFileDialog fileDialog = new SaveFileDialog();
|
||||
fileDialog.Filter = "Config|*.json";
|
||||
fileDialog.FilterIndex = 2;
|
||||
fileDialog.RestoreDirectory = true;
|
||||
SaveFileDialog fileDialog = new SaveFileDialog
|
||||
{
|
||||
Filter = "Config|*.json",
|
||||
FilterIndex = 2,
|
||||
RestoreDirectory = true
|
||||
};
|
||||
if (fileDialog.ShowDialog() != DialogResult.OK)
|
||||
{
|
||||
return;
|
||||
|
|
|
@ -16,18 +16,22 @@ namespace v2rayN.Handler
|
|||
Image img = null;
|
||||
try
|
||||
{
|
||||
QrCodeEncodingOptions options = new QrCodeEncodingOptions();
|
||||
options.CharacterSet = "UTF-8";
|
||||
options.DisableECI = true; // Extended Channel Interpretation (ECI) 主要用于特殊的字符集。并不是所有的扫描器都支持这种编码。
|
||||
options.ErrorCorrection = ZXing.QrCode.Internal.ErrorCorrectionLevel.M; // 纠错级别
|
||||
options.Width = 500;
|
||||
options.Height = 500;
|
||||
options.Margin = 1;
|
||||
QrCodeEncodingOptions options = new QrCodeEncodingOptions
|
||||
{
|
||||
CharacterSet = "UTF-8",
|
||||
DisableECI = true, // Extended Channel Interpretation (ECI) 主要用于特殊的字符集。并不是所有的扫描器都支持这种编码。
|
||||
ErrorCorrection = ZXing.QrCode.Internal.ErrorCorrectionLevel.M, // 纠错级别
|
||||
Width = 500,
|
||||
Height = 500,
|
||||
Margin = 1
|
||||
};
|
||||
// options.Hints,更多属性,也可以在这里添加。
|
||||
|
||||
BarcodeWriter writer = new BarcodeWriter();
|
||||
writer.Format = BarcodeFormat.QR_CODE;
|
||||
writer.Options = options;
|
||||
BarcodeWriter writer = new BarcodeWriter
|
||||
{
|
||||
Format = BarcodeFormat.QR_CODE,
|
||||
Options = options
|
||||
};
|
||||
Bitmap bmp = writer.Write(strContent);
|
||||
img = (Image)bmp;
|
||||
return img;
|
||||
|
|
|
@ -226,16 +226,20 @@ namespace v2rayN.Handler
|
|||
&& userRule.Count > 0)
|
||||
{
|
||||
//Domain
|
||||
RulesItem rulesDomain = new RulesItem();
|
||||
rulesDomain.type = "field";
|
||||
rulesDomain.outboundTag = tag;
|
||||
rulesDomain.domain = new List<string>();
|
||||
RulesItem rulesDomain = new RulesItem
|
||||
{
|
||||
type = "field",
|
||||
outboundTag = tag,
|
||||
domain = new List<string>()
|
||||
};
|
||||
|
||||
//IP
|
||||
RulesItem rulesIP = new RulesItem();
|
||||
rulesIP.type = "field";
|
||||
rulesIP.outboundTag = tag;
|
||||
rulesIP.ip = new List<string>();
|
||||
RulesItem rulesIP = new RulesItem
|
||||
{
|
||||
type = "field",
|
||||
outboundTag = tag,
|
||||
ip = new List<string>()
|
||||
};
|
||||
|
||||
foreach (string u in userRule)
|
||||
{
|
||||
|
@ -283,10 +287,12 @@ namespace v2rayN.Handler
|
|||
//IP
|
||||
if (ipOrDomain == "ip" || ipOrDomain == "")
|
||||
{
|
||||
RulesItem rulesItem = new RulesItem();
|
||||
rulesItem.type = "field";
|
||||
rulesItem.outboundTag = Global.directTag;
|
||||
rulesItem.ip = new List<string>();
|
||||
RulesItem rulesItem = new RulesItem
|
||||
{
|
||||
type = "field",
|
||||
outboundTag = Global.directTag,
|
||||
ip = new List<string>()
|
||||
};
|
||||
rulesItem.ip.Add($"geoip:{code}");
|
||||
|
||||
v2rayConfig.routing.rules.Add(rulesItem);
|
||||
|
@ -294,10 +300,12 @@ namespace v2rayN.Handler
|
|||
|
||||
if (ipOrDomain == "domain" || ipOrDomain == "")
|
||||
{
|
||||
RulesItem rulesItem = new RulesItem();
|
||||
rulesItem.type = "field";
|
||||
rulesItem.outboundTag = Global.directTag;
|
||||
rulesItem.domain = new List<string>();
|
||||
RulesItem rulesItem = new RulesItem
|
||||
{
|
||||
type = "field",
|
||||
outboundTag = Global.directTag,
|
||||
domain = new List<string>()
|
||||
};
|
||||
rulesItem.domain.Add($"geosite:{code}");
|
||||
v2rayConfig.routing.rules.Add(rulesItem);
|
||||
}
|
||||
|
@ -412,10 +420,12 @@ namespace v2rayN.Handler
|
|||
if (!Utils.IsNullOrEmpty(config.security())
|
||||
&& !Utils.IsNullOrEmpty(config.id()))
|
||||
{
|
||||
var socksUsersItem = new SocksUsersItem();
|
||||
socksUsersItem.user = config.security();
|
||||
socksUsersItem.pass = config.id();
|
||||
socksUsersItem.level = 1;
|
||||
var socksUsersItem = new SocksUsersItem
|
||||
{
|
||||
user = config.security(),
|
||||
pass = config.id(),
|
||||
level = 1
|
||||
};
|
||||
|
||||
serversItem.users = new List<SocksUsersItem>() { socksUsersItem };
|
||||
}
|
||||
|
@ -452,8 +462,10 @@ namespace v2rayN.Handler
|
|||
{
|
||||
streamSettings.security = config.streamSecurity();
|
||||
|
||||
TlsSettings tlsSettings = new TlsSettings();
|
||||
tlsSettings.allowInsecure = config.allowInsecure();
|
||||
TlsSettings tlsSettings = new TlsSettings
|
||||
{
|
||||
allowInsecure = config.allowInsecure()
|
||||
};
|
||||
if (!string.IsNullOrWhiteSpace(host))
|
||||
{
|
||||
tlsSettings.serverName = host;
|
||||
|
@ -466,9 +478,11 @@ namespace v2rayN.Handler
|
|||
{
|
||||
//kcp基本配置暂时是默认值,用户能自己设置伪装类型
|
||||
case "kcp":
|
||||
KcpSettings kcpSettings = new KcpSettings();
|
||||
kcpSettings.mtu = config.kcpItem.mtu;
|
||||
kcpSettings.tti = config.kcpItem.tti;
|
||||
KcpSettings kcpSettings = new KcpSettings
|
||||
{
|
||||
mtu = config.kcpItem.mtu,
|
||||
tti = config.kcpItem.tti
|
||||
};
|
||||
if (iobound.Equals("out"))
|
||||
{
|
||||
kcpSettings.uplinkCapacity = config.kcpItem.uplinkCapacity;
|
||||
|
@ -488,20 +502,26 @@ namespace v2rayN.Handler
|
|||
kcpSettings.congestion = config.kcpItem.congestion;
|
||||
kcpSettings.readBufferSize = config.kcpItem.readBufferSize;
|
||||
kcpSettings.writeBufferSize = config.kcpItem.writeBufferSize;
|
||||
kcpSettings.header = new Header();
|
||||
kcpSettings.header.type = config.headerType();
|
||||
kcpSettings.header = new Header
|
||||
{
|
||||
type = config.headerType()
|
||||
};
|
||||
streamSettings.kcpSettings = kcpSettings;
|
||||
break;
|
||||
//ws
|
||||
case "ws":
|
||||
WsSettings wsSettings = new WsSettings();
|
||||
wsSettings.connectionReuse = true;
|
||||
WsSettings wsSettings = new WsSettings
|
||||
{
|
||||
connectionReuse = true
|
||||
};
|
||||
|
||||
string path = config.path();
|
||||
if (!string.IsNullOrWhiteSpace(host))
|
||||
{
|
||||
wsSettings.headers = new Headers();
|
||||
wsSettings.headers.Host = host;
|
||||
wsSettings.headers = new Headers
|
||||
{
|
||||
Host = host
|
||||
};
|
||||
}
|
||||
if (!string.IsNullOrWhiteSpace(path))
|
||||
{
|
||||
|
@ -535,11 +555,15 @@ namespace v2rayN.Handler
|
|||
break;
|
||||
//quic
|
||||
case "quic":
|
||||
QuicSettings quicsettings = new QuicSettings();
|
||||
quicsettings.security = host;
|
||||
quicsettings.key = config.path();
|
||||
quicsettings.header = new Header();
|
||||
quicsettings.header.type = config.headerType();
|
||||
QuicSettings quicsettings = new QuicSettings
|
||||
{
|
||||
security = host,
|
||||
key = config.path(),
|
||||
header = new Header
|
||||
{
|
||||
type = config.headerType()
|
||||
}
|
||||
};
|
||||
streamSettings.quicSettings = quicsettings;
|
||||
if (config.streamSecurity() == Global.StreamSecurity)
|
||||
{
|
||||
|
@ -550,10 +574,14 @@ namespace v2rayN.Handler
|
|||
//tcp带http伪装
|
||||
if (config.headerType().Equals(Global.TcpHeaderHttp))
|
||||
{
|
||||
TcpSettings tcpSettings = new TcpSettings();
|
||||
tcpSettings.connectionReuse = true;
|
||||
tcpSettings.header = new Header();
|
||||
tcpSettings.header.type = config.headerType();
|
||||
TcpSettings tcpSettings = new TcpSettings
|
||||
{
|
||||
connectionReuse = true,
|
||||
header = new Header
|
||||
{
|
||||
type = config.headerType()
|
||||
}
|
||||
};
|
||||
|
||||
if (iobound.Equals("out"))
|
||||
{
|
||||
|
@ -616,8 +644,10 @@ namespace v2rayN.Handler
|
|||
//}
|
||||
}
|
||||
//servers.Add("localhost");
|
||||
v2rayConfig.dns = new Mode.Dns();
|
||||
v2rayConfig.dns.servers = servers;
|
||||
v2rayConfig.dns = new Mode.Dns
|
||||
{
|
||||
servers = servers
|
||||
};
|
||||
}
|
||||
catch
|
||||
{
|
||||
|
@ -662,10 +692,12 @@ namespace v2rayN.Handler
|
|||
|
||||
if (!v2rayConfig.routing.rules.Exists(item => { return item.outboundTag == tag; }))
|
||||
{
|
||||
var apiRoutingRule = new Mode.RulesItem();
|
||||
apiRoutingRule.inboundTag = new List<string> { tag };
|
||||
apiRoutingRule.outboundTag = tag;
|
||||
apiRoutingRule.type = "field";
|
||||
var apiRoutingRule = new Mode.RulesItem
|
||||
{
|
||||
inboundTag = new List<string> { tag },
|
||||
outboundTag = tag,
|
||||
type = "field"
|
||||
};
|
||||
v2rayConfig.routing.rules.Add(apiRoutingRule);
|
||||
}
|
||||
}
|
||||
|
@ -1345,9 +1377,10 @@ namespace v2rayN.Handler
|
|||
|
||||
private static VmessItem ResolveVmess4Kitsunebi(string result)
|
||||
{
|
||||
VmessItem vmessItem = new VmessItem();
|
||||
|
||||
vmessItem.configType = (int)EConfigType.Vmess;
|
||||
VmessItem vmessItem = new VmessItem
|
||||
{
|
||||
configType = (int)EConfigType.Vmess
|
||||
};
|
||||
result = result.Substring(Global.vmessProtocol.Length);
|
||||
int indexSplit = result.IndexOf("?");
|
||||
if (indexSplit > 0)
|
||||
|
@ -1435,10 +1468,12 @@ namespace v2rayN.Handler
|
|||
|
||||
configCopy.index = index;
|
||||
|
||||
var inbound = new Inbounds();
|
||||
inbound.listen = Global.Loopback;
|
||||
inbound.port = httpPort + index;
|
||||
inbound.protocol = Global.InboundHttp;
|
||||
var inbound = new Inbounds
|
||||
{
|
||||
listen = Global.Loopback,
|
||||
port = httpPort + index,
|
||||
protocol = Global.InboundHttp
|
||||
};
|
||||
inbound.tag = Global.InboundHttp + inbound.port.ToString();
|
||||
v2rayConfig.inbounds.Add(inbound);
|
||||
|
||||
|
@ -1448,10 +1483,12 @@ namespace v2rayN.Handler
|
|||
v2rayConfigCopy.outbounds[0].tag = Global.agentTag + inbound.port.ToString();
|
||||
v2rayConfig.outbounds.Add(v2rayConfigCopy.outbounds[0]);
|
||||
|
||||
var rule = new Mode.RulesItem();
|
||||
rule.inboundTag = new List<string> { inbound.tag };
|
||||
rule.outboundTag = v2rayConfigCopy.outbounds[0].tag;
|
||||
rule.type = "field";
|
||||
var rule = new Mode.RulesItem
|
||||
{
|
||||
inboundTag = new List<string> { inbound.tag },
|
||||
outboundTag = v2rayConfigCopy.outbounds[0].tag,
|
||||
type = "field"
|
||||
};
|
||||
v2rayConfig.routing.rules.Add(rule);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue