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

save trogan-go

This commit is contained in:
nuxt-autumn 2021-05-23 17:40:06 +08:00
parent b71d1f2bc2
commit 3f75fbf003
5 changed files with 33 additions and 6 deletions

View File

@ -1,4 +1,5 @@
using System;
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
@ -46,6 +47,7 @@ namespace ProxySuper.Core.Models.Projects
/// <summary>
/// 是否开启WebSocket
/// </summary>
[JsonIgnore]
public bool EnableWebSocket
{
get

View File

@ -11,6 +11,18 @@ namespace ProxySuper.Core.Services
{
public class ShareLink
{
public static string BuildTrojanGo(TrojanGoSettings settings)
{
throw new NotImplementedException();
StringBuilder strBuilder = new StringBuilder();
strBuilder.Append("trojan-go://");
strBuilder.Append($"{settings.Password}@{settings.Domain}:{settings.Port}/?");
strBuilder.Append($"sni={settings.Domain}&");
return strBuilder.ToString();
}
public static string Build(XrayType xrayType, XraySettings settings)
{

View File

@ -28,6 +28,13 @@ namespace ProxySuper.Core.Services
settings["password"][0] = parameters.Password;
settings["ssl"]["sni"] = parameters.Domain;
if (parameters.EnableWebSocket)
{
settings["websocket"]["enabled"] = true;
settings["websocket"]["path"] = parameters.WebSocketPath;
settings["websocket"]["host"] = parameters.WebSocketDomain;
}
return JsonConvert.SerializeObject(settings, Formatting.Indented, new JsonSerializerSettings()
{
NullValueHandling = NullValueHandling.Ignore

View File

@ -111,15 +111,17 @@ namespace ProxySuper.Core.ViewModels
if (record.Type == ProjectType.Xray)
{
result = await _navigationService.Navigate<XrayEditorViewModel, Record, Record>(record);
record.Host = result.Host;
record.XraySettings = result.XraySettings;
}
else
if (record.Type == ProjectType.TrojanGo)
{
result = await _navigationService.Navigate<TrojanGoEditorViewModel, Record, Record>(record);
record.Host = result.Host;
record.TrojanGoSettings = result.TrojanGoSettings;
}
if (result == null) return;
record.Host = result.Host;
record.XraySettings = result.XraySettings;
SaveToJson();
}

View File

@ -10,7 +10,11 @@
"ssl": {
"cert": "/usr/local/etc/trojan-go/trojan-go.crt",
"key": "/usr/local/etc/trojan-go/trojan-go.key",
"sni": ""
"sni": "example.com"
},
"websocket": {
"enabled": false,
"path": "/ws",
"host": "example.com"
}
}