1
0
mirror of https://github.com/proxysu/ProxySU.git synced 2024-11-22 05:06:08 +03:00

grpc share link and multi user

This commit is contained in:
autumn 2021-06-30 18:36:27 +08:00
parent fe94157c7b
commit a2b27076b1
8 changed files with 76 additions and 8 deletions

View File

@ -84,6 +84,11 @@ namespace ProxySuper.Core.Models.Projects
/// </summary> /// </summary>
public string UUID { get; set; } public string UUID { get; set; }
/// <summary>
/// 多用户
/// </summary>
public List<string> MulitUUID { get; set; } = new List<string>();
/// <summary> /// <summary>
/// 伪装域名 /// 伪装域名
/// </summary> /// </summary>

View File

@ -168,7 +168,7 @@ namespace ProxySuper.Core.Services
case XrayType.VLESS_gRPC: case XrayType.VLESS_gRPC:
_protocol = "vless"; _protocol = "vless";
_type = "grpc"; _type = "grpc";
_path = settings.VLESS_gRPC_ServiceName; _port = settings.VLESS_gRPC_Port;
_descriptiveText = "vless-gRPC"; _descriptiveText = "vless-gRPC";
break; break;
case XrayType.Trojan_TCP: case XrayType.Trojan_TCP:
@ -198,6 +198,12 @@ namespace ProxySuper.Core.Services
{ {
parametersURL += "&flow=xtls-rprx-direct"; parametersURL += "&flow=xtls-rprx-direct";
} }
if (xrayType == XrayType.VLESS_gRPC)
{
parametersURL += $"&serviceName={settings.VLESS_gRPC_ServiceName}&mode=gun";
}
} }

View File

@ -95,8 +95,31 @@ namespace ProxySuper.Core.Services
return caddyStr; return caddyStr;
} }
private static void SetClients(dynamic bound, List<string> uuidList, bool withXtls = false)
{
bound.settings.clients.Clear();
uuidList.ForEach(id =>
{
object obj;
if (!withXtls)
{
obj = new { id = id };
}
else
{
obj = new { id = id, flow = "xtls-rprx-direct" };
}
bound.settings.clients.Add(JToken.FromObject(obj));
});
}
public static string BuildXrayConfig(XraySettings parameters) public static string BuildXrayConfig(XraySettings parameters)
{ {
var uuidList = parameters.MulitUUID;
uuidList.Insert(0, parameters.UUID);
var xrayConfig = LoadXrayConfig(); var xrayConfig = LoadXrayConfig();
var baseBound = GetBound("VLESS_TCP_XTLS.json"); var baseBound = GetBound("VLESS_TCP_XTLS.json");
baseBound.port = parameters.Port; baseBound.port = parameters.Port;
@ -105,13 +128,13 @@ namespace ProxySuper.Core.Services
dest = FullbackPort dest = FullbackPort
})); }));
xrayConfig.inbounds.Add(baseBound); xrayConfig.inbounds.Add(baseBound);
baseBound.settings.clients[0].id = parameters.UUID; SetClients(baseBound, uuidList, withXtls: true);
if (parameters.Types.Contains(XrayType.VLESS_WS)) if (parameters.Types.Contains(XrayType.VLESS_WS))
{ {
var wsInbound = GetBound("VLESS_WS.json"); var wsInbound = GetBound("VLESS_WS.json");
wsInbound.port = VLESS_WS_Port; wsInbound.port = VLESS_WS_Port;
wsInbound.settings.clients[0].id = parameters.UUID; SetClients(wsInbound, uuidList);
wsInbound.streamSettings.wsSettings.path = parameters.VLESS_WS_Path; wsInbound.streamSettings.wsSettings.path = parameters.VLESS_WS_Path;
baseBound.settings.fallbacks.Add(JToken.FromObject(new baseBound.settings.fallbacks.Add(JToken.FromObject(new
{ {
@ -126,7 +149,7 @@ namespace ProxySuper.Core.Services
{ {
var gRPCInBound = GetBound("VLESS_gRPC.json"); var gRPCInBound = GetBound("VLESS_gRPC.json");
gRPCInBound.port = parameters.VLESS_gRPC_Port; gRPCInBound.port = parameters.VLESS_gRPC_Port;
gRPCInBound.settings.clients[0].id = parameters.UUID; SetClients(gRPCInBound, uuidList);
gRPCInBound.streamSettings.grpcSettings.serviceName = parameters.VLESS_gRPC_ServiceName; gRPCInBound.streamSettings.grpcSettings.serviceName = parameters.VLESS_gRPC_ServiceName;
gRPCInBound.streamSettings.tlsSettings.serverName = parameters.Domain; gRPCInBound.streamSettings.tlsSettings.serverName = parameters.Domain;
xrayConfig.inbounds.Add(JToken.FromObject(gRPCInBound)); xrayConfig.inbounds.Add(JToken.FromObject(gRPCInBound));
@ -136,7 +159,7 @@ namespace ProxySuper.Core.Services
{ {
var kcpBound = GetBound("VLESS_KCP.json"); var kcpBound = GetBound("VLESS_KCP.json");
kcpBound.port = parameters.VLESS_KCP_Port; kcpBound.port = parameters.VLESS_KCP_Port;
kcpBound.settings.clients[0].id = parameters.UUID; SetClients(kcpBound, uuidList);
kcpBound.streamSettings.kcpSettings.header.type = parameters.VLESS_KCP_Type; kcpBound.streamSettings.kcpSettings.header.type = parameters.VLESS_KCP_Type;
kcpBound.streamSettings.kcpSettings.seed = parameters.VLESS_KCP_Seed; kcpBound.streamSettings.kcpSettings.seed = parameters.VLESS_KCP_Seed;
xrayConfig.inbounds.Add(JToken.FromObject(kcpBound)); xrayConfig.inbounds.Add(JToken.FromObject(kcpBound));
@ -146,7 +169,7 @@ namespace ProxySuper.Core.Services
{ {
var mtcpBound = GetBound("VMESS_TCP.json"); var mtcpBound = GetBound("VMESS_TCP.json");
mtcpBound.port = VMESS_TCP_Port; mtcpBound.port = VMESS_TCP_Port;
mtcpBound.settings.clients[0].id = parameters.UUID; SetClients(mtcpBound, uuidList);
mtcpBound.streamSettings.tcpSettings.header.request.path = parameters.VMESS_TCP_Path; mtcpBound.streamSettings.tcpSettings.header.request.path = parameters.VMESS_TCP_Path;
baseBound.settings.fallbacks.Add(JToken.FromObject(new baseBound.settings.fallbacks.Add(JToken.FromObject(new
{ {
@ -161,7 +184,7 @@ namespace ProxySuper.Core.Services
{ {
var mwsBound = GetBound("VMESS_WS.json"); var mwsBound = GetBound("VMESS_WS.json");
mwsBound.port = VMESS_WS_Port; mwsBound.port = VMESS_WS_Port;
mwsBound.settings.clients[0].id = parameters.UUID; SetClients(mwsBound, uuidList);
mwsBound.streamSettings.wsSettings.path = parameters.VMESS_WS_Path; mwsBound.streamSettings.wsSettings.path = parameters.VMESS_WS_Path;
baseBound.settings.fallbacks.Add(JToken.FromObject(new baseBound.settings.fallbacks.Add(JToken.FromObject(new
{ {
@ -176,7 +199,7 @@ namespace ProxySuper.Core.Services
{ {
var kcpBound = GetBound("VMESS_KCP.json"); var kcpBound = GetBound("VMESS_KCP.json");
kcpBound.port = parameters.VMESS_KCP_Port; kcpBound.port = parameters.VMESS_KCP_Port;
kcpBound.settings.clients[0].id = parameters.UUID; SetClients(kcpBound, uuidList);
kcpBound.streamSettings.kcpSettings.header.type = parameters.VMESS_KCP_Type; kcpBound.streamSettings.kcpSettings.header.type = parameters.VMESS_KCP_Type;
kcpBound.streamSettings.kcpSettings.seed = parameters.VMESS_KCP_Seed; kcpBound.streamSettings.kcpSettings.seed = parameters.VMESS_KCP_Seed;
xrayConfig.inbounds.Add(JToken.FromObject(kcpBound)); xrayConfig.inbounds.Add(JToken.FromObject(kcpBound));

View File

@ -110,6 +110,18 @@ namespace ProxySuper.Core.ViewModels
} }
} }
public string MultiUUID
{
get => string.Join(",", Settings.MulitUUID);
set
{
var input = value.Replace('', ',');
var arr = input.Split(',').ToList();
Settings.MulitUUID = arr;
RaisePropertyChanged("MultiUUID");
}
}
public string Domain public string Domain
{ {
get => Settings.Domain; get => Settings.Domain;

View File

@ -319,6 +319,22 @@
<TextBox Text="{Binding Path=Port}" Width="120" /> <TextBox Text="{Binding Path=Port}" Width="120" />
<Label Content="{DynamicResource XrayPortDefault}" Foreground="Red" /> <Label Content="{DynamicResource XrayPortDefault}" Foreground="Red" />
</StackPanel> </StackPanel>
<!--多用户-->
<StackPanel Margin="30,10,0,0"
Orientation="Vertical">
<StackPanel Orientation="Horizontal">
<Label Content="{DynamicResource MultiUser}" Width="120" />
<TextBox Text="{Binding Path=MultiUUID}"
Height="60"
TextWrapping="Wrap"
Width="200" />
</StackPanel>
<StackPanel>
<TextBlock Margin="120,3,0,0" Text="{DynamicResource MultiUserHelp}" />
</StackPanel>
</StackPanel>
</StackPanel> </StackPanel>
</StackPanel> </StackPanel>

View File

@ -76,6 +76,8 @@
<sys:String x:Key="XrayDomain">Address</sys:String> <sys:String x:Key="XrayDomain">Address</sys:String>
<sys:String x:Key="XrayMarkDomain">GuiseHost</sys:String> <sys:String x:Key="XrayMarkDomain">GuiseHost</sys:String>
<sys:String x:Key="XrayUUID">UUID</sys:String> <sys:String x:Key="XrayUUID">UUID</sys:String>
<sys:String x:Key="MultiUser">Multi User</sys:String>
<sys:String x:Key="MultiUserHelp">Multi Id split with ","</sys:String>
<sys:String x:Key="VlessWsPath">VLESS WS Path</sys:String> <sys:String x:Key="VlessWsPath">VLESS WS Path</sys:String>
<sys:String x:Key="VlessKcpSeed">VLESS KCP Seed</sys:String> <sys:String x:Key="VlessKcpSeed">VLESS KCP Seed</sys:String>
<sys:String x:Key="VlessKcpType">VLESS KCP Type</sys:String> <sys:String x:Key="VlessKcpType">VLESS KCP Type</sys:String>

View File

@ -75,6 +75,8 @@
<sys:String x:Key="XrayDomain">域名</sys:String> <sys:String x:Key="XrayDomain">域名</sys:String>
<sys:String x:Key="XrayMarkDomain">偽裝域名</sys:String> <sys:String x:Key="XrayMarkDomain">偽裝域名</sys:String>
<sys:String x:Key="XrayUUID">UUID</sys:String> <sys:String x:Key="XrayUUID">UUID</sys:String>
<sys:String x:Key="MultiUser">多用戶</sys:String>
<sys:String x:Key="MultiUserHelp">多個UUID用“,”分隔</sys:String>
<sys:String x:Key="VlessWsPath">VLESS WS路徑</sys:String> <sys:String x:Key="VlessWsPath">VLESS WS路徑</sys:String>
<sys:String x:Key="VlessKcpSeed">VLESS KCP Seed</sys:String> <sys:String x:Key="VlessKcpSeed">VLESS KCP Seed</sys:String>
<sys:String x:Key="VlessKcpType">VLESS KCP偽裝</sys:String> <sys:String x:Key="VlessKcpType">VLESS KCP偽裝</sys:String>

View File

@ -76,6 +76,8 @@
<sys:String x:Key="XrayDomain">域名</sys:String> <sys:String x:Key="XrayDomain">域名</sys:String>
<sys:String x:Key="XrayMarkDomain">伪装域名</sys:String> <sys:String x:Key="XrayMarkDomain">伪装域名</sys:String>
<sys:String x:Key="XrayUUID">UUID</sys:String> <sys:String x:Key="XrayUUID">UUID</sys:String>
<sys:String x:Key="MultiUser">多用户</sys:String>
<sys:String x:Key="MultiUserHelp">多个UUID用“,”分隔</sys:String>
<sys:String x:Key="VlessWsPath">VLESS WS路径</sys:String> <sys:String x:Key="VlessWsPath">VLESS WS路径</sys:String>
<sys:String x:Key="VlessKcpSeed">VLESS KCP Seed</sys:String> <sys:String x:Key="VlessKcpSeed">VLESS KCP Seed</sys:String>
<sys:String x:Key="VlessKcpType">VLESS KCP伪装</sys:String> <sys:String x:Key="VlessKcpType">VLESS KCP伪装</sys:String>