1
0
mirror of https://github.com/proxysu/ProxySU.git synced 2024-11-25 14:46: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.Collections.Generic;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
@ -46,6 +47,7 @@ namespace ProxySuper.Core.Models.Projects
/// <summary> /// <summary>
/// 是否开启WebSocket /// 是否开启WebSocket
/// </summary> /// </summary>
[JsonIgnore]
public bool EnableWebSocket public bool EnableWebSocket
{ {
get get

View File

@ -11,6 +11,18 @@ namespace ProxySuper.Core.Services
{ {
public class ShareLink 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) public static string Build(XrayType xrayType, XraySettings settings)
{ {

View File

@ -28,6 +28,13 @@ namespace ProxySuper.Core.Services
settings["password"][0] = parameters.Password; settings["password"][0] = parameters.Password;
settings["ssl"]["sni"] = parameters.Domain; 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() return JsonConvert.SerializeObject(settings, Formatting.Indented, new JsonSerializerSettings()
{ {
NullValueHandling = NullValueHandling.Ignore NullValueHandling = NullValueHandling.Ignore

View File

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

View File

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