mirror of
https://github.com/MaxiFan/TunnelX.git
synced 2026-05-19 08:04:41 +03:00
8283b9d6d1
Co-authored-by: Cursor <cursoragent@cursor.com>
40 lines
1.7 KiB
C#
40 lines
1.7 KiB
C#
namespace AppTunnel.Models;
|
|
|
|
/// <summary>
|
|
/// Server connection configuration (L2TP/IPsec, V2Ray).
|
|
/// </summary>
|
|
public class ServerConfig
|
|
{
|
|
public string ServerAddress { get; set; } = string.Empty;
|
|
public string Username { get; set; } = string.Empty;
|
|
public string Password { get; set; } = string.Empty;
|
|
public string PreSharedKey { get; set; } = string.Empty;
|
|
public string ConnectionName { get; set; } = "TunnelX";
|
|
public TunnelType TunnelType { get; set; } = TunnelType.L2tpIpsec;
|
|
public string V2RayConfig { get; set; } = "";
|
|
public string OpenVpnConfig { get; set; } = "";
|
|
public string OpenVpnExePath { get; set; } = "";
|
|
public string OpenVpnUsername { get; set; } = "";
|
|
public string OpenVpnPassword { get; set; } = "";
|
|
public string OpenVpnPrivateKeyPassword { get; set; } = "";
|
|
public ProxyProtocol ProxyProtocol { get; set; } = ProxyProtocol.Socks5;
|
|
public string ProxyServerAddress { get; set; } = "";
|
|
public int ProxyPort { get; set; } = 1080;
|
|
public string ProxyUsername { get; set; } = "";
|
|
public string ProxyPassword { get; set; } = "";
|
|
public bool AutoTuneMtu { get; set; } = true;
|
|
public bool EnableDnsOptimization { get; set; } = true;
|
|
public bool EnableGameMode { get; set; } = false;
|
|
|
|
public string BuildProxyUri()
|
|
{
|
|
var scheme = ProxyProtocol == ProxyProtocol.Http ? "http" : "socks5";
|
|
var port = ProxyPort > 0 ? ProxyPort : (ProxyProtocol == ProxyProtocol.Http ? 3128 : 1080);
|
|
var auth = string.IsNullOrWhiteSpace(ProxyUsername)
|
|
? ""
|
|
: $"{Uri.EscapeDataString(ProxyUsername)}:{Uri.EscapeDataString(ProxyPassword ?? "")}@";
|
|
|
|
return $"{scheme}://{auth}{ProxyServerAddress.Trim()}:{port}#TunnelX-Proxy";
|
|
}
|
|
}
|