mirror of
https://github.com/proxysu/ProxySU.git
synced 2024-11-21 20:56:08 +03:00
save trojanGO
This commit is contained in:
parent
3f75fbf003
commit
888e981d41
@ -8,12 +8,21 @@ namespace ProxySuper.Core.Models.Projects
|
||||
{
|
||||
public class NaiveProxySettings : IProjectSettings
|
||||
{
|
||||
public NaiveProxySettings()
|
||||
{
|
||||
Port = 443;
|
||||
}
|
||||
|
||||
public List<int> FreePorts => new List<int>();
|
||||
|
||||
public ProjectType Type { get; set; } = ProjectType.NaiveProxy;
|
||||
|
||||
public int Port { get; set; }
|
||||
|
||||
public string Domain { get; set; }
|
||||
|
||||
public List<int> FreePorts => throw new NotImplementedException();
|
||||
public string UserName { get; set; }
|
||||
|
||||
public ProjectType Type { get => throw new NotImplementedException(); set => throw new NotImplementedException(); }
|
||||
public string Password { get; set; }
|
||||
}
|
||||
}
|
||||
|
@ -1,4 +1,5 @@
|
||||
using Newtonsoft.Json;
|
||||
using ProxySuper.Core.Services;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
@ -12,6 +13,7 @@ namespace ProxySuper.Core.Models.Projects
|
||||
public TrojanGoSettings()
|
||||
{
|
||||
Port = 443;
|
||||
WebSocketPath = "/ws";
|
||||
}
|
||||
|
||||
public List<int> FreePorts
|
||||
@ -52,7 +54,7 @@ namespace ProxySuper.Core.Models.Projects
|
||||
{
|
||||
get
|
||||
{
|
||||
return !string.IsNullOrEmpty(WebSocketPath) && !string.IsNullOrEmpty(WebSocketDomain);
|
||||
return !string.IsNullOrEmpty(WebSocketPath);
|
||||
}
|
||||
}
|
||||
|
||||
@ -61,9 +63,5 @@ namespace ProxySuper.Core.Models.Projects
|
||||
/// </summary>
|
||||
public string WebSocketPath { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// websocket域名
|
||||
/// </summary>
|
||||
public string WebSocketDomain { get; set; }
|
||||
}
|
||||
}
|
||||
|
@ -83,6 +83,7 @@
|
||||
<Compile Include="Models\Record.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<Compile Include="Helpers\Utils.cs" />
|
||||
<Compile Include="Services\NaiveProxyProject.cs" />
|
||||
<Compile Include="Services\ProjectBase.cs" />
|
||||
<Compile Include="Services\ShareLink.cs" />
|
||||
<Compile Include="Services\TrojanGoConfigBuilder.cs" />
|
||||
|
102
ProxySuper.Core/Services/NaiveProxyProject.cs
Normal file
102
ProxySuper.Core/Services/NaiveProxyProject.cs
Normal file
@ -0,0 +1,102 @@
|
||||
using ProxySuper.Core.Models.Projects;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows;
|
||||
|
||||
namespace ProxySuper.Core.Services
|
||||
{
|
||||
public class NaiveProxyProject : ProjectBase<NaiveProxySettings>
|
||||
{
|
||||
public override void Install()
|
||||
{
|
||||
try
|
||||
{
|
||||
EnsureRootAuth();
|
||||
|
||||
if (FileExists("/usr/local/bin/trojan-go"))
|
||||
{
|
||||
var btnResult = MessageBox.Show("已经安装Trojan-Go,是否需要重装?", "提示", MessageBoxButton.YesNo);
|
||||
if (btnResult == MessageBoxResult.No)
|
||||
{
|
||||
MessageBox.Show("安装终止", "提示");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
WriteOutput("检测安装系统环境...");
|
||||
EnsureSystemEnv();
|
||||
WriteOutput("检测安装系统环境完成");
|
||||
|
||||
WriteOutput("配置服务器端口...");
|
||||
ConfigurePort();
|
||||
WriteOutput("端口配置完成");
|
||||
|
||||
WriteOutput("安装必要的系统工具...");
|
||||
ConfigureSoftware();
|
||||
WriteOutput("系统工具安装完成");
|
||||
|
||||
WriteOutput("检测IP6...");
|
||||
ConfigureIPv6();
|
||||
WriteOutput("检测IP6完成");
|
||||
|
||||
WriteOutput("配置防火墙...");
|
||||
ConfigureFirewall();
|
||||
WriteOutput("防火墙配置完成");
|
||||
|
||||
WriteOutput("同步系统和本地时间...");
|
||||
SyncTimeDiff();
|
||||
WriteOutput("时间同步完成");
|
||||
|
||||
WriteOutput("检测域名是否绑定本机IP...");
|
||||
ValidateDomain();
|
||||
WriteOutput("域名检测完成");
|
||||
|
||||
WriteOutput("安装Trojan-Go...");
|
||||
// InstallTrojanGo();
|
||||
WriteOutput("Trojan-Go安装完成");
|
||||
|
||||
WriteOutput("安装Caddy...");
|
||||
InstallCaddy();
|
||||
// UploadCaddyFile();
|
||||
WriteOutput("Caddy安装完成");
|
||||
|
||||
WriteOutput("启动BBR");
|
||||
EnableBBR();
|
||||
|
||||
RunCmd("systemctl restart trojan-go");
|
||||
WriteOutput("************");
|
||||
WriteOutput("安装完成,尽情享用吧......");
|
||||
WriteOutput("************");
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
var errorLog = "安装终止," + ex.Message;
|
||||
WriteOutput(errorLog);
|
||||
MessageBox.Show(errorLog);
|
||||
}
|
||||
}
|
||||
|
||||
private void InstallNaiveProxy()
|
||||
{
|
||||
WriteOutput("安装 NaiveProxy");
|
||||
RunCmd(@"curl https://raw.githubusercontent.com/proxysu/shellscript/master/Caddy-Naive/caddy-naive-install.sh yes | bash");
|
||||
var success = FileExists("/usr/local/bin/trojan-go");
|
||||
if (success == false)
|
||||
{
|
||||
throw new Exception("trojan-go 安装失败,请联系开发者!");
|
||||
}
|
||||
|
||||
RunCmd($"sed -i 's/User=nobody/User=root/g' /etc/systemd/system/trojan-go.service");
|
||||
RunCmd($"sed -i 's/CapabilityBoundingSet=/#CapabilityBoundingSet=/g' /etc/systemd/system/trojan-go.service");
|
||||
RunCmd($"sed -i 's/AmbientCapabilities=/#AmbientCapabilities=/g' /etc/systemd/system/trojan-go.service");
|
||||
RunCmd($"systemctl daemon-reload");
|
||||
|
||||
RunCmd("systemctl enable trojan-go");
|
||||
RunCmd("systemctl start trojan-go");
|
||||
WriteOutput("NaiveProxy 安装完成");
|
||||
}
|
||||
}
|
||||
}
|
@ -13,12 +13,20 @@ namespace ProxySuper.Core.Services
|
||||
{
|
||||
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}&");
|
||||
strBuilder.Append($"{HttpUtility.UrlEncode(settings.Password)}@{settings.Domain}:{settings.Port}/?");
|
||||
strBuilder.Append($"sni={HttpUtility.UrlEncode(settings.Domain)}&");
|
||||
if (settings.EnableWebSocket)
|
||||
{
|
||||
strBuilder.Append($"type=ws&host={HttpUtility.UrlEncode(settings.Domain)}&path={HttpUtility.UrlEncode(settings.WebSocketPath)}&");
|
||||
}
|
||||
else
|
||||
{
|
||||
strBuilder.Append("type=original&");
|
||||
}
|
||||
strBuilder.Append($"#{HttpUtility.UrlEncode("trojan-go")}");
|
||||
|
||||
return strBuilder.ToString();
|
||||
}
|
||||
|
@ -32,7 +32,7 @@ namespace ProxySuper.Core.Services
|
||||
{
|
||||
settings["websocket"]["enabled"] = true;
|
||||
settings["websocket"]["path"] = parameters.WebSocketPath;
|
||||
settings["websocket"]["host"] = parameters.WebSocketDomain;
|
||||
settings["websocket"]["host"] = parameters.Domain;
|
||||
}
|
||||
|
||||
return JsonConvert.SerializeObject(settings, Formatting.Indented, new JsonSerializerSettings()
|
||||
|
@ -50,6 +50,7 @@ namespace ProxySuper.Core.Services
|
||||
{
|
||||
RunCmd("systemctl stop trojan-go");
|
||||
RunCmd("systemctl stop caddy");
|
||||
base.UninstallCaddy();
|
||||
|
||||
RunCmd("rm -rf /usr/local/bin/trojan-go");
|
||||
RunCmd("rm -rf /usr/local/etc/trojan-go");
|
||||
@ -110,12 +111,13 @@ namespace ProxySuper.Core.Services
|
||||
|
||||
WriteOutput("安装Caddy...");
|
||||
InstallCaddy();
|
||||
UploadCaddyFile();
|
||||
WriteOutput("Caddy安装完成");
|
||||
|
||||
WriteOutput("启动BBR");
|
||||
EnableBBR();
|
||||
|
||||
UploadCaddyFile();
|
||||
RunCmd("systemctl restart trojan-go");
|
||||
WriteOutput("************");
|
||||
WriteOutput("安装完成,尽情享用吧......");
|
||||
WriteOutput("************");
|
||||
@ -138,9 +140,9 @@ namespace ProxySuper.Core.Services
|
||||
throw new Exception("trojan-go 安装失败,请联系开发者!");
|
||||
}
|
||||
|
||||
RunCmd($"sed -i 's/User=nobody/User=root/g' /etc/systemd/system/xray.service");
|
||||
RunCmd($"sed -i 's/CapabilityBoundingSet=/#CapabilityBoundingSet=/g' /etc/systemd/system/xray.service");
|
||||
RunCmd($"sed -i 's/AmbientCapabilities=/#AmbientCapabilities=/g' /etc/systemd/system/xray.service");
|
||||
RunCmd($"sed -i 's/User=nobody/User=root/g' /etc/systemd/system/trojan-go.service");
|
||||
RunCmd($"sed -i 's/CapabilityBoundingSet=/#CapabilityBoundingSet=/g' /etc/systemd/system/trojan-go.service");
|
||||
RunCmd($"sed -i 's/AmbientCapabilities=/#AmbientCapabilities=/g' /etc/systemd/system/trojan-go.service");
|
||||
RunCmd($"systemctl daemon-reload");
|
||||
|
||||
RunCmd("systemctl enable trojan-go");
|
||||
|
@ -111,12 +111,16 @@ namespace ProxySuper.Core.ViewModels
|
||||
if (record.Type == ProjectType.Xray)
|
||||
{
|
||||
result = await _navigationService.Navigate<XrayEditorViewModel, Record, Record>(record);
|
||||
if (result == null) return;
|
||||
|
||||
record.Host = result.Host;
|
||||
record.XraySettings = result.XraySettings;
|
||||
}
|
||||
if (record.Type == ProjectType.TrojanGo)
|
||||
{
|
||||
result = await _navigationService.Navigate<TrojanGoEditorViewModel, Record, Record>(record);
|
||||
if (result == null) return;
|
||||
|
||||
record.Host = result.Host;
|
||||
record.TrojanGoSettings = result.TrojanGoSettings;
|
||||
}
|
||||
|
@ -1,5 +1,6 @@
|
||||
using MvvmCross.ViewModels;
|
||||
using ProxySuper.Core.Models.Projects;
|
||||
using ProxySuper.Core.Services;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
@ -17,6 +18,12 @@ namespace ProxySuper.Core.ViewModels
|
||||
Settings = parameter;
|
||||
}
|
||||
|
||||
|
||||
public string Link
|
||||
{
|
||||
get
|
||||
{
|
||||
return ShareLink.BuildTrojanGo(Settings);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -8,7 +8,8 @@
|
||||
<sys:String x:Key="SaveAs">SaveAs</sys:String>
|
||||
<sys:String x:Key="Install">Install</sys:String>
|
||||
<sys:String x:Key="Settings">Settings</sys:String>
|
||||
|
||||
<sys:String x:Key="ReadmeWebsiteDemo">The following is a static web page connection provided by netizens, please check whether there is an index.html file by yourself</sys:String>
|
||||
|
||||
<!--Main Menu-->
|
||||
<sys:String x:Key="MainMenuAddHost">Add Host</sys:String>
|
||||
<sys:String x:Key="MainMenuActions">Actions</sys:String>
|
||||
|
@ -8,6 +8,7 @@
|
||||
<sys:String x:Key="SaveAs">另存为</sys:String>
|
||||
<sys:String x:Key="Install">安装</sys:String>
|
||||
<sys:String x:Key="Settings">配置</sys:String>
|
||||
<sys:String x:Key="ReadmeWebsiteDemo">如下是网友提供的静态网页连接,请自行检查是否有index.html文件</sys:String>
|
||||
|
||||
<!--Main Menu-->
|
||||
<sys:String x:Key="MainMenuAddHost">添加主机</sys:String>
|
||||
|
@ -19,6 +19,8 @@
|
||||
<RowDefinition Height="36" />
|
||||
<RowDefinition Height="36" />
|
||||
<RowDefinition Height="36" />
|
||||
<RowDefinition Height="36" />
|
||||
<RowDefinition Height="36" />
|
||||
</Grid.RowDefinitions>
|
||||
|
||||
<Label Grid.Row="0" Grid.Column="0" Content="主机(Host)" />
|
||||
@ -32,5 +34,11 @@
|
||||
|
||||
<Label Grid.Row="3" Grid.Column="0" Content="SNI" />
|
||||
<TextBox Grid.Row="3" Grid.Column="1" Text="{Binding Settings.Domain}" IsReadOnly="True" />
|
||||
|
||||
<Label Grid.Row="4" Grid.Column="0" Content="WebSocket(Path)" />
|
||||
<TextBox Grid.Row="4" Grid.Column="1" Text="{Binding Settings.WebSocketPath}" IsReadOnly="True" />
|
||||
|
||||
<Label Grid.Row="5" Grid.Column="0" Content="链接(ShareLink)" />
|
||||
<TextBox Grid.Row="5" Grid.Column="1" Text="{Binding Link, Mode=OneTime}" IsReadOnly="True" />
|
||||
</Grid>
|
||||
</views:MvxWindow>
|
||||
|
@ -51,11 +51,8 @@
|
||||
<Label Content="{DynamicResource TrojanGoMaskDomain}" Grid.Row="3" Grid.Column="0" />
|
||||
<TextBox Text="{Binding Settings.MaskDomain}" Grid.Row="3" Grid.Column="1" />
|
||||
|
||||
<!--<Label Content="{DynamicResource TrojanGoWebSocketPath}" Grid.Row="4" Grid.Column="0" />
|
||||
<Label Content="{DynamicResource TrojanGoWebSocketPath}" Grid.Row="4" Grid.Column="0" />
|
||||
<TextBox Text="{Binding Settings.WebSocketPath}" Grid.Row="4" Grid.Column="1" />
|
||||
|
||||
<Label Content="{DynamicResource TrojanGoWebSocketDomain}" Grid.Row="5" Grid.Column="0" />
|
||||
<TextBox Text="{Binding Settings.WebSocketDomain}" Grid.Row="5" Grid.Column="1" />-->
|
||||
</Grid>
|
||||
|
||||
<Border BorderBrush="#eee" BorderThickness="0,1,0,0">
|
||||
|
@ -19,7 +19,7 @@ namespace ProxySuper.WPF.Views
|
||||
/// <summary>
|
||||
/// TrojanEditorView.xaml 的交互逻辑
|
||||
/// </summary>
|
||||
[MvxWindowPresentation(Identifier = nameof(XrayEditorView), Modal = false)]
|
||||
[MvxWindowPresentation(Identifier = nameof(TrojanGoEditorView), Modal = false)]
|
||||
public partial class TrojanGoEditorView : MvxWindow
|
||||
{
|
||||
public TrojanGoEditorView()
|
||||
|
@ -35,5 +35,21 @@
|
||||
<Button Height="24" Padding="10,0" Margin="10,0,0,0" IsEnabled="{Binding Connected}" Click="InstallCert" Content="{DynamicResource XrayInstallerInstallCert}" />
|
||||
<Button Height="24" Padding="10,0" Margin="10,0,0,0" IsEnabled="{Binding Connected}" Click="UploadWeb" Content="{DynamicResource XrayInstallerUploadWeb}" />
|
||||
</StackPanel>
|
||||
|
||||
<Label Margin="10" Content="{DynamicResource ReadmeWebsiteDemo}" />
|
||||
<StackPanel Orientation="Horizontal">
|
||||
<TextBlock Margin="10,0,0,0">
|
||||
<Hyperlink NavigateUri="https://www.themezy.com" Click="OpenLink">Themezy</Hyperlink>
|
||||
</TextBlock>
|
||||
<TextBlock Margin="20,0,0,0">
|
||||
<Hyperlink NavigateUri="https://onepagelove.com/templates/free-templates" Click="OpenLink">One Page Love</Hyperlink>
|
||||
</TextBlock>
|
||||
<TextBlock Margin="20,0,0,0">
|
||||
<Hyperlink NavigateUri="https://html5up.net/" Click="OpenLink">HTML5 UP</Hyperlink>
|
||||
</TextBlock>
|
||||
<TextBlock Margin="20,0,0,0">
|
||||
<Hyperlink NavigateUri="https://templatemo.com/" Click="OpenLink">template mo</Hyperlink>
|
||||
</TextBlock>
|
||||
</StackPanel>
|
||||
</StackPanel>
|
||||
</views:MvxWindow>
|
||||
|
@ -8,6 +8,7 @@ using Renci.SshNet;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Diagnostics;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
@ -122,6 +123,13 @@ namespace ProxySuper.WPF.Views
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
private void OpenLink(object sender, RoutedEventArgs e)
|
||||
{
|
||||
Hyperlink link = sender as Hyperlink;
|
||||
Process.Start(new ProcessStartInfo(link.NavigateUri.AbsoluteUri));
|
||||
}
|
||||
|
||||
private void Install(object sender, RoutedEventArgs e)
|
||||
{
|
||||
Task.Factory.StartNew(Project.Install);
|
||||
@ -130,7 +138,11 @@ namespace ProxySuper.WPF.Views
|
||||
|
||||
private void Uninstall(object sender, RoutedEventArgs e)
|
||||
{
|
||||
Task.Factory.StartNew(Project.Uninstall);
|
||||
var result = MessageBox.Show("您确认要卸载代理吗?", "提示", MessageBoxButton.YesNo);
|
||||
if (result == MessageBoxResult.Yes)
|
||||
{
|
||||
Task.Factory.StartNew(Project.Uninstall);
|
||||
}
|
||||
}
|
||||
|
||||
private void InstallCert(object sender, RoutedEventArgs e)
|
||||
|
@ -39,5 +39,21 @@
|
||||
<Button Height="24" Padding="10,0" Margin="10,0,0,0" IsEnabled="{Binding Connected}" Click="UploadWeb" Content="{DynamicResource XrayInstallerUploadWeb}" />
|
||||
<Button Height="24" Padding="10,0" Margin="10,0,0,0" IsEnabled="{Binding Connected}" Click="UploadCert" Content="{DynamicResource XrayInstallerUploadCert}" />
|
||||
</StackPanel>
|
||||
|
||||
<Label Margin="10" Content="{DynamicResource ReadmeWebsiteDemo}" />
|
||||
<StackPanel Orientation="Horizontal">
|
||||
<TextBlock Margin="10,0,0,0">
|
||||
<Hyperlink NavigateUri="https://www.themezy.com" Click="OpenLink">Themezy</Hyperlink>
|
||||
</TextBlock>
|
||||
<TextBlock Margin="20,0,0,0">
|
||||
<Hyperlink NavigateUri="https://onepagelove.com/templates/free-templates" Click="OpenLink">One Page Love</Hyperlink>
|
||||
</TextBlock>
|
||||
<TextBlock Margin="20,0,0,0">
|
||||
<Hyperlink NavigateUri="https://html5up.net/" Click="OpenLink">HTML5 UP</Hyperlink>
|
||||
</TextBlock>
|
||||
<TextBlock Margin="20,0,0,0">
|
||||
<Hyperlink NavigateUri="https://templatemo.com/" Click="OpenLink">template mo</Hyperlink>
|
||||
</TextBlock>
|
||||
</StackPanel>
|
||||
</StackPanel>
|
||||
</views:MvxWindow>
|
||||
|
@ -7,9 +7,11 @@ using ProxySuper.Core.ViewModels;
|
||||
using Renci.SshNet;
|
||||
using System;
|
||||
using System.ComponentModel;
|
||||
using System.Diagnostics;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows;
|
||||
using System.Windows.Automation.Peers;
|
||||
using System.Windows.Documents;
|
||||
using System.Windows.Threading;
|
||||
|
||||
namespace ProxySuper.WPF.Views
|
||||
@ -115,6 +117,12 @@ namespace ProxySuper.WPF.Views
|
||||
|
||||
}
|
||||
|
||||
private void OpenLink(object sender, RoutedEventArgs e)
|
||||
{
|
||||
Hyperlink link = sender as Hyperlink;
|
||||
Process.Start(new ProcessStartInfo(link.NavigateUri.AbsoluteUri));
|
||||
}
|
||||
|
||||
private void Install(object sender, RoutedEventArgs e)
|
||||
{
|
||||
Task.Factory.StartNew(Project.Install);
|
||||
|
Loading…
Reference in New Issue
Block a user