mirror of
https://github.com/proxysu/ProxySU.git
synced 2024-11-22 05:06:08 +03:00
fix xray config issue
This commit is contained in:
parent
8199b3d9d2
commit
b6e77b88b4
@ -19,7 +19,6 @@ namespace ProxySU_Core.Models
|
||||
VLESS_TCP_Path = "/vlesstcp";
|
||||
VMESS_WS_Path = "/vmessws";
|
||||
VMESS_TCP_Path = "/vmesstcp";
|
||||
Trojan_TCP_Path = "/trojan";
|
||||
TrojanPassword = Guid.NewGuid().ToString();
|
||||
}
|
||||
|
||||
@ -53,11 +52,6 @@ namespace ProxySU_Core.Models
|
||||
/// </summary>
|
||||
public string VMESS_TCP_Path { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// trojan tcp路径
|
||||
/// </summary>
|
||||
public string Trojan_TCP_Path { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// trojan密码
|
||||
/// </summary>
|
||||
@ -94,7 +88,7 @@ namespace ProxySU_Core.Models
|
||||
case XrayType.VMESS_WS_TLS:
|
||||
return VMESS_WS_Path;
|
||||
case XrayType.Trojan_TCP_TLS:
|
||||
return Trojan_TCP_Path;
|
||||
return string.Empty;
|
||||
default:
|
||||
return string.Empty;
|
||||
}
|
||||
|
@ -26,4 +26,4 @@
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
}
|
||||
|
@ -80,80 +80,86 @@ namespace ProxySU_Core.ViewModels.Developers
|
||||
{
|
||||
var xrayConfig = LoadXrayConfig();
|
||||
var baseBound = LoadJsonObj(Path.Combine(ServerInboundsDir, "VLESS_TCP_XTLS.json"));
|
||||
baseBound["port"] = parameters.Port;
|
||||
baseBound["settings"]["fallbacks"].Add(new
|
||||
baseBound.port = parameters.Port;
|
||||
baseBound.settings.fallbacks.Add(JToken.FromObject(new
|
||||
{
|
||||
dest = 80,
|
||||
xver = 1,
|
||||
});
|
||||
xrayConfig["inbounds"].Add(baseBound);
|
||||
}));
|
||||
xrayConfig.inbounds.Add(baseBound);
|
||||
|
||||
if (parameters.Types.Contains(XrayType.VLESS_TCP_XTLS))
|
||||
{
|
||||
baseBound["settings"]["clients"][0]["id"] = parameters.UUID;
|
||||
baseBound.settings.clients[0].id = parameters.UUID;
|
||||
}
|
||||
|
||||
if (parameters.Types.Contains(XrayType.VLESS_WS_TLS))
|
||||
{
|
||||
baseBound["settings"]["clients"][0]["id"] = parameters.UUID;
|
||||
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(new
|
||||
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(wsInbound);
|
||||
}));
|
||||
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(new
|
||||
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(mtcpBound);
|
||||
}));
|
||||
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(new
|
||||
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(mwsBound);
|
||||
}));
|
||||
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] = new
|
||||
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(trojanTcpBound);
|
||||
});
|
||||
xrayConfig.inbounds.Add(JToken.FromObject(trojanTcpBound));
|
||||
}
|
||||
|
||||
return JsonConvert.SerializeObject(xrayConfig, Formatting.Indented);
|
||||
return JsonConvert.SerializeObject(
|
||||
xrayConfig,
|
||||
Formatting.Indented,
|
||||
new JsonSerializerSettings()
|
||||
{
|
||||
NullValueHandling = NullValueHandling.Ignore
|
||||
});
|
||||
}
|
||||
|
||||
private static dynamic LoadJsonObj(string path)
|
||||
@ -161,7 +167,7 @@ namespace ProxySU_Core.ViewModels.Developers
|
||||
if (File.Exists(path))
|
||||
{
|
||||
var jsonStr = File.ReadAllText(path, Encoding.UTF8);
|
||||
return JsonConvert.DeserializeObject(jsonStr);
|
||||
return JToken.FromObject(JsonConvert.DeserializeObject(jsonStr));
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
@ -60,12 +60,6 @@ namespace ProxySU_Core.ViewModels
|
||||
set => settings.VMESS_WS_Path = value;
|
||||
}
|
||||
|
||||
public string Trojan_TCP_Path
|
||||
{
|
||||
get => settings.Trojan_TCP_Path;
|
||||
set => settings.Trojan_TCP_Path = value;
|
||||
}
|
||||
|
||||
public string TrojanPassword
|
||||
{
|
||||
get => settings.TrojanPassword;
|
||||
@ -193,7 +187,7 @@ namespace ProxySU_Core.ViewModels
|
||||
settings.Types.Remove(XrayType.Trojan_TCP_TLS);
|
||||
}
|
||||
Notify("Checked_Trojan_TCP");
|
||||
Notify("Trojan_TCP_Path_Visibility");
|
||||
Notify("Trojan_TCP_Pwd_Visibility");
|
||||
}
|
||||
}
|
||||
|
||||
@ -225,7 +219,7 @@ namespace ProxySU_Core.ViewModels
|
||||
return Checked_VMESS_WS ? Visibility.Visible : Visibility.Hidden;
|
||||
}
|
||||
}
|
||||
public Visibility Trojan_TCP_Path_Visibility
|
||||
public Visibility Trojan_TCP_Pwd_Visibility
|
||||
{
|
||||
get
|
||||
{
|
||||
|
@ -297,19 +297,12 @@
|
||||
Width="200" />
|
||||
</StackPanel>
|
||||
|
||||
<StackPanel Margin="0,10,0,0" Orientation="Horizontal" Visibility="{Binding Settings.Trojan_TCP_Path_Visibility}">
|
||||
<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 Margin="0,10,0,0" Orientation="Horizontal" Visibility="{Binding Settings.Trojan_TCP_Path_Visibility}">
|
||||
<Label Content="Trojan Path" Width="120" VerticalAlignment="Center" />
|
||||
<TextBox Text="{Binding Path=Settings.TrojanPath}"
|
||||
IsEnabled="{Binding Checked_Trojan_TCP}"
|
||||
Width="200" />
|
||||
</StackPanel>
|
||||
</StackPanel>
|
||||
</StackPanel>
|
||||
</GroupBox>
|
||||
|
Loading…
Reference in New Issue
Block a user