-
Notifications
You must be signed in to change notification settings - Fork 18
/
Command.cs
86 lines (76 loc) 路 2.52 KB
/
Command.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
锘縰sing NaiveSharp.ConstText;
using NaiveSharp.Model;
using System.Diagnostics;
using System.IO;
using System.Windows.Forms;
namespace NaiveSharp.Controller
{
public static class Command
{
// proto only accept http & socks
public static void RunNaive(string proto)
{
var p = new Process();
p.StartInfo.FileName = PATH.NAIVE_EXE;
p.StartInfo.Arguments = "--proxy=" +
NaiveCmdBuilder.Proxy(Config.Scheme, Config.Username, Config.Password,
Config.Host) +
" --listen=" + proto.ToLower() + "://127.0.0.1:1080";
if (Config.Padding ?? false)
{
p.StartInfo.Arguments += " --padding";
}
// TODO: ADD EXTRA-HEADERS SUPPORT
if (Config.Debug)
{
p.StartInfo.Arguments += " --log";
MessageBox.Show(p.StartInfo.Arguments);
p.StartInfo.UseShellExecute = true;
}
else
{
p.StartInfo.UseShellExecute = false;
p.StartInfo.CreateNoWindow = true;
}
p.Start();
}
public static void RunClash()
{
var p = new Process();
p.StartInfo.FileName = PATH.CLASH_EXE;
p.StartInfo.Arguments = $"-d {PATH.CLASH}";
p.StartInfo.UseShellExecute = false;
p.StartInfo.CreateNoWindow = true;
p.Start();
}
public static void RunPrivoxyWithGFWList()
{
var p = new Process();
p.StartInfo.FileName = "cmd.exe";
p.StartInfo.Arguments = $"/c START /MIN {PATH.PRIVOXY_EXE} {PATH.PRIVOXY_CONF_GFW_TXT}";
p.StartInfo.UseShellExecute = false;
p.StartInfo.CreateNoWindow = true;
p.Start();
}
public static void RunPrivoxy()
{
var p = new Process();
p.StartInfo.FileName = "cmd.exe";
p.StartInfo.Arguments = $"/c START /MIN {PATH.PRIVOXY_EXE} {PATH.PRIVOXY_CONF_DEF_INI}";
p.StartInfo.UseShellExecute = false;
p.StartInfo.CreateNoWindow = true;
p.Start();
}
public static void InitializeTmp()
{
try
{
Directory.Delete(PATH.TMP, true);
}
finally
{
Directory.CreateDirectory(PATH.TMP);
}
}
}
}