IDE0017-简化对象初始化

This commit is contained in:
YFdyh000 2020-03-15 03:23:43 +08:00
parent 8b68ecb891
commit d8d8346d45
9 changed files with 255 additions and 168 deletions

View file

@ -17,8 +17,10 @@ namespace v2rayN.Base
this.port = port; this.port = port;
this._responderMethod = method; this._responderMethod = method;
Thread thread = new Thread(StartListen); Thread thread = new Thread(StartListen)
thread.IsBackground = true; {
IsBackground = true
};
thread.Start(); thread.Start();
} }
@ -46,8 +48,10 @@ namespace v2rayN.Base
} }
TcpClient socket = listener.AcceptTcpClient(); TcpClient socket = listener.AcceptTcpClient();
Thread thread = new Thread(new ParameterizedThreadStart(ProcessThread)); Thread thread = new Thread(new ParameterizedThreadStart(ProcessThread))
thread.IsBackground = true; {
IsBackground = true
};
thread.Start(socket); thread.Start(socket);
Thread.Sleep(1); Thread.Sleep(1);
} }

View file

@ -207,9 +207,11 @@ namespace v2rayN.Forms
{ {
ClearServer(); ClearServer();
OpenFileDialog fileDialog = new OpenFileDialog(); OpenFileDialog fileDialog = new OpenFileDialog
fileDialog.Multiselect = false; {
fileDialog.Filter = "Config|*.json|All|*.*"; Multiselect = false,
Filter = "Config|*.json|All|*.*"
};
if (fileDialog.ShowDialog() != DialogResult.OK) if (fileDialog.ShowDialog() != DialogResult.OK)
{ {
return; return;

View file

@ -271,8 +271,10 @@ namespace v2rayN.Forms
VmessItem item = config.vmess[k]; VmessItem item = config.vmess[k];
string name = item.getSummary(); string name = item.getSummary();
ToolStripMenuItem ts = new ToolStripMenuItem(name); ToolStripMenuItem ts = new ToolStripMenuItem(name)
ts.Tag = k; {
Tag = k
};
if (config.index.Equals(k)) if (config.index.Equals(k))
{ {
ts.Checked = true; ts.Checked = true;
@ -422,8 +424,10 @@ namespace v2rayN.Forms
if (config.vmess[index].configType == (int)EConfigType.Vmess) if (config.vmess[index].configType == (int)EConfigType.Vmess)
{ {
var fm = new AddServerForm(); var fm = new AddServerForm
fm.EditIndex = index; {
EditIndex = index
};
if (fm.ShowDialog() == DialogResult.OK) if (fm.ShowDialog() == DialogResult.OK)
{ {
//刷新 //刷新
@ -433,8 +437,10 @@ namespace v2rayN.Forms
} }
else if (config.vmess[index].configType == (int)EConfigType.Shadowsocks) else if (config.vmess[index].configType == (int)EConfigType.Shadowsocks)
{ {
var fm = new AddServer3Form(); var fm = new AddServer3Form
fm.EditIndex = index; {
EditIndex = index
};
if (fm.ShowDialog() == DialogResult.OK) if (fm.ShowDialog() == DialogResult.OK)
{ {
RefreshServers(); RefreshServers();
@ -443,8 +449,10 @@ namespace v2rayN.Forms
} }
else if (config.vmess[index].configType == (int)EConfigType.Socks) else if (config.vmess[index].configType == (int)EConfigType.Socks)
{ {
var fm = new AddServer4Form(); var fm = new AddServer4Form
fm.EditIndex = index; {
EditIndex = index
};
if (fm.ShowDialog() == DialogResult.OK) if (fm.ShowDialog() == DialogResult.OK)
{ {
RefreshServers(); RefreshServers();
@ -453,8 +461,10 @@ namespace v2rayN.Forms
} }
else else
{ {
var fm2 = new AddServer2Form(); var fm2 = new AddServer2Form
fm2.EditIndex = index; {
EditIndex = index
};
if (fm2.ShowDialog() == DialogResult.OK) if (fm2.ShowDialog() == DialogResult.OK)
{ {
//刷新 //刷新
@ -524,8 +534,10 @@ namespace v2rayN.Forms
private void menuAddVmessServer_Click(object sender, EventArgs e) private void menuAddVmessServer_Click(object sender, EventArgs e)
{ {
AddServerForm fm = new AddServerForm(); AddServerForm fm = new AddServerForm
fm.EditIndex = -1; {
EditIndex = -1
};
if (fm.ShowDialog() == DialogResult.OK) if (fm.ShowDialog() == DialogResult.OK)
{ {
//刷新 //刷新
@ -772,9 +784,11 @@ namespace v2rayN.Forms
{ {
UI.Show(UIRes.I18N("CustomServerTips")); UI.Show(UIRes.I18N("CustomServerTips"));
OpenFileDialog fileDialog = new OpenFileDialog(); OpenFileDialog fileDialog = new OpenFileDialog
fileDialog.Multiselect = false; {
fileDialog.Filter = "Config|*.json|All|*.*"; Multiselect = false,
Filter = "Config|*.json|All|*.*"
};
if (fileDialog.ShowDialog() != DialogResult.OK) if (fileDialog.ShowDialog() != DialogResult.OK)
{ {
return; return;
@ -800,8 +814,10 @@ namespace v2rayN.Forms
private void menuAddShadowsocksServer_Click(object sender, EventArgs e) private void menuAddShadowsocksServer_Click(object sender, EventArgs e)
{ {
var fm = new AddServer3Form(); var fm = new AddServer3Form
fm.EditIndex = -1; {
EditIndex = -1
};
if (fm.ShowDialog() == DialogResult.OK) if (fm.ShowDialog() == DialogResult.OK)
{ {
//刷新 //刷新
@ -813,8 +829,10 @@ namespace v2rayN.Forms
private void menuAddSocksServer_Click(object sender, EventArgs e) private void menuAddSocksServer_Click(object sender, EventArgs e)
{ {
var fm = new AddServer4Form(); var fm = new AddServer4Form
fm.EditIndex = -1; {
EditIndex = -1
};
if (fm.ShowDialog() == DialogResult.OK) if (fm.ShowDialog() == DialogResult.OK)
{ {
//刷新 //刷新

View file

@ -98,10 +98,12 @@ namespace v2rayN.Forms
private void AddSub() private void AddSub()
{ {
var subItem = new SubItem(); var subItem = new SubItem
subItem.id = string.Empty; {
subItem.remarks = "remarks"; id = string.Empty,
subItem.url = "url"; remarks = "remarks",
url = "url"
};
config.subItem.Add(subItem); config.subItem.Add(subItem);
} }
} }

View file

@ -30,34 +30,38 @@ namespace v2rayN.Handler
} }
if (config == null) if (config == null)
{ {
config = new Config(); config = new Config
config.index = -1; {
config.logEnabled = false; index = -1,
config.loglevel = "warning"; logEnabled = false,
config.vmess = new List<VmessItem>(); loglevel = "warning",
vmess = new List<VmessItem>(),
//Mux //Mux
config.muxEnabled = true; muxEnabled = true,
////默认监听端口 ////默认监听端口
//config.pacPort = 8888; //config.pacPort = 8888;
// 默认不开启统计
config.enableStatistics = false;
// 默认中等刷新率 // 默认不开启统计
config.statisticsFreshRate = (int)Global.StatisticsFreshRate.medium; enableStatistics = false,
// 默认中等刷新率
statisticsFreshRate = (int)Global.StatisticsFreshRate.medium
};
} }
//本地监听 //本地监听
if (config.inbound == null) if (config.inbound == null)
{ {
config.inbound = new List<InItem>(); config.inbound = new List<InItem>();
InItem inItem = new InItem(); InItem inItem = new InItem
inItem.protocol = Global.InboundSocks; {
inItem.localPort = 10808; protocol = Global.InboundSocks,
inItem.udpEnabled = true; localPort = 10808,
inItem.sniffingEnabled = true; udpEnabled = true,
sniffingEnabled = true
};
config.inbound.Add(inItem); config.inbound.Add(inItem);
@ -100,14 +104,16 @@ namespace v2rayN.Handler
//kcp //kcp
if (config.kcpItem == null) if (config.kcpItem == null)
{ {
config.kcpItem = new KcpItem(); config.kcpItem = new KcpItem
config.kcpItem.mtu = 1350; {
config.kcpItem.tti = 50; mtu = 1350,
config.kcpItem.uplinkCapacity = 12; tti = 50,
config.kcpItem.downlinkCapacity = 100; uplinkCapacity = 12,
config.kcpItem.readBufferSize = 2; downlinkCapacity = 100,
config.kcpItem.writeBufferSize = 2; readBufferSize = 2,
config.kcpItem.congestion = false; writeBufferSize = 2,
congestion = false
};
} }
if (config.uiItem == null) if (config.uiItem == null)
{ {
@ -259,20 +265,22 @@ namespace v2rayN.Handler
return -1; return -1;
} }
VmessItem vmessItem = new VmessItem(); VmessItem vmessItem = new VmessItem
vmessItem.configVersion = config.vmess[index].configVersion; {
vmessItem.configType = config.vmess[index].configType; configVersion = config.vmess[index].configVersion,
vmessItem.address = config.vmess[index].address; configType = config.vmess[index].configType,
vmessItem.port = config.vmess[index].port; address = config.vmess[index].address,
vmessItem.id = config.vmess[index].id; port = config.vmess[index].port,
vmessItem.alterId = config.vmess[index].alterId; id = config.vmess[index].id,
vmessItem.security = config.vmess[index].security; alterId = config.vmess[index].alterId,
vmessItem.network = config.vmess[index].network; security = config.vmess[index].security,
vmessItem.headerType = config.vmess[index].headerType; network = config.vmess[index].network,
vmessItem.requestHost = config.vmess[index].requestHost; headerType = config.vmess[index].headerType,
vmessItem.path = config.vmess[index].path; requestHost = config.vmess[index].requestHost,
vmessItem.streamSecurity = config.vmess[index].streamSecurity; path = config.vmess[index].path,
vmessItem.remarks = string.Format("{0}-clone", config.vmess[index].remarks); streamSecurity = config.vmess[index].streamSecurity,
remarks = string.Format("{0}-clone", config.vmess[index].remarks)
};
config.vmess.Insert(index + 1, vmessItem); // 插入到下一项 config.vmess.Insert(index + 1, vmessItem); // 插入到下一项
@ -345,18 +353,20 @@ namespace v2rayN.Handler
VmessItem vmessItem = config.vmess[index]; VmessItem vmessItem = config.vmess[index];
if (vmessItem.configType == (int)EConfigType.Vmess) if (vmessItem.configType == (int)EConfigType.Vmess)
{ {
VmessQRCode vmessQRCode = new VmessQRCode(); VmessQRCode vmessQRCode = new VmessQRCode
vmessQRCode.v = vmessItem.configVersion.ToString(); {
vmessQRCode.ps = vmessItem.remarks.TrimEx(); //备注也许很长 ; v = vmessItem.configVersion.ToString(),
vmessQRCode.add = vmessItem.address; ps = vmessItem.remarks.TrimEx(), //备注也许很长 ;
vmessQRCode.port = vmessItem.port.ToString(); add = vmessItem.address,
vmessQRCode.id = vmessItem.id; port = vmessItem.port.ToString(),
vmessQRCode.aid = vmessItem.alterId.ToString(); id = vmessItem.id,
vmessQRCode.net = vmessItem.network; aid = vmessItem.alterId.ToString(),
vmessQRCode.type = vmessItem.headerType; net = vmessItem.network,
vmessQRCode.host = vmessItem.requestHost; type = vmessItem.headerType,
vmessQRCode.path = vmessItem.path; host = vmessItem.requestHost,
vmessQRCode.tls = vmessItem.streamSecurity; path = vmessItem.path,
tls = vmessItem.streamSecurity
};
url = Utils.ToJson(vmessQRCode); url = Utils.ToJson(vmessQRCode);
url = Utils.Base64Encode(url); url = Utils.Base64Encode(url);
@ -535,10 +545,12 @@ namespace v2rayN.Handler
return -1; return -1;
} }
VmessItem vmessItem = new VmessItem(); VmessItem vmessItem = new VmessItem
vmessItem.address = newFileName; {
vmessItem.configType = (int)EConfigType.Custom; address = newFileName,
vmessItem.remarks = string.Format("import custom@{0}", DateTime.Now.ToShortDateString()); configType = (int)EConfigType.Custom,
remarks = string.Format("import custom@{0}", DateTime.Now.ToShortDateString())
};
config.vmess.Add(vmessItem); config.vmess.Add(vmessItem);
if (config.vmess.Count == 1) if (config.vmess.Count == 1)
@ -799,10 +811,12 @@ namespace v2rayN.Handler
} }
} }
var subItem = new SubItem(); var subItem = new SubItem
subItem.id = string.Empty; {
subItem.remarks = "import sub"; id = string.Empty,
subItem.url = url; remarks = "import sub",
url = url
};
config.subItem.Add(subItem); config.subItem.Add(subItem);
return SaveSubItem(ref config); return SaveSubItem(ref config);

View file

@ -60,8 +60,10 @@ namespace v2rayN.Handler
public async Task CheckUpdateAsync(string type) public async Task CheckUpdateAsync(string type)
{ {
Utils.SetSecurityProtocol(); Utils.SetSecurityProtocol();
WebRequestHandler webRequestHandler = new WebRequestHandler(); WebRequestHandler webRequestHandler = new WebRequestHandler
webRequestHandler.AllowAutoRedirect = false; {
AllowAutoRedirect = false
};
HttpClient httpClient = new HttpClient(webRequestHandler); HttpClient httpClient = new HttpClient(webRequestHandler);
string url; string url;

View file

@ -85,10 +85,12 @@ namespace v2rayN.Handler
return; return;
} }
SaveFileDialog fileDialog = new SaveFileDialog(); SaveFileDialog fileDialog = new SaveFileDialog
fileDialog.Filter = "Config|*.json"; {
fileDialog.FilterIndex = 2; Filter = "Config|*.json",
fileDialog.RestoreDirectory = true; FilterIndex = 2,
RestoreDirectory = true
};
if (fileDialog.ShowDialog() != DialogResult.OK) if (fileDialog.ShowDialog() != DialogResult.OK)
{ {
return; return;
@ -124,10 +126,12 @@ namespace v2rayN.Handler
return; return;
} }
SaveFileDialog fileDialog = new SaveFileDialog(); SaveFileDialog fileDialog = new SaveFileDialog
fileDialog.Filter = "Config|*.json"; {
fileDialog.FilterIndex = 2; Filter = "Config|*.json",
fileDialog.RestoreDirectory = true; FilterIndex = 2,
RestoreDirectory = true
};
if (fileDialog.ShowDialog() != DialogResult.OK) if (fileDialog.ShowDialog() != DialogResult.OK)
{ {
return; return;

View file

@ -16,18 +16,22 @@ namespace v2rayN.Handler
Image img = null; Image img = null;
try try
{ {
QrCodeEncodingOptions options = new QrCodeEncodingOptions(); QrCodeEncodingOptions options = new QrCodeEncodingOptions
options.CharacterSet = "UTF-8"; {
options.DisableECI = true; // Extended Channel Interpretation (ECI) 主要用于特殊的字符集。并不是所有的扫描器都支持这种编码。 CharacterSet = "UTF-8",
options.ErrorCorrection = ZXing.QrCode.Internal.ErrorCorrectionLevel.M; // 纠错级别 DisableECI = true, // Extended Channel Interpretation (ECI) 主要用于特殊的字符集。并不是所有的扫描器都支持这种编码。
options.Width = 500; ErrorCorrection = ZXing.QrCode.Internal.ErrorCorrectionLevel.M, // 纠错级别
options.Height = 500; Width = 500,
options.Margin = 1; Height = 500,
Margin = 1
};
// options.Hints更多属性也可以在这里添加。 // options.Hints更多属性也可以在这里添加。
BarcodeWriter writer = new BarcodeWriter(); BarcodeWriter writer = new BarcodeWriter
writer.Format = BarcodeFormat.QR_CODE; {
writer.Options = options; Format = BarcodeFormat.QR_CODE,
Options = options
};
Bitmap bmp = writer.Write(strContent); Bitmap bmp = writer.Write(strContent);
img = (Image)bmp; img = (Image)bmp;
return img; return img;

View file

@ -226,16 +226,20 @@ namespace v2rayN.Handler
&& userRule.Count > 0) && userRule.Count > 0)
{ {
//Domain //Domain
RulesItem rulesDomain = new RulesItem(); RulesItem rulesDomain = new RulesItem
rulesDomain.type = "field"; {
rulesDomain.outboundTag = tag; type = "field",
rulesDomain.domain = new List<string>(); outboundTag = tag,
domain = new List<string>()
};
//IP //IP
RulesItem rulesIP = new RulesItem(); RulesItem rulesIP = new RulesItem
rulesIP.type = "field"; {
rulesIP.outboundTag = tag; type = "field",
rulesIP.ip = new List<string>(); outboundTag = tag,
ip = new List<string>()
};
foreach (string u in userRule) foreach (string u in userRule)
{ {
@ -283,10 +287,12 @@ namespace v2rayN.Handler
//IP //IP
if (ipOrDomain == "ip" || ipOrDomain == "") if (ipOrDomain == "ip" || ipOrDomain == "")
{ {
RulesItem rulesItem = new RulesItem(); RulesItem rulesItem = new RulesItem
rulesItem.type = "field"; {
rulesItem.outboundTag = Global.directTag; type = "field",
rulesItem.ip = new List<string>(); outboundTag = Global.directTag,
ip = new List<string>()
};
rulesItem.ip.Add($"geoip:{code}"); rulesItem.ip.Add($"geoip:{code}");
v2rayConfig.routing.rules.Add(rulesItem); v2rayConfig.routing.rules.Add(rulesItem);
@ -294,10 +300,12 @@ namespace v2rayN.Handler
if (ipOrDomain == "domain" || ipOrDomain == "") if (ipOrDomain == "domain" || ipOrDomain == "")
{ {
RulesItem rulesItem = new RulesItem(); RulesItem rulesItem = new RulesItem
rulesItem.type = "field"; {
rulesItem.outboundTag = Global.directTag; type = "field",
rulesItem.domain = new List<string>(); outboundTag = Global.directTag,
domain = new List<string>()
};
rulesItem.domain.Add($"geosite:{code}"); rulesItem.domain.Add($"geosite:{code}");
v2rayConfig.routing.rules.Add(rulesItem); v2rayConfig.routing.rules.Add(rulesItem);
} }
@ -412,10 +420,12 @@ namespace v2rayN.Handler
if (!Utils.IsNullOrEmpty(config.security()) if (!Utils.IsNullOrEmpty(config.security())
&& !Utils.IsNullOrEmpty(config.id())) && !Utils.IsNullOrEmpty(config.id()))
{ {
var socksUsersItem = new SocksUsersItem(); var socksUsersItem = new SocksUsersItem
socksUsersItem.user = config.security(); {
socksUsersItem.pass = config.id(); user = config.security(),
socksUsersItem.level = 1; pass = config.id(),
level = 1
};
serversItem.users = new List<SocksUsersItem>() { socksUsersItem }; serversItem.users = new List<SocksUsersItem>() { socksUsersItem };
} }
@ -452,8 +462,10 @@ namespace v2rayN.Handler
{ {
streamSettings.security = config.streamSecurity(); streamSettings.security = config.streamSecurity();
TlsSettings tlsSettings = new TlsSettings(); TlsSettings tlsSettings = new TlsSettings
tlsSettings.allowInsecure = config.allowInsecure(); {
allowInsecure = config.allowInsecure()
};
if (!string.IsNullOrWhiteSpace(host)) if (!string.IsNullOrWhiteSpace(host))
{ {
tlsSettings.serverName = host; tlsSettings.serverName = host;
@ -466,9 +478,11 @@ namespace v2rayN.Handler
{ {
//kcp基本配置暂时是默认值用户能自己设置伪装类型 //kcp基本配置暂时是默认值用户能自己设置伪装类型
case "kcp": case "kcp":
KcpSettings kcpSettings = new KcpSettings(); KcpSettings kcpSettings = new KcpSettings
kcpSettings.mtu = config.kcpItem.mtu; {
kcpSettings.tti = config.kcpItem.tti; mtu = config.kcpItem.mtu,
tti = config.kcpItem.tti
};
if (iobound.Equals("out")) if (iobound.Equals("out"))
{ {
kcpSettings.uplinkCapacity = config.kcpItem.uplinkCapacity; kcpSettings.uplinkCapacity = config.kcpItem.uplinkCapacity;
@ -488,20 +502,26 @@ namespace v2rayN.Handler
kcpSettings.congestion = config.kcpItem.congestion; kcpSettings.congestion = config.kcpItem.congestion;
kcpSettings.readBufferSize = config.kcpItem.readBufferSize; kcpSettings.readBufferSize = config.kcpItem.readBufferSize;
kcpSettings.writeBufferSize = config.kcpItem.writeBufferSize; kcpSettings.writeBufferSize = config.kcpItem.writeBufferSize;
kcpSettings.header = new Header(); kcpSettings.header = new Header
kcpSettings.header.type = config.headerType(); {
type = config.headerType()
};
streamSettings.kcpSettings = kcpSettings; streamSettings.kcpSettings = kcpSettings;
break; break;
//ws //ws
case "ws": case "ws":
WsSettings wsSettings = new WsSettings(); WsSettings wsSettings = new WsSettings
wsSettings.connectionReuse = true; {
connectionReuse = true
};
string path = config.path(); string path = config.path();
if (!string.IsNullOrWhiteSpace(host)) if (!string.IsNullOrWhiteSpace(host))
{ {
wsSettings.headers = new Headers(); wsSettings.headers = new Headers
wsSettings.headers.Host = host; {
Host = host
};
} }
if (!string.IsNullOrWhiteSpace(path)) if (!string.IsNullOrWhiteSpace(path))
{ {
@ -535,11 +555,15 @@ namespace v2rayN.Handler
break; break;
//quic //quic
case "quic": case "quic":
QuicSettings quicsettings = new QuicSettings(); QuicSettings quicsettings = new QuicSettings
quicsettings.security = host; {
quicsettings.key = config.path(); security = host,
quicsettings.header = new Header(); key = config.path(),
quicsettings.header.type = config.headerType(); header = new Header
{
type = config.headerType()
}
};
streamSettings.quicSettings = quicsettings; streamSettings.quicSettings = quicsettings;
if (config.streamSecurity() == Global.StreamSecurity) if (config.streamSecurity() == Global.StreamSecurity)
{ {
@ -550,10 +574,14 @@ namespace v2rayN.Handler
//tcp带http伪装 //tcp带http伪装
if (config.headerType().Equals(Global.TcpHeaderHttp)) if (config.headerType().Equals(Global.TcpHeaderHttp))
{ {
TcpSettings tcpSettings = new TcpSettings(); TcpSettings tcpSettings = new TcpSettings
tcpSettings.connectionReuse = true; {
tcpSettings.header = new Header(); connectionReuse = true,
tcpSettings.header.type = config.headerType(); header = new Header
{
type = config.headerType()
}
};
if (iobound.Equals("out")) if (iobound.Equals("out"))
{ {
@ -616,8 +644,10 @@ namespace v2rayN.Handler
//} //}
} }
//servers.Add("localhost"); //servers.Add("localhost");
v2rayConfig.dns = new Mode.Dns(); v2rayConfig.dns = new Mode.Dns
v2rayConfig.dns.servers = servers; {
servers = servers
};
} }
catch catch
{ {
@ -662,10 +692,12 @@ namespace v2rayN.Handler
if (!v2rayConfig.routing.rules.Exists(item => { return item.outboundTag == tag; })) if (!v2rayConfig.routing.rules.Exists(item => { return item.outboundTag == tag; }))
{ {
var apiRoutingRule = new Mode.RulesItem(); var apiRoutingRule = new Mode.RulesItem
apiRoutingRule.inboundTag = new List<string> { tag }; {
apiRoutingRule.outboundTag = tag; inboundTag = new List<string> { tag },
apiRoutingRule.type = "field"; outboundTag = tag,
type = "field"
};
v2rayConfig.routing.rules.Add(apiRoutingRule); v2rayConfig.routing.rules.Add(apiRoutingRule);
} }
} }
@ -1345,9 +1377,10 @@ namespace v2rayN.Handler
private static VmessItem ResolveVmess4Kitsunebi(string result) private static VmessItem ResolveVmess4Kitsunebi(string result)
{ {
VmessItem vmessItem = new VmessItem(); VmessItem vmessItem = new VmessItem
{
vmessItem.configType = (int)EConfigType.Vmess; configType = (int)EConfigType.Vmess
};
result = result.Substring(Global.vmessProtocol.Length); result = result.Substring(Global.vmessProtocol.Length);
int indexSplit = result.IndexOf("?"); int indexSplit = result.IndexOf("?");
if (indexSplit > 0) if (indexSplit > 0)
@ -1435,10 +1468,12 @@ namespace v2rayN.Handler
configCopy.index = index; configCopy.index = index;
var inbound = new Inbounds(); var inbound = new Inbounds
inbound.listen = Global.Loopback; {
inbound.port = httpPort + index; listen = Global.Loopback,
inbound.protocol = Global.InboundHttp; port = httpPort + index,
protocol = Global.InboundHttp
};
inbound.tag = Global.InboundHttp + inbound.port.ToString(); inbound.tag = Global.InboundHttp + inbound.port.ToString();
v2rayConfig.inbounds.Add(inbound); v2rayConfig.inbounds.Add(inbound);
@ -1448,10 +1483,12 @@ namespace v2rayN.Handler
v2rayConfigCopy.outbounds[0].tag = Global.agentTag + inbound.port.ToString(); v2rayConfigCopy.outbounds[0].tag = Global.agentTag + inbound.port.ToString();
v2rayConfig.outbounds.Add(v2rayConfigCopy.outbounds[0]); v2rayConfig.outbounds.Add(v2rayConfigCopy.outbounds[0]);
var rule = new Mode.RulesItem(); var rule = new Mode.RulesItem
rule.inboundTag = new List<string> { inbound.tag }; {
rule.outboundTag = v2rayConfigCopy.outbounds[0].tag; inboundTag = new List<string> { inbound.tag },
rule.type = "field"; outboundTag = v2rayConfigCopy.outbounds[0].tag,
type = "field"
};
v2rayConfig.routing.rules.Add(rule); v2rayConfig.routing.rules.Add(rule);
} }