mirror of
https://github.com/2dust/v2rayN.git
synced 2025-08-24 03:46:55 +00:00
添加代理转发设置
This commit is contained in:
parent
07bdcb5491
commit
5883e90bee
8 changed files with 3441 additions and 2275 deletions
31
v2rayN/v2rayN/Forms/OptionSettingForm.Designer.cs
generated
31
v2rayN/v2rayN/Forms/OptionSettingForm.Designer.cs
generated
|
@ -1,4 +1,6 @@
|
|||
namespace v2rayN.Forms
|
||||
using v2rayN.Handler;
|
||||
|
||||
namespace v2rayN.Forms
|
||||
{
|
||||
partial class OptionSettingForm
|
||||
{
|
||||
|
@ -33,6 +35,8 @@
|
|||
this.tabControl1 = new System.Windows.Forms.TabControl();
|
||||
this.tabPage1 = new System.Windows.Forms.TabPage();
|
||||
this.groupBox1 = new System.Windows.Forms.GroupBox();
|
||||
this.label12 = new System.Windows.Forms.Label();
|
||||
this.TransitList = new System.Windows.Forms.ComboBox();
|
||||
this.label16 = new System.Windows.Forms.Label();
|
||||
this.cmblistenerType = new System.Windows.Forms.ComboBox();
|
||||
this.chksniffingEnabled2 = new System.Windows.Forms.CheckBox();
|
||||
|
@ -99,6 +103,7 @@
|
|||
this.panel2 = new System.Windows.Forms.Panel();
|
||||
this.btnOK = new System.Windows.Forms.Button();
|
||||
this.panel1 = new System.Windows.Forms.Panel();
|
||||
this.chktransitEnabled = new System.Windows.Forms.CheckBox();
|
||||
this.tabControl1.SuspendLayout();
|
||||
this.tabPage1.SuspendLayout();
|
||||
this.groupBox1.SuspendLayout();
|
||||
|
@ -145,6 +150,9 @@
|
|||
//
|
||||
// groupBox1
|
||||
//
|
||||
this.groupBox1.Controls.Add(this.chktransitEnabled);
|
||||
this.groupBox1.Controls.Add(this.label12);
|
||||
this.groupBox1.Controls.Add(this.TransitList);
|
||||
this.groupBox1.Controls.Add(this.label16);
|
||||
this.groupBox1.Controls.Add(this.cmblistenerType);
|
||||
this.groupBox1.Controls.Add(this.chksniffingEnabled2);
|
||||
|
@ -169,6 +177,18 @@
|
|||
this.groupBox1.Name = "groupBox1";
|
||||
this.groupBox1.TabStop = false;
|
||||
//
|
||||
// label12
|
||||
//
|
||||
resources.ApplyResources(this.label12, "label12");
|
||||
this.label12.Name = "label12";
|
||||
//
|
||||
// TransitList
|
||||
//
|
||||
this.TransitList.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
|
||||
this.TransitList.FormattingEnabled = true;
|
||||
resources.ApplyResources(this.TransitList, "TransitList");
|
||||
this.TransitList.Name = "TransitList";
|
||||
//
|
||||
// label16
|
||||
//
|
||||
resources.ApplyResources(this.label16, "label16");
|
||||
|
@ -614,6 +634,12 @@
|
|||
resources.ApplyResources(this.panel1, "panel1");
|
||||
this.panel1.Name = "panel1";
|
||||
//
|
||||
// chktransitEnabled
|
||||
//
|
||||
resources.ApplyResources(this.chktransitEnabled, "chktransitEnabled");
|
||||
this.chktransitEnabled.Name = "chktransitEnabled";
|
||||
this.chktransitEnabled.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// OptionSettingForm
|
||||
//
|
||||
resources.ApplyResources(this, "$this");
|
||||
|
@ -725,5 +751,8 @@
|
|||
private System.Windows.Forms.Label label4;
|
||||
private System.Windows.Forms.CheckBox chkKeepOlderDedupl;
|
||||
private System.Windows.Forms.LinkLabel linkLabelRoutingDoc;
|
||||
private System.Windows.Forms.Label label12;
|
||||
private System.Windows.Forms.ComboBox TransitList;
|
||||
private System.Windows.Forms.CheckBox chktransitEnabled;
|
||||
}
|
||||
}
|
|
@ -36,6 +36,23 @@ namespace v2rayN.Forms
|
|||
chklogEnabled.Checked = config.logEnabled;
|
||||
cmbloglevel.Text = config.loglevel;
|
||||
|
||||
//代理转发
|
||||
chktransitEnabled.Checked = config.transitEnabled;
|
||||
ConfigHandler.LoadConfig(ref config);
|
||||
if (config.vmess == null)
|
||||
{
|
||||
TransitList.Items.Add(null);
|
||||
}
|
||||
else
|
||||
{
|
||||
for (int i = 0; i < config.vmess.Count; i++)
|
||||
{
|
||||
TransitList.Items.Add(i.ToString() + ' ' + config.vmess[i].remarks);
|
||||
}
|
||||
}
|
||||
TransitList.Text = config.transitSetting.ToString() + ' ' + config.vmess[config.transitSetting].remarks;
|
||||
|
||||
|
||||
//Mux
|
||||
chkmuxEnabled.Checked = config.muxEnabled;
|
||||
|
||||
|
@ -196,6 +213,11 @@ namespace v2rayN.Forms
|
|||
bool logEnabled = chklogEnabled.Checked;
|
||||
string loglevel = cmbloglevel.Text.TrimEx();
|
||||
|
||||
//代理转发
|
||||
//bool logEnabled = chklogEnabled.Checked;
|
||||
System.Text.RegularExpressions.Match matchNumber = System.Text.RegularExpressions.Regex.Match(TransitList.Text, "(^[0-9]+)");
|
||||
int transitSetting = Convert.ToInt32(matchNumber.Value);
|
||||
|
||||
//Mux
|
||||
bool muxEnabled = chkmuxEnabled.Checked;
|
||||
|
||||
|
@ -257,6 +279,10 @@ namespace v2rayN.Forms
|
|||
config.logEnabled = logEnabled;
|
||||
config.loglevel = loglevel;
|
||||
|
||||
//代理转发
|
||||
config.transitEnabled = chktransitEnabled.Checked;
|
||||
config.transitSetting = transitSetting;
|
||||
|
||||
//Mux
|
||||
config.muxEnabled = muxEnabled;
|
||||
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -188,6 +188,9 @@
|
|||
<data name="chksniffingEnabled2.Text" xml:space="preserve">
|
||||
<value>开启流量探测</value>
|
||||
</data>
|
||||
<data name="chktransitEnabled.Text" xml:space="preserve">
|
||||
<value>代理转发</value>
|
||||
</data>
|
||||
<data name="chkudpEnabled.Size" type="System.Drawing.Size, System.Drawing">
|
||||
<value>66, 16</value>
|
||||
</data>
|
||||
|
|
|
@ -323,9 +323,129 @@ namespace v2rayN.Handler
|
|||
/// <returns></returns>
|
||||
private static int outbound(Config config, ref V2rayConfig v2rayConfig)
|
||||
{
|
||||
int configIndex = config.index;
|
||||
Outbounds outbound;
|
||||
try
|
||||
{
|
||||
Outbounds outbound = v2rayConfig.outbounds[0];
|
||||
if(config.transitEnabled)
|
||||
{
|
||||
config.index = config.transitSetting;
|
||||
outbound = v2rayConfig.outbounds[0];
|
||||
if (config.configType() == (int)EConfigType.Vmess)
|
||||
{
|
||||
VnextItem vnextItem;
|
||||
if (outbound.settings.vnext.Count <= 0)
|
||||
{
|
||||
vnextItem = new VnextItem();
|
||||
outbound.settings.vnext.Add(vnextItem);
|
||||
}
|
||||
else
|
||||
{
|
||||
vnextItem = outbound.settings.vnext[0];
|
||||
}
|
||||
//远程服务器地址和端口
|
||||
vnextItem.address = config.address();
|
||||
vnextItem.port = config.port();
|
||||
|
||||
UsersItem usersItem;
|
||||
if (vnextItem.users.Count <= 0)
|
||||
{
|
||||
usersItem = new UsersItem();
|
||||
vnextItem.users.Add(usersItem);
|
||||
}
|
||||
else
|
||||
{
|
||||
usersItem = vnextItem.users[0];
|
||||
}
|
||||
//远程服务器用户ID
|
||||
usersItem.id = config.id();
|
||||
usersItem.alterId = config.alterId();
|
||||
usersItem.email = Global.userEMail;
|
||||
usersItem.security = config.security();
|
||||
|
||||
//Mux
|
||||
outbound.mux.enabled = config.muxEnabled;
|
||||
outbound.mux.concurrency = config.muxEnabled ? 8 : -1;
|
||||
|
||||
outbound.protocol = "vmess";
|
||||
outbound.settings.servers = null;
|
||||
}
|
||||
else if (config.configType() == (int)EConfigType.Shadowsocks)
|
||||
{
|
||||
ServersItem serversItem;
|
||||
if (outbound.settings.servers.Count <= 0)
|
||||
{
|
||||
serversItem = new ServersItem();
|
||||
outbound.settings.servers.Add(serversItem);
|
||||
}
|
||||
else
|
||||
{
|
||||
serversItem = outbound.settings.servers[0];
|
||||
}
|
||||
//远程服务器地址和端口
|
||||
serversItem.address = config.address();
|
||||
serversItem.port = config.port();
|
||||
serversItem.password = config.id();
|
||||
serversItem.method = config.security();
|
||||
|
||||
serversItem.ota = false;
|
||||
serversItem.level = 1;
|
||||
|
||||
outbound.mux.enabled = false;
|
||||
outbound.mux.concurrency = -1;
|
||||
|
||||
|
||||
outbound.protocol = "shadowsocks";
|
||||
outbound.settings.vnext = null;
|
||||
}
|
||||
else if (config.configType() == (int)EConfigType.Socks)
|
||||
{
|
||||
ServersItem serversItem;
|
||||
if (outbound.settings.servers.Count <= 0)
|
||||
{
|
||||
serversItem = new ServersItem();
|
||||
outbound.settings.servers.Add(serversItem);
|
||||
}
|
||||
else
|
||||
{
|
||||
serversItem = outbound.settings.servers[0];
|
||||
}
|
||||
//远程服务器地址和端口
|
||||
serversItem.address = config.address();
|
||||
serversItem.port = config.port();
|
||||
serversItem.method = null;
|
||||
serversItem.password = null;
|
||||
|
||||
if (!Utils.IsNullOrEmpty(config.security())
|
||||
&& !Utils.IsNullOrEmpty(config.id()))
|
||||
{
|
||||
SocksUsersItem socksUsersItem = new SocksUsersItem
|
||||
{
|
||||
user = config.security(),
|
||||
pass = config.id(),
|
||||
level = 1
|
||||
};
|
||||
|
||||
serversItem.users = new List<SocksUsersItem>() { socksUsersItem };
|
||||
}
|
||||
|
||||
outbound.mux.enabled = false;
|
||||
outbound.mux.concurrency = -1;
|
||||
|
||||
outbound.protocol = "socks";
|
||||
outbound.settings.vnext = null;
|
||||
}
|
||||
|
||||
outbound = v2rayConfig.outbounds[1];
|
||||
config.index = configIndex;
|
||||
}
|
||||
else
|
||||
{
|
||||
v2rayConfig.outbounds.RemoveAt(0);
|
||||
outbound = v2rayConfig.outbounds[0];
|
||||
outbound.tag = "proxy";
|
||||
}
|
||||
|
||||
if (config.configType() == (int)EConfigType.Vmess)
|
||||
{
|
||||
VnextItem vnextItem;
|
||||
|
|
|
@ -36,6 +36,22 @@ namespace v2rayN.Mode
|
|||
get; set;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 允许代理转发
|
||||
/// </summary>
|
||||
public bool transitEnabled
|
||||
{
|
||||
get; set;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 日志等级
|
||||
/// </summary>
|
||||
public int transitSetting
|
||||
{
|
||||
get; set;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 活动配置序号
|
||||
/// </summary>
|
||||
|
|
|
@ -187,6 +187,8 @@ namespace v2rayN.Mode
|
|||
///
|
||||
/// </summary>
|
||||
public Mux mux { get; set; }
|
||||
|
||||
public ProxySettings proxySettings { get; set; }
|
||||
}
|
||||
|
||||
public class Outboundsettings
|
||||
|
@ -517,4 +519,12 @@ namespace v2rayN.Mode
|
|||
public Header header { get; set; }
|
||||
}
|
||||
|
||||
public class ProxySettings
|
||||
{
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public string tag { get; set; }
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,85 +1,129 @@
|
|||
{
|
||||
"log": {
|
||||
"access": "",
|
||||
"error": "",
|
||||
"loglevel": "error"
|
||||
},
|
||||
"log": {
|
||||
"access": "Vaccess.log",
|
||||
"error": "Verror.log",
|
||||
"loglevel": "warning"
|
||||
},
|
||||
"inbounds": [
|
||||
{
|
||||
"tag": "proxy",
|
||||
"port": 10808,
|
||||
"protocol": "socks",
|
||||
"listen": "127.0.0.1",
|
||||
"settings": {
|
||||
"auth": "noauth",
|
||||
"udp": true
|
||||
},
|
||||
"sniffing": {
|
||||
"enabled": true,
|
||||
"destOverride": [
|
||||
"http",
|
||||
"tls"
|
||||
]
|
||||
}
|
||||
}
|
||||
],
|
||||
"outbounds": [{
|
||||
"tag": "proxy",
|
||||
"protocol": "vmess",
|
||||
"settings": {
|
||||
"vnext": [{
|
||||
"address": "v2ray.cool",
|
||||
"port": 10086,
|
||||
"users": [{
|
||||
"id": "a3482e88-686a-4a58-8126-99c9df64b7bf",
|
||||
"alterId": 64,
|
||||
"security": "auto"
|
||||
}]
|
||||
}],
|
||||
"servers": [{
|
||||
"address": "v2ray.cool",
|
||||
"method": "chacha20",
|
||||
"ota": false,
|
||||
"password": "123456",
|
||||
"port": 10086,
|
||||
"level": 1
|
||||
}]
|
||||
},
|
||||
"streamSettings": {
|
||||
"network": "tcp"
|
||||
},
|
||||
"mux": {
|
||||
"enabled": false
|
||||
}
|
||||
},
|
||||
{
|
||||
"protocol": "freedom",
|
||||
"settings": {},
|
||||
"tag": "direct"
|
||||
},
|
||||
{
|
||||
"protocol": "blackhole",
|
||||
"tag": "block",
|
||||
"settings": {
|
||||
"response": {
|
||||
"type": "http"
|
||||
}
|
||||
}
|
||||
}
|
||||
],
|
||||
"routing": {
|
||||
"domainStrategy": "IPIfNonMatch",
|
||||
"rules": [
|
||||
{
|
||||
"inboundTag": ["api"],
|
||||
"outboundTag": "api",
|
||||
"type": "field"
|
||||
"log": {
|
||||
"access": "",
|
||||
"error": "",
|
||||
"loglevel": "error"
|
||||
},
|
||||
"log": {
|
||||
"access": "Vaccess.log",
|
||||
"error": "Verror.log",
|
||||
"loglevel": "warning"
|
||||
},
|
||||
"inbounds": [
|
||||
{
|
||||
"tag": "proxy",
|
||||
"port": 10808,
|
||||
"protocol": "socks",
|
||||
"listen": "127.0.0.1",
|
||||
"settings": {
|
||||
"auth": "noauth",
|
||||
"udp": true
|
||||
},
|
||||
"sniffing": {
|
||||
"enabled": true,
|
||||
"destOverride": [
|
||||
"http",
|
||||
"tls"
|
||||
]
|
||||
}
|
||||
}
|
||||
],
|
||||
"outbounds": [
|
||||
{
|
||||
"tag": "proxy",
|
||||
"protocol": "vmess",
|
||||
"settings": {
|
||||
"vnext": [
|
||||
{
|
||||
"address": "v2ray.cool",
|
||||
"port": 10086,
|
||||
"users": [
|
||||
{
|
||||
"id": "a3482e88-686a-4a58-8126-99c9df64b7bf",
|
||||
"alterId": 64,
|
||||
"security": "auto"
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"servers": [
|
||||
{
|
||||
"address": "v2ray.cool",
|
||||
"method": "chacha20",
|
||||
"ota": false,
|
||||
"password": "123456",
|
||||
"port": 10086,
|
||||
"level": 1
|
||||
}
|
||||
]
|
||||
},
|
||||
"proxySettings": {
|
||||
"tag": "transit"
|
||||
},
|
||||
"mux": {
|
||||
"enabled": false
|
||||
}
|
||||
},
|
||||
{
|
||||
"tag": "transit",
|
||||
"protocol": "vmess",
|
||||
"settings": {
|
||||
"vnext": [
|
||||
{
|
||||
"address": "v2ray.cool",
|
||||
"port": 10086,
|
||||
"users": [
|
||||
{
|
||||
"id": "a3482e88-686a-4a58-8126-99c9df64b7bf",
|
||||
"alterId": 64,
|
||||
"security": "auto"
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"servers": [
|
||||
{
|
||||
"address": "v2ray.cool",
|
||||
"method": "chacha20",
|
||||
"ota": false,
|
||||
"password": "123456",
|
||||
"port": 10086,
|
||||
"level": 1
|
||||
}
|
||||
]
|
||||
},
|
||||
"streamSettings": {
|
||||
"network": "tcp"
|
||||
},
|
||||
"mux": {
|
||||
"enabled": false
|
||||
}
|
||||
},
|
||||
{
|
||||
"protocol": "freedom",
|
||||
"settings": {},
|
||||
"tag": "direct"
|
||||
},
|
||||
{
|
||||
"protocol": "blackhole",
|
||||
"tag": "block",
|
||||
"settings": {
|
||||
"response": {
|
||||
"type": "http"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
],
|
||||
"routing": {
|
||||
"domainStrategy": "IPIfNonMatch",
|
||||
"rules": [
|
||||
{
|
||||
"inboundTag": [
|
||||
"api"
|
||||
],
|
||||
"outboundTag": "api",
|
||||
"type": "field"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue