Skip to content

Commit

Permalink
添加VLESS的mKCP模式
Browse files Browse the repository at this point in the history
  • Loading branch information
proxysu committed Oct 28, 2020
1 parent cf529a2 commit 62a4eb9
Show file tree
Hide file tree
Showing 8 changed files with 165 additions and 57 deletions.
127 changes: 74 additions & 53 deletions ProxySU/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ public class LanguageInfo

public static string proxyType = "V2Ray"; //代理类型标识: V2Ray\TrojanGo\Trojan\NaiveProxy
public static readonly string pwdir = AppDomain.CurrentDomain.BaseDirectory; //执行文件所在目录
public static bool mKCPvlessIsSet = false; //mKCP是否使用VLESS协议
static bool testDomain = false; //设置标识--域名是否需要检测解析,初始化为不需要
static string ipv4 = String.Empty; //保存获取的ipv4地址
static string ipv6 = String.Empty; //保存获取的ipv6地址
Expand Down Expand Up @@ -1475,7 +1476,15 @@ private bool GenerateServerConfigurationV2Ray(SshClient client)
//else if (String.Equals(ReceiveConfigurationParameters[0], "MkcpNone")|| String.Equals(ReceiveConfigurationParameters[0], "mKCP2SRTP")||String.Equals(ReceiveConfigurationParameters[0], "mKCPuTP")|| String.Equals(ReceiveConfigurationParameters[0], "mKCP2WechatVideo")|| String.Equals(ReceiveConfigurationParameters[0], "mKCP2DTLS")|| String.Equals(ReceiveConfigurationParameters[0], "mKCP2WireGuard"))
else if (ReceiveConfigurationParameters[0].Contains("mKCP") == true)
{
inboundsConfigJson = $"{pwdir}" + @"TemplateConfg\v2ray\server\05_inbounds\mkcp_server_config.json";
if(mKCPvlessIsSet == true)
{
inboundsConfigJson = $"{pwdir}" + @"TemplateConfg\v2ray\server\05_inbounds\vless_mkcp_server_config.json";
}
else
{
inboundsConfigJson = $"{pwdir}" + @"TemplateConfg\v2ray\server\05_inbounds\mkcp_server_config.json";
}

}

// else if (String.Equals(ReceiveConfigurationParameters[0], "QuicNone") || String.Equals(ReceiveConfigurationParameters[0], "QuicSRTP") || String.Equals(ReceiveConfigurationParameters[0], "Quic2uTP") || String.Equals(ReceiveConfigurationParameters[0], "QuicWechatVideo") || String.Equals(ReceiveConfigurationParameters[0], "QuicDTLS") || String.Equals(ReceiveConfigurationParameters[0], "QuicWireGuard"))
Expand Down Expand Up @@ -1817,7 +1826,15 @@ private bool GenerateClientConfigurationV2Ray()
//else if (String.Equals(ReceiveConfigurationParameters[0], "MkcpNone")|| String.Equals(ReceiveConfigurationParameters[0], "mKCP2SRTP")||String.Equals(ReceiveConfigurationParameters[0], "mKCPuTP")|| String.Equals(ReceiveConfigurationParameters[0], "mKCP2WechatVideo")|| String.Equals(ReceiveConfigurationParameters[0], "mKCP2DTLS")|| String.Equals(ReceiveConfigurationParameters[0], "mKCP2WireGuard"))
else if (ReceiveConfigurationParameters[0].Contains("mKCP") == true)
{
outboundsConfigJson = $"{pwdir}" + @"TemplateConfg\v2ray\client\06_outbounds\mkcp_client_config.json";
if (mKCPvlessIsSet == true)
{
outboundsConfigJson = $"{pwdir}" + @"TemplateConfg\v2ray\client\06_outbounds\vless_mkcp_client_config.json";
}
else
{
outboundsConfigJson = $"{pwdir}" + @"TemplateConfg\v2ray\client\06_outbounds\mkcp_client_config.json";
}

}
// else if (String.Equals(ReceiveConfigurationParameters[0], "QuicNone") || String.Equals(ReceiveConfigurationParameters[0], "QuicSRTP") || String.Equals(ReceiveConfigurationParameters[0], "Quic2uTP") || String.Equals(ReceiveConfigurationParameters[0], "QuicWechatVideo") || String.Equals(ReceiveConfigurationParameters[0], "QuicDTLS") || String.Equals(ReceiveConfigurationParameters[0], "QuicWireGuard"))
else if (ReceiveConfigurationParameters[0].Contains("Quic") == true)
Expand Down Expand Up @@ -6902,59 +6919,63 @@ private void ButtonWebBrowserForwardFreeWallURL_Click(object sender, RoutedEvent
#region 测试用代码
private void Button_Click(object sender, RoutedEventArgs e)
{
proxyType = "V2Ray";
ResultClientInformation resultClientInformation = new ResultClientInformation();
resultClientInformation.ShowDialog();
return;
//string pwdir = AppDomain.CurrentDomain.BaseDirectory;
//MessageBox.Show(pwdir);
ConnectionInfo connectionInfo = GenerateConnectionInfo();
if (connectionInfo == null)
{
//****** "远程主机连接信息有误,请检查!" ******
MessageBox.Show(Application.Current.FindResource("MessageBoxShow_ErrorHostConnection").ToString());
return;
}
using (var client = new SshClient(connectionInfo))
{
client.Connect();
if (client.IsConnected == true)
{
//******"主机登录成功"******
SetUpProgressBarProcessing(3);
currentStatus = Application.Current.FindResource("DisplayInstallInfo_LoginSuccessful").ToString();
MainWindowsShowInfo(currentStatus);

}
SetUpNat64(client, true);
//FilterFastestIP(client);
//string cmdErr = client.RunCommand(@"aaa ee").Error;
//MessageBox.Show(cmdErr);
//SshCommand cmdResult = client.RunCommand(@"pwd");
//string result = cmdResult.Result;
//MessageBox.Show("result:" + result);
//string error = cmdResult.Error;
//MessageBox.Show("err:" + error);

//int cmdExitStatus = cmdResult.ExitStatus;
//MessageBox.Show("cmdExitStatus:" + cmdExitStatus.ToString());

//SshCommand cmdResultCat = client.RunCommand(@"cat tt.t");
//string resultCat = cmdResultCat.Result;
//MessageBox.Show("resultCat:" + resultCat);
//string errorCat = cmdResultCat.Error;
//MessageBox.Show("errCat:" + errorCat);

//cmdExitStatus = cmdResultCat.ExitStatus;
//MessageBox.Show("cmdExitStatus:" + cmdExitStatus.ToString());

//SoftInstalledSuccessOrFail(client, "v2ray", @"/usr/local/bin/v2ray");
//CaddyInstall(client);
//if (client.IsConnected == true)
//{
// MessageBox.Show("Connected");
//}
//if (client.IsConnected == false)
//{
// MessageBox.Show("disConnected");
//}
}
//ConnectionInfo connectionInfo = GenerateConnectionInfo();
//if (connectionInfo == null)
//{
// //****** "远程主机连接信息有误,请检查!" ******
// MessageBox.Show(Application.Current.FindResource("MessageBoxShow_ErrorHostConnection").ToString());
// return;
//}
//using (var client = new SshClient(connectionInfo))
//{
// client.Connect();
// if (client.IsConnected == true)
// {
// //******"主机登录成功"******
// SetUpProgressBarProcessing(3);
// currentStatus = Application.Current.FindResource("DisplayInstallInfo_LoginSuccessful").ToString();
// MainWindowsShowInfo(currentStatus);

// }
// SetUpNat64(client, true);
//FilterFastestIP(client);
//string cmdErr = client.RunCommand(@"aaa ee").Error;
//MessageBox.Show(cmdErr);
//SshCommand cmdResult = client.RunCommand(@"pwd");
//string result = cmdResult.Result;
//MessageBox.Show("result:" + result);
//string error = cmdResult.Error;
//MessageBox.Show("err:" + error);

//int cmdExitStatus = cmdResult.ExitStatus;
//MessageBox.Show("cmdExitStatus:" + cmdExitStatus.ToString());

//SshCommand cmdResultCat = client.RunCommand(@"cat tt.t");
//string resultCat = cmdResultCat.Result;
//MessageBox.Show("resultCat:" + resultCat);
//string errorCat = cmdResultCat.Error;
//MessageBox.Show("errCat:" + errorCat);

//cmdExitStatus = cmdResultCat.ExitStatus;
//MessageBox.Show("cmdExitStatus:" + cmdExitStatus.ToString());

//SoftInstalledSuccessOrFail(client, "v2ray", @"/usr/local/bin/v2ray");
//CaddyInstall(client);
//if (client.IsConnected == true)
//{
// MessageBox.Show("Connected");
//}
//if (client.IsConnected == false)
//{
// MessageBox.Show("disConnected");
//}
// }
}

private string CaddyInstallTest(SshClient client)
Expand Down
4 changes: 2 additions & 2 deletions ProxySU/ResultClientInformation.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
<RowDefinition Height="0.12*"></RowDefinition>
</Grid.RowDefinitions>
<!-- V2Ray客户端配置参数 -->
<GroupBox Header="{DynamicResource GroupBoxHeaderClientParameter}" x:Name="GroupBoxV2rayClient" Visibility="Collapsed" Grid.Row="0">
<GroupBox Header="{DynamicResource GroupBoxHeaderClientParameter}" x:Name="GroupBoxV2rayClient" Visibility="Visible" Grid.Row="0">
<Grid >
<Grid.ColumnDefinitions>
<ColumnDefinition Width="0.5*"></ColumnDefinition>
Expand Down Expand Up @@ -93,7 +93,7 @@
</Grid>
</GroupBox>
<!-- Trojan-Go客户端配置参数 -->
<GroupBox Header="{DynamicResource GroupBoxHeaderClientParameter}" x:Name="GroupBoxTrojanGoClient" Visibility="Visible" Grid.Row="0">
<GroupBox Header="{DynamicResource GroupBoxHeaderClientParameter}" x:Name="GroupBoxTrojanGoClient" Visibility="Collapsed" Grid.Row="0">
<Grid >
<Grid.ColumnDefinitions>
<ColumnDefinition Width="0.5*"></ColumnDefinition>
Expand Down
10 changes: 9 additions & 1 deletion ProxySU/ResultClientInformation.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,13 @@ public ResultClientInformation()
}
else if (MainWindow.ReceiveConfigurationParameters[0].Contains("mKCP") == true)
{
if(MainWindow.mKCPvlessIsSet == true)
{
TextBlockVmessOrVless.Text = Application.Current.FindResource("TabItemHeaderV2RayVlessProtocol").ToString();
TextBoxEncryption.Text = "none";
HideAlterId();
HideGroupBoxClientQRandURL();
}
if (String.Equals(MainWindow.ReceiveConfigurationParameters[0], "mKCPNone") == true)
{
TextBoxCamouflageType.Text = "none";
Expand Down Expand Up @@ -967,7 +974,8 @@ private void GenerateV2rayShareQRcodeAndBase64Url()
if (String.Equals(MainWindow.ReceiveConfigurationParameters[0], "VlessXtlsTcp") == false
&& String.Equals(MainWindow.ReceiveConfigurationParameters[0], "VlessTcpTlsWeb") == false
&& String.Equals(MainWindow.ReceiveConfigurationParameters[0], "VlessWebSocketTlsWeb") == false
&& String.Equals(MainWindow.ReceiveConfigurationParameters[0], "VlessHttp2Web") == false)
&& String.Equals(MainWindow.ReceiveConfigurationParameters[0], "VlessHttp2Web") == false
&& MainWindow.mKCPvlessIsSet == false)
{
using (StreamWriter sw = new StreamWriter($"{configSavePath}\\url.txt"))
{
Expand Down
10 changes: 9 additions & 1 deletion ProxySU/V2RayTemplateWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,15 @@
<RowDefinition></RowDefinition>
<RowDefinition></RowDefinition>
</Grid.RowDefinitions>
<RadioButton x:Name="RadioButtonMkcpNone" Content="{DynamicResource RadioButtonV2RayMkcpNone}" GroupName="TemplateGroup" Grid.Column="0" Grid.Row="1" Checked="RadioButtonMkcp_Checked" HorizontalAlignment="Left" VerticalAlignment="Center"></RadioButton>
<Grid Grid.Column="1" Grid.ColumnSpan="2">
<Grid.ColumnDefinitions>
<ColumnDefinition></ColumnDefinition>
<ColumnDefinition></ColumnDefinition>
</Grid.ColumnDefinitions>
<RadioButton x:Name="RadioButtonVMESSmKCP" Content="VMESS" Grid.Column="0" HorizontalAlignment="Center" VerticalAlignment="Center"></RadioButton>
<RadioButton x:Name="RadioButtonVLESSmKCP" Content="VLESS" Grid.Column="1" HorizontalAlignment="Center" VerticalAlignment="Center"></RadioButton>
</Grid>
<RadioButton x:Name="RadioButtonMkcpNone" Content="{DynamicResource RadioButtonV2RayMkcpNone}" GroupName="TemplateGroup" Grid.Column="0" Grid.Row="1" Checked="RadioButtonMkcp_Checked" HorizontalAlignment="Left" VerticalAlignment="Center"></RadioButton>
<TextBlock Text="{DynamicResource TextBlockV2RayMkcpNoneExplain}" TextWrapping="Wrap" Grid.Column="1" Grid.Row="1" Grid.ColumnSpan="3" HorizontalAlignment="Left" VerticalAlignment="Center"></TextBlock>
<RadioButton x:Name="RadioButton2mKCP2SRTP" Content="mKCP+SRTP" GroupName="TemplateGroup" Grid.Column="0" Grid.Row="2" Checked="RadioButtonMkcp_Checked" HorizontalAlignment="Left" VerticalAlignment="Center"></RadioButton>
<TextBlock Text="{DynamicResource TextBlockV2RayMkcpSRTPExplain}" TextWrapping="Wrap" Grid.Column="1" Grid.Row="2" Grid.ColumnSpan="3" HorizontalAlignment="Left" VerticalAlignment="Center"></TextBlock>
Expand Down
10 changes: 10 additions & 0 deletions ProxySU/V2RayTemplateWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ public WindowTemplateConfiguration()

//隐藏QUIC密钥
FirstQuicHideEncryption();
RadioButtonVMESSmKCP.IsChecked = true;
}
//取消不在当前活动选项卡中的其他所有选项卡中的所有RadioBuuton的选中状态
//代码参考网址:https://blog.csdn.net/weixin_42583999/article/details/103468857
Expand Down Expand Up @@ -557,6 +558,15 @@ private void ButtondDecide_Click(object sender, RoutedEventArgs e)
//传递uuid
MainWindow.ReceiveConfigurationParameters[2] = TextBoxNewUUID.Text.ToString();

if (RadioButtonVLESSmKCP.IsChecked == true)
{
MainWindow.mKCPvlessIsSet = true;
}
else
{
MainWindow.mKCPvlessIsSet = false;
}

if (domainNotEmpty)
{
this.Close();
Expand Down
Binary file modified ProxySU/bin/Beta/Beta.zip
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
{
"outbounds": [
{
"protocol": "vless",
"settings": {
"vnext": [
{
"address": null,
"port": null,
"users": [
{
"id": null,
"encryption": "none"
}
]
}
]
},
"streamSettings": {
"network": "kcp",
"kcpSettings": {
"uplinkCapacity": 100,
"downlinkCapacity": 100,
"congestion": true,
"header": {
"type": null
},
"seed": null
}
}
}
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
{
"inbounds": [
{
"port": null,
"protocol": "vless",
"settings": {
"clients": [
{
"id": null
}
],
"decryption": "none"
},
"streamSettings": {
"network": "mkcp",
"kcpSettings": {
"uplinkCapacity": 100,
"downlinkCapacity": 100,
"congestion": true,
"header": {
"type": null
},
"seed": null
}
}
}
]
}

0 comments on commit 62a4eb9

Please sign in to comment.