1
0
mirror of https://github.com/proxysu/ProxySU.git synced 2024-11-25 14:46:08 +03:00

update vmess share link

This commit is contained in:
next-autumn 2021-03-16 17:22:00 +08:00
parent 4d5e15afb3
commit 737deb7ca5
3 changed files with 78 additions and 2 deletions

View File

@ -0,0 +1,23 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ProxySU_Core.Common
{
public class Base64
{
public static string Encode(string plainText)
{
var plainTextBytes = System.Text.Encoding.UTF8.GetBytes(plainText);
return System.Convert.ToBase64String(plainTextBytes);
}
public static string Decode(string base64EncodedData)
{
var base64EncodedBytes = System.Convert.FromBase64String(base64EncodedData);
return System.Text.Encoding.UTF8.GetString(base64EncodedBytes);
}
}
}

View File

@ -117,6 +117,7 @@
<DependentUpon>App.xaml</DependentUpon> <DependentUpon>App.xaml</DependentUpon>
<SubType>Code</SubType> <SubType>Code</SubType>
</Compile> </Compile>
<Compile Include="Common\Base64.cs" />
<Compile Include="Converters\LoginSecretTypeConverter.cs" /> <Compile Include="Converters\LoginSecretTypeConverter.cs" />
<Compile Include="Models\Host.cs" /> <Compile Include="Models\Host.cs" />
<Compile Include="Models\XraySettings.cs" /> <Compile Include="Models\XraySettings.cs" />

View File

@ -1,4 +1,6 @@
using ProxySU_Core.Models; using Newtonsoft.Json;
using ProxySU_Core.Common;
using ProxySU_Core.Models;
using ProxySU_Core.ViewModels.Developers; using ProxySU_Core.ViewModels.Developers;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
@ -262,7 +264,42 @@ namespace ProxySU_Core.ViewModels
public string BuildVmessShareLink(XrayType xrayType) public string BuildVmessShareLink(XrayType xrayType)
{ {
return "vmess://xxxxxx"; var vmess = new Vmess
{
v = "2",
add = settings.Domain,
port = settings.Port.ToString(),
id = settings.UUID,
aid = "0",
net = "",
type = "none",
host = settings.Domain,
path = "",
tls = "tls",
ps = "",
};
switch (xrayType)
{
case XrayType.VMESS_TCP_TLS:
vmess.ps = "vmess-tcp-tls";
vmess.net = "tcp";
vmess.type = "http";
vmess.path = VMESS_TCP_Path;
break;
case XrayType.VMESS_WS_TLS:
vmess.ps = "vmess-ws-tls";
vmess.net = "ws";
vmess.type = "none";
vmess.path = VMESS_WS_Path;
break;
default:
return string.Empty;
}
var base64Url = Base64.Encode(JsonConvert.SerializeObject(vmess));
return $"vmess://" + base64Url;
} }
public string BuildVlessShareLink(XrayType xrayType) public string BuildVlessShareLink(XrayType xrayType)
@ -347,4 +384,19 @@ namespace ProxySU_Core.ViewModels
} }
public class Vmess
{
public string v { get; set; }
public string ps { get; set; }
public string add { get; set; }
public string port { get; set; }
public string id { get; set; }
public string aid { get; set; }
public string net { get; set; }
public string type { get; set; }
public string host { get; set; }
public string path { get; set; }
public string tls { get; set; }
}
} }