1
0
mirror of https://github.com/proxysu/ProxySU.git synced 2024-11-21 20:56:08 +03:00

add grpc params

This commit is contained in:
autumn 2021-06-29 17:43:48 +08:00
parent 2f0f9fb09d
commit 9923437691
11 changed files with 72 additions and 61 deletions

View File

@ -33,5 +33,13 @@ namespace ProxySuper.Core.Services
{
return DateTime.Now.Ticks.ToString();
}
private static Random random = new Random();
public static string RandomString(int length)
{
const string chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
return new string(Enumerable.Repeat(chars, length)
.Select(s => s[random.Next(s.Length)]).ToArray());
}
}
}

View File

@ -1,4 +1,5 @@
using Newtonsoft.Json;
using ProxySuper.Core.Services;
using System;
using System.Collections.Generic;
using System.Linq;
@ -21,13 +22,13 @@ namespace ProxySuper.Core.Models.Projects
UUID = guid;
Types = new List<XrayType>();
VLESS_WS_Path = "/vlessws";
VLESS_WS_Path = "/" + Utils.RandomString(6);
VLESS_KCP_Type = "none";
VLESS_KCP_Seed = guid;
VLESS_gRPC_ServiceName = "xray_gRPC";
VLESS_gRPC_ServiceName = "/" + Utils.RandomString(7);
VMESS_WS_Path = "/vmessws";
VMESS_TCP_Path = "/vmesstcp";
VMESS_WS_Path = "/" + Utils.RandomString(8);
VMESS_TCP_Path = "/" + Utils.RandomString(9);
VMESS_KCP_Seed = guid;
VMESS_KCP_Type = "none";

View File

@ -67,7 +67,6 @@
<Compile Include="Converters\ProxyTypeConverter.cs" />
<Compile Include="Converters\VisibleConverter.cs" />
<Compile Include="Helpers\DateTimeUtils.cs" />
<Compile Include="Helpers\Rand.cs" />
<Compile Include="Models\Hosts\Host.cs" />
<Compile Include="Models\Hosts\LocalProxyType.cs" />
<Compile Include="Models\Hosts\LoginSecretType.cs" />

View File

@ -29,6 +29,7 @@ namespace ProxySuper.Core.Services
public static int VLESS_WS_Port = 1111;
public static int VLESS_H2_Port = 1112;
public static int VLESS_mKCP_Port = 1113;
public static int VLESS_gRPC_Port = 1114;
public static int VMESS_TCP_Port = 1210;
public static int VMESS_WS_Port = 1211;
@ -93,6 +94,18 @@ namespace ProxySuper.Core.Services
caddyStr = caddyStr.Replace("##reverse_proxy##", "");
}
if (parameters.Types.Contains(XrayType.VLESS_gRPC))
{
var grpcCaddyfile = File.ReadAllText(Path.Combine(CaddyFileDir, "grpc.caddyfile"));
grpcCaddyfile = grpcCaddyfile.Replace("##domain##", parameters.Domain);
grpcCaddyfile = grpcCaddyfile.Replace("##port##", parameters.VLESS_gRPC_Port.ToString());
grpcCaddyfile = grpcCaddyfile.Replace("##local_port##", VLESS_gRPC_Port.ToString());
grpcCaddyfile = grpcCaddyfile.Replace("##path##", parameters.VLESS_gRPC_ServiceName);
caddyStr += "\n";
caddyStr += grpcCaddyfile;
}
return caddyStr;
}
@ -126,7 +139,7 @@ namespace ProxySuper.Core.Services
if (parameters.Types.Contains(XrayType.VLESS_gRPC))
{
var gRPCInBound = GetBound("VLESS_gRPC.json");
gRPCInBound.port = parameters.VLESS_gRPC_Port;
gRPCInBound.port = VLESS_gRPC_Port;
gRPCInBound.settings.clients[0].id = parameters.UUID;
gRPCInBound.streamSettings.grpcSettings.serviceName = parameters.VLESS_gRPC_ServiceName;
xrayConfig.inbounds.Add(JToken.FromObject(gRPCInBound));

View File

@ -42,6 +42,14 @@
<Label Content="{DynamicResource VlessKcpDesc}" FontSize="13" Foreground="LimeGreen" />
</CheckBox>
<!--gRPC-->
<CheckBox Margin="0,15,0,0"
VerticalContentAlignment="Center"
Foreground="LimeGreen"
IsChecked="{Binding Path=Checked_VLESS_gRPC}">
<Label Content="VLESS gRPC&#x0a;基于http2多路复用。" FontSize="13" Foreground="LimeGreen" />
</CheckBox>
<!--TCP-->
<!--<CheckBox Content="VMESS over TCP with TLS&#x0a;不推荐"
Margin="0,15,0,0"
@ -78,13 +86,6 @@
<Label Content="{DynamicResource TrojanDesc}" FontSize="13" Foreground="CadetBlue" />
</CheckBox>
<!--gRPC-->
<!--<CheckBox Content="VLESS gRPC&#x0a;基于http2多路复用。"
Margin="0,15,0,0"
Grid.Column="0"
Style="{StaticResource MahApps.Styles.CheckBox}"
IsChecked="{Binding Path=Checked_VLESS_gRPC}"/>-->
</StackPanel>
<!--************************** 参数 **************************-->
@ -168,21 +169,28 @@
</StackPanel>
<!--gRPC Port-->
<!--<StackPanel Margin="30,15,0,0"
<StackPanel Margin="30,15,0,0"
Orientation="Horizontal"
Visibility="{
Binding Path=Checked_VLESS_gRPC,
Converter={StaticResource VisibleConverter}
}">
<Label Content="gRPC端口" Width="120" Foreground="LimeGreen" />
<TextBox Text="{Binding Path=VLESS_gRPC_Port}" Width="120" />
<Label Content="{DynamicResource VlessRPCPort}" Width="120" Foreground="LimeGreen" />
<TextBox Text="{Binding Path=VLESS_gRPC_Port}" Width="200" />
</StackPanel>
<Label Content="服务器" Width="120" Margin="10,0,0,0" Foreground="LimeGreen" />
<TextBox Text="{Binding Path=VLESS_gRPC_ServiceName}" Width="120" />
</StackPanel>-->
<StackPanel Margin="30,15,0,0"
Orientation="Horizontal"
Visibility="{
Binding Path=Checked_VLESS_gRPC,
Converter={StaticResource VisibleConverter}
}">
<Label Content="{DynamicResource VlessRPCName}" Width="120" Foreground="LimeGreen" />
<TextBox Text="{Binding Path=VLESS_gRPC_ServiceName}" Width="200" />
</StackPanel>
<!--Tcp Path-->
<!--<StackPanel Margin="30,15,0,0"
<!--Tcp Path
<StackPanel Margin="30,15,0,0"
Orientation="Horizontal"
Visibility="{
Binding Path=Checked_VMESS_TCP,

View File

@ -5,38 +5,7 @@
  <AllowedReferenceRelatedFileExtensions>
    <!-- 阻止默认的 XML 和 PDB 文件复制到 RELEASE 的输出目录. 只有*.allowedextension 扩展名的文件可以被包含, 当然这个扩展的文件并不存在.-->
    .allowedextension
  </AllowedReferenceRelatedFileExtensions>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{B083EBFD-2925-46C9-8B00-E2C1300CEBA1}</ProjectGuid>
<OutputType>WinExe</OutputType>
<RootNamespace>ProxySuper.WPF</RootNamespace>
<AssemblyName>ProxySuper.WPF</AssemblyName>
<TargetFrameworkVersion>v4.7.2</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<ProjectTypeGuids>{60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
<WarningLevel>4</WarningLevel>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
<Deterministic>true</Deterministic>
<NuGetPackageImportStamp>
</NuGetPackageImportStamp>
<IsWebBootstrapper>false</IsWebBootstrapper>
<TargetFrameworkProfile />
<PublishUrl>publish\</PublishUrl>
<Install>true</Install>
<InstallFrom>Disk</InstallFrom>
<UpdateEnabled>false</UpdateEnabled>
<UpdateMode>Foreground</UpdateMode>
<UpdateInterval>7</UpdateInterval>
<UpdateIntervalUnits>Days</UpdateIntervalUnits>
<UpdatePeriodically>false</UpdatePeriodically>
<UpdateRequired>false</UpdateRequired>
<MapFileExtensions>true</MapFileExtensions>
<ApplicationRevision>0</ApplicationRevision>
<ApplicationVersion>1.0.0.%2a</ApplicationVersion>
<UseApplicationTrust>false</UseApplicationTrust>
<BootstrapperEnabled>true</BootstrapperEnabled>
</PropertyGroup>
  </AllowedReferenceRelatedFileExtensions><Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration><Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform><ProjectGuid>{B083EBFD-2925-46C9-8B00-E2C1300CEBA1}</ProjectGuid><OutputType>WinExe</OutputType><RootNamespace>ProxySuper.WPF</RootNamespace><AssemblyName>ProxySuper.WPF</AssemblyName><TargetFrameworkVersion>v4.7.2</TargetFrameworkVersion><FileAlignment>512</FileAlignment><ProjectTypeGuids>{60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids><WarningLevel>4</WarningLevel><AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects><Deterministic>true</Deterministic><NuGetPackageImportStamp></NuGetPackageImportStamp><IsWebBootstrapper>false</IsWebBootstrapper><TargetFrameworkProfile /><PublishUrl>publish\</PublishUrl><Install>true</Install><InstallFrom>Disk</InstallFrom><UpdateEnabled>false</UpdateEnabled><UpdateMode>Foreground</UpdateMode><UpdateInterval>7</UpdateInterval><UpdateIntervalUnits>Days</UpdateIntervalUnits><UpdatePeriodically>false</UpdatePeriodically><UpdateRequired>false</UpdateRequired><MapFileExtensions>true</MapFileExtensions><ApplicationRevision>0</ApplicationRevision><ApplicationVersion>1.0.0.%2a</ApplicationVersion><UseApplicationTrust>false</UseApplicationTrust><BootstrapperEnabled>true</BootstrapperEnabled></PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugSymbols>true</DebugSymbols>
@ -334,6 +303,9 @@
<None Include="Templates\xray\caddy\base.caddyfile">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="Templates\xray\caddy\grpc.caddyfile">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="Templates\xray\client\00_log\00_log.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>

View File

@ -79,6 +79,8 @@
<sys:String x:Key="VlessKcpSeed">VLESS KCP Seed</sys:String>
<sys:String x:Key="VlessKcpType">VLESS KCP Type</sys:String>
<sys:String x:Key="VlessKcpPort">VLESS KCP Port</sys:String>
<sys:String x:Key="VlessRPCName">gRPC Service Name</sys:String>
<sys:String x:Key="VlessRPCPort">gRPC Port</sys:String>
<sys:String x:Key="VmessWsPath">VMESS WS Path</sys:String>
<sys:String x:Key="VmessKcpSeed">VMESS KCP Seed</sys:String>
<sys:String x:Key="VmessKcpType">VMESS KCP Type</sys:String>

View File

@ -78,6 +78,8 @@
<sys:String x:Key="VlessKcpSeed">VLESS KCP Seed</sys:String>
<sys:String x:Key="VlessKcpType">VLESS KCP偽裝</sys:String>
<sys:String x:Key="VlessKcpPort">VLESS KCP端口</sys:String>
<sys:String x:Key="VlessRPCName">gRPC路徑</sys:String>
<sys:String x:Key="VlessRPCPort">gRPC端口</sys:String>
<sys:String x:Key="VmessWsPath">VMESS WS路徑</sys:String>
<sys:String x:Key="VmessKcpSeed">VMESS KCP Seed</sys:String>
<sys:String x:Key="VmessKcpType">VMESS KCP偽裝</sys:String>

View File

@ -79,6 +79,8 @@
<sys:String x:Key="VlessKcpSeed">VLESS KCP Seed</sys:String>
<sys:String x:Key="VlessKcpType">VLESS KCP伪装</sys:String>
<sys:String x:Key="VlessKcpPort">VLESS KCP端口</sys:String>
<sys:String x:Key="VlessRPCName">gRPC路径</sys:String>
<sys:String x:Key="VlessRPCPort">gRPC端口</sys:String>
<sys:String x:Key="VmessWsPath">VMESS WS路径</sys:String>
<sys:String x:Key="VmessKcpSeed">VMESS KCP Seed</sys:String>
<sys:String x:Key="VmessKcpType">VMESS KCP伪装</sys:String>

View File

@ -0,0 +1,10 @@
##domain##:##port## {
@grpc {
protocol grpc
path ##path##
}
reverse_proxy @grpc h2c://127.0.0.1:##local_port##
root * /var/www
file_server
}

View File

@ -1,5 +1,5 @@
{
"port": 2002,
"port": 2003,
"listen": "127.0.0.1",
"protocol": "vless",
"settings": {
@ -13,13 +13,7 @@
"streamSettings": {
"network": "grpc",
"grpcSettings": {
"serviceName": "",
"certificates": [
{
"certificateFile": "/usr/local/etc/xray/ssl/xray_ssl.crt",
"keyFile": "/usr/local/etc/xray/ssl/xray_ssl.key"
}
]
"serviceName": ""
}
}
}