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

add config files

This commit is contained in:
next-autumn 2021-03-04 18:25:52 +08:00
parent e548affd70
commit 8199b3d9d2
11 changed files with 233 additions and 119 deletions

View File

@ -238,34 +238,93 @@
<Generator>SettingsSingleFileGenerator</Generator>
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
</None>
<None Include="Templates\xray\base.json" />
<None Include="Templates\xray\caddy\base.caddyfile" />
<None Include="Templates\xray\client\00_log\00_log.json" />
<None Include="Templates\xray\client\01_api\01_api.json" />
<None Include="Templates\xray\client\02_dns\02_dns.json" />
<None Include="Templates\xray\client\03_routing\03_routing.json" />
<None Include="Templates\xray\client\04_policy\04_policy.json" />
<None Include="Templates\xray\client\05_inbounds\05_inbounds.json" />
<None Include="Templates\xray\client\06_outbounds\06_outbounds.json" />
<None Include="Templates\xray\client\06_outbounds\VLESS_HTTP2_TLS.json" />
<None Include="Templates\xray\client\06_outbounds\VLESS_TCP_TLS_WS.json" />
<None Include="Templates\xray\client\07_transport\07_transport.json" />
<None Include="Templates\xray\client\08_stats\08_stats.json" />
<None Include="Templates\xray\client\09_reverse\09_reverse.json" />
<None Include="Templates\xray\server\01_api\01_api.json" />
<None Include="Templates\xray\server\02_dns\02_dns.json" />
<None Include="Templates\xray\server\03_routing\03_routing.json" />
<None Include="Templates\xray\server\04_policy\04_policy.json" />
<None Include="Templates\xray\server\05_inbounds\05_inbounds.json" />
<None Include="Templates\xray\server\05_inbounds\Trojan_TCP_TLS.json" />
<None Include="Templates\xray\server\05_inbounds\VLESS_TCP_XTLS.json" />
<None Include="Templates\xray\server\05_inbounds\VLESS_WS_TLS.json" />
<None Include="Templates\xray\server\05_inbounds\VMESS_TCP_TLS.json" />
<None Include="Templates\xray\server\05_inbounds\VMESS_WS_TLS.json" />
<None Include="Templates\xray\server\06_outbounds\06_outbounds.json" />
<None Include="Templates\xray\server\07_transport\07_transport.json" />
<None Include="Templates\xray\server\08_stats\08_stats.json" />
<None Include="Templates\xray\server\09_reverse\09_reverse.json" />
<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" />

View File

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

View File

@ -57,7 +57,7 @@ namespace ProxySU_Core.ViewModels.Developers
/// <summary>
/// 执行安装命令
/// </summary>
public abstract void Execute();
public abstract void Install();
/// <summary>
/// 配置系统基础环境
@ -420,7 +420,7 @@ namespace ProxySU_Core.ViewModels.Developers
return true;
}
private void ConfigurePort(bool force = true)
public void ConfigurePort(bool force = true)
{
if (Parameters.Port == 80 || Parameters.Port == 443)
{
@ -429,6 +429,8 @@ namespace ProxySU_Core.ViewModels.Developers
}
else
{
SetPortFree(80);
SetPortFree(443);
SetPortFree(Parameters.Port);
}
}

View File

@ -29,7 +29,7 @@ namespace ProxySU_Core.ViewModels.Developers
{
}
public override void Execute()
public override void Install()
{
try
{
@ -47,6 +47,8 @@ namespace ProxySU_Core.ViewModels.Developers
EnsureSystemEnv();
ConfigurePort();
ConfigureSoftware();
ConfigureIPv6();

View File

@ -36,5 +36,11 @@ namespace ProxySU_Core.ViewModels
Notify("Settings");
}
}
public void Notify()
{
Notify("Host");
Notify("Settings");
}
}
}

View File

@ -11,82 +11,82 @@ namespace ProxySU_Core.ViewModels
{
public class XraySettingsViewModel : BaseViewModel
{
private XraySettings p;
public XraySettings settings;
public XraySettingsViewModel(XraySettings parameters)
{
this.p = parameters;
this.settings = parameters;
}
public string UUID
{
get => p.UUID;
set => p.UUID = value;
get => settings.UUID;
set => settings.UUID = value;
}
public string Domain
{
get => p.Domain;
set => p.Domain = value;
get => settings.Domain;
set => settings.Domain = value;
}
public string MaskDomain
{
get => p.MaskDomain;
set => p.MaskDomain = value;
get => settings.MaskDomain;
set => settings.MaskDomain = value;
}
public string VLESS_TCP_Path
{
get => p.VLESS_TCP_Path;
set => p.VLESS_TCP_Path = value;
get => settings.VLESS_TCP_Path;
set => settings.VLESS_TCP_Path = value;
}
public string VLESS_WS_Path
{
get => p.VLESS_WS_Path;
set => p.VLESS_WS_Path = value;
get => settings.VLESS_WS_Path;
set => settings.VLESS_WS_Path = value;
}
public string VMESS_TCP_Path
{
get => p.VMESS_TCP_Path;
set => p.VMESS_TCP_Path = value;
get => settings.VMESS_TCP_Path;
set => settings.VMESS_TCP_Path = value;
}
public string VMESS_WS_Path
{
get => p.VMESS_WS_Path;
set => p.VMESS_WS_Path = value;
get => settings.VMESS_WS_Path;
set => settings.VMESS_WS_Path = value;
}
public string Trojan_TCP_Path
{
get => p.Trojan_TCP_Path;
set => p.Trojan_TCP_Path = value;
get => settings.Trojan_TCP_Path;
set => settings.Trojan_TCP_Path = value;
}
public string TrojanPassword
{
get => p.TrojanPassword;
set => p.TrojanPassword = value;
get => settings.TrojanPassword;
set => settings.TrojanPassword = value;
}
public bool Checked_VLESS_TCP
{
get
{
return p.Types.Contains(XrayType.VLESS_TCP_TLS);
return settings.Types.Contains(XrayType.VLESS_TCP_TLS);
}
set
{
if (value == true)
{
p.Types.Add(XrayType.VLESS_TCP_TLS);
settings.Types.Add(XrayType.VLESS_TCP_TLS);
}
else
{
p.Types.Remove(XrayType.VLESS_TCP_TLS);
settings.Types.Remove(XrayType.VLESS_TCP_TLS);
}
Notify("Checked_VLESS_TCP");
Notify("VLESS_TCP_Path_Visibility");
@ -97,17 +97,17 @@ namespace ProxySU_Core.ViewModels
{
get
{
return p.Types.Contains(XrayType.VLESS_TCP_XTLS);
return settings.Types.Contains(XrayType.VLESS_TCP_XTLS);
}
set
{
if (value == true)
{
p.Types.Add(XrayType.VLESS_TCP_XTLS);
settings.Types.Add(XrayType.VLESS_TCP_XTLS);
}
else
{
p.Types.Remove(XrayType.VLESS_TCP_XTLS);
settings.Types.Remove(XrayType.VLESS_TCP_XTLS);
}
Notify("Checked_VLESS_XTLS");
}
@ -117,17 +117,17 @@ namespace ProxySU_Core.ViewModels
{
get
{
return p.Types.Contains(XrayType.VLESS_WS_TLS);
return settings.Types.Contains(XrayType.VLESS_WS_TLS);
}
set
{
if (value == true)
{
p.Types.Add(XrayType.VLESS_WS_TLS);
settings.Types.Add(XrayType.VLESS_WS_TLS);
}
else
{
p.Types.Remove(XrayType.VLESS_WS_TLS);
settings.Types.Remove(XrayType.VLESS_WS_TLS);
}
Notify("Checked_VLESS_WS");
Notify("VLESS_WS_Path_Visibility");
@ -138,17 +138,17 @@ namespace ProxySU_Core.ViewModels
{
get
{
return p.Types.Contains(XrayType.VMESS_TCP_TLS);
return settings.Types.Contains(XrayType.VMESS_TCP_TLS);
}
set
{
if (value == true)
{
p.Types.Add(XrayType.VMESS_TCP_TLS);
settings.Types.Add(XrayType.VMESS_TCP_TLS);
}
else
{
p.Types.Remove(XrayType.VMESS_TCP_TLS);
settings.Types.Remove(XrayType.VMESS_TCP_TLS);
}
Notify("Checked_VMESS_TCP");
Notify("VMESS_TCP_Path_Visibility");
@ -159,17 +159,17 @@ namespace ProxySU_Core.ViewModels
{
get
{
return p.Types.Contains(XrayType.VMESS_WS_TLS);
return settings.Types.Contains(XrayType.VMESS_WS_TLS);
}
set
{
if (value == true)
{
p.Types.Add(XrayType.VMESS_WS_TLS);
settings.Types.Add(XrayType.VMESS_WS_TLS);
}
else
{
p.Types.Remove(XrayType.VMESS_WS_TLS);
settings.Types.Remove(XrayType.VMESS_WS_TLS);
}
Notify("Checked_VMESS_WS");
Notify("VMESS_WS_Path_Visibility");
@ -180,17 +180,17 @@ namespace ProxySU_Core.ViewModels
{
get
{
return p.Types.Contains(XrayType.Trojan_TCP_TLS);
return settings.Types.Contains(XrayType.Trojan_TCP_TLS);
}
set
{
if (value == true)
{
p.Types.Add(XrayType.Trojan_TCP_TLS);
settings.Types.Add(XrayType.Trojan_TCP_TLS);
}
else
{
p.Types.Remove(XrayType.Trojan_TCP_TLS);
settings.Types.Remove(XrayType.Trojan_TCP_TLS);
}
Notify("Checked_Trojan_TCP");
Notify("Trojan_TCP_Path_Visibility");

View File

@ -101,8 +101,13 @@ namespace ProxySU_Core
private void AddHost(object sender, RoutedEventArgs e)
{
var hostWindow = new RecordEditorWindow(new Record());
hostWindow.ShowDialog();
var newRecord = new Record();
var hostWindow = new RecordEditorWindow(newRecord);
var result = hostWindow.ShowDialog();
if (result == true)
{
Records.Add(new RecordViewModel(newRecord));
}
}
private void EditHost(object sender, RoutedEventArgs e)
@ -110,7 +115,11 @@ namespace ProxySU_Core
if (DataGrid.SelectedItem is RecordViewModel project)
{
var hostWindow = new RecordEditorWindow(project.record);
hostWindow.ShowDialog();
var result = hostWindow.ShowDialog();
if (result == true)
{
project.Notify();
}
}
}
@ -130,13 +139,13 @@ namespace ProxySU_Core
private void Connect(object sender, RoutedEventArgs e)
{
var project = DataGrid.SelectedItem as Record;
var project = DataGrid.SelectedItem as RecordViewModel;
if (project == null)
{
DialogManager.ShowMessageAsync(this, "提示", "请选择一个服务器");
}
TerminalWindow terminalWindow = new TerminalWindow(project);
TerminalWindow terminalWindow = new TerminalWindow(project.record);
terminalWindow.Show();
}
}

View File

@ -136,71 +136,71 @@
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}
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}
}"/>
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}
}"/>
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" />
Width="100"
Text="{DynamicResource ProxyHostName}"
VerticalAlignment="Center" />
<TextBox
Width="200"
Text="{Binding Path=Host.Proxy.Address}" />
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"/>
Width="100"
Text="{DynamicResource ProxyHostPort}"
VerticalAlignment="Center"/>
<TextBox
Width="200"
Text="{Binding Path=Host.Proxy.Port}" />
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"/>
Width="100"
Text="{DynamicResource ProxyUserName}"
VerticalAlignment="Center"/>
<TextBox
Width="200"
Text="{Binding Path=Host.Proxy.UserName}"/>
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"/>
Width="100"
Text="{DynamicResource ProxyPassword}"
VerticalAlignment="Center"/>
<TextBox
Width="200"
Text="{Binding Path=Host.Proxy.Password}"/>
Width="200"
Text="{Binding Path=Host.Proxy.Password}"/>
</StackPanel>
</StackPanel>
@ -315,6 +315,11 @@
</GroupBox>
</StackPanel>
<Button Content="保存" Grid.Row="3" Width="120" Height="32" HorizontalAlignment="Right" Margin="0,0,20,0"></Button>
<Button Content="保存"
Grid.Row="3"
Width="120" Height="32"
Click="Save"
HorizontalAlignment="Right"
Margin="0,0,20,0"></Button>
</Grid>
</metro:MetroWindow>

View File

@ -27,6 +27,8 @@ namespace ProxySU_Core.Views
public XraySettingsViewModel Settings { get; set; }
public EventHandler OnSaved;
public RecordEditorWindow(Record record)
{
InitializeComponent();
@ -38,5 +40,13 @@ namespace ProxySU_Core.Views
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

@ -14,6 +14,7 @@
Foreground="LawnGreen"
FontSize="14"
FontFamily="Consolas"
x:Name="OutputTextBox"
Height="320">
<FlowDocument>
<Paragraph>

View File

@ -25,16 +25,18 @@ namespace ProxySU_Core
/// </summary>
public partial class TerminalWindow
{
private Record Record { get; set; }
private readonly Terminal _vm;
private SshClient _sshClient;
public TerminalWindow(Record project)
public TerminalWindow(Record record)
{
InitializeComponent();
ResizeMode = ResizeMode.NoResize;
WindowStartupLocation = WindowStartupLocation.CenterScreen;
_vm = new Terminal(project.Host);
this.Record = record;
_vm = new Terminal(record.Host);
DataContext = _vm;
_vm.AddOutput("Connect ...");
@ -106,10 +108,23 @@ namespace ProxySU_Core
private void WriteShell(string outShell)
{
_vm.AddOutput(outShell);
Dispatcher.Invoke(() =>
{
OutputTextBox.ScrollToEnd();
});
}
private void Install(object sender, RoutedEventArgs e)
{
XrayProject project = new XrayProject(
_sshClient,
Record.Settings,
WriteShell);
Task.Factory.StartNew(() =>
{
project.Install();
});
}