Skip to content

Commit

Permalink
增加websocket的host
Browse files Browse the repository at this point in the history
  • Loading branch information
yangjunxin committed Aug 16, 2023
1 parent eeeaf66 commit 3ac67ed
Show file tree
Hide file tree
Showing 10 changed files with 67 additions and 3 deletions.
11 changes: 11 additions & 0 deletions Directory.Build.props
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<Project>
<PropertyGroup>
<Version>1.0.1.0</Version>
<AssemblyVersion>1.0.1.0</AssemblyVersion>
<FileVersion>1.0.1.0</FileVersion>
<Authors>gilfoylex</Authors>
<Company>gilfoylex</Company>
<Copyright>Copyright © 2023 gilfoylex</Copyright>
<Product>Reykjavik</Product>
</PropertyGroup>
</Project>
9 changes: 9 additions & 0 deletions Reykjavik/view_models/ConnectViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,14 @@ public string WsPath
set => SetProperty(ref _wsPath, value);
}

private string _wsHost = "";

public string WsHost
{
get => _wsHost;
set => SetProperty(ref _wsHost, value);
}

#endregion


Expand Down Expand Up @@ -192,6 +200,7 @@ public void CopySettings(ConnectViewModel other)
TlsServerAddress = other.TlsServerAddress;
AllowInsecure = other.AllowInsecure;
WsPath = other.WsPath;
WsHost = other.WsHost;
}
}
}
11 changes: 10 additions & 1 deletion Reykjavik/view_models/HomeViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ partial class MainViewModel
private void StartXRay()
{
var path = GenXrayConfig();
_xRayProcessHelper.Start(path, models.DefaultXRayConfig.ApiPort);
_xRayProcessHelper.Start(path, IpAddress, models.DefaultXRayConfig.ApiPort);
}

public void StopXRay()
Expand Down Expand Up @@ -258,6 +258,10 @@ public ConnectViewModel OutBoundToConnectVm(models.XRayConfigDefine.Outbound ot,
if (string.Compare(ot.streamSettings.network, "ws", StringComparison.OrdinalIgnoreCase) == 0 && ot.streamSettings.wsSettings != null)
{
ret.WsPath = ot.streamSettings.wsSettings.path;
if (ot.streamSettings.wsSettings.headers != null && ot.streamSettings.wsSettings.headers.TryGetValue("host", out var settingsHeader))
{
ret.WsHost = settingsHeader;
}
}

if (string.Compare(ot.streamSettings.security, "tls", StringComparison.OrdinalIgnoreCase) == 0 && ot.streamSettings.tlsSettings != null)
Expand Down Expand Up @@ -354,6 +358,11 @@ private models.XRayConfigDefine.Outbound ConnectVmToOutBound(ConnectViewModel vm
{
path = vm.WsPath
};

if (!string.IsNullOrEmpty(vm.WsHost))
{
ret.streamSettings.wsSettings.headers = new Dictionary<string, string>(){{"host", vm.WsHost}};
}
}

if (string.Compare(vm.Security, "tls", StringComparison.OrdinalIgnoreCase) == 0)
Expand Down
9 changes: 9 additions & 0 deletions Reykjavik/views/ConnectWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,15 @@
<Label Margin="10 0 0 0" Style="{DynamicResource SubTitle}">TLS服务器地址:</Label>
<TextBox Grid.Column="1" MaxLines="1" Text="{Binding TlsServerAddress}"></TextBox>
</Grid>
<Grid Margin="0 5"
Visibility="{Binding Network, Converter={x:Static vt:CompareToVisibility.Instance}, ConverterParameter=ws}">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="120" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<Label Margin="10 0 0 0" Style="{DynamicResource SubTitle}">WebSocket Host:</Label>
<TextBox Grid.Column="1" MaxLines="1" Text="{Binding WsHost}"></TextBox>
</Grid>
<Grid Margin="0 5"
Visibility="{Binding Network, Converter={x:Static vt:CompareToVisibility.Instance}, ConverterParameter=ws}">
<Grid.ColumnDefinitions>
Expand Down
Binary file added SystemProxy/SystemProxy.rc
Binary file not shown.
4 changes: 4 additions & 0 deletions SystemProxy/SystemProxy.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,7 @@
<ItemGroup>
<ClInclude Include="framework.h" />
<ClInclude Include="pch.h" />
<ClInclude Include="resource.h" />
<ClInclude Include="SystemProxy.h" />
</ItemGroup>
<ItemGroup>
Expand All @@ -175,6 +176,9 @@
</ClCompile>
<ClCompile Include="SystemProxy.cpp" />
</ItemGroup>
<ItemGroup>
<ResourceCompile Include="SystemProxy.rc" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
Expand Down
8 changes: 8 additions & 0 deletions SystemProxy/SystemProxy.vcxproj.filters
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@
<ClInclude Include="SystemProxy.h">
<Filter>头文件</Filter>
</ClInclude>
<ClInclude Include="resource.h">
<Filter>头文件</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<ClCompile Include="dllmain.cpp">
Expand All @@ -36,4 +39,9 @@
<Filter>源文件</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ResourceCompile Include="SystemProxy.rc">
<Filter>资源文件</Filter>
</ResourceCompile>
</ItemGroup>
</Project>
14 changes: 14 additions & 0 deletions SystemProxy/resource.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
//{{NO_DEPENDENCIES}}
// Microsoft Visual C++ generated include file.
// Used by SystemProxy.rc

// жÔÏóµÄÏÂÒ»×éĬÈÏÖµ
//
#ifdef APSTUDIO_INVOKED
#ifndef APSTUDIO_READONLY_SYMBOLS
#define _APS_NEXT_RESOURCE_VALUE 101
#define _APS_NEXT_COMMAND_VALUE 40001
#define _APS_NEXT_CONTROL_VALUE 1001
#define _APS_NEXT_SYMED_VALUE 101
#endif
#endif
Binary file added UIBase/svg2xaml.zip
Binary file not shown.
4 changes: 2 additions & 2 deletions XrayServer/XrayProcessHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public XRayProcessHelper()
_xrayPath = Path.Join(currentPath, "xray_x64.exe");
}

public async void Start(string configPath, int apiPort)
public async void Start(string configPath, string ipAddress, int apiPort)
{
await Task.Factory.StartNew(() =>
{
Expand All @@ -39,7 +39,7 @@ await Task.Factory.StartNew(() =>
_process.Start();
Interlocked.Increment(ref _isRuning);

_channel = GrpcChannel.ForAddress($"http://127.0.0.1:{apiPort}");
_channel = GrpcChannel.ForAddress($"http://{ipAddress}:{apiPort}");

// 利用job作业系统管理子进程的生命周期
ChildProcessTracker.AddProcess(_process);
Expand Down

0 comments on commit 3ac67ed

Please sign in to comment.