1
0
Fork 0
mirror of https://github.com/proxysu/ProxySU.git synced 2025-04-10 12:40:55 +00:00

Merge pull request #1 from proxysu/master

update
This commit is contained in:
xnxy2012 2021-03-13 10:15:30 +08:00 committed by GitHub
commit 2408ecc9da
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
79 changed files with 4468 additions and 85 deletions

1
.gitignore vendored
View file

@ -198,3 +198,4 @@ FakesAssemblies/
# vs code
.vscode/*
/ProxySU_Core/Data/Record.json

View file

@ -1,10 +0,0 @@
<Application x:Class="ProxySU.Core.App"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="clr-namespace:ProxySU.Core"
xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes"
StartupUri="MainWindow.xaml">
<Application.Resources>
</Application.Resources>
</Application>

View file

@ -1,28 +0,0 @@
<Window x:Class="ProxySU.Core.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:ProxySU.Core"
mc:Ignorable="d"
Title="MainWindow" Height="450" Width="800">
<Grid>
<Menu Style="{DynamicResource MaterialDesignMenu}">
<MenuItem Header="文件" Style="{DynamicResource MaterialDesignMenuItem}">
<MenuItem Header="SubMenu">肖文杰</MenuItem>
</MenuItem>
<MenuItem Header="文件" Style="{DynamicResource MaterialDesignMenuItem}"></MenuItem>
<MenuItem Header="文件" Style="{DynamicResource MaterialDesignMenuItem}"></MenuItem>
</Menu>
<!--<TabControl Style="{DynamicResource MaterialDesignNavigatilRailTabControl}" >
<TabItem Header="Item2" Style="{DynamicResource MaterialDesignNavigationRailTabItem}">
<Button Style="{DynamicResource MaterialDesignRaisedButton}" Content="Hello!"></Button>
</TabItem>
<TabItem Header="Item2"></TabItem>
</TabControl>-->
</Grid>
</Window>

View file

@ -1,28 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
namespace ProxySU.Core
{
/// <summary>
/// Interaction logic for MainWindow.xaml
/// </summary>
public partial class MainWindow : Window
{
public MainWindow()
{
InitializeComponent();
}
}
}

View file

@ -1,13 +0,0 @@
<Project Sdk="Microsoft.NET.Sdk.WindowsDesktop">
<PropertyGroup>
<OutputType>WinExe</OutputType>
<TargetFramework>netcoreapp3.1</TargetFramework>
<UseWPF>true</UseWPF>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="MaterialDesignThemes" Version="3.2.0" />
</ItemGroup>
</Project>

View file

@ -1,10 +1,12 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 15
VisualStudioVersion = 15.0.28307.1022
# Visual Studio Version 16
VisualStudioVersion = 16.0.31005.135
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ProxySU", "ProxySU\ProxySU.csproj", "{DD5505BC-E7F1-4D03-ABC7-B636E893FC09}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ProxySU_Core", "ProxySU_Core\ProxySU_Core.csproj", "{B066015C-D347-4493-92F1-6556D3863996}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
@ -15,6 +17,10 @@ Global
{DD5505BC-E7F1-4D03-ABC7-B636E893FC09}.Debug|Any CPU.Build.0 = Debug|Any CPU
{DD5505BC-E7F1-4D03-ABC7-B636E893FC09}.Release|Any CPU.ActiveCfg = Release|Any CPU
{DD5505BC-E7F1-4D03-ABC7-B636E893FC09}.Release|Any CPU.Build.0 = Release|Any CPU
{B066015C-D347-4493-92F1-6556D3863996}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{B066015C-D347-4493-92F1-6556D3863996}.Debug|Any CPU.Build.0 = Debug|Any CPU
{B066015C-D347-4493-92F1-6556D3863996}.Release|Any CPU.ActiveCfg = Release|Any CPU
{B066015C-D347-4493-92F1-6556D3863996}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE

View file

@ -71,8 +71,8 @@
<Reference Include="QRCoder">
<HintPath>..\qrcoder\net40\QRCoder.dll</HintPath>
</Reference>
<Reference Include="Renci.SshNet">
<HintPath>..\ssh.net\net40\Renci.SshNet.dll</HintPath>
<Reference Include="Renci.SshNet, Version=2020.0.1.0, Culture=neutral, PublicKeyToken=1cee9f8bde3db106, processorArchitecture=MSIL">
<HintPath>..\packages\SSH.NET.2020.0.1\lib\net40\Renci.SshNet.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Data" />
@ -181,6 +181,7 @@
<Generator>ResXFileCodeGenerator</Generator>
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
</EmbeddedResource>
<None Include="packages.config" />
<None Include="Properties\Settings.settings">
<Generator>SettingsSingleFileGenerator</Generator>
<LastGenOutput>Settings.Designer.cs</LastGenOutput>

View file

@ -1,4 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="SSH.NET" version="2016.1.0" targetFramework="net40" />
<package id="SSH.NET" version="2020.0.1" targetFramework="net40" />
</packages>

14
ProxySU_Core/App.config Normal file
View file

@ -0,0 +1,14 @@
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6.1" />
</startup>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="ControlzEx" publicKeyToken="69f1c32f803d307e" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-5.0.0.0" newVersion="5.0.0.0" />
</dependentAssembly>
</assemblyBinding>
</runtime>
</configuration>

33
ProxySU_Core/App.xaml Normal file
View file

@ -0,0 +1,33 @@
<Application x:Class="ProxySU_Core.App"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="clr-namespace:ProxySU_Core"
xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes"
StartupUri="Views/MainWindow.xaml">
<Application.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<!--Languages-->
<ResourceDictionary Source="/Resources/Languages/zh_cn.xaml" />
<!-- MahApps -->
<ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Controls.xaml" />
<ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Fonts.xaml" />
<ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Themes/Light.Teal.xaml" />
<!-- Material Design -->
<ResourceDictionary Source="pack://application:,,,/MaterialDesignThemes.Wpf;component/Themes/MaterialDesignTheme.Light.xaml" />
<ResourceDictionary Source="pack://application:,,,/MaterialDesignThemes.Wpf;component/Themes/MaterialDesignTheme.Defaults.xaml" />
<ResourceDictionary Source="pack://application:,,,/MaterialDesignColors;component/Themes/Recommended/Primary/MaterialDesignColor.Teal.xaml" />
<ResourceDictionary Source="pack://application:,,,/MaterialDesignColors;component/Themes/Recommended/Accent/MaterialDesignColor.Teal.xaml" />
<!-- Material Design: MahApps Compatibility -->
<ResourceDictionary Source="pack://application:,,,/MaterialDesignThemes.MahApps;component/Themes/MaterialDesignTheme.MahApps.Fonts.xaml" />
<ResourceDictionary Source="pack://application:,,,/MaterialDesignThemes.MahApps;component/Themes/MaterialDesignTheme.MahApps.Flyout.xaml" />
<!--Override Themes-->
<ResourceDictionary Source="/Resources/Styles/MaterialDesignThemes.Overrides.xaml" />
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
</Application.Resources>
</Application>

View file

@ -6,7 +6,7 @@ using System.Linq;
using System.Threading.Tasks;
using System.Windows;
namespace ProxySU.Core
namespace ProxySU_Core
{
/// <summary>
/// Interaction logic for App.xaml

View file

@ -0,0 +1,32 @@
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Text;
using System.Windows.Data;
namespace ProxySU_Core.Converters
{
public class LoginSecretTypeConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
return value != null && value.Equals(parameter);
}
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
if (value == null)
{
return Binding.DoNothing;
}
if (!value.Equals(true))
{
return Binding.DoNothing;
}
return parameter;
}
}
}

View file

@ -0,0 +1,31 @@
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Text;
using System.Windows.Data;
namespace ProxySU_Core.Converters
{
public class ProxyTypeConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
return value != null && value.Equals(parameter);
}
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
if (value == null)
{
return Binding.DoNothing;
}
if (!value.Equals(true))
{
return Binding.DoNothing;
}
return parameter;
}
}
}

View file

@ -0,0 +1,35 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ProxySU_Core.Models
{
public class Host
{
public Host()
{
Proxy = new LocalProxy();
}
public string Tag { get; set; }
public string Address { get; set; }
public string UserName { get; set; }
public string Password { get; set; }
public int Port { get; set; } = 22;
public string PrivateKeyPath { get; set; }
public LocalProxy Proxy { get; set; }
public LoginSecretType SecretType { get; set; }
}
}

View file

@ -0,0 +1,20 @@
using System;
using System.Collections.Generic;
using System.Text;
namespace ProxySU_Core.Models
{
public class LocalProxy
{
public string Address { get; set; } = "127.0.0.1";
public int Port { get; set; } = 1080;
public LocalProxyType Type { get; set; }
public string UserName { get; set; }
public string Password { get; set; }
}
}

View file

@ -0,0 +1,23 @@
using System;
using System.Collections.Generic;
using System.Text;
namespace ProxySU_Core.Models
{
public enum LocalProxyType
{
None = 0,
//
// 摘要:
// A SOCKS4 proxy server.
Socks4 = 1,
//
// 摘要:
// A SOCKS5 proxy server.
Socks5 = 2,
//
// 摘要:
// A HTTP proxy server.
Http = 3
}
}

View file

@ -0,0 +1,12 @@
using System;
using System.Collections.Generic;
using System.Text;
namespace ProxySU_Core.Models
{
public enum LoginSecretType
{
Password = 0,
PrivateKey = 1
}
}

View file

@ -0,0 +1,24 @@
using ProxySU_Core.Models;
using System;
using System.Collections.Generic;
using System.Text;
namespace ProxySU_Core.Models
{
public class Record
{
public Record()
{
}
public Record(Host host)
{
this.Host = host;
}
public Host Host { get; set; } = new Host();
public XraySettings Settings { get; set; } = new XraySettings();
}
}

View file

@ -0,0 +1,110 @@
using ProxySU_Core.ViewModels.Developers;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ProxySU_Core.Models
{
public class XraySettings : IParameters
{
public XraySettings()
{
var guid = Guid.NewGuid().ToString();
Port = 443;
UUID = guid;
Types = new List<XrayType> { XrayType.VLESS_TCP_XTLS };
VLESS_WS_Path = "/vlessws";
VLESS_TCP_Path = "/vlesstcp";
VMESS_WS_Path = "/vmessws";
VMESS_TCP_Path = "/vmesstcp";
TrojanPassword = guid;
}
/// <summary>
/// 访问端口
/// </summary>
public int Port { get; set; }
/// <summary>
/// UUID
/// </summary>
public string UUID { get; set; }
/// <summary>
/// vless ws路径
/// </summary>
public string VLESS_WS_Path { get; set; }
/// <summary>
/// vless tcp路径
/// </summary>
public string VLESS_TCP_Path { get; set; }
/// <summary>
/// vmess ws路径
/// </summary>
public string VMESS_WS_Path { get; set; }
/// <summary>
/// vmess tcp路径
/// </summary>
public string VMESS_TCP_Path { get; set; }
/// <summary>
/// trojan密码
/// </summary>
public string TrojanPassword { get; set; }
/// <summary>
/// 域名
/// </summary>
public string Domain { get; set; }
/// <summary>
/// 伪装域名
/// </summary>
public string MaskDomain { get; set; }
/// <summary>
/// 安装类型
/// </summary>
public List<XrayType> Types { get; set; }
public string GetPath(XrayType type)
{
switch (type)
{
case XrayType.VLESS_TCP_TLS:
return VLESS_TCP_Path;
case XrayType.VLESS_TCP_XTLS:
return VLESS_TCP_Path;
case XrayType.VLESS_WS_TLS:
return VLESS_WS_Path;
case XrayType.VMESS_TCP_TLS:
return VMESS_TCP_Path;
case XrayType.VMESS_WS_TLS:
return VMESS_WS_Path;
case XrayType.Trojan_TCP_TLS:
return string.Empty;
default:
return string.Empty;
}
}
}
public enum XrayType
{
VLESS_TCP_TLS,
VLESS_TCP_XTLS,
VLESS_WS_TLS,
VMESS_TCP_TLS,
VMESS_WS_TLS,
Trojan_TCP_TLS
}
}

View file

@ -0,0 +1,55 @@
using System.Reflection;
using System.Resources;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Windows;
// 有关程序集的一般信息由以下
// 控制。更改这些特性值可修改
// 与程序集关联的信息。
[assembly: AssemblyTitle("ProxySU_Core")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("ProxySU_Core")]
[assembly: AssemblyCopyright("Copyright © 2021")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// 将 ComVisible 设置为 false 会使此程序集中的类型
//对 COM 组件不可见。如果需要从 COM 访问此程序集中的类型
//请将此类型的 ComVisible 特性设置为 true。
[assembly: ComVisible(false)]
//若要开始生成可本地化的应用程序,请设置
//.csproj 文件中的 <UICulture>CultureYouAreCodingWith</UICulture>
//例如,如果您在源文件中使用的是美国英语,
//使用的是美国英语,请将 <UICulture> 设置为 en-US。 然后取消
//对以下 NeutralResourceLanguage 特性的注释。 更新
//以下行中的“en-US”以匹配项目文件中的 UICulture 设置。
//[assembly: NeutralResourcesLanguage("en-US", UltimateResourceFallbackLocation.Satellite)]
[assembly: ThemeInfo(
ResourceDictionaryLocation.None, //主题特定资源词典所处位置
//(未在页面中找到资源时使用,
//或应用程序资源字典中找到时使用)
ResourceDictionaryLocation.SourceAssembly //常规资源词典所处位置
//(未在页面中找到资源时使用,
//、应用程序或任何主题专用资源字典中找到时使用)
)]
// 程序集的版本信息由下列四个值组成:
//
// 主版本
// 次版本
// 生成号
// 修订号
//
//可以指定所有这些值,也可以使用“生成号”和“修订号”的默认值
//通过使用 "*",如下所示:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]

View file

@ -0,0 +1,70 @@
//------------------------------------------------------------------------------
// <auto-generated>
// 此代码由工具生成。
// 运行时版本: 4.0.30319.42000
//
// 对此文件的更改可能导致不正确的行为,如果
// 重新生成代码,则所做更改将丢失。
// </auto-generated>
//------------------------------------------------------------------------------
namespace ProxySU_Core.Properties
{
/// <summary>
/// 强类型资源类,用于查找本地化字符串等。
/// </summary>
// 此类是由 StronglyTypedResourceBuilder
// 类通过类似于 ResGen 或 Visual Studio 的工具自动生成的。
// 若要添加或删除成员,请编辑 .ResX 文件,然后重新运行 ResGen
// (以 /str 作为命令选项),或重新生成 VS 项目。
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
internal class Resources
{
private static global::System.Resources.ResourceManager resourceMan;
private static global::System.Globalization.CultureInfo resourceCulture;
[global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
internal Resources()
{
}
/// <summary>
/// 返回此类使用的缓存 ResourceManager 实例。
/// </summary>
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
internal static global::System.Resources.ResourceManager ResourceManager
{
get
{
if ((resourceMan == null))
{
global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("ProxySU_Core.Properties.Resources", typeof(Resources).Assembly);
resourceMan = temp;
}
return resourceMan;
}
}
/// <summary>
/// 重写当前线程的 CurrentUICulture 属性,对
/// 使用此强类型资源类的所有资源查找执行重写。
/// </summary>
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
internal static global::System.Globalization.CultureInfo Culture
{
get
{
return resourceCulture;
}
set
{
resourceCulture = value;
}
}
}
}

View file

@ -0,0 +1,117 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>

View file

@ -0,0 +1,29 @@
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
// Runtime Version:4.0.30319.42000
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
namespace ProxySU_Core.Properties
{
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "11.0.0.0")]
internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase
{
private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
public static Settings Default
{
get
{
return defaultInstance;
}
}
}
}

View file

@ -0,0 +1,7 @@
<?xml version='1.0' encoding='utf-8'?>
<SettingsFile xmlns="uri:settings" CurrentProfile="(Default)">
<Profiles>
<Profile Name="(Default)" />
</Profiles>
<Settings />
</SettingsFile>

View file

@ -0,0 +1,321 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{B066015C-D347-4493-92F1-6556D3863996}</ProjectGuid>
<OutputType>WinExe</OutputType>
<RootNamespace>ProxySU_Core</RootNamespace>
<AssemblyName>ProxySU_Core</AssemblyName>
<TargetFrameworkVersion>v4.6.1</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<ProjectTypeGuids>{60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
<WarningLevel>4</WarningLevel>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
<Deterministic>true</Deterministic>
<NuGetPackageImportStamp>
</NuGetPackageImportStamp>
<IsWebBootstrapper>false</IsWebBootstrapper>
<PublishUrl>C:\Users\huife\Desktop\publish_new\</PublishUrl>
<Install>true</Install>
<InstallFrom>Disk</InstallFrom>
<UpdateEnabled>false</UpdateEnabled>
<UpdateMode>Foreground</UpdateMode>
<UpdateInterval>7</UpdateInterval>
<UpdateIntervalUnits>Days</UpdateIntervalUnits>
<UpdatePeriodically>false</UpdatePeriodically>
<UpdateRequired>false</UpdateRequired>
<MapFileExtensions>true</MapFileExtensions>
<ApplicationRevision>1</ApplicationRevision>
<ApplicationVersion>1.0.0.%2a</ApplicationVersion>
<UseApplicationTrust>false</UseApplicationTrust>
<PublishWizardCompleted>true</PublishWizardCompleted>
<BootstrapperEnabled>true</BootstrapperEnabled>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup>
<ManifestCertificateThumbprint>D529B8E43BC86188988D830C545B400612900BB3</ManifestCertificateThumbprint>
</PropertyGroup>
<PropertyGroup>
<ManifestKeyFile>ProxySU_Core_TemporaryKey.pfx</ManifestKeyFile>
</PropertyGroup>
<PropertyGroup>
<GenerateManifests>true</GenerateManifests>
</PropertyGroup>
<PropertyGroup>
<SignManifests>true</SignManifests>
</PropertyGroup>
<ItemGroup>
<Reference Include="ControlzEx, Version=5.0.0.0, Culture=neutral, PublicKeyToken=69f1c32f803d307e, processorArchitecture=MSIL">
<HintPath>..\packages\ControlzEx.5.0.0\lib\net452\ControlzEx.dll</HintPath>
</Reference>
<Reference Include="MahApps.Metro, Version=2.0.0.0, Culture=neutral, PublicKeyToken=51482d6f650b2b3f, processorArchitecture=MSIL">
<HintPath>..\packages\MahApps.Metro.2.4.4\lib\net46\MahApps.Metro.dll</HintPath>
</Reference>
<Reference Include="MaterialDesignColors, Version=2.0.0.2422, Culture=neutral, PublicKeyToken=df2a72020bd7962a, processorArchitecture=MSIL">
<HintPath>..\packages\MaterialDesignColors.2.0.0\lib\net452\MaterialDesignColors.dll</HintPath>
</Reference>
<Reference Include="MaterialDesignThemes.MahApps, Version=0.1.6.2422, Culture=neutral, PublicKeyToken=df2a72020bd7962a, processorArchitecture=MSIL">
<HintPath>..\packages\MaterialDesignThemes.MahApps.0.1.6\lib\net452\MaterialDesignThemes.MahApps.dll</HintPath>
</Reference>
<Reference Include="MaterialDesignThemes.Wpf, Version=4.0.0.2422, Culture=neutral, PublicKeyToken=df2a72020bd7962a, processorArchitecture=MSIL">
<HintPath>..\packages\MaterialDesignThemes.4.0.0\lib\net452\MaterialDesignThemes.Wpf.dll</HintPath>
</Reference>
<Reference Include="Microsoft.Xaml.Behaviors, Version=1.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\packages\Microsoft.Xaml.Behaviors.Wpf.1.1.31\lib\net45\Microsoft.Xaml.Behaviors.dll</HintPath>
</Reference>
<Reference Include="Newtonsoft.Json, Version=12.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
<HintPath>..\packages\Newtonsoft.Json.12.0.3\lib\net45\Newtonsoft.Json.dll</HintPath>
</Reference>
<Reference Include="Renci.SshNet, Version=2020.0.1.0, Culture=neutral, PublicKeyToken=1cee9f8bde3db106, processorArchitecture=MSIL">
<HintPath>..\packages\SSH.NET.2020.0.1\lib\net40\Renci.SshNet.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.ComponentModel.DataAnnotations" />
<Reference Include="System.Configuration" />
<Reference Include="System.Data" />
<Reference Include="System.Web" />
<Reference Include="System.Web.Extensions" />
<Reference Include="System.Xml" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="System.Net.Http" />
<Reference Include="System.Xaml">
<RequiredTargetFramework>4.0</RequiredTargetFramework>
</Reference>
<Reference Include="WindowsBase" />
<Reference Include="PresentationCore" />
<Reference Include="PresentationFramework" />
</ItemGroup>
<ItemGroup>
<ApplicationDefinition Include="App.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</ApplicationDefinition>
<Compile Include="App.xaml.cs">
<DependentUpon>App.xaml</DependentUpon>
<SubType>Code</SubType>
</Compile>
<Compile Include="Converters\LoginSecretTypeConverter.cs" />
<Compile Include="Models\Host.cs" />
<Compile Include="Models\XraySettings.cs" />
<Compile Include="Tools\DateTimeUtils.cs" />
<Compile Include="Tools\Extensions.cs" />
<Compile Include="ViewModels\BaseCommand.cs" />
<Compile Include="ViewModels\BaseViewModel.cs" />
<Compile Include="ViewModels\Developers\ConfigBuilder.cs" />
<Compile Include="ViewModels\Developers\IParameters.cs" />
<Compile Include="ViewModels\Developers\Project.cs" />
<Compile Include="ViewModels\Developers\XrayProject.cs" />
<Compile Include="ViewModels\HostViewModel.cs" />
<Compile Include="Models\LocalProxy.cs" />
<Compile Include="Models\LocalProxyType.cs" />
<Compile Include="Models\LoginSecretType.cs" />
<Compile Include="Models\Record.cs" />
<Compile Include="ViewModels\RecordViewModel.cs" />
<Compile Include="ViewModels\Terminal.cs" />
<Compile Include="ViewModels\XraySettingsViewModel.cs" />
<Compile Include="Views\ClientInfoWindow.xaml.cs">
<DependentUpon>ClientInfoWindow.xaml</DependentUpon>
</Compile>
<Compile Include="Views\MainWindow.xaml.cs">
<DependentUpon>MainWindow.xaml</DependentUpon>
</Compile>
<Compile Include="Views\RecordEditorWindow.xaml.cs">
<DependentUpon>RecordEditorWindow.xaml</DependentUpon>
</Compile>
<Compile Include="Views\TerminalWindow.xaml.cs">
<DependentUpon>TerminalWindow.xaml</DependentUpon>
</Compile>
</ItemGroup>
<ItemGroup>
<Compile Include="Converters\ProxyTypeConverter.cs" />
<Compile Include="Properties\AssemblyInfo.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="Properties\Resources.Designer.cs">
<AutoGen>True</AutoGen>
<DesignTime>True</DesignTime>
<DependentUpon>Resources.resx</DependentUpon>
</Compile>
<Compile Include="Properties\Settings.Designer.cs">
<AutoGen>True</AutoGen>
<DependentUpon>Settings.settings</DependentUpon>
<DesignTimeSharedInput>True</DesignTimeSharedInput>
</Compile>
<EmbeddedResource Include="Properties\Resources.resx">
<Generator>ResXFileCodeGenerator</Generator>
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
</EmbeddedResource>
<None Include="packages.config" />
<None Include="Properties\Settings.settings">
<Generator>SettingsSingleFileGenerator</Generator>
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
</None>
<None Include="Templates\xray\base.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="Templates\xray\caddy\base.caddyfile">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="Templates\xray\client\00_log\00_log.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="Templates\xray\client\01_api\01_api.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="Templates\xray\client\02_dns\02_dns.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="Templates\xray\client\03_routing\03_routing.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="Templates\xray\client\04_policy\04_policy.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="Templates\xray\client\05_inbounds\05_inbounds.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="Templates\xray\client\06_outbounds\06_outbounds.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="Templates\xray\client\06_outbounds\VLESS_HTTP2_TLS.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="Templates\xray\client\06_outbounds\VLESS_TCP_TLS_WS.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="Templates\xray\client\07_transport\07_transport.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="Templates\xray\client\08_stats\08_stats.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="Templates\xray\client\09_reverse\09_reverse.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="Templates\xray\server\00_log\00_log.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="Templates\xray\server\01_api\01_api.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="Templates\xray\server\02_dns\02_dns.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="Templates\xray\server\03_routing\03_routing.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="Templates\xray\server\04_policy\04_policy.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="Templates\xray\server\05_inbounds\05_inbounds.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="Templates\xray\server\05_inbounds\Trojan_TCP_TLS.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="Templates\xray\server\05_inbounds\VLESS_TCP_XTLS.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="Templates\xray\server\05_inbounds\VLESS_WS_TLS.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="Templates\xray\server\05_inbounds\VMESS_TCP_TLS.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="Templates\xray\server\05_inbounds\VMESS_WS_TLS.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="Templates\xray\server\06_outbounds\06_outbounds.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="Templates\xray\server\07_transport\07_transport.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="Templates\xray\server\08_stats\08_stats.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="Templates\xray\server\09_reverse\09_reverse.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
</ItemGroup>
<ItemGroup>
<None Include="App.config" />
</ItemGroup>
<ItemGroup>
<Page Include="Resources\Languages\en.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</Page>
<Page Include="Resources\Languages\zh_cn.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</Page>
<Page Include="Resources\Styles\MaterialDesignThemes.Overrides.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</Page>
<Page Include="Views\ClientInfoWindow.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="Views\MainWindow.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</Page>
<Page Include="Views\RecordEditorWindow.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="Views\TerminalWindow.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</Page>
</ItemGroup>
<ItemGroup>
<Folder Include="Data\" />
</ItemGroup>
<ItemGroup>
<BootstrapperPackage Include=".NETFramework,Version=v4.6.1">
<Visible>False</Visible>
<ProductName>Microsoft .NET Framework 4.6.1 %28x86 和 x64%29</ProductName>
<Install>true</Install>
</BootstrapperPackage>
<BootstrapperPackage Include="Microsoft.Net.Framework.3.5.SP1">
<Visible>False</Visible>
<ProductName>.NET Framework 3.5 SP1</ProductName>
<Install>false</Install>
</BootstrapperPackage>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<Import Project="..\packages\MaterialDesignThemes.4.0.0\build\MaterialDesignThemes.targets" Condition="Exists('..\packages\MaterialDesignThemes.4.0.0\build\MaterialDesignThemes.targets')" />
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
<PropertyGroup>
<ErrorText>这台计算机上缺少此项目引用的 NuGet 程序包。使用“NuGet 程序包还原”可下载这些程序包。有关更多信息,请参见 http://go.microsoft.com/fwlink/?LinkID=322105。缺少的文件是 {0}。</ErrorText>
</PropertyGroup>
<Error Condition="!Exists('..\packages\MaterialDesignThemes.4.0.0\build\MaterialDesignThemes.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\MaterialDesignThemes.4.0.0\build\MaterialDesignThemes.targets'))" />
</Target>
<ProjectExtensions />
</Project>

View file

@ -0,0 +1,49 @@
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:sys="clr-namespace:System;assembly=mscorlib">
<sys:String x:Key="TabItemHeaderAppDeployment">Deployment</sys:String>
<sys:String x:Key="LanguageText">Language</sys:String>
<sys:String x:Key="LanguageChinese">Chinese</sys:String>
<sys:String x:Key="LanguageEnglish">English</sys:String>
<sys:String x:Key="Hosts">Hosts</sys:String>
<sys:String x:Key="AddHost">Add Host</sys:String>
<sys:String x:Key="Actions">Actions</sys:String>
<sys:String x:Key="Connect">Connect</sys:String>
<sys:String x:Key="Edit">Edit</sys:String>
<sys:String x:Key="EditTemp">Edit Xray</sys:String>
<sys:String x:Key="Delete">Delete</sys:String>
<sys:String x:Key="Install">Install</sys:String>
<sys:String x:Key="Save">Save</sys:String>
<sys:String x:Key="Info">Info</sys:String>
<sys:String x:Key="Warning">Warning</sys:String>
<sys:String x:Key="Error">Error</sys:String>
<!--Host Window-->
<sys:String x:Key="HostWindowTitle">Server Manager</sys:String>
<sys:String x:Key="ConnectionGroupName">Connection</sys:String>
<sys:String x:Key="HostUserName">User</sys:String>
<sys:String x:Key="HostPassword">Password</sys:String>
<sys:String x:Key="HostTag">Tag</sys:String>
<sys:String x:Key="HostAddress">Host</sys:String>
<sys:String x:Key="HostPort">Port</sys:String>
<sys:String x:Key="HostLoginType">Method</sys:String>
<sys:String x:Key="PasswordLogin">Password Login</sys:String>
<sys:String x:Key="CertLogin">KeyLogin</sys:String>
<sys:String x:Key="KeyLoginField">Key</sys:String>
<sys:String x:Key="KeyUpload">Upload</sys:String>
<sys:String x:Key="ProxyGroupName">Proxy</sys:String>
<sys:String x:Key="ProxyType">Method</sys:String>
<sys:String x:Key="ProxyTypeNone">None</sys:String>
<sys:String x:Key="ProxyTypeHttp">Http</sys:String>
<sys:String x:Key="ProxyTypeSocks5">Socks5</sys:String>
<sys:String x:Key="ProxyHostName">Host</sys:String>
<sys:String x:Key="ProxyHostPort">Port</sys:String>
<sys:String x:Key="ProxyUserName">User</sys:String>
<sys:String x:Key="ProxyPassword">Password</sys:String>
<sys:String x:Key="HostAddressNotNull">Please enter host</sys:String>
<sys:String x:Key="HostPortNotNull">Please enter port</sys:String>
<sys:String x:Key="PorxyAddressNotNull">Please enter proxy host</sys:String>
<sys:String x:Key="ProxyProtNotNull">Please enter proxy port</sys:String>
<!--Terminal Window-->
</ResourceDictionary>

View file

@ -0,0 +1,49 @@
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:sys="clr-namespace:System;assembly=mscorlib">
<sys:String x:Key="TabItemHeaderAppDeployment">应用布署</sys:String>
<sys:String x:Key="LanguageText">语言</sys:String>
<sys:String x:Key="LanguageChinese">中文</sys:String>
<sys:String x:Key="LanguageEnglish">英文</sys:String>
<sys:String x:Key="Hosts">主机列表</sys:String>
<sys:String x:Key="AddHost">添加主机</sys:String>
<sys:String x:Key="Actions">操作</sys:String>
<sys:String x:Key="Connect">连接</sys:String>
<sys:String x:Key="Install">安装</sys:String>
<sys:String x:Key="Edit">编辑</sys:String>
<sys:String x:Key="EditTemp">编辑模板</sys:String>
<sys:String x:Key="Delete">删除</sys:String>
<sys:String x:Key="Save">保存</sys:String>
<sys:String x:Key="Info">消息</sys:String>
<sys:String x:Key="Warning">提示</sys:String>
<sys:String x:Key="Error">错误</sys:String>
<!--Host Window-->
<sys:String x:Key="HostWindowTitle">服务器管理</sys:String>
<sys:String x:Key="ConnectionGroupName">连接</sys:String>
<sys:String x:Key="HostUserName">用户名</sys:String>
<sys:String x:Key="HostPassword">密码</sys:String>
<sys:String x:Key="HostTag">别名</sys:String>
<sys:String x:Key="HostAddress">主机</sys:String>
<sys:String x:Key="HostPort">端口</sys:String>
<sys:String x:Key="HostLoginType">登陆方式</sys:String>
<sys:String x:Key="PasswordLogin">密码登陆</sys:String>
<sys:String x:Key="KeyLogin">密钥登陆</sys:String>
<sys:String x:Key="KeyLoginField">密钥</sys:String>
<sys:String x:Key="KeyUpload">上传</sys:String>
<sys:String x:Key="ProxyGroupName">代理</sys:String>
<sys:String x:Key="ProxyType">类型</sys:String>
<sys:String x:Key="ProxyTypeNone">无</sys:String>
<sys:String x:Key="ProxyTypeHttp">Http</sys:String>
<sys:String x:Key="ProxyTypeSocks5">Socks5</sys:String>
<sys:String x:Key="ProxyHostName">代理地址</sys:String>
<sys:String x:Key="ProxyHostPort">代理端口</sys:String>
<sys:String x:Key="ProxyUserName">用户名</sys:String>
<sys:String x:Key="ProxyPassword">密码</sys:String>
<sys:String x:Key="HostAddressNotNull">请输入主机</sys:String>
<sys:String x:Key="HostPortNotNull">请输入端口号</sys:String>
<sys:String x:Key="PorxyAddressNotNull">请输入代理地址</sys:String>
<sys:String x:Key="ProxyProtNotNull">请输入代理端口号</sys:String>
<!--Terminal Window-->
</ResourceDictionary>

View file

@ -0,0 +1,48 @@
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:materialDesign="clr-namespace:MaterialDesignThemes.Wpf;assembly=MaterialDesignThemes.Wpf">
<Style
TargetType="{x:Type TabItem}"
BasedOn="{StaticResource MaterialDesignNavigationRailTabItem}"
x:Key="MaterialDesignNavigationRailTabItem">
<Setter Property="Height" Value="52" />
<Setter Property="Padding" Value="12,0" />
</Style>
<Style
TargetType="GroupBox"
x:Key="MaterialDesignHeaderedContentControl">
</Style>
<Style
TargetType="DataGridCell"
BasedOn="{StaticResource MahApps.Styles.DataGridCell}"
x:Key="DataGridCell">
<Setter Property="BorderThickness" Value="0"/>
<Setter Property="HorizontalAlignment" Value="Center"/>
<Setter Property="Padding" Value="10,7"/>
<Style.Triggers>
<Trigger Property="IsMouseOver" Value="True">
<Setter Property="Foreground" Value="{DynamicResource MahApps.Brushes.Accent}" />
</Trigger>
<Trigger Property="IsSelected" Value="True">
<Setter Property="Foreground" Value="{DynamicResource MahApps.Brushes.Accent}" />
<Setter Property="FontWeight" Value="Bold"/>
</Trigger>
</Style.Triggers>
</Style>
<Style TargetType="DataGridColumnHeader"
BasedOn="{StaticResource MaterialDesignDataGridColumnHeader}"
x:Key="DataGridColumnHeader">
<Setter Property="HorizontalAlignment" Value="Center" />
<Setter Property="BorderThickness" Value="0,0,0,1"/>
</Style>
<Style
TargetType="DataGrid"
BasedOn="{StaticResource MahApps.Styles.DataGrid}"
x:Key="DataGrid">
</Style>
</ResourceDictionary>

View file

@ -0,0 +1,12 @@
{
"log": {},
"api": {},
"dns": {},
"routing": {},
"policy": {},
"inbounds": [],
"outbounds": [],
"transport": {},
"stats": {},
"reverse": {}
}

View file

@ -0,0 +1,5 @@
##domain##:80 {
root * /usr/share/caddy
file_server
##reverse_proxy##
}

View file

@ -0,0 +1,5 @@
{
"log": {
"loglevel": "warning"
}
}

View file

@ -0,0 +1,3 @@
{
"api": null
}

View file

@ -0,0 +1,3 @@
{
"dns": {}
}

View file

@ -0,0 +1,3 @@
{
"routing": {}
}

View file

@ -0,0 +1,3 @@
{
"policy": {}
}

View file

@ -0,0 +1,23 @@
{
"inbounds": [
{
"protocol": "http",
"port": 1081
},
{
"port": 1080,
"protocol": "socks",
"sniffing": {
"enabled": true,
"destOverride": [
"http",
"tls"
]
},
"settings": {
"udp": true,
"auth": "noauth"
}
}
]
}

View file

@ -0,0 +1,3 @@
{
"outbounds": []
}

View file

@ -0,0 +1,31 @@
{
"outbounds": [
{
"protocol": "vless",
"settings": {
"vnext": [
{
"address": "",
"port": 443,
"users": [
{
"id": "",
"encryption": "none"
}
]
}
]
},
"streamSettings": {
"network": "h2",
"security": "tls",
"httpSettings": {
"host": [
""
],
"path": null
}
}
}
]
}

View file

@ -0,0 +1,32 @@
{
"outbounds": [
{
"protocol": "vless",
"settings": {
"vnext": [
{
"address": "",
"port": 443,
"users": [
{
"id": "",
"encryption": "none",
"level": 0
}
]
}
]
},
"streamSettings": {
"network": "ws",
"security": "tls",
"tlsSettings": {
"serverName": ""
},
"wsSettings": {
"path": ""
}
}
}
]
}

View file

@ -0,0 +1,3 @@
{
"transport": {}
}

View file

@ -0,0 +1,3 @@
{
"stats": null
}

View file

@ -0,0 +1,3 @@
{
"reverse": {}
}

View file

@ -0,0 +1,6 @@
{
"log": {
"access": "none",
"loglevel": "none"
}
}

View file

@ -0,0 +1,3 @@
{
"api": {}
}

View file

@ -0,0 +1,3 @@
{
"dns": {}
}

View file

@ -0,0 +1,14 @@
{
"routing": {
"domainStrategy": "AsIs",
"rules": [
{
"type": "field",
"ip": [
"geoip:private"
],
"outboundTag": "block"
}
]
}
}

View file

@ -0,0 +1,3 @@
{
"policy": {}
}

View file

@ -0,0 +1,3 @@
{
"inbounds": []
}

View file

@ -0,0 +1,26 @@
{
"port": 1310,
"listen": "127.0.0.1",
"protocol": "trojan",
"settings": {
"clients": [
{
"password": "",
"level": 0,
"email": "love@example.com"
}
],
"fallbacks": [
{
"dest": 80
}
]
},
"streamSettings": {
"network": "tcp",
"security": "none",
"tcpSettings": {
"acceptProxyProtocol": true
}
}
}

View file

@ -0,0 +1,31 @@
{
"port": 443,
"protocol": "vless",
"settings": {
"clients": [
{
"id": "",
"flow": "xtls-rprx-direct",
"level": 0,
"email": "love@example.com"
}
],
"decryption": "none",
"fallbacks": []
},
"streamSettings": {
"network": "tcp",
"security": "xtls",
"xtlsSettings": {
"alpn": [
"http/1.1"
],
"certificates": [
{
"certificateFile": "/usr/local/etc/xray/ssl/xray_ssl.crt",
"keyFile": "/usr/local/etc/xray/ssl/xray_ssl.key"
}
]
}
}
}

View file

@ -0,0 +1,23 @@
{
"port": 1234,
"listen": "127.0.0.1",
"protocol": "vless",
"settings": {
"clients": [
{
"id": "",
"level": 0,
"email": "love@example.com"
}
],
"decryption": "none"
},
"streamSettings": {
"network": "ws",
"security": "none",
"wsSettings": {
"acceptProxyProtocol": true,
"path": "/websocket"
}
}
}

View file

@ -0,0 +1,29 @@
{
"port": 443,
"listen": "127.0.0.1",
"protocol": "vmess",
"settings": {
"clients": [
{
"id": "",
"level": 0,
"email": "love@example.com"
}
]
},
"streamSettings": {
"network": "tcp",
"security": "none",
"tcpSettings": {
"acceptProxyProtocol": true,
"header": {
"type": "http",
"request": {
"path": [
"/vmesstcp"
]
}
}
}
}
}

View file

@ -0,0 +1,22 @@
{
"port": 3456,
"listen": "127.0.0.1",
"protocol": "vmess",
"settings": {
"clients": [
{
"id": "",
"level": 0,
"email": "love@example.com"
}
]
},
"streamSettings": {
"network": "ws",
"security": "none",
"wsSettings": {
"acceptProxyProtocol": true,
"path": "/vmessws"
}
}
}

View file

@ -0,0 +1,12 @@
{
"outbounds": [
{
"protocol": "freedom",
"tag": "direct"
},
{
"protocol": "blackhole",
"tag": "block"
}
]
}

View file

@ -0,0 +1,3 @@
{
"transport": {}
}

View file

@ -0,0 +1,3 @@
{
"stats": {}
}

View file

@ -0,0 +1,3 @@
{
"reverse": {}
}

View file

@ -0,0 +1,83 @@
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Net;
using System.Runtime.InteropServices;
using System.Text;
namespace ProxySU_Core.Tools
{
public static class DateTimeUtils
{
/// <summary>
/// 从国家授时中心获取标准GMT时间读取https://www.tsa.cn
/// GMT时间与UTC时间没有差别可以UTC=GMT
/// </summary>
/// <returns>返回网络时间</returns>
public static DateTime GetUTCTime()
{
DateTime time;
try
{
HttpWebRequest request = (HttpWebRequest)WebRequest.Create("https://www.tsa.cn");
request.Method = "HEAD";
request.AllowAutoRedirect = false;
HttpWebResponse reponse = (HttpWebResponse)request.GetResponse();
string cc = reponse.GetResponseHeader("date");
reponse.Close();
bool s = GMTStrParse(cc, out time);
return time;
}
catch
{
return new DateTime(1970, 1, 1, 0, 0, 0, 0);
}
}
public static bool GMTStrParse(string gmtStr, out DateTime gmtTime) //抓取的date是GMT格式的字符串这里转成datetime
{
CultureInfo enUS = new CultureInfo("en-US");
bool s = DateTime.TryParseExact(gmtStr, "r", enUS, DateTimeStyles.None, out gmtTime);
return s;
}
//设置系统时间的API函数
[DllImport("kernel32.dll")]
private static extern bool SetLocalTime(ref SYSTEMTIME time);
[StructLayout(LayoutKind.Sequential)]
private struct SYSTEMTIME
{
public short year;
public short month;
public short dayOfWeek;
public short day;
public short hour;
public short minute;
public short second;
public short milliseconds;
}
/// <summary>
/// 设置系统时间
/// </summary>
/// <param name="dt">需要设置的时间</param>
/// <returns>返回系统时间设置状态true为成功false为失败</returns>
public static bool SetDate(DateTime dt)
{
SYSTEMTIME st;
st.year = (short)dt.Year;
st.month = (short)dt.Month;
st.dayOfWeek = (short)dt.DayOfWeek;
st.day = (short)dt.Day;
st.hour = (short)dt.Hour;
st.minute = (short)dt.Minute;
st.second = (short)dt.Second;
st.milliseconds = (short)dt.Millisecond;
bool rt = SetLocalTime(ref st);
return rt;
}
}
}

View file

@ -0,0 +1,62 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.Serialization.Formatters.Binary;
using System.Text;
using System.Threading.Tasks;
namespace System
{
public static class Extensions
{
// Deep clone
public static T DeepClone<T>(this T obj)
{
if (obj == null)
throw new ArgumentNullException("Object cannot be null");
return (T)Process(obj);
}
static object Process(object obj)
{
if (obj == null)
return null;
Type type = obj.GetType();
if (type.IsValueType || type == typeof(string))
{
return obj;
}
else if (type.IsArray)
{
Type elementType = Type.GetType(
type.FullName.Replace("[]", string.Empty));
var array = obj as Array;
Array copied = Array.CreateInstance(elementType, array.Length);
for (int i = 0; i < array.Length; i++)
{
copied.SetValue(Process(array.GetValue(i)), i);
}
return Convert.ChangeType(copied, obj.GetType());
}
else if (type.IsClass)
{
object toret = Activator.CreateInstance(obj.GetType());
FieldInfo[] fields = type.GetFields(BindingFlags.Public |
BindingFlags.NonPublic | BindingFlags.Instance);
foreach (FieldInfo field in fields)
{
object fieldValue = field.GetValue(obj);
if (fieldValue == null)
continue;
field.SetValue(toret, Process(fieldValue));
}
return toret;
}
else
throw new ArgumentException("Unknown type");
}
}
}

View file

@ -0,0 +1,41 @@
using System;
using System.Collections.Generic;
using System.Text;
using System.Windows.Input;
namespace ProxySU_Core.ViewModels
{
public class BaseCommand : ICommand
{
private readonly Action<object> _execution;
private readonly Func<object, bool> _canExecute;
public BaseCommand(Action<object> execution, Func<object, bool> canExecute = null)
{
_execution = execution;
_canExecute = canExecute;
}
public event EventHandler CanExecuteChanged;
public bool CanExecute(object parameter)
{
if (_canExecute == null)
{
return true;
}
return _canExecute(parameter);
}
public void Execute(object parameter)
{
if (_execution != null && CanExecute(parameter))
{
_execution.Invoke(parameter);
}
}
}
}

View file

@ -0,0 +1,20 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Text;
namespace ProxySU_Core.ViewModels
{
public abstract class BaseViewModel : INotifyPropertyChanged
{
public event PropertyChangedEventHandler PropertyChanged;
public void Notify(string propertyName)
{
if (PropertyChanged != null)
{
PropertyChanged.Invoke(this, new PropertyChangedEventArgs(propertyName));
}
}
}
}

View file

@ -0,0 +1,186 @@
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using ProxySU_Core.Models;
using System;
using System.Collections.Generic;
using System.IO;
using System.Text;
namespace ProxySU_Core.ViewModels.Developers
{
public class ConfigBuilder
{
public dynamic xrayConfig { get; set; }
public string CaddyConfig { get; set; }
private const string ServerLogDir = @"Templates\xray\server\00_log";
private const string ServerApiDir = @"Templates\xray\server\01_api";
private const string ServerDnsDir = @"Templates\xray\server\02_dns";
private const string ServerRoutingDir = @"Templates\xray\server\03_routing";
private const string ServerPolicyDir = @"Templates\xray\server\04_policy";
private const string ServerInboundsDir = @"Templates\xray\server\05_inbounds";
private const string ServerOutboundsDir = @"Templates\xray\server\06_outbounds";
private const string ServerTransportDir = @"Templates\xray\server\07_transport";
private const string ServerStatsDir = @"Templates\xray\server\08_stats";
private const string ServerReverseDir = @"Templates\xray\server\09_reverse";
private const string CaddyFileDir = @"Templates\xray\caddy";
public const int VLESS_TCP_Port = 1110;
public const int VLESS_WS_Port = 1111;
public const int VMESS_TCP_Port = 2110;
public const int VMESS_WS_Port = 2111;
public const int Trojan_TCP_Port = 3110;
public static dynamic LoadXrayConfig()
{
dynamic logObj = LoadJsonObj(Path.Combine(ServerLogDir, "00_log.json"));
dynamic apiObj = LoadJsonObj(Path.Combine(ServerApiDir, "01_api.json"));
dynamic dnsObj = LoadJsonObj(Path.Combine(ServerDnsDir, "02_dns.json"));
dynamic routingObj = LoadJsonObj(Path.Combine(ServerRoutingDir, "03_routing.json"));
dynamic policyObj = LoadJsonObj(Path.Combine(ServerPolicyDir, "04_policy.json"));
dynamic inboundsObj = LoadJsonObj(Path.Combine(ServerInboundsDir, "05_inbounds.json"));
dynamic outboundsObj = LoadJsonObj(Path.Combine(ServerOutboundsDir, "06_outbounds.json"));
dynamic transportObj = LoadJsonObj(Path.Combine(ServerTransportDir, "07_transport.json"));
dynamic statsObj = LoadJsonObj(Path.Combine(ServerStatsDir, "08_stats.json"));
dynamic reverseObj = LoadJsonObj(Path.Combine(ServerReverseDir, "09_reverse.json"));
return new
{
log = logObj["log"],
//api = apiObj["api"], api不能为空
dns = dnsObj["dns"],
routing = routingObj["routing"],
policy = policyObj["policy"],
inbounds = inboundsObj["inbounds"],
outbounds = outboundsObj["outbounds"],
transport = transportObj["transport"],
stats = statsObj["stats"],
reverse = reverseObj["reverse"]
};
}
public static string BuildCaddyConfig(XraySettings parameters, bool useCustomWeb = false)
{
var caddyStr = File.ReadAllText(Path.Combine(CaddyFileDir, "base.caddyfile"));
caddyStr = caddyStr.Replace("##domain##", parameters.Domain);
if (!useCustomWeb && !string.IsNullOrEmpty(parameters.MaskDomain))
{
var prefix = "http://";
if (parameters.MaskDomain.StartsWith("https://"))
{
prefix = "https://";
}
var domain = parameters.MaskDomain
.TrimStart("http://".ToCharArray())
.TrimStart("https://".ToCharArray());
caddyStr = caddyStr.Replace("##reverse_proxy##", $"reverse_proxy {prefix}{domain} {{ \n header_up Host {domain} \n }}");
}
else
{
caddyStr = caddyStr.Replace("##reverse_proxy##", "");
}
return caddyStr;
}
public static string BuildXrayConfig(XraySettings parameters)
{
var xrayConfig = LoadXrayConfig();
var baseBound = LoadJsonObj(Path.Combine(ServerInboundsDir, "VLESS_TCP_XTLS.json"));
baseBound.port = parameters.Port;
baseBound.settings.fallbacks.Add(JToken.FromObject(new
{
dest = 80,
xver = 1,
}));
xrayConfig.inbounds.Add(baseBound);
if (parameters.Types.Contains(XrayType.VLESS_TCP_XTLS))
{
baseBound.settings.clients[0].id = parameters.UUID;
}
if (parameters.Types.Contains(XrayType.VLESS_WS_TLS))
{
baseBound.settings.clients[0].id = parameters.UUID;
var wsInbound = LoadJsonObj(Path.Combine(ServerInboundsDir, "VLESS_WS_TLS.json"));
wsInbound.port = VLESS_WS_Port;
wsInbound.settings.clients[0].id = parameters.UUID;
wsInbound.streamSettings.wsSettings.path = parameters.VLESS_WS_Path;
baseBound.settings.fallbacks.Add(JToken.FromObject(new
{
dest = VLESS_WS_Port,
path = parameters.VLESS_WS_Path,
xver = 1,
}));
xrayConfig.inbounds.Add(JToken.FromObject(wsInbound));
}
if (parameters.Types.Contains(XrayType.VMESS_TCP_TLS))
{
var mtcpBound = LoadJsonObj(Path.Combine(ServerInboundsDir, "VMESS_TCP_TLS.json"));
mtcpBound.port = VMESS_TCP_Port;
mtcpBound.settings.clients[0].id = parameters.UUID;
mtcpBound.streamSettings.tcpSettings.header.request.path = parameters.VMESS_TCP_Path;
baseBound.settings.fallbacks.Add(JToken.FromObject(new
{
dest = VMESS_TCP_Port,
path = parameters.VMESS_TCP_Path,
xver = 1,
}));
xrayConfig.inbounds.Add(JToken.FromObject(mtcpBound));
}
if (parameters.Types.Contains(XrayType.VMESS_WS_TLS))
{
var mwsBound = LoadJsonObj(Path.Combine(ServerInboundsDir, "VMESS_WS_TLS.json"));
mwsBound.port = VMESS_WS_Port;
mwsBound.settings.clients[0].id = parameters.UUID;
mwsBound.streamSettings.wsSettings.path = parameters.VMESS_WS_Path;
baseBound.settings.fallbacks.Add(JToken.FromObject(new
{
dest = VMESS_WS_Port,
path = parameters.VMESS_WS_Path,
xver = 1,
}));
xrayConfig.inbounds.Add(JToken.FromObject(mwsBound));
}
if (parameters.Types.Contains(XrayType.Trojan_TCP_TLS))
{
var trojanTcpBound = LoadJsonObj(Path.Combine(ServerInboundsDir, "Trojan_TCP_TLS.json"));
trojanTcpBound.port = Trojan_TCP_Port;
trojanTcpBound.settings.clients[0].password = parameters.TrojanPassword;
baseBound.settings.fallbacks[0] = JToken.FromObject(new
{
dest = Trojan_TCP_Port,
xver = 1,
});
xrayConfig.inbounds.Add(JToken.FromObject(trojanTcpBound));
}
return JsonConvert.SerializeObject(
xrayConfig,
Formatting.Indented,
new JsonSerializerSettings()
{
NullValueHandling = NullValueHandling.Ignore
});
}
private static dynamic LoadJsonObj(string path)
{
if (File.Exists(path))
{
var jsonStr = File.ReadAllText(path, Encoding.UTF8);
return JToken.FromObject(JsonConvert.DeserializeObject(jsonStr));
}
return null;
}
}
}

View file

@ -0,0 +1,13 @@
using System;
using System.Collections.Generic;
using System.Text;
namespace ProxySU_Core.ViewModels.Developers
{
public interface IParameters
{
int Port { get; set; }
string Domain { get; set; }
}
}

View file

@ -0,0 +1,577 @@
using ProxySU_Core.Tools;
using Renci.SshNet;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
namespace ProxySU_Core.ViewModels.Developers
{
public enum CmdType
{
None,
Apt,
Dnf,
Yum
}
public abstract class Project<TParameters> : BaseViewModel where TParameters : IParameters
{
private SshClient _sshClient;
protected Action<string> WriteOutput;
protected CmdType CmdType { get; set; }
protected bool IsSELinux { get; set; }
protected bool OnlyIpv6 { get; set; }
protected string IPv4 { get; set; }
protected string IPv6 { get; set; }
protected TParameters Parameters { get; set; }
public Project(SshClient sshClient, TParameters parameters, Action<string> writeOutput)
{
_sshClient = sshClient;
WriteOutput = writeOutput;
Parameters = parameters;
}
protected string RunCmd(string cmdStr)
{
var cmd = _sshClient.CreateCommand(cmdStr);
WriteOutput(cmdStr);
var result = cmd.Execute();
WriteOutput(result);
return result;
}
/// <summary>
/// 执行安装命令
/// </summary>
public abstract void Install();
/// <summary>
/// 配置系统基础环境
/// </summary>
protected void EnsureSystemEnv()
{
string cmd;
// 确认安装命令
if (CmdType == CmdType.None)
{
cmd = RunCmd("command -v apt-get");
if (!string.IsNullOrEmpty(cmd))
{
CmdType = CmdType.Apt;
}
}
if (CmdType == CmdType.None)
{
cmd = RunCmd("command -v dnf");
if (!string.IsNullOrEmpty(cmd))
{
CmdType = CmdType.Dnf;
}
}
if (CmdType == CmdType.None)
{
cmd = RunCmd("command -v yum");
if (!string.IsNullOrEmpty(cmd))
{
CmdType = CmdType.Yum;
}
}
// systemctl
cmd = RunCmd("command -v systemctl");
var hasSystemCtl = !string.IsNullOrEmpty(cmd);
// SELinux
cmd = RunCmd("command -v getenforce");
IsSELinux = !string.IsNullOrEmpty(cmd);
if (CmdType == CmdType.None || !hasSystemCtl)
{
throw new Exception("系统缺乏必要的安装组件如:apt-get||dnf||yum||Syetemd主机系统推荐使用CentOS 7/8,Debian 8/9/10,Ubuntu 16.04及以上版本");
}
// 判断是否启用了SELinux,如果启用了并且工作在Enforcing模式下则改为Permissive模式
if (IsSELinux)
{
cmd = RunCmd("getenforce");
// 检测到系统启用SELinux且工作在严格模式下需改为宽松模式
if (cmd.Contains("Enforcing"))
{
RunCmd("setenforce 0");
RunCmd(@"sed -i 's/SELINUX=enforcing/SELINUX=permissive/' /etc/selinux/config");
}
}
}
/// <summary>
/// 确保Root账户登陆
/// </summary>
protected void EnsureRootAuth()
{
// 禁止一些可能产生的干扰信息
RunCmd(@"sed -i 's/echo/#echo/g' ~/.bashrc");
RunCmd(@"sed -i 's/echo/#echo/g' ~/.profile");
// 检测是否运行在Root权限下
var cmd = RunCmd("id -u");
if (!cmd.Equals("0\n"))
{
throw new Exception("请使用Root账户登陆主机");
}
}
/// <summary>
/// 配置IPV6环境
/// </summary>
protected void ConfigureIPv6()
{
if (IsOnlyIpv6())
{
SetNat64();
}
}
/// <summary>
/// 配置必要的软件
/// </summary>
protected void ConfigureSoftware()
{
string cmd = RunCmd("command -v sudo");
if (string.IsNullOrEmpty(cmd))
{
RunCmd(GetInstallCmd("sudo"));
}
// 安装curl,wget,unzip
cmd = RunCmd("command -v curl");
if (string.IsNullOrEmpty(cmd))
{
RunCmd(GetInstallCmd("curl"));
}
cmd = RunCmd("command -v wget");
if (string.IsNullOrEmpty(cmd))
{
RunCmd(GetInstallCmd("wget"));
}
cmd = RunCmd("command -v unzip");
if (string.IsNullOrEmpty(cmd))
{
RunCmd(GetInstallCmd("unzip"));
}
// 安装dig
cmd = RunCmd("command -v dig");
if (string.IsNullOrEmpty(cmd))
{
if (CmdType == CmdType.Apt)
{
RunCmd(GetUpdateCmd());
RunCmd(GetInstallCmd("dnsutils"));
}
else if (CmdType == CmdType.Dnf)
{
RunCmd(GetUpdateCmd());
RunCmd(GetInstallCmd("bind-utils"));
}
else if (CmdType == CmdType.Yum)
{
RunCmd(GetUpdateCmd());
RunCmd(GetInstallCmd("bind-utils"));
}
}
// 处理极其少见的xz-utils未安装的情况
if (CmdType == CmdType.Apt)
{
RunCmd(GetInstallCmd("xz-utils"));
}
else
{
RunCmd(GetInstallCmd("xz-devel"));
}
// 检测是否安装lsof
cmd = RunCmd("command -v lsof");
if (string.IsNullOrEmpty(cmd))
{
RunCmd(GetInstallCmd("lsof"));
}
}
/// <summary>
/// 配置防火墙
/// </summary>
protected void ConfigureFirewall()
{
string cmd;
cmd = RunCmd("command -v firewall-cmd");
if (!string.IsNullOrEmpty(cmd))
{
//有很奇怪的vps主机在firewalld未运行时端口是关闭的无法访问。所以要先启动firewalld
//用于保证acme.sh申请证书成功
cmd = RunCmd("firewall-cmd --state");
if (cmd.Trim() != "running")
{
RunCmd("systemctl restart firewalld");
}
if (Parameters.Port == 443)
{
RunCmd("firewall-cmd --zone=public --add-port=80/tcp --permanent");
RunCmd("firewall-cmd --zone=public --add-port=443/tcp --permanent");
RunCmd("firewall-cmd --zone=public --add-port=80/udp --permanent");
RunCmd("firewall-cmd --zone=public --add-port=443/udp --permanent");
RunCmd("yes | firewall-cmd --reload");
}
else
{
RunCmd($"firewall-cmd --zone=public --add-port={Parameters.Port}/tcp --permanent");
RunCmd($"firewall-cmd --zone=public --add-port={Parameters.Port}/udp --permanent");
RunCmd("yes | firewall-cmd --reload");
}
return;
}
cmd = RunCmd("command -v ufw");
if (!string.IsNullOrEmpty(cmd))
{
if (Parameters.Port == 443)
{
RunCmd("ufw allow 80/tcp");
RunCmd("ufw allow 443/tcp");
RunCmd("ufw allow 80/udp");
RunCmd("ufw allow 443/udp");
RunCmd("yes | ufw reload");
}
else
{
RunCmd($"ufw allow {Parameters.Port}/tcp");
RunCmd($"ufw allow {Parameters.Port}/udp");
RunCmd("yes | ufw reload");
}
}
}
/// <summary>
/// 配置同步时间差
/// </summary>
protected void SyncTimeDiff()
{
RunCmd("rm -f /etc/localtime");
RunCmd("ln -s /usr/share/zoneinfo/UTC /etc/localtime");
var result = RunCmd("date +%s");
var vpsSeconds = Convert.ToInt64(result);
var localSeconds = (int)(DateTime.Now.ToUniversalTime() - DateTime.Parse("1970-01-01")).TotalSeconds;
if (Math.Abs(vpsSeconds - localSeconds) >= 90)
{
// 同步本地时间
var netUtcTime = DateTimeUtils.GetUTCTime();
DateTimeUtils.SetDate(netUtcTime.ToLocalTime());
// 同步VPS时间
var utcTS = DateTimeUtils.GetUTCTime() - new DateTime(1970, 1, 1, 0, 0, 0, 0);
long timeStampVPS = Convert.ToInt64(utcTS.TotalSeconds);
RunCmd($"date --set=\"$(date \"+%Y-%m-%d %H:%M:%S\" -d @{timeStampVPS.ToString()})\"");
}
}
/// <summary>
/// 验证域名是否绑定了主机
/// </summary>
protected void ValidateDomain()
{
if (OnlyIpv6)
{
string cmdFilter = @"| grep -oE '(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))' | head -n 1";
var cmd = $"dig @resolver1.opendns.com AAAA {Parameters.Domain} +short -6 {cmdFilter}";
var result = RunCmd(cmd).TrimEnd('\r', '\n');
if (result == IPv6) return;
}
else
{
string cmdFilter = @"| grep -oE '[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+' | head -n 1";
var cmd = $"dig @resolver1.opendns.com A {Parameters.Domain} +short -4 {cmdFilter}";
var result = RunCmd(cmd).TrimEnd('\r', '\n');
if (result == IPv4) return;
}
var btnResult = MessageBox.Show(
$"{Parameters.Domain}未能正常解析到服务器的IP如果您使用了CDN请忽略是否继续安装?", "提示", MessageBoxButton.YesNo);
if (btnResult == MessageBoxResult.No)
{
throw new Exception($"域名解析失败,安装停止!");
}
}
/// <summary>
/// 判断是否安装某个软件
/// </summary>
/// <param name="path"></param>
/// <returns></returns>
protected bool FileExists(string path)
{
var cmdStr = $"if [[ -f {path} ]];then echo '1';else echo '0'; fi";
var cmd = RunCmd(cmdStr);
return cmd.Trim() == "1";
}
/// <summary>
/// 安装 Caddy
/// </summary>
protected void InstallCaddy()
{
RunCmd("rm -rf caddy_install.sh");
RunCmd("curl -o caddy_install.sh https://raw.githubusercontent.com/proxysu/shellscript/master/Caddy-Naive/caddy-naive-install.sh");
RunCmd("yes | bash caddy_install.sh");
//if (CmdType == CmdType.Apt)
//{
// RunCmd("sudo apt install -y debian-keyring debian-archive-keyring apt-transport-https");
// RunCmd("curl -1sLf 'https://dl.cloudsmith.io/public/caddy/stable/gpg.key' | sudo apt-key add -");
// RunCmd("curl -1sLf 'https://dl.cloudsmith.io/public/caddy/stable/debian.deb.txt' | sudo tee -a /etc/apt/sources.list.d/caddy-stable.list");
// RunCmd(GetUpdateCmd());
// RunCmd("sudo apt install caddy");
//}
//else if (CmdType == CmdType.Dnf)
//{
// RunCmd("echo y | dnf install 'dnf-command(copr)'");
// RunCmd("echo y | dnf copr enable @caddy/caddy");
// RunCmd(GetUpdateCmd());
// RunCmd("dnf install caddy");
//}
//else if (CmdType == CmdType.Yum)
//{
// RunCmd("echo y | echo y | yum install yum-plugin-copr");
// RunCmd("echo y | echo y | yum copr enable @caddy/caddy");
// RunCmd(GetUpdateCmd());
// RunCmd("yum install caddy");
//}
}
#region
private bool IsOnlyIpv6()
{
string cmd;
cmd = RunCmd(@"curl -s https://api.ip.sb/ip --ipv4 --max-time 8");
IPv4 = cmd.TrimEnd('\r', '\n');
if (!string.IsNullOrEmpty(IPv4))
{
OnlyIpv6 = false;
return false;
}
cmd = RunCmd(@"curl -s https://api.ip.sb/ip --ipv6 --max-time 8");
IPv6 = cmd.TrimEnd('\r', '\n');
if (string.IsNullOrEmpty(IPv6))
{
throw new Exception("未检测可用的的IP地址");
}
OnlyIpv6 = true;
return OnlyIpv6;
}
private bool SetPortFree(int port, bool force = true)
{
string result = RunCmd($"lsof -n -P -i :{port} | grep LISTEN");
if (!string.IsNullOrEmpty(result))
{
if (force)
{
var btnResult = MessageBox.Show($"{port}端口被占用,将强制停止占用{port}端口的程序?", "提示", MessageBoxButton.YesNo);
if (btnResult == MessageBoxResult.No)
{
throw new Exception($"{port}端口被占用,安装停止!");
}
string[] process = result.Split(' ');
RunCmd($"systemctl stop {process[0]}");
RunCmd($"systemctl disable {process[0]}");
RunCmd($"pkill {process[0]}");
return SetPortFree(port, force: false);
}
else
{
return false;
}
}
return true;
}
public void ConfigurePort(bool force = true)
{
if (Parameters.Port == 80 || Parameters.Port == 443)
{
SetPortFree(80);
SetPortFree(443);
}
else
{
SetPortFree(80);
SetPortFree(443);
SetPortFree(Parameters.Port);
}
}
protected void SetNat64()
{
var dns64List = FilterFastestIP();
if (dns64List.Count == 0)
{
throw new Exception("未找到有效的Nat64网关");
}
var exists = FileExists("/etc/resolv.conf.proxysu");
if (!exists)
{
var cmdStr = @"mv /etc/resolv.conf /etc/resolv.conf.proxysu";
RunCmd(cmdStr);
}
foreach (var gateip in dns64List)
{
RunCmd($"echo \"nameserver {gateip}\" > /etc/resolv.conf");
}
}
protected void RemoveNat64()
{
RunCmd("rm /etc/resolv.conf");
RunCmd("mv /etc/resolv.conf.proxysu /etc/resolv.conf");
}
private List<string> FilterFastestIP()
{
string[] gateNat64 = {
"2a01:4f9:c010:3f02::1",
"2001:67c:2b0::4",
"2001:67c:2b0::6",
"2a09:11c0:f1:bbf0::70",
"2a01:4f8:c2c:123f::1",
"2001:67c:27e4:15::6411",
"2001:67c:27e4::64",
"2001:67c:27e4:15::64",
"2001:67c:27e4::60",
"2a00:1098:2b::1",
"2a03:7900:2:0:31:3:104:161",
"2a00:1098:2c::1",
"2a09:11c0:100::53",
};
Dictionary<string, float> dns64List = new Dictionary<string, float>();
foreach (var gateip in gateNat64)
{
var cmdStr = $"ping6 -c4 {gateip} | grep avg | awk '{{print $4}}'|cut -d/ -f2";
var cmd = RunCmd(cmdStr);
if (!string.IsNullOrEmpty(cmd))
{
if (float.TryParse(cmd, out float delay))
{
dns64List.Add(gateip, delay);
}
}
}
return dns64List.Keys.ToList();
}
#endregion
protected void UploadFile(Stream stream, string path)
{
using (var sftp = new SftpClient(_sshClient.ConnectionInfo))
{
sftp.Connect();
sftp.UploadFile(stream, path, true);
sftp.Disconnect();
}
}
/// <summary>
/// 根据系统环境匹配更新命令
/// </summary>
/// <returns></returns>
protected string GetUpdateCmd()
{
if (CmdType == CmdType.Apt)
{
return "apt-get update";
}
else if (CmdType == CmdType.Dnf)
{
return "dnf clean all;dnf makecache";
}
else if (CmdType == CmdType.Yum)
{
return "yum clean all;yum makecache";
}
throw new Exception("未识别的系统");
}
/// <summary>
/// 根据系统匹配安装命令
/// </summary>
/// <param name="soft"></param>
/// <returns></returns>
protected string GetInstallCmd(string soft)
{
if (CmdType == CmdType.Apt)
{
return "echo y | apt-get install " + soft;
}
else if (CmdType == CmdType.Dnf)
{
return "echo y | dnf -y install " + soft;
}
else if (CmdType == CmdType.Yum)
{
return "echo y | yum -y install " + soft;
}
throw new Exception("未识别的系统");
}
}
}

View file

@ -0,0 +1,321 @@
using Renci.SshNet;
using System;
using System.Collections.Generic;
using System.IO;
using System.Text;
using System.Windows;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using ProxySU_Core.Models;
namespace ProxySU_Core.ViewModels.Developers
{
public class XrayProject : Project<XraySettings>
{
private const string ServerLogDir = @"Templates\xray\server\00_log";
private const string ServerApiDir = @"Templates\xray\server\01_api";
private const string ServerDnsDir = @"Templates\xray\server\02_dns";
private const string ServerRoutingDir = @"Templates\xray\server\03_routing";
private const string ServerPolicyDir = @"Templates\xray\server\04_policy";
private const string ServerInboundsDir = @"Templates\xray\server\05_inbounds";
private const string ServerOutboundsDir = @"Templates\xray\server\06_outbounds";
private const string ServerTransportDir = @"Templates\xray\server\07_transport";
private const string ServerStatsDir = @"Templates\xray\server\08_stats";
private const string ServerReverseDir = @"Templates\xray\server\09_reverse";
private const string CaddyFileDir = @"Templates\xray\caddy";
public XrayProject(SshClient sshClient, XraySettings parameters, Action<string> writeOutput) : base(sshClient, parameters, writeOutput)
{
}
public void InstallCert()
{
EnsureRootAuth();
EnsureSystemEnv();
this.InstallCertToXray();
RunCmd("systemctl restart xray");
WriteOutput("************ 安装证书完成 ************");
}
public void UploadWeb(Stream stream)
{
EnsureRootAuth();
EnsureSystemEnv();
if (!FileExists("/usr/share/caddy"))
{
RunCmd("mkdir /usr/share/caddy");
}
RunCmd("rm -rf /usr/share/caddy/*");
UploadFile(stream, "/usr/share/caddy/caddy.zip");
RunCmd("unzip /usr/share/caddy/caddy.zip -d /usr/share/caddy");
RunCmd("chmod -R 777 /usr/share/caddy");
UploadCaddyFile(useCustomWeb: true);
WriteOutput("************ 上传网站模板完成 ************");
}
public void UpdateXraySettings()
{
EnsureRootAuth();
EnsureSystemEnv();
var configJson = ConfigBuilder.BuildXrayConfig(Parameters);
var stream = new MemoryStream(Encoding.UTF8.GetBytes(configJson));
RunCmd("rm -rf /usr/local/etc/xray/config.json");
UploadFile(stream, "/usr/local/etc/xray/config.json");
RunCmd("systemctl restart xray");
WriteOutput("************ 更新Xray配置成功更新配置不包含域名如果域名更换请重新安装。 ************");
}
public void ReinstallCaddy()
{
EnsureRootAuth();
EnsureSystemEnv();
InstallCaddy();
UploadCaddyFile();
WriteOutput("************ 重装Caddy完成 ************");
}
public override void Install()
{
try
{
EnsureRootAuth();
if (FileExists("/usr/local/bin/xray"))
{
var btnResult = MessageBox.Show("已经安装Xray是否需要重装", "提示", 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("安装Xray-Core...");
InstallXrayWithCert();
WriteOutput("Xray-Core安装完成");
WriteOutput("安装Caddy...");
InstallCaddy();
WriteOutput("Caddy安装完成");
WriteOutput("启动BBR");
EnableBBR();
WriteOutput("BBR启动成功");
UploadCaddyFile();
WriteOutput("************");
WriteOutput("安装完成,尽情享用吧......");
WriteOutput("************");
}
catch (Exception ex)
{
MessageBox.Show("安装终止," + ex.Message);
}
}
private void UploadCaddyFile(bool useCustomWeb = false)
{
var configJson = ConfigBuilder.BuildCaddyConfig(Parameters, useCustomWeb);
var stream = new MemoryStream(Encoding.UTF8.GetBytes(configJson));
RunCmd("mv /etc/caddy/Caddyfile /etc/caddy/Caddyfile.back");
UploadFile(stream, "/etc/caddy/Caddyfile");
RunCmd("systemctl restart caddy");
}
private void EnableBBR()
{
var osVersion = RunCmd("uname -r");
var canInstallBBR = CheckKernelVersionBBR(osVersion.Split('-')[0]);
var bbrInfo = RunCmd("sysctl net.ipv4.tcp_congestion_control | grep bbr");
var installed = bbrInfo.Contains("bbr");
if (canInstallBBR && !installed)
{
RunCmd(@"bash -c 'echo ""net.core.default_qdisc=fq"" >> /etc/sysctl.conf'");
RunCmd(@"bash -c 'echo ""net.ipv4.tcp_congestion_control=bbr"" >> /etc/sysctl.conf'");
RunCmd(@"sysctl -p");
if (OnlyIpv6)
{
RemoveNat64();
}
}
if (!canInstallBBR)
{
WriteOutput("****** 系统不满足启用BBR条件启动失败。 ******");
}
}
private bool CheckKernelVersionBBR(string kernelVer)
{
string[] linuxKernelCompared = kernelVer.Split('.');
if (int.Parse(linuxKernelCompared[0]) > 4)
{
return true;
}
else if (int.Parse(linuxKernelCompared[0]) < 4)
{
return false;
}
else if (int.Parse(linuxKernelCompared[0]) == 4)
{
if (int.Parse(linuxKernelCompared[1]) >= 9)
{
return true;
}
else if (int.Parse(linuxKernelCompared[1]) < 9)
{
return false;
}
}
return false;
}
private void InstallXrayWithCert()
{
RunCmd("bash -c \"$(curl -L https://github.com/XTLS/Xray-install/raw/main/install-release.sh)\" @ install");
if (!FileExists("/usr/local/bin/xray"))
{
throw new Exception("Xray-Core安装失败请联系开发者");
}
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($"systemctl daemon-reload");
if (FileExists("/usr/local/etc/xray/config.json"))
{
RunCmd(@"mv /usr/local/etc/xray/config.json /usr/local/etc/xray/config.json.1");
}
WriteOutput("安装TLS证书");
InstallCertToXray();
WriteOutput("TLS证书安装完成");
var configJson = ConfigBuilder.BuildXrayConfig(Parameters);
var stream = new MemoryStream(Encoding.UTF8.GetBytes(configJson));
RunCmd("rm -rf /usr/local/etc/xray/config.json");
UploadFile(stream, "/usr/local/etc/xray/config.json");
RunCmd("systemctl restart xray");
}
private void InstallCertToXray()
{
// 安装依赖
RunCmd(GetInstallCmd("socat"));
// 解决搬瓦工CentOS缺少问题
RunCmd(GetInstallCmd("automake autoconf libtool"));
// 安装Acme
var result = RunCmd($"curl https://raw.githubusercontent.com/acmesh-official/acme.sh/master/acme.sh | sh -s -- --install-online -m {GetRandomEmail()}");
if (result.Contains("Install success"))
{
WriteOutput("安装 acme.sh 成功");
}
else
{
throw new Exception("安装 acme.sh 失败,请联系开发者!");
}
RunCmd("cd ~/.acme.sh/");
RunCmd("alias acme.sh=~/.acme.sh/acme.sh");
// 申请证书
if (OnlyIpv6)
{
var cmd = $"/root/.acme.sh/acme.sh --force --debug --issue --standalone -d {Parameters.Domain} --listen-v6";
result = RunCmd(cmd);
}
else
{
var cmd = $"/root/.acme.sh/acme.sh --force --debug --issue --standalone -d {Parameters.Domain}";
result = RunCmd(cmd);
}
if (result.Contains("Cert success"))
{
WriteOutput("申请证书成功");
}
else
{
throw new Exception("申请证书失败,请联系开发者!");
}
// 安装证书到xray
RunCmd("mkdir -p /usr/local/etc/xray/ssl");
RunCmd($"/root/.acme.sh/acme.sh --installcert -d {Parameters.Domain} --certpath /usr/local/etc/xray/ssl/xray_ssl.crt --keypath /usr/local/etc/xray/ssl/xray_ssl.key --capath /usr/local/etc/xray/ssl/xray_ssl.crt");
result = RunCmd(@"if [ ! -f ""/usr/local/etc/xray/ssl/xray_ssl.key"" ]; then echo ""0""; else echo ""1""; fi | head -n 1");
if (result.Contains("1"))
{
WriteOutput("安装证书成功");
}
else
{
throw new Exception("安装证书失败,请联系开发者!");
}
RunCmd(@"chmod 755 /usr/local/etc/xray/ssl");
}
private string GetRandomEmail()
{
Random r = new Random();
var num = r.Next(200000000, 900000000);
return $"{num}@qq.com";
}
private int GetRandomPort()
{
var random = new Random();
return random.Next(10001, 60000);
}
private dynamic LoadJsonObj(string path)
{
if (File.Exists(path))
{
var jsonStr = File.ReadAllText(path, Encoding.UTF8);
return JsonConvert.DeserializeObject(jsonStr);
}
return null;
}
}
}

View file

@ -0,0 +1,143 @@
using Microsoft.Win32;
using Newtonsoft.Json;
using ProxySU_Core.Models;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Windows;
using System.Windows.Input;
namespace ProxySU_Core.ViewModels
{
public class HostViewModel : BaseViewModel
{
public Host host;
private readonly ICommand _selectKeyCommand;
public HostViewModel(Host host)
{
_selectKeyCommand = new BaseCommand(obj => OpenFileDialog(obj));
this.host = host;
}
public string Tag
{
get => host.Tag;
set
{
host.Tag = value;
Notify("Tag");
}
}
public string Address
{
get => host.Address;
set
{
host.Address = value;
Notify("Address");
}
}
public string UserName
{
get => host.UserName;
set => host.UserName = value;
}
public string Password
{
get => host.Password;
set => host.Password = value;
}
public int Port
{
get => host.Port;
set => host.Port = value;
}
public string PrivateKeyPath
{
get => host.PrivateKeyPath;
set => host.PrivateKeyPath = value;
}
public LocalProxy Proxy
{
get => host.Proxy;
set
{
host.Proxy = value;
Notify("Proxy");
}
}
public LoginSecretType SecretType
{
get => host.SecretType;
set
{
host.SecretType = value;
Notify("SecretType");
Notify("KeyUploaderVisiblity");
Notify("PasswordVisiblity");
}
}
[JsonIgnore]
public Visibility PasswordVisiblity
{
get
{
if (SecretType == LoginSecretType.Password)
{
return Visibility.Visible;
}
return Visibility.Collapsed;
}
}
[JsonIgnore]
public Visibility KeyUploaderVisiblity
{
get
{
if (SecretType == LoginSecretType.PrivateKey)
{
return Visibility.Visible;
}
return Visibility.Collapsed;
}
}
[JsonIgnore]
public ICommand SelectKeyCommand
{
get
{
return _selectKeyCommand;
}
}
private void OpenFileDialog(object obj)
{
var fileDialog = new OpenFileDialog();
fileDialog.FileOk += OnFileOk;
fileDialog.ShowDialog();
}
private void OnFileOk(object sender, CancelEventArgs e)
{
var file = sender as OpenFileDialog;
PrivateKeyPath = file.FileName;
}
}
}

View file

@ -0,0 +1,46 @@
using ProxySU_Core.Models;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ProxySU_Core.ViewModels
{
public class RecordViewModel : BaseViewModel
{
public Record record;
public RecordViewModel(Record record)
{
this.record = record;
}
public Host Host
{
get => record.Host;
set
{
record.Host = value;
Notify("Host");
}
}
public XraySettings Settings
{
get => record.Settings;
set
{
record.Settings = value;
Notify("Settings");
}
}
public void Notify()
{
Notify("Host");
Notify("Settings");
}
}
}

View file

@ -0,0 +1,38 @@
using ProxySU_Core.Models;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Text;
namespace ProxySU_Core.ViewModels
{
public class Terminal : BaseViewModel
{
private bool hasConnected;
public Terminal(Host host)
{
Host = host;
HasConnected = false;
}
public bool HasConnected
{
get
{
return hasConnected;
}
set
{
hasConnected = value;
Notify("HasConnected");
}
}
public Host Host { get; set; }
public string CommandText { get; set; }
public string OutputText { get; set; }
}
}

View file

@ -0,0 +1,238 @@
using ProxySU_Core.Models;
using ProxySU_Core.ViewModels.Developers;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
namespace ProxySU_Core.ViewModels
{
public class XraySettingsViewModel : BaseViewModel
{
public XraySettings settings;
public XraySettingsViewModel(XraySettings parameters)
{
this.settings = parameters;
}
public string UUID
{
get => settings.UUID;
set => settings.UUID = value;
}
public string Domain
{
get => settings.Domain;
set => settings.Domain = value;
}
public string MaskDomain
{
get => settings.MaskDomain;
set => settings.MaskDomain = value;
}
public string VLESS_TCP_Path
{
get => settings.VLESS_TCP_Path;
set => settings.VLESS_TCP_Path = value;
}
public string VLESS_WS_Path
{
get => settings.VLESS_WS_Path;
set => settings.VLESS_WS_Path = value;
}
public string VMESS_TCP_Path
{
get => settings.VMESS_TCP_Path;
set => settings.VMESS_TCP_Path = value;
}
public string VMESS_WS_Path
{
get => settings.VMESS_WS_Path;
set => settings.VMESS_WS_Path = value;
}
public string TrojanPassword
{
get => settings.TrojanPassword;
set => settings.TrojanPassword = value;
}
public bool Checked_VLESS_TCP
{
get
{
return settings.Types.Contains(XrayType.VLESS_TCP_TLS);
}
set
{
if (value == true)
{
if (!settings.Types.Contains(XrayType.VLESS_TCP_TLS))
settings.Types.Add(XrayType.VLESS_TCP_TLS);
}
else
{
settings.Types.Remove(XrayType.VLESS_TCP_TLS);
}
Notify("Checked_VLESS_TCP");
Notify("VLESS_TCP_Path_Visibility");
}
}
public bool Checked_VLESS_XTLS
{
get
{
return settings.Types.Contains(XrayType.VLESS_TCP_XTLS);
}
set
{
if (value == true)
{
if (!settings.Types.Contains(XrayType.VLESS_TCP_XTLS))
settings.Types.Add(XrayType.VLESS_TCP_XTLS);
}
else
{
settings.Types.Remove(XrayType.VLESS_TCP_XTLS);
}
Notify("Checked_VLESS_XTLS");
}
}
public bool Checked_VLESS_WS
{
get
{
return settings.Types.Contains(XrayType.VLESS_WS_TLS);
}
set
{
if (value == true)
{
if (!settings.Types.Contains(XrayType.VLESS_WS_TLS))
settings.Types.Add(XrayType.VLESS_WS_TLS);
}
else
{
settings.Types.Remove(XrayType.VLESS_WS_TLS);
}
Notify("Checked_VLESS_WS");
Notify("VLESS_WS_Path_Visibility");
}
}
public bool Checked_VMESS_TCP
{
get
{
return settings.Types.Contains(XrayType.VMESS_TCP_TLS);
}
set
{
if (value == true)
{
if (!settings.Types.Contains(XrayType.VMESS_TCP_TLS))
settings.Types.Add(XrayType.VMESS_TCP_TLS);
}
else
{
settings.Types.Remove(XrayType.VMESS_TCP_TLS);
}
Notify("Checked_VMESS_TCP");
Notify("VMESS_TCP_Path_Visibility");
}
}
public bool Checked_VMESS_WS
{
get
{
return settings.Types.Contains(XrayType.VMESS_WS_TLS);
}
set
{
if (value == true)
{
if (!settings.Types.Contains(XrayType.VMESS_WS_TLS))
settings.Types.Add(XrayType.VMESS_WS_TLS);
}
else
{
settings.Types.Remove(XrayType.VMESS_WS_TLS);
}
Notify("Checked_VMESS_WS");
Notify("VMESS_WS_Path_Visibility");
}
}
public bool Checked_Trojan_TCP
{
get
{
return settings.Types.Contains(XrayType.Trojan_TCP_TLS);
}
set
{
if (value == true)
{
if (!settings.Types.Contains(XrayType.Trojan_TCP_TLS))
settings.Types.Add(XrayType.Trojan_TCP_TLS);
}
else
{
settings.Types.Remove(XrayType.Trojan_TCP_TLS);
}
Notify("Checked_Trojan_TCP");
Notify("Trojan_TCP_Pwd_Visibility");
}
}
public Visibility VLESS_TCP_Path_Visibility
{
get
{
return Checked_VLESS_TCP ? Visibility.Visible : Visibility.Hidden;
}
}
public Visibility VLESS_WS_Path_Visibility
{
get
{
return Checked_VLESS_WS ? Visibility.Visible : Visibility.Hidden;
}
}
public Visibility VMESS_TCP_Path_Visibility
{
get
{
return Checked_VMESS_TCP ? Visibility.Visible : Visibility.Hidden;
}
}
public Visibility VMESS_WS_Path_Visibility
{
get
{
return Checked_VMESS_WS ? Visibility.Visible : Visibility.Hidden;
}
}
public Visibility Trojan_TCP_Pwd_Visibility
{
get
{
return Checked_Trojan_TCP ? Visibility.Visible : Visibility.Hidden;
}
}
}
}

View file

@ -0,0 +1,309 @@
<metro:MetroWindow x:Class="ProxySU_Core.Views.ClientInfoWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:metro="http://metro.mahapps.com/winfx/xaml/controls"
xmlns:local="clr-namespace:ProxySU_Core.Views"
mc:Ignorable="d"
Title="查看配置" Height="450" Width="800">
<Grid>
<TabControl
Background="#fff"
Style="{StaticResource MaterialDesignNavigatilRailTabControl}"
Padding="10">
<TabItem Width="200"
IsEnabled="{Binding Settings.Checked_VLESS_XTLS}"
Style="{StaticResource MaterialDesignNavigationRailTabItem}"
Header="VLESS-TCP-XTLS">
<StackPanel Orientation="Vertical">
<StackPanel Orientation="Horizontal">
<Label Content="地址(address)" Width="120" />
<TextBox Text="{Binding Settings.Domain}" IsReadOnly="True" Width="200" />
</StackPanel>
<StackPanel Orientation="Horizontal" Margin="0,10,0,0">
<Label Content="端口(port)" Width="120" />
<TextBox Text="443" IsReadOnly="True" Width="200" />
</StackPanel>
<StackPanel Orientation="Horizontal" Margin="0,10,0,0">
<Label Content="用户ID(id)" Width="120" />
<TextBox Text="{Binding Settings.UUID}" IsReadOnly="True" Width="300" />
</StackPanel>
<StackPanel Orientation="Horizontal" Margin="0,10,0,0">
<Label Content="流控(flow)" Width="120" />
<TextBox Text="xtls-rprx-direct" IsReadOnly="True" Width="200" />
</StackPanel>
<StackPanel Orientation="Horizontal" Margin="0,10,0,0">
<Label Content="加密(encryption)" Width="120" />
<TextBox Text="none" IsReadOnly="True" Width="200" />
</StackPanel>
<StackPanel Orientation="Horizontal" Margin="0,10,0,0">
<Label Content="传输协议(network)" Width="120" />
<TextBox Text="tcp" IsReadOnly="True" Width="200" />
</StackPanel>
<StackPanel Orientation="Horizontal" Margin="0,10,0,0">
<Label Content="伪装类型(type)" Width="120" />
<TextBox Text="none" IsReadOnly="True" Width="200" />
</StackPanel>
<StackPanel Orientation="Horizontal" Margin="0,10,0,0">
<Label Content="伪装域名(host)" Width="120" />
<TextBox Text="{Binding Settings.Domain}" IsReadOnly="True" Width="200" />
</StackPanel>
<StackPanel Orientation="Horizontal" Margin="0,10,0,0">
<Label Content="路径(path)" Width="120" />
<TextBox Text="" IsReadOnly="True" Width="200" />
</StackPanel>
<StackPanel Orientation="Horizontal" Margin="0,10,0,0">
<Label Content="传输安全(tls)" Width="120" />
<TextBox Text="xtls" IsReadOnly="True" Width="200" />
</StackPanel>
</StackPanel>
</TabItem>
<TabItem Width="200"
IsEnabled="{Binding Settings.Checked_VLESS_TCP}"
Style="{StaticResource MaterialDesignNavigationRailTabItem}"
Header="VLESS-TCP-TLS">
<StackPanel Orientation="Vertical">
<StackPanel Orientation="Horizontal">
<Label Content="地址(address)" Width="120" />
<TextBox Text="{Binding Settings.Domain}" IsReadOnly="True" Width="200" />
</StackPanel>
<StackPanel Orientation="Horizontal" Margin="0,10,0,0">
<Label Content="端口(port)" Width="120" />
<TextBox Text="443" IsReadOnly="True" Width="200" />
</StackPanel>
<StackPanel Orientation="Horizontal" Margin="0,10,0,0">
<Label Content="用户ID(id)" Width="120" />
<TextBox Text="{Binding Settings.UUID}" IsReadOnly="True" Width="300" />
</StackPanel>
<StackPanel Orientation="Horizontal" Margin="0,10,0,0">
<Label Content="流控(flow)" Width="120" />
<TextBox Text="" IsReadOnly="True" Width="200" />
</StackPanel>
<StackPanel Orientation="Horizontal" Margin="0,10,0,0">
<Label Content="加密(encryption)" Width="120" />
<TextBox Text="none" IsReadOnly="True" Width="200" />
</StackPanel>
<StackPanel Orientation="Horizontal" Margin="0,10,0,0">
<Label Content="传输协议(network)" Width="120" />
<TextBox Text="tcp" IsReadOnly="True" Width="200" />
</StackPanel>
<StackPanel Orientation="Horizontal" Margin="0,10,0,0">
<Label Content="伪装类型(type)" Width="120" />
<TextBox Text="none" IsReadOnly="True" Width="200" />
</StackPanel>
<StackPanel Orientation="Horizontal" Margin="0,10,0,0">
<Label Content="伪装域名(host)" Width="120" />
<TextBox Text="{Binding Settings.Domain}" IsReadOnly="True" Width="200" />
</StackPanel>
<StackPanel Orientation="Horizontal" Margin="0,10,0,0">
<Label Content="路径(path)" Width="120" />
<TextBox Text="{Binding Settings.VLESS_TCP_Path}" IsReadOnly="True" Width="200" />
</StackPanel>
<StackPanel Orientation="Horizontal" Margin="0,10,0,0">
<Label Content="传输安全(tls)" Width="120" />
<TextBox Text="tls" IsReadOnly="True" Width="200" />
</StackPanel>
</StackPanel>
</TabItem>
<TabItem Width="200"
IsEnabled="{Binding Settings.Checked_VLESS_WS}"
Style="{StaticResource MaterialDesignNavigationRailTabItem}"
Header="VLESS-WebSocket-TLS">
<StackPanel Orientation="Vertical">
<StackPanel Orientation="Horizontal">
<Label Content="地址(address)" Width="120" />
<TextBox Text="{Binding Settings.Domain}" IsReadOnly="True" Width="200" />
</StackPanel>
<StackPanel Orientation="Horizontal" Margin="0,10,0,0">
<Label Content="端口(port)" Width="120" />
<TextBox Text="443" IsReadOnly="True" Width="200" />
</StackPanel>
<StackPanel Orientation="Horizontal" Margin="0,10,0,0">
<Label Content="用户ID(id)" Width="120" />
<TextBox Text="{Binding Settings.UUID}" IsReadOnly="True" Width="300" />
</StackPanel>
<StackPanel Orientation="Horizontal" Margin="0,10,0,0">
<Label Content="流控(flow)" Width="120" />
<TextBox Text="" IsReadOnly="True" Width="200" />
</StackPanel>
<StackPanel Orientation="Horizontal" Margin="0,10,0,0">
<Label Content="加密(encryption)" Width="120" />
<TextBox Text="none" IsReadOnly="True" Width="200" />
</StackPanel>
<StackPanel Orientation="Horizontal" Margin="0,10,0,0">
<Label Content="传输协议(network)" Width="120" />
<TextBox Text="ws" IsReadOnly="True" Width="200" />
</StackPanel>
<StackPanel Orientation="Horizontal" Margin="0,10,0,0">
<Label Content="伪装类型(type)" Width="120" />
<TextBox Text="none" IsReadOnly="True" Width="200" />
</StackPanel>
<StackPanel Orientation="Horizontal" Margin="0,10,0,0">
<Label Content="伪装域名(host)" Width="120" />
<TextBox Text="{Binding Settings.Domain}" IsReadOnly="True" Width="200" />
</StackPanel>
<StackPanel Orientation="Horizontal" Margin="0,10,0,0">
<Label Content="路径(path)" Width="120" />
<TextBox Text="{Binding Settings.VLESS_WS_Path}" IsReadOnly="True" Width="200" />
</StackPanel>
<StackPanel Orientation="Horizontal" Margin="0,10,0,0">
<Label Content="传输安全(tls)" Width="120" />
<TextBox Text="tls" IsReadOnly="True" Width="200" />
</StackPanel>
</StackPanel>
</TabItem>
<TabItem Width="200"
IsEnabled="{Binding Settings.Checked_VMESS_TCP}"
Style="{StaticResource MaterialDesignNavigationRailTabItem}"
Header="VMESS-TCP-TLS">
<StackPanel Orientation="Vertical">
<StackPanel Orientation="Horizontal">
<Label Content="地址(address)" Width="120" />
<TextBox Text="{Binding Settings.Domain}" IsReadOnly="True" Width="200" />
</StackPanel>
<StackPanel Orientation="Horizontal" Margin="0,10,0,0">
<Label Content="端口(port)" Width="120" />
<TextBox Text="443" IsReadOnly="True" Width="200" />
</StackPanel>
<StackPanel Orientation="Horizontal" Margin="0,10,0,0">
<Label Content="用户ID(id)" Width="120" />
<TextBox Text="{Binding Settings.UUID}" IsReadOnly="True" Width="300" />
</StackPanel>
<StackPanel Orientation="Horizontal" Margin="0,10,0,0">
<Label Content="加密(security)" Width="120" />
<TextBox Text="none" IsReadOnly="True" Width="200" />
</StackPanel>
<StackPanel Orientation="Horizontal" Margin="0,10,0,0">
<Label Content="传输协议(network)" Width="120" />
<TextBox Text="tcp" IsReadOnly="True" Width="200" />
</StackPanel>
<StackPanel Orientation="Horizontal" Margin="0,10,0,0">
<Label Content="伪装类型(type)" Width="120" />
<TextBox Text="http" IsReadOnly="True" Width="200" />
</StackPanel>
<StackPanel Orientation="Horizontal" Margin="0,10,0,0">
<Label Content="伪装域名(host)" Width="120" />
<TextBox Text="{Binding Settings.Domain}" IsReadOnly="True" Width="200" />
</StackPanel>
<StackPanel Orientation="Horizontal" Margin="0,10,0,0">
<Label Content="路径(path)" Width="120" />
<TextBox Text="{Binding Settings.VMESS_TCP_Path}" IsReadOnly="True" Width="200" />
</StackPanel>
<StackPanel Orientation="Horizontal" Margin="0,10,0,0">
<Label Content="传输安全(tls)" Width="120" />
<TextBox Text="tls" IsReadOnly="True" Width="200" />
</StackPanel>
</StackPanel>
</TabItem>
<TabItem Width="200"
IsEnabled="{Binding Settings.Checked_VMESS_WS}"
Style="{StaticResource MaterialDesignNavigationRailTabItem}"
Header="VLESS-WebSocket-TLS">
<StackPanel Orientation="Vertical">
<StackPanel Orientation="Horizontal">
<Label Content="地址(address)" Width="120" />
<TextBox Text="{Binding Settings.Domain}" IsReadOnly="True" Width="200" />
</StackPanel>
<StackPanel Orientation="Horizontal" Margin="0,10,0,0">
<Label Content="端口(port)" Width="120" />
<TextBox Text="443" IsReadOnly="True" Width="200" />
</StackPanel>
<StackPanel Orientation="Horizontal" Margin="0,10,0,0">
<Label Content="用户ID(id)" Width="120" />
<TextBox Text="{Binding Settings.UUID}" IsReadOnly="True" Width="300" />
</StackPanel>
<StackPanel Orientation="Horizontal" Margin="0,10,0,0">
<Label Content="加密(security)" Width="120" />
<TextBox Text="none" IsReadOnly="True" Width="200" />
</StackPanel>
<StackPanel Orientation="Horizontal" Margin="0,10,0,0">
<Label Content="传输协议(network)" Width="120" />
<TextBox Text="ws" IsReadOnly="True" Width="200" />
</StackPanel>
<StackPanel Orientation="Horizontal" Margin="0,10,0,0">
<Label Content="伪装类型(type)" Width="120" />
<TextBox Text="none" IsReadOnly="True" Width="200" />
</StackPanel>
<StackPanel Orientation="Horizontal" Margin="0,10,0,0">
<Label Content="伪装域名(host)" Width="120" />
<TextBox Text="{Binding Settings.Domain}" IsReadOnly="True" Width="200" />
</StackPanel>
<StackPanel Orientation="Horizontal" Margin="0,10,0,0">
<Label Content="路径(path)" Width="120" />
<TextBox Text="{Binding Settings.VMESS_WS_Path}" IsReadOnly="True" Width="200" />
</StackPanel>
<StackPanel Orientation="Horizontal" Margin="0,10,0,0">
<Label Content="传输安全(tls)" Width="120" />
<TextBox Text="tls" IsReadOnly="True" Width="200" />
</StackPanel>
</StackPanel>
</TabItem>
<TabItem Width="200"
IsEnabled="{Binding Settings.Checked_Trojan_TCP}"
Style="{StaticResource MaterialDesignNavigationRailTabItem}"
Header="VLESS-TCP-Trojan">
<StackPanel Orientation="Vertical">
<StackPanel Orientation="Horizontal">
<Label Content="服务器地址" Width="120" />
<TextBox Text="{Binding Settings.Domain}" IsReadOnly="True" Width="200" />
</StackPanel>
<StackPanel Orientation="Horizontal" Margin="0,10,0,0">
<Label Content="服务器端口" Width="120" />
<TextBox Text="443" IsReadOnly="True" Width="200" />
</StackPanel>
<StackPanel Orientation="Horizontal" Margin="0,10,0,0">
<Label Content="密码" Width="120" />
<TextBox Text="{Binding Settings.TrojanPassword}" IsReadOnly="True" Width="300" />
</StackPanel>
</StackPanel>
</TabItem>
</TabControl>
</Grid>
</metro:MetroWindow>

View file

@ -0,0 +1,36 @@
using ProxySU_Core.Models;
using ProxySU_Core.ViewModels;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
namespace ProxySU_Core.Views
{
/// <summary>
/// ClientInfoWindow.xaml 的交互逻辑
/// </summary>
public partial class ClientInfoWindow
{
public XraySettingsViewModel Settings { get; set; }
public ClientInfoWindow(Record record)
{
InitializeComponent();
ResizeMode = ResizeMode.NoResize;
WindowStartupLocation = WindowStartupLocation.CenterScreen;
Settings = new XraySettingsViewModel(record.Settings);
DataContext = this;
}
}
}

View file

@ -0,0 +1,118 @@
<metro:MetroWindow x:Class="ProxySU_Core.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:ProxySU_Core"
mc:Ignorable="d"
BorderThickness="1"
xmlns:metro="http://metro.mahapps.com/winfx/xaml/controls"
xmlns:mah="clr-namespace:MahApps.Metro.Controls;assembly=MahApps.Metro"
TextElement.FontSize="14"
Title="ProxySU Core" Height="800" Width="1200">
<mah:MetroWindow.LeftWindowCommands>
<mah:WindowCommands>
<Button Click="LaunchGitHubSite" ToolTip="Open up the GitHub site">
github
</Button>
</mah:WindowCommands>
</mah:MetroWindow.LeftWindowCommands>
<mah:MetroWindow.RightWindowCommands>
<mah:WindowCommands>
<StackPanel Orientation="Horizontal" Margin="0,0,20,0">
<TextBlock Text="{DynamicResource LanguageText}" VerticalAlignment="Center" Margin="0,0,20,0" />
<ComboBox
SelectionChanged="ChangeLanguage"
x:Name="cmbLanguage"
SelectedIndex="0">
<ComboBoxItem x:Name="zh_cn" Content="{DynamicResource LanguageChinese}"></ComboBoxItem>
<ComboBoxItem x:Name="en" Content="{DynamicResource LanguageEnglish}"></ComboBoxItem>
</ComboBox>
</StackPanel>
</mah:WindowCommands>
</mah:MetroWindow.RightWindowCommands>
<Window.Resources>
<DataTemplate x:Key="HostTagTemplate">
<TextBlock Text="{Binding Tag}" />
</DataTemplate>
</Window.Resources>
<Grid>
<TabControl
Background="#fff"
Style="{StaticResource MaterialDesignNavigatilRailTabControl}"
Padding="10">
<TabItem
Width="160"
Style="{StaticResource MaterialDesignNavigationRailTabItem}"
Header="{DynamicResource TabItemHeaderAppDeployment}">
<StackPanel Orientation="Vertical">
<StackPanel HorizontalAlignment="Left" Orientation="Horizontal">
<Button
Content="{DynamicResource AddHost}"
Click="AddHost"
Width="100"/>
</StackPanel>
<DataGrid ItemsSource="{Binding Records}"
Margin="0,20,0,0"
IsReadOnly="True"
x:Name="DataGrid"
CellStyle="{StaticResource DataGridCell}"
Style="{StaticResource MaterialDesignDataGrid}"
ColumnHeaderStyle="{StaticResource DataGridColumnHeader}"
SelectionUnit="FullRow"
BorderBrush="#eee"
BorderThickness="1"
AutoGenerateColumns="False">
<DataGrid.Columns>
<DataGridTextColumn Header="{DynamicResource HostTag}"
Binding="{Binding Path=Host.Tag}"
Width="150"/>
<DataGridTextColumn Header="{DynamicResource HostAddress}"
Binding="{Binding Path=Host.Address}"
Width="200"/>
<DataGridTextColumn Header="{DynamicResource HostPort}"
Binding="{Binding Path=Host.Port}"
Width="100"/>
<DataGridTextColumn Header="{DynamicResource ProxyGroupName}"
Binding="{Binding Path=Host.Proxy.Type}"
Width="100"/>
<DataGridTemplateColumn>
<DataGridTemplateColumn.Header>
<TextBlock Text="{DynamicResource Actions}" />
</DataGridTemplateColumn.Header>
<DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<StackPanel Orientation="Horizontal">
<Button Content="{DynamicResource Connect}" FontSize="12" Height="24" Click="Connect" />
<Button Content="{DynamicResource Edit}" FontSize="12" Height="24" Margin="10,0,0,0" Click="EditHost" />
<Button Content="查看配置" FontSize="12" Height="24" Margin="10,0,0,0" Click="ShowClientInfo" />
<Button Content="{DynamicResource Delete}" FontSize="12" Height="24" Margin="10,0,0,0" Click="DeleteHost" />
</StackPanel>
</DataTemplate>
</DataGridTemplateColumn.CellTemplate>
</DataGridTemplateColumn>
</DataGrid.Columns>
</DataGrid>
</StackPanel>
</TabItem>
<TabItem
Width="160"
Style="{StaticResource MaterialDesignNavigationRailTabItem}"
Header="其他功能">
<StackPanel>
<TextBlock Text="还不知道要点啥...看大家建议?" />
</StackPanel>
</TabItem>
</TabControl>
</Grid>
</metro:MetroWindow>

View file

@ -0,0 +1,182 @@
using MahApps.Metro.Controls.Dialogs;
using Newtonsoft.Json;
using Newtonsoft.Json.Serialization;
using ProxySU_Core.Models;
using ProxySU_Core.ViewModels;
using ProxySU_Core.ViewModels.Developers;
using ProxySU_Core.Views;
using Renci.SshNet;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
namespace ProxySU_Core
{
/// <summary>
/// Interaction logic for MainWindow.xaml
/// </summary>
public partial class MainWindow
{
private const string RecordPath = @"Data\Record.json";
public ObservableCollection<RecordViewModel> Records { get; set; }
public MainWindow()
{
WindowStartupLocation = WindowStartupLocation.CenterScreen;
InitializeComponent();
Records = new ObservableCollection<RecordViewModel>();
if (File.Exists(RecordPath))
{
var recordsJson = File.ReadAllText(RecordPath, Encoding.UTF8);
if (!string.IsNullOrEmpty(recordsJson))
{
var records = JsonConvert.DeserializeObject<List<Record>>(recordsJson);
records.ForEach(item =>
{
Records.Add(new RecordViewModel(item));
});
}
}
DataContext = this;
}
private void SaveRecord()
{
var recordList = Records.Select(x => x.record);
var json = JsonConvert.SerializeObject(recordList,
Formatting.Indented,
new JsonSerializerSettings
{
ContractResolver = new CamelCasePropertyNamesContractResolver()
});
if (!Directory.Exists("Data"))
{
Directory.CreateDirectory("Data");
}
File.WriteAllText("Data\\Record.json", json, Encoding.UTF8);
}
private void LaunchGitHubSite(object sender, RoutedEventArgs e)
{
System.Diagnostics.Process.Start("explorer.exe", "https://github.com/proxysu/ProxySU");
}
private void LaunchCoffeeSite(object sender, RoutedEventArgs e)
{
System.Diagnostics.Process.Start("explorer.exe", "https://github.com/proxysu/ProxySU");
}
private void ChangeLanguage(object sender, SelectionChangedEventArgs e)
{
var selection = cmbLanguage.SelectedValue as ComboBoxItem;
if (selection.Name == "zh_cn")
{
ChangeLanguage("zh_cn");
}
else if (selection.Name == "en")
{
ChangeLanguage("en");
}
}
private void ChangeLanguage(string culture)
{
ResourceDictionary resource = new ResourceDictionary();
if (string.Equals(culture, "zh_cn", StringComparison.OrdinalIgnoreCase))
{
resource.Source = new Uri(@"Resources\Languages\zh_cn.xaml", UriKind.Relative);
}
else if (string.Equals(culture, "en", StringComparison.OrdinalIgnoreCase))
{
resource.Source = new Uri(@"Resources\Languages\en.xaml", UriKind.Relative);
}
Application.Current.Resources.MergedDictionaries[0] = resource;
}
private void AddHost(object sender, RoutedEventArgs e)
{
var newRecord = new Record();
var hostWindow = new RecordEditorWindow(newRecord);
var result = hostWindow.ShowDialog();
if (result == true)
{
Records.Add(new RecordViewModel(newRecord));
SaveRecord();
}
}
private void EditHost(object sender, RoutedEventArgs e)
{
if (DataGrid.SelectedItem is RecordViewModel project)
{
var hostWindow = new RecordEditorWindow(project.record);
var result = hostWindow.ShowDialog();
if (result == true)
{
project.Notify();
SaveRecord();
}
}
}
private void ShowClientInfo(object sender, RoutedEventArgs e)
{
if (DataGrid.SelectedItem is RecordViewModel project)
{
var dialog = new ClientInfoWindow(project.record);
dialog.ShowDialog();
}
}
private void DeleteHost(object sender, RoutedEventArgs e)
{
if (DataGrid.SelectedItem is RecordViewModel project)
{
var result = MessageBox.Show($"您确认删除主机{project.Host.Tag}吗?", "提示", MessageBoxButton.OKCancel);
if (result == MessageBoxResult.OK)
{
Records.Remove(project);
}
}
}
private void Connect(object sender, RoutedEventArgs e)
{
var project = DataGrid.SelectedItem as RecordViewModel;
if (project == null)
{
DialogManager.ShowMessageAsync(this, "提示", "请选择一个服务器");
}
TerminalWindow terminalWindow = new TerminalWindow(project.record);
terminalWindow.Show();
}
}
}

View file

@ -0,0 +1,318 @@
<metro:MetroWindow x:Class="ProxySU_Core.Views.RecordEditorWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:metro="http://metro.mahapps.com/winfx/xaml/controls"
xmlns:models="clr-namespace:ProxySU_Core.Models"
xmlns:local="clr-namespace:ProxySU_Core.Views"
xmlns:converters="clr-namespace:ProxySU_Core.Converters"
mc:Ignorable="d"
Title="编辑主机信息" Height="800" Width="710">
<Window.Resources>
<converters:LoginSecretTypeConverter x:Key="LoginSecretTypeConverter" />
<converters:ProxyTypeConverter x:Key="ProxyTypeConverter" />
</Window.Resources>
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="300" />
<RowDefinition Height="5"/>
<RowDefinition Height="400" />
<RowDefinition Height="40" />
</Grid.RowDefinitions>
<StackPanel Orientation="Horizontal" Grid.Row="0" Margin="10">
<GroupBox
Style="{StaticResource MaterialDesignHeaderedContentControl}"
Header="{StaticResource ConnectionGroupName}">
<StackPanel Margin="10">
<StackPanel Orientation="Horizontal" Margin="0,0,0,0">
<TextBlock
Width="100"
Text="{DynamicResource HostTag}"
VerticalAlignment="Center"/>
<TextBox
Text="{Binding Path=Host.Tag}"
Width="200" />
</StackPanel>
<StackPanel Orientation="Horizontal" Margin="0,10,0,0">
<TextBlock
Width="100"
Text="{DynamicResource HostAddress}"
VerticalAlignment="Center"/>
<TextBox
Text="{Binding Path=Host.Address}"
Width="200" />
</StackPanel>
<StackPanel Orientation="Horizontal" Margin="0,10,0,0">
<TextBlock
Width="100"
Text="{DynamicResource HostPort}"
VerticalAlignment="Center" />
<TextBox
Text="{Binding Path=Host.Port}"
Width="200"/>
</StackPanel>
<StackPanel Orientation="Horizontal" Margin="0,10,0,0">
<TextBlock
Width="100"
Text="{DynamicResource HostUserName}"
VerticalAlignment="Center" />
<TextBox
Text="{Binding Path=Host.UserName}"
Width="200"/>
</StackPanel>
<StackPanel Orientation="Horizontal" Margin="0,10,0,0">
<TextBlock
Width="100"
Text="{DynamicResource HostLoginType}"
VerticalAlignment="Center" />
<RadioButton
GroupName="LoginType"
IsChecked="{
Binding Path=Host.SecretType,
Converter={StaticResource LoginSecretTypeConverter},
ConverterParameter={x:Static models:LoginSecretType.Password}
}"
Content="{DynamicResource PasswordLogin}" />
<RadioButton
Margin="10,0,0,0"
GroupName="LoginType"
IsChecked="{
Binding Path=Host.SecretType,
Converter={StaticResource LoginSecretTypeConverter},
ConverterParameter={x:Static models:LoginSecretType.PrivateKey}
}"
Content="{DynamicResource KeyLogin}" />
</StackPanel>
<StackPanel Orientation="Horizontal" Margin="0,10,0,0" Visibility="{Binding PasswordVisiblity}">
<TextBlock
Width="100"
Text="{DynamicResource HostPassword}"
VerticalAlignment="Center" />
<TextBox
IsEnabled="{
Binding Path=Host.SecretType,
Converter={StaticResource LoginSecretTypeConverter},
ConverterParameter={x:Static models:LoginSecretType.Password}
}"
Text="{Binding Path=Host.Password}"
Width="200"/>
</StackPanel>
<StackPanel Orientation="Horizontal" Margin="0,10,0,0" Visibility="{Binding Path=Host.KeyUploaderVisiblity}">
<TextBlock
Width="100"
Text="{DynamicResource KeyLoginField}"
VerticalAlignment="Center" />
<Button
IsEnabled="{
Binding Path=Host.SecretType,
Converter={StaticResource LoginSecretTypeConverter},
ConverterParameter={x:Static models:LoginSecretType.PrivateKey}
}"
Command="{Binding Path=Host.SelectKeyCommand}"
Content="{DynamicResource KeyUpload}" />
</StackPanel>
</StackPanel>
</GroupBox>
<GroupBox
Margin="20,0,0,0"
Header="{DynamicResource ProxyGroupName}"
Style="{StaticResource MaterialDesignHeaderedContentControl}">
<StackPanel Margin="10">
<StackPanel Orientation="Horizontal" Margin="0,0,0,0">
<TextBlock
Width="100"
Text="{DynamicResource ProxyType}" />
<RadioButton
GroupName="ProxyType"
Content="{StaticResource ProxyTypeNone}"
IsChecked="{
Binding Path=Host.Proxy.Type,
Converter={StaticResource ProxyTypeConverter},
ConverterParameter={x:Static models:LocalProxyType.None}
}"/>
<RadioButton
Margin="10,0,0,0"
GroupName="ProxyType"
Content="{DynamicResource ProxyTypeHttp}"
IsChecked="{
Binding Path=Host.Proxy.Type,
Converter={StaticResource ProxyTypeConverter},
ConverterParameter={x:Static models:LocalProxyType.Http}
}"/>
<RadioButton
Margin="10,0,0,0"
GroupName="ProxyType"
Content="{DynamicResource ProxyTypeSocks5}"
IsChecked="{
Binding Path=Host.Proxy.Type,
Converter={StaticResource ProxyTypeConverter},
ConverterParameter={x:Static models:LocalProxyType.Socks5}
}"/>
</StackPanel>
<StackPanel Orientation="Horizontal" Margin="0,10,0,0">
<TextBlock
Width="100"
Text="{DynamicResource ProxyHostName}"
VerticalAlignment="Center" />
<TextBox
Width="200"
Text="{Binding Path=Host.Proxy.Address}" />
</StackPanel>
<StackPanel Orientation="Horizontal" Margin="0,10,0,0">
<TextBlock
Width="100"
Text="{DynamicResource ProxyHostPort}"
VerticalAlignment="Center"/>
<TextBox
Width="200"
Text="{Binding Path=Host.Proxy.Port}" />
</StackPanel>
<StackPanel Orientation="Horizontal" Margin="0,10,0,0">
<TextBlock
Width="100"
Text="{DynamicResource ProxyUserName}"
VerticalAlignment="Center"/>
<TextBox
Width="200"
Text="{Binding Path=Host.Proxy.UserName}"/>
</StackPanel>
<StackPanel Orientation="Horizontal" Margin="0,10,0,0">
<TextBlock
Width="100"
Text="{DynamicResource ProxyPassword}"
VerticalAlignment="Center"/>
<TextBox
Width="200"
Text="{Binding Path=Host.Proxy.Password}"/>
</StackPanel>
</StackPanel>
</GroupBox>
</StackPanel>
<GridSplitter Grid.Row="1" Height="5" HorizontalAlignment="Stretch" />
<StackPanel Orientation="Horizontal" Grid.Row="2" Margin="10">
<GroupBox
Padding="10"
Style="{StaticResource MaterialDesignHeaderedContentControl}"
Header="选择方式">
<StackPanel Orientation="Horizontal">
<StackPanel>
<CheckBox Content="VLESS OVER TCP with XTLS"
Style="{StaticResource MahApps.Styles.CheckBox}"
IsChecked="{Binding Path=Settings.Checked_VLESS_XTLS}"
Margin="0,10,0,0" />
<Label Content="数倍性能首选方式不支持CDN" Margin="20,0,0,0" />
<CheckBox Content="VLESS over TCP with TLS"
Style="{StaticResource MahApps.Styles.CheckBox}"
IsChecked="{Binding Path=Settings.Checked_VLESS_TCP}"
Margin="0,10,0,0" />
<Label Content="不支持CDN" Margin="20,0,0,0" />
<CheckBox Content="VLESS over WS with TLS"
Style="{StaticResource MahApps.Styles.CheckBox}"
IsChecked="{Binding Path=Settings.Checked_VLESS_WS}"
Margin="0,10,0,0" />
<Label Content="推荐支持CDN" Margin="20,0,0,0" />
<CheckBox Content="VMess over TCP with TLS"
Style="{StaticResource MahApps.Styles.CheckBox}"
IsChecked="{Binding Path=Settings.Checked_VMESS_TCP}"
Margin="0,10,0,0" />
<Label Content="不推荐" Margin="20,0,0,0" Foreground="Red" />
<CheckBox Content="VMess over WS with TLS"
Style="{StaticResource MahApps.Styles.CheckBox}"
IsChecked="{Binding Path=Settings.Checked_VMESS_WS}"
Margin="0,10,0,0" />
<Label Content="常规支持CDN" Margin="20,0,0,0" />
<CheckBox Content="Trojan over TCP with TLS"
Style="{StaticResource MahApps.Styles.CheckBox}"
IsChecked="{Binding Path=Settings.Checked_Trojan_TCP}"
Margin="0,10,0,0" />
<Label Content="Torjan协议不支持CDN" Margin="20,0,0,0" />
</StackPanel>
<StackPanel Margin="120,0,0,0">
<StackPanel Margin="0,0,0,0" Orientation="Horizontal">
<Label Content="UUID" Width="80" VerticalAlignment="Center" />
<TextBox Text="{Binding Path=Settings.UUID}" Width="200" />
</StackPanel>
<StackPanel Margin="0,10,0,0" Orientation="Horizontal">
<Label Content="域名" Width="80" VerticalAlignment="Center" />
<TextBox Text="{Binding Path=Settings.Domain}" Width="200" />
</StackPanel>
<StackPanel Margin="0,10,0,0" Orientation="Horizontal">
<Label Content="伪装域名" Width="80" VerticalAlignment="Center" />
<TextBox Text="{Binding Path=Settings.MaskDomain}" Width="200" />
</StackPanel>
<StackPanel Margin="0,10,0,0" Orientation="Horizontal" Visibility="{Binding Settings.VLESS_TCP_Path_Visibility}">
<Label Content="VLESS-TCP-Path" Width="120" VerticalAlignment="Center" />
<TextBox Text="{Binding Path=Settings.VLESS_TCP_Path}"
IsEnabled="{Binding Checked_VLESS_TCP}"
Width="200" />
</StackPanel>
<StackPanel Margin="0,10,0,0" Orientation="Horizontal" Visibility="{Binding Settings.VLESS_WS_Path_Visibility}">
<Label Content="VLESS-WS-Path" Width="120" VerticalAlignment="Center" />
<TextBox Text="{Binding Path=Settings.VLESS_WS_Path}"
IsEnabled="{Binding Checked_VLESS_WS}"
Width="200" />
</StackPanel>
<StackPanel Margin="0,10,0,0" Orientation="Horizontal" Visibility="{Binding Settings.VMESS_TCP_Path_Visibility}">
<Label Content="VMESS-TCP-Path" Width="120" VerticalAlignment="Center" />
<TextBox Text="{Binding Path=Settings.VMESS_TCP_Path}"
IsEnabled="{Binding Checked_VMESS_TCP}"
Width="200" />
</StackPanel>
<StackPanel Margin="0,10,0,0" Orientation="Horizontal" Visibility="{Binding Settings.VMESS_WS_Path_Visibility}">
<Label Content="VMESS-WS-Path" Width="120" VerticalAlignment="Center" />
<TextBox Text="{Binding Path=Settings.VMESS_WS_Path}"
IsEnabled="{Binding Checked_VMESS_WS}"
Width="200" />
</StackPanel>
<StackPanel Margin="0,10,0,0" Orientation="Horizontal" Visibility="{Binding Settings.Trojan_TCP_Pwd_Visibility}">
<Label Content="Trojan密码" Width="120" VerticalAlignment="Center" />
<TextBox Text="{Binding Path=Settings.TrojanPassword}"
IsEnabled="{Binding Checked_Trojan_TCP}"
Width="200" />
</StackPanel>
</StackPanel>
</StackPanel>
</GroupBox>
</StackPanel>
<Button Content="保存"
Grid.Row="3"
Width="120" Height="32"
Click="Save"
HorizontalAlignment="Right"
Margin="0,0,20,0"></Button>
</Grid>
</metro:MetroWindow>

View file

@ -0,0 +1,52 @@
using ProxySU_Core.Models;
using ProxySU_Core.ViewModels;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
namespace ProxySU_Core.Views
{
/// <summary>
/// RecordEditorWindow.xaml 的交互逻辑
/// </summary>
public partial class RecordEditorWindow
{
public Record Record { get; set; }
public HostViewModel Host { get; set; }
public XraySettingsViewModel Settings { get; set; }
public EventHandler OnSaved;
public RecordEditorWindow(Record record)
{
InitializeComponent();
ResizeMode = ResizeMode.NoResize;
WindowStartupLocation = WindowStartupLocation.CenterScreen;
this.Record = record;
Host = new HostViewModel(record.Host.DeepClone());
Settings = new XraySettingsViewModel(record.Settings.DeepClone());
this.DataContext = this;
}
public void Save(object sender, RoutedEventArgs e)
{
Record.Host = Host.host;
Record.Settings = Settings.settings;
DialogResult = true;
Close();
}
}
}

View file

@ -0,0 +1,77 @@
<metro:MetroWindow x:Class="ProxySU_Core.TerminalWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:ProxySU_Core"
xmlns:metro="http://metro.mahapps.com/winfx/xaml/controls"
mc:Ignorable="d"
Title="主机控制台" Height="500" Width="800">
<StackPanel>
<TextBox IsReadOnly="True"
Block.LineHeight="18"
Background="#000"
Foreground="LawnGreen"
FontSize="14"
FontFamily="Consolas"
x:Name="OutputTextBox"
Height="320"
Text="{Binding Path=OutputText}"
/>
<StackPanel Margin="10"
Orientation="Horizontal"
HorizontalAlignment="Left">
<Button Content="安装Xray"
Click="Install"
Height="32"
IsEnabled="{Binding HasConnected}"
Width="100"/>
<Button Content="更新Xray配置"
Margin="10,0,0,0"
Click="UpdateXraySettings"
Height="32"
IsEnabled="{Binding HasConnected}"
Width="120"/>
<Button Content="申请TLS证书"
Margin="10,0,0,0"
Height="32"
Width="120"
IsEnabled="{Binding HasConnected}"
Click="InstallCert"/>
<Button Content="上传伪装网站"
Margin="10,0,0,0"
Height="32"
Width="120"
IsEnabled="{Binding HasConnected}"
Click="UploadWeb"/>
<Button Content="重装Caddy"
Margin="10,0,0,0"
Click="ReinstallCaddy"
Height="32"
IsEnabled="{Binding HasConnected}"
Width="120"/>
</StackPanel>
<StackPanel Margin="10,0,0,0">
<Label Content="静态网页模版(感谢网友推荐),将网站压缩包上传到服务区即可。" />
<TextBlock>
<Hyperlink NavigateUri="https://www.themezy.com" Click="OpenLink">Themezy</Hyperlink>
</TextBlock>
<TextBlock>
<Hyperlink NavigateUri="https://onepagelove.com/templates/free-templates" Click="OpenLink">One Page Love</Hyperlink>
</TextBlock>
<TextBlock>
<Hyperlink NavigateUri="https://html5up.net/" Click="OpenLink">HTML5 UP</Hyperlink>
</TextBlock>
<TextBlock>
<Hyperlink NavigateUri="https://templatemo.com/" Click="OpenLink">template mo</Hyperlink>
</TextBlock>
</StackPanel>
</StackPanel>
</metro:MetroWindow>

View file

@ -0,0 +1,188 @@
using MahApps.Metro.Controls.Dialogs;
using Microsoft.Win32;
using ProxySU_Core.Models;
using ProxySU_Core.ViewModels;
using ProxySU_Core.ViewModels.Developers;
using ProxySU_Core.Views;
using Renci.SshNet;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Diagnostics;
using System.IO;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
namespace ProxySU_Core
{
/// <summary>
/// TerminalWindow.xaml 的交互逻辑
/// </summary>
public partial class TerminalWindow
{
private Record Record { get; set; }
private readonly Terminal _vm;
private SshClient _sshClient;
XrayProject project;
public TerminalWindow(Record record)
{
InitializeComponent();
ResizeMode = ResizeMode.NoResize;
WindowStartupLocation = WindowStartupLocation.CenterScreen;
this.Record = record;
_vm = new Terminal(record.Host);
DataContext = _vm;
WriteOutput("Connect ...");
Task.Factory.StartNew(() =>
{
try
{
OpenConnect(_vm.Host);
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
});
}
protected override void OnClosed(EventArgs e)
{
base.OnClosed(e);
_vm.HasConnected = false;
if (_sshClient != null)
_sshClient.Disconnect();
if (_sshClient != null)
_sshClient.Dispose();
}
private ConnectionInfo CreateConnectionInfo(Host host)
{
AuthenticationMethod auth = null;
if (host.SecretType == LoginSecretType.Password)
{
auth = new PasswordAuthenticationMethod(host.UserName, host.Password);
}
else if (host.SecretType == LoginSecretType.PrivateKey)
{
auth = new PrivateKeyAuthenticationMethod(host.UserName, new PrivateKeyFile(host.PrivateKeyPath));
}
if (host.Proxy.Type == LocalProxyType.None)
{
return new ConnectionInfo(host.Address, host.Port, host.UserName, auth);
}
else
{
return new ConnectionInfo(
host: host.Address,
port: host.Port,
username: host.UserName,
proxyType: (ProxyTypes)(int)host.Proxy.Type,
proxyHost: host.Proxy.Address,
proxyPort: host.Proxy.Port,
proxyUsername: host.Proxy.UserName,
proxyPassword: host.Proxy.Password,
authenticationMethods: auth);
}
}
private void OpenConnect(Host host)
{
var conneInfo = CreateConnectionInfo(host);
_sshClient = new SshClient(conneInfo);
_sshClient.Connect();
WriteOutput("Connected");
_vm.HasConnected = true;
project = new XrayProject(_sshClient, Record.Settings, WriteOutput);
}
private void WriteOutput(string outShell)
{
if (!outShell.EndsWith("\n"))
{
outShell += "\n";
}
Dispatcher.Invoke(() =>
{
OutputTextBox.AppendText(outShell);
OutputTextBox.ScrollToEnd();
});
}
private void Install(object sender, RoutedEventArgs e)
{
Task.Factory.StartNew(() =>
{
project.Install();
});
}
private void InstallCert(object sender, RoutedEventArgs e)
{
Task.Factory.StartNew(() =>
{
project.InstallCert();
});
}
private void UploadWeb(object sender, RoutedEventArgs e)
{
var fileDialog = new OpenFileDialog();
fileDialog.FileOk += OnFileOk;
fileDialog.ShowDialog();
}
private void ReinstallCaddy(object sender, RoutedEventArgs e)
{
Task.Factory.StartNew(() =>
{
project.ReinstallCaddy();
});
}
private void UpdateXraySettings(object sender, RoutedEventArgs e)
{
Task.Factory.StartNew(() =>
{
project.UpdateXraySettings();
});
}
private void OnFileOk(object sender, CancelEventArgs e)
{
Task.Factory.StartNew(() =>
{
var file = sender as OpenFileDialog;
using (var stream = file.OpenFile())
{
project.UploadWeb(stream);
}
});
}
private void OpenLink(object sender, RoutedEventArgs e)
{
Hyperlink link = sender as Hyperlink;
Process.Start(new ProcessStartInfo(link.NavigateUri.AbsoluteUri));
}
}
}

View file

@ -0,0 +1,11 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="ControlzEx" version="5.0.0" targetFramework="net461" />
<package id="MahApps.Metro" version="2.4.4" targetFramework="net461" />
<package id="MaterialDesignColors" version="2.0.0" targetFramework="net461" />
<package id="MaterialDesignThemes" version="4.0.0" targetFramework="net461" />
<package id="MaterialDesignThemes.MahApps" version="0.1.6" targetFramework="net461" />
<package id="Microsoft.Xaml.Behaviors.Wpf" version="1.1.31" targetFramework="net461" />
<package id="Newtonsoft.Json" version="12.0.3" targetFramework="net461" />
<package id="SSH.NET" version="2020.0.1" targetFramework="net461" />
</packages>