mirror of
https://github.com/proxysu/ProxySU.git
synced 2024-11-22 05:06:08 +03:00
修正Json生成错误
This commit is contained in:
parent
873701e4cb
commit
3744b6174e
@ -156,13 +156,7 @@
|
||||
<RowDefinition></RowDefinition>
|
||||
<RowDefinition></RowDefinition>
|
||||
</Grid.RowDefinitions>
|
||||
<Button Content="测试接收到的模参数" Grid.Column="0" Grid.Row="0" Margin="10,10,10.333,10" Click="Button_Click" Grid.ColumnSpan="2"></Button>
|
||||
<Button Content="测试结果窗口" Grid.Column="0" Grid.Row="1" Margin="10,10,10.333,9.667" Click="Button_Click_1" Grid.ColumnSpan="2"></Button>
|
||||
<Button Content="测试ssh命令" Grid.Column="2" Grid.Row="0" Margin="9.667,10,9.666,10" Click="Button_Click_2"></Button>
|
||||
<Button Content="测试生成v2rayN导入格式" Grid.Column="3" Grid.Row="0" Margin="10.334,10,10,10" Click="Button_Click_3"></Button>
|
||||
<Button Content="测试生成config.json文件" Grid.Column="2" Grid.Row="1" Margin="9.667,10,9.666,9.667" Click="Button_Click_4"></Button>
|
||||
<Button Content="测试时间" Grid.Column="4" Grid.Row="0" Margin="10,10,10.333,10" Click="Button_Click_5"></Button>
|
||||
<Button Content="测试字符串操作" Grid.Column="3" Grid.Row="1" Margin="10" Click="Button_Click_6"></Button>
|
||||
|
||||
</Grid>
|
||||
</TabItem>
|
||||
</TabControl>
|
||||
|
@ -558,36 +558,28 @@ namespace ProxySU
|
||||
textBlockName.Dispatcher.BeginInvoke(updateAction, textBlockName, progressBar, currentStatus);
|
||||
Thread.Sleep(1000);
|
||||
//生成服务端配置
|
||||
//if (!Directory.Exists("config"))//如果不存在就创建file文件夹
|
||||
//{
|
||||
// Directory.CreateDirectory("config");//创建该文件夹
|
||||
//}
|
||||
//string clientConfig = "TemplateConfg\\tcp_client_config.json";
|
||||
|
||||
using (StreamReader reader = File.OpenText(serverConfig))
|
||||
{
|
||||
JObject serverJson = (JObject)JToken.ReadFrom(new JsonTextReader(reader));
|
||||
// do stuff
|
||||
//MessageBox.Show(clientJson.ToString());
|
||||
//clientJson["inbounds"][0]["settings"]["vnext"][0]["address"] = ReceiveConfigurationParameters[4];
|
||||
|
||||
if (serverConfig.Contains("WebSocketTLSWeb") == false)
|
||||
{
|
||||
serverJson["inbounds"][0]["port"] = ReceiveConfigurationParameters[1];
|
||||
}
|
||||
|
||||
serverJson["inbounds"][0]["settings"]["clients"][0]["id"] = ReceiveConfigurationParameters[2];
|
||||
if (serverJson.Property("path") != null)
|
||||
|
||||
if (serverConfig.Contains("WebSocketTLSWeb") == true)
|
||||
{
|
||||
//成员path存在
|
||||
serverJson["inbounds"][0]["streamSettings"]["wsSettings"]["path"] = ReceiveConfigurationParameters[3];
|
||||
|
||||
}
|
||||
if (serverJson.Property("type") != null)
|
||||
|
||||
if (serverConfig.Contains("mkcp") == true)
|
||||
{
|
||||
//成员type存在
|
||||
serverJson["inbounds"][0]["streamSettings"]["kcpSettings"]["header"]["type"] = ReceiveConfigurationParameters[5];
|
||||
|
||||
}
|
||||
|
||||
|
||||
using (StreamWriter sw = new StreamWriter(@"config.json"))
|
||||
{
|
||||
sw.Write(serverJson.ToString());
|
||||
@ -675,23 +667,19 @@ namespace ProxySU
|
||||
using (StreamReader reader = File.OpenText(clientConfig))
|
||||
{
|
||||
JObject clientJson = (JObject)JToken.ReadFrom(new JsonTextReader(reader));
|
||||
// do stuff
|
||||
//MessageBox.Show(clientJson.ToString());
|
||||
|
||||
clientJson["outbounds"][0]["settings"]["vnext"][0]["address"] = ReceiveConfigurationParameters[4];
|
||||
clientJson["outbounds"][0]["settings"]["vnext"][0]["port"] = ReceiveConfigurationParameters[1];
|
||||
clientJson["outbounds"][0]["settings"]["vnext"][0]["users"][0]["id"] = ReceiveConfigurationParameters[2];
|
||||
if (clientJson.Property("path") != null)
|
||||
if (clientConfig.Contains("WebSocketTLSWeb")==true)
|
||||
{
|
||||
//成员path存在
|
||||
clientJson["outbounds"][0]["streamSettings"]["wsSettings"]["path"] = ReceiveConfigurationParameters[3];
|
||||
|
||||
}
|
||||
if (clientJson.Property("type") != null)
|
||||
if (clientConfig.Contains("mkcp")==true)
|
||||
{
|
||||
//成员type存在
|
||||
clientJson["outbounds"][0]["streamSettings"]["kcpSettings"]["header"]["type"] = ReceiveConfigurationParameters[5];
|
||||
|
||||
}
|
||||
|
||||
|
||||
using (StreamWriter sw = new StreamWriter(@"config\config.json"))
|
||||
{
|
||||
@ -920,204 +908,6 @@ namespace ProxySU
|
||||
MessageBox.Show("尚未完善,敬请期待");
|
||||
}
|
||||
|
||||
#region 测试面板上的代码设置
|
||||
//测试接收到的模板参数
|
||||
private void Button_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
foreach (string num in ReceiveConfigurationParameters)
|
||||
{
|
||||
MessageBox.Show(num);
|
||||
}
|
||||
}
|
||||
|
||||
private void Button_Click_1(object sender, RoutedEventArgs e)
|
||||
{
|
||||
//ResultClientInformation resultClientInformation = new ResultClientInformation();
|
||||
//resultClientInformation.ShowDialog();
|
||||
string stampTime = "1489739011";
|
||||
string sshCmd = $"date --set=\"$(date \"+%Y-%m-%d %H:%M:%S\" -d @{stampTime})\"";
|
||||
MessageBox.Show(sshCmd);
|
||||
}
|
||||
|
||||
private void Button_Click_2(object sender, RoutedEventArgs e)
|
||||
{
|
||||
string sshHostName = TextBoxHost.Text.ToString();
|
||||
int sshPort = int.Parse(TextBoxPort.Text);
|
||||
string sshUser = TextBoxUserName.Text.ToString();
|
||||
string sshPassword = PasswordBoxHostPassword.Password.ToString();
|
||||
ReceiveConfigurationParameters[4] = "";
|
||||
//string emailAddress = ReceiveConfigurationParameters[4];
|
||||
//string sshCmd;
|
||||
//sshCmd = "ping "+ ReceiveConfigurationParameters[4] + " -c 1 | grep -oE -m1 \"([0-9]{1,3}\\.){3}[0-9]{1,3}\"";
|
||||
|
||||
//string resultCmd;
|
||||
//string upLoadPath = "/etc/caddy/Caddyfile";
|
||||
var connectionInfo = new PasswordConnectionInfo(sshHostName, sshPort, sshUser, sshPassword);
|
||||
using (var client = new SshClient(connectionInfo))
|
||||
{
|
||||
client.Connect();
|
||||
//MessageBox.Show(client.RunCommand("date +%s").Result.ToString());
|
||||
long timesStamp1 = Convert.ToInt64(client.RunCommand("date +%s").Result.ToString());
|
||||
MessageBox.Show(timesStamp1.ToString());
|
||||
long timesStamp2 = timesStamp1 - 300;
|
||||
MessageBox.Show(timesStamp2.ToString());
|
||||
client.Disconnect();
|
||||
return;
|
||||
}
|
||||
}
|
||||
//测试生成v2rayN导入格式json
|
||||
// {
|
||||
// "v": "2",
|
||||
// "ps": "",
|
||||
// "add": "",
|
||||
// "port": "",
|
||||
// "id": "",
|
||||
// "aid": "16",
|
||||
// "net": "tcp",
|
||||
// "type": "none",
|
||||
// "host": "",
|
||||
// "path": "",
|
||||
// "tls": ""
|
||||
//}
|
||||
private void Button_Click_3(object sender, RoutedEventArgs e)
|
||||
{
|
||||
string v2rayNjsonFile = @"{
|
||||
""v"": """",
|
||||
""ps"": """",
|
||||
""add"": """",
|
||||
""port"": """",
|
||||
""id"": """",
|
||||
""aid"": """",
|
||||
""net"": """",
|
||||
""type"": """",
|
||||
""host"": """",
|
||||
""path"": """",
|
||||
""tls"": """"
|
||||
}";
|
||||
//MessageBox.Show(v2rayNjsonFile);
|
||||
JObject v2rayNjsonObject = JObject.Parse(v2rayNjsonFile);
|
||||
v2rayNjsonObject["v"] = "2";
|
||||
v2rayNjsonObject["add"] = "";
|
||||
v2rayNjsonObject["port"] = "";
|
||||
v2rayNjsonObject["id"] = "";
|
||||
v2rayNjsonObject["aid"] = "16";
|
||||
v2rayNjsonObject["net"] = "";
|
||||
v2rayNjsonObject["type"] = "";
|
||||
v2rayNjsonObject["host"] = "";
|
||||
v2rayNjsonObject["path"] = "";
|
||||
v2rayNjsonObject["tls"] = "";
|
||||
v2rayNjsonObject["ps"] = v2rayNjsonObject["add"];
|
||||
//MessageBox.Show(v2rayNjsonObject["v"].ToString());
|
||||
|
||||
}
|
||||
|
||||
private void Button_Click_4(object sender, RoutedEventArgs e)
|
||||
{
|
||||
if (!Directory.Exists("config"))//如果不存在就创建file文件夹
|
||||
{
|
||||
Directory.CreateDirectory("config");//创建该文件夹
|
||||
}
|
||||
string clientConfig= "TemplateConfg\\tcp_client_config.json";
|
||||
using (StreamReader reader = File.OpenText(clientConfig))
|
||||
{
|
||||
JObject clientJson = (JObject)JToken.ReadFrom(new JsonTextReader(reader));
|
||||
// do stuff
|
||||
MessageBox.Show(clientJson.ToString());
|
||||
clientJson["outbounds"][0]["settings"]["vnext"][0]["address"] = ReceiveConfigurationParameters[4];
|
||||
clientJson["outbounds"][0]["settings"]["vnext"][0]["port"] = ReceiveConfigurationParameters[1];
|
||||
clientJson["outbounds"][0]["settings"]["vnext"][0]["users"][0]["id"] = ReceiveConfigurationParameters[2];
|
||||
if (clientJson.Property("path") != null)
|
||||
{
|
||||
//成员path存在
|
||||
clientJson["outbounds"][0]["streamSettings"]["wsSettings"]["path"] = ReceiveConfigurationParameters[3];
|
||||
|
||||
}
|
||||
if (clientJson.Property("type") != null)
|
||||
{
|
||||
//成员type存在
|
||||
clientJson["outbounds"][0]["streamSettings"]["kcpSettings"]["header"]["type"] = ReceiveConfigurationParameters[5];
|
||||
|
||||
}
|
||||
|
||||
using (StreamWriter sw = new StreamWriter(@"config\config.json"))
|
||||
{
|
||||
sw.Write(clientJson.ToString());
|
||||
}
|
||||
}
|
||||
}
|
||||
private void Button_Click_6(object sender, RoutedEventArgs e)
|
||||
{
|
||||
string testfirst = "0123456789";
|
||||
int startnum = 3, lenth = 4;
|
||||
string resultstr = testfirst.Substring(startnum, lenth);
|
||||
MessageBox.Show(resultstr);
|
||||
|
||||
}
|
||||
|
||||
private void Button_Click_5(object sender, RoutedEventArgs e)
|
||||
{
|
||||
//获取本地时间戳
|
||||
//TimeSpan ts = DateTime.Now.ToUniversalTime() - new DateTime(1970, 1, 1, 0, 0, 0, 0);
|
||||
//long timeStampLocal = Convert.ToInt64(ts.TotalSeconds);
|
||||
//MessageBox.Show("本地时间戳"+timeStampLocal.ToString());
|
||||
//获取网络时间戳
|
||||
//Thread.Sleep(1000);
|
||||
try
|
||||
{
|
||||
TimeSpan utcTS = NetTime.GetUTCTime() - new DateTime(1970, 1, 1, 0, 0, 0, 0);
|
||||
long timeStampVPS = Convert.ToInt64(utcTS.TotalSeconds);
|
||||
MessageBox.Show("网络时间戳" + timeStampVPS.ToString());
|
||||
}
|
||||
catch(Exception ex1)
|
||||
{
|
||||
MessageBox.Show(ex1.ToString());
|
||||
}
|
||||
//string netDatetime = NetTime.GetUTCTime().AddHours(8).ToString();
|
||||
//MessageBox.Show(netDatetime);
|
||||
|
||||
//TimeZoneInfo localZone = TimeZoneInfo.Local;
|
||||
////MessageBox.Show($"Local Time Zone ID: {localZone.Id}");
|
||||
//MessageBox.Show($"Display Name is: {localZone.DisplayName}.");
|
||||
//MessageBox.Show($"Standard name is: {localZone.StandardName}.");
|
||||
//MessageBox.Show($" Daylight saving name is: {localZone.DaylightName}.");
|
||||
//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();
|
||||
//MessageBox.Show(cc);
|
||||
//DateTime time;
|
||||
//bool s = GMTStrParse(cc, out time);
|
||||
//return time.AddHours(8); //GMT要加8个小时才是北京时间
|
||||
//WebRequest wrt = null;
|
||||
//WebResponse wrp = null;
|
||||
//wrt = WebRequest.Create("https://www.tsa.cn/");
|
||||
//wrp = wrt.GetResponse();
|
||||
//string html = string.Empty;
|
||||
//using (Stream stream = wrp.GetResponseStream())
|
||||
//{
|
||||
// using (StreamReader sr = new StreamReader(stream, Encoding.UTF8))
|
||||
// {
|
||||
// html = sr.ReadToEnd();
|
||||
// using (StreamWriter sw = new StreamWriter(@"html.txt"))
|
||||
// {
|
||||
// sw.Write(html.ToString());
|
||||
// }
|
||||
// }
|
||||
//}
|
||||
//TimeSpan ts = DateTime.Now - new DateTime(1970, 1, 1, 0, 0, 0, 0);
|
||||
//long timeStamp = Convert.ToInt64(ts.TotalSeconds);
|
||||
//MessageBox.Show(timeStamp.ToString());
|
||||
|
||||
//DateTime dateNow = DateTime.Now;
|
||||
//MessageBox.Show(TimeZoneInfo.ConvertTimeToUtc(dateNow).ToString());
|
||||
//Console.WriteLine("The date and time are {0} UTC.",
|
||||
// TimeZoneInfo.ConvertTimeToUtc(dateNow));
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private void ButtonWebBrowserBack_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
try
|
||||
|
Binary file not shown.
Binary file not shown.
@ -25,11 +25,11 @@
|
||||
"settings": {
|
||||
"vnext": [
|
||||
{
|
||||
"address":"",
|
||||
"address":null,
|
||||
"port":null,
|
||||
"users":[
|
||||
{
|
||||
"id":"",
|
||||
"id":null,
|
||||
"alterId":16,
|
||||
"security":"auto"
|
||||
}
|
||||
@ -41,7 +41,7 @@
|
||||
"network":"ws",
|
||||
"security":"tls",
|
||||
"wsSettings":{
|
||||
"path":""
|
||||
"path":null
|
||||
}
|
||||
},
|
||||
"mux": {
|
||||
|
@ -1,6 +1,6 @@
|
||||
##domain## {
|
||||
root /var/www
|
||||
tls ##email##
|
||||
tls off
|
||||
##sites##
|
||||
proxy ##path## localhost:10000 {
|
||||
websocket
|
||||
|
@ -7,7 +7,7 @@
|
||||
"settings": {
|
||||
"clients": [
|
||||
{
|
||||
"id": "",
|
||||
"id": null,
|
||||
"alterId": 64
|
||||
}
|
||||
]
|
||||
@ -15,7 +15,7 @@
|
||||
"streamSettings": {
|
||||
"network": "ws",
|
||||
"wsSettings": {
|
||||
"path": ""
|
||||
"path": null
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -25,11 +25,11 @@
|
||||
"settings": {
|
||||
"vnext": [
|
||||
{
|
||||
"address": "",
|
||||
"address": null,
|
||||
"port": null,
|
||||
"users": [
|
||||
{
|
||||
"id": "",
|
||||
"id": null,
|
||||
"alterId": 16,
|
||||
"security": "auto"
|
||||
}
|
||||
@ -48,7 +48,7 @@
|
||||
"readBufferSize": 2,
|
||||
"writeBufferSize": 2,
|
||||
"header": {
|
||||
"type": ""
|
||||
"type": null
|
||||
}
|
||||
}
|
||||
},
|
||||
|
@ -6,7 +6,7 @@
|
||||
"settings": {
|
||||
"clients": [
|
||||
{
|
||||
"id": "",
|
||||
"id": null,
|
||||
"alterId": 64
|
||||
}
|
||||
]
|
||||
@ -18,7 +18,7 @@
|
||||
"downlinkCapacity": 100,
|
||||
"congestion": true,
|
||||
"header": {
|
||||
"type": ""
|
||||
"type": null
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -25,11 +25,11 @@
|
||||
"settings": {
|
||||
"vnext": [
|
||||
{
|
||||
"address": "",
|
||||
"address": null,
|
||||
"port": null,
|
||||
"users": [
|
||||
{
|
||||
"id": "",
|
||||
"id": null,
|
||||
"alterId": 16,
|
||||
"security": "auto"
|
||||
}
|
||||
|
@ -25,11 +25,11 @@
|
||||
"settings": {
|
||||
"vnext": [
|
||||
{
|
||||
"address": "",
|
||||
"address": null,
|
||||
"port": null,
|
||||
"users": [
|
||||
{
|
||||
"id": "",
|
||||
"id": null,
|
||||
"alterId": 16
|
||||
}
|
||||
]
|
||||
|
@ -6,7 +6,7 @@
|
||||
"settings": {
|
||||
"clients": [
|
||||
{
|
||||
"id": "",
|
||||
"id": null,
|
||||
"alterId": 64
|
||||
}
|
||||
]
|
||||
|
@ -7,7 +7,7 @@
|
||||
"settings": {
|
||||
"clients": [
|
||||
{
|
||||
"id": "",
|
||||
"id": null,
|
||||
"alterId": 64
|
||||
}
|
||||
]
|
||||
|
Loading…
Reference in New Issue
Block a user