├── .gitignore
├── CLEAN.BAT
├── README.md
├── v2tap.sln
└── v2tap
├── App.config
├── MainForm.Designer.cs
├── MainForm.cs
├── MainForm.resx
├── Properties
├── AssemblyInfo.cs
├── Resources.Designer.cs
├── Resources.resx
├── Settings.Designer.cs
└── Settings.settings
├── Utils
└── SharedUtils.cs
├── v2tap.cs
└── v2tap.csproj
/.gitignore:
--------------------------------------------------------------------------------
1 | /.vs
--------------------------------------------------------------------------------
/CLEAN.BAT:
--------------------------------------------------------------------------------
1 | @ECHO OFF
2 | cd v2tap
3 | rd /s /q bin
4 | rd /s /q obj
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # v2tap
2 | TUN/TAP + tun2socks + v2ray 实现的 VPN 工具
3 |
4 | # 文档完善中 ...
--------------------------------------------------------------------------------
/v2tap.sln:
--------------------------------------------------------------------------------
1 |
2 | Microsoft Visual Studio Solution File, Format Version 12.00
3 | # Visual Studio 15
4 | VisualStudioVersion = 15.0.28307.168
5 | MinimumVisualStudioVersion = 10.0.40219.1
6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "v2tap", "v2tap\v2tap.csproj", "{2DF9C9CB-74E0-42C5-A8BC-038BE6FE5869}"
7 | EndProject
8 | Global
9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution
10 | Debug|Any CPU = Debug|Any CPU
11 | Release|Any CPU = Release|Any CPU
12 | EndGlobalSection
13 | GlobalSection(ProjectConfigurationPlatforms) = postSolution
14 | {2DF9C9CB-74E0-42C5-A8BC-038BE6FE5869}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
15 | {2DF9C9CB-74E0-42C5-A8BC-038BE6FE5869}.Debug|Any CPU.Build.0 = Debug|Any CPU
16 | {2DF9C9CB-74E0-42C5-A8BC-038BE6FE5869}.Release|Any CPU.ActiveCfg = Release|Any CPU
17 | {2DF9C9CB-74E0-42C5-A8BC-038BE6FE5869}.Release|Any CPU.Build.0 = Release|Any CPU
18 | EndGlobalSection
19 | GlobalSection(SolutionProperties) = preSolution
20 | HideSolutionNode = FALSE
21 | EndGlobalSection
22 | GlobalSection(ExtensibilityGlobals) = postSolution
23 | SolutionGuid = {7605EBF6-F905-47DA-9CFE-A8C0913EC205}
24 | EndGlobalSection
25 | EndGlobal
26 |
--------------------------------------------------------------------------------
/v2tap/App.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/v2tap/MainForm.Designer.cs:
--------------------------------------------------------------------------------
1 | namespace v2tap
2 | {
3 | partial class MainForm
4 | {
5 | ///
6 | /// 必需的设计器变量。
7 | ///
8 | private System.ComponentModel.IContainer components = null;
9 |
10 | ///
11 | /// 清理所有正在使用的资源。
12 | ///
13 | /// 如果应释放托管资源,为 true;否则为 false。
14 | protected override void Dispose(bool disposing)
15 | {
16 | if (disposing && (components != null))
17 | {
18 | components.Dispose();
19 | }
20 | base.Dispose(disposing);
21 | }
22 |
23 | #region Windows 窗体设计器生成的代码
24 |
25 | ///
26 | /// 设计器支持所需的方法 - 不要修改
27 | /// 使用代码编辑器修改此方法的内容。
28 | ///
29 | private void InitializeComponent()
30 | {
31 | this.ControlButton = new System.Windows.Forms.Button();
32 | this.v2rayConfigInfoGroupBox = new System.Windows.Forms.GroupBox();
33 | this.v2rayChinaDNSTextBox = new System.Windows.Forms.TextBox();
34 | this.v2rayDefaultDNSTextBox = new System.Windows.Forms.TextBox();
35 | this.v2rayChinaDNSLabel = new System.Windows.Forms.Label();
36 | this.v2rayDefaultDNSLabel = new System.Windows.Forms.Label();
37 | this.v2rayTLSSecureCheckBox = new System.Windows.Forms.CheckBox();
38 | this.v2rayPathLabel = new System.Windows.Forms.Label();
39 | this.v2rayPathTextBox = new System.Windows.Forms.TextBox();
40 | this.v2rayTransferMethodComboBox = new System.Windows.Forms.ComboBox();
41 | this.v2rayTransferMethodLabel = new System.Windows.Forms.Label();
42 | this.v2rayServerPortTextBox = new System.Windows.Forms.TextBox();
43 | this.v2rayAlterIDTextBox = new System.Windows.Forms.TextBox();
44 | this.v2rayAlterIDLabel = new System.Windows.Forms.Label();
45 | this.v2rayUserIDTextBox = new System.Windows.Forms.TextBox();
46 | this.v2rayUserIDLabel = new System.Windows.Forms.Label();
47 | this.v2rayServerAddressTextBox = new System.Windows.Forms.TextBox();
48 | this.v2rayServerAddressLabel = new System.Windows.Forms.Label();
49 | this.v2rayServerLabel = new System.Windows.Forms.Label();
50 | this.TUNTAPConfigInfoGroupBox = new System.Windows.Forms.GroupBox();
51 | this.TUNTAPPointsTextBox = new System.Windows.Forms.TextBox();
52 | this.TUNTAPPointsLabel = new System.Windows.Forms.Label();
53 | this.TUNTAPDNSTextBox = new System.Windows.Forms.TextBox();
54 | this.TUNTAPDNSLabel = new System.Windows.Forms.Label();
55 | this.TUNTAPGatewayTextBox = new System.Windows.Forms.TextBox();
56 | this.TUNTAPGatewayLabel = new System.Windows.Forms.Label();
57 | this.TUNTAPAddressTextBox = new System.Windows.Forms.TextBox();
58 | this.TUNTAPAddressLabel = new System.Windows.Forms.Label();
59 | this.StatusLabel = new System.Windows.Forms.Label();
60 | this.AdapterConfigInfoGroupBox = new System.Windows.Forms.GroupBox();
61 | this.AdapterGatewayComboBox = new System.Windows.Forms.ComboBox();
62 | this.AdapterGatewayLabel = new System.Windows.Forms.Label();
63 | this.AdapterAddressComboBox = new System.Windows.Forms.ComboBox();
64 | this.AdapterAddressLabel = new System.Windows.Forms.Label();
65 | this.v2rayConfigInfoGroupBox.SuspendLayout();
66 | this.TUNTAPConfigInfoGroupBox.SuspendLayout();
67 | this.AdapterConfigInfoGroupBox.SuspendLayout();
68 | this.SuspendLayout();
69 | //
70 | // ControlButton
71 | //
72 | this.ControlButton.Location = new System.Drawing.Point(336, 449);
73 | this.ControlButton.Name = "ControlButton";
74 | this.ControlButton.Size = new System.Drawing.Size(75, 23);
75 | this.ControlButton.TabIndex = 0;
76 | this.ControlButton.Text = "启动";
77 | this.ControlButton.UseVisualStyleBackColor = true;
78 | this.ControlButton.Click += new System.EventHandler(this.ControlButton_Click);
79 | //
80 | // v2rayConfigInfoGroupBox
81 | //
82 | this.v2rayConfigInfoGroupBox.Controls.Add(this.v2rayChinaDNSTextBox);
83 | this.v2rayConfigInfoGroupBox.Controls.Add(this.v2rayDefaultDNSTextBox);
84 | this.v2rayConfigInfoGroupBox.Controls.Add(this.v2rayChinaDNSLabel);
85 | this.v2rayConfigInfoGroupBox.Controls.Add(this.v2rayDefaultDNSLabel);
86 | this.v2rayConfigInfoGroupBox.Controls.Add(this.v2rayTLSSecureCheckBox);
87 | this.v2rayConfigInfoGroupBox.Controls.Add(this.v2rayPathLabel);
88 | this.v2rayConfigInfoGroupBox.Controls.Add(this.v2rayPathTextBox);
89 | this.v2rayConfigInfoGroupBox.Controls.Add(this.v2rayTransferMethodComboBox);
90 | this.v2rayConfigInfoGroupBox.Controls.Add(this.v2rayTransferMethodLabel);
91 | this.v2rayConfigInfoGroupBox.Controls.Add(this.v2rayServerPortTextBox);
92 | this.v2rayConfigInfoGroupBox.Controls.Add(this.v2rayAlterIDTextBox);
93 | this.v2rayConfigInfoGroupBox.Controls.Add(this.v2rayAlterIDLabel);
94 | this.v2rayConfigInfoGroupBox.Controls.Add(this.v2rayUserIDTextBox);
95 | this.v2rayConfigInfoGroupBox.Controls.Add(this.v2rayUserIDLabel);
96 | this.v2rayConfigInfoGroupBox.Controls.Add(this.v2rayServerAddressTextBox);
97 | this.v2rayConfigInfoGroupBox.Controls.Add(this.v2rayServerAddressLabel);
98 | this.v2rayConfigInfoGroupBox.Controls.Add(this.v2rayServerLabel);
99 | this.v2rayConfigInfoGroupBox.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
100 | this.v2rayConfigInfoGroupBox.Location = new System.Drawing.Point(12, 12);
101 | this.v2rayConfigInfoGroupBox.Name = "v2rayConfigInfoGroupBox";
102 | this.v2rayConfigInfoGroupBox.Size = new System.Drawing.Size(399, 224);
103 | this.v2rayConfigInfoGroupBox.TabIndex = 1;
104 | this.v2rayConfigInfoGroupBox.TabStop = false;
105 | this.v2rayConfigInfoGroupBox.Text = "v2ray 配置信息";
106 | //
107 | // v2rayChinaDNSTextBox
108 | //
109 | this.v2rayChinaDNSTextBox.Location = new System.Drawing.Point(81, 169);
110 | this.v2rayChinaDNSTextBox.Name = "v2rayChinaDNSTextBox";
111 | this.v2rayChinaDNSTextBox.Size = new System.Drawing.Size(309, 23);
112 | this.v2rayChinaDNSTextBox.TabIndex = 16;
113 | this.v2rayChinaDNSTextBox.Text = "114.114.114.114";
114 | this.v2rayChinaDNSTextBox.TextAlign = System.Windows.Forms.HorizontalAlignment.Center;
115 | //
116 | // v2rayDefaultDNSTextBox
117 | //
118 | this.v2rayDefaultDNSTextBox.Location = new System.Drawing.Point(81, 140);
119 | this.v2rayDefaultDNSTextBox.Name = "v2rayDefaultDNSTextBox";
120 | this.v2rayDefaultDNSTextBox.Size = new System.Drawing.Size(309, 23);
121 | this.v2rayDefaultDNSTextBox.TabIndex = 15;
122 | this.v2rayDefaultDNSTextBox.Text = "8.8.8.8";
123 | this.v2rayDefaultDNSTextBox.TextAlign = System.Windows.Forms.HorizontalAlignment.Center;
124 | //
125 | // v2rayChinaDNSLabel
126 | //
127 | this.v2rayChinaDNSLabel.AutoSize = true;
128 | this.v2rayChinaDNSLabel.Location = new System.Drawing.Point(6, 172);
129 | this.v2rayChinaDNSLabel.Name = "v2rayChinaDNSLabel";
130 | this.v2rayChinaDNSLabel.Size = new System.Drawing.Size(74, 17);
131 | this.v2rayChinaDNSLabel.TabIndex = 14;
132 | this.v2rayChinaDNSLabel.Text = "中国 DNS:";
133 | //
134 | // v2rayDefaultDNSLabel
135 | //
136 | this.v2rayDefaultDNSLabel.AutoSize = true;
137 | this.v2rayDefaultDNSLabel.Location = new System.Drawing.Point(6, 143);
138 | this.v2rayDefaultDNSLabel.Name = "v2rayDefaultDNSLabel";
139 | this.v2rayDefaultDNSLabel.Size = new System.Drawing.Size(74, 17);
140 | this.v2rayDefaultDNSLabel.TabIndex = 13;
141 | this.v2rayDefaultDNSLabel.Text = "默认 DNS:";
142 | //
143 | // v2rayTLSSecureCheckBox
144 | //
145 | this.v2rayTLSSecureCheckBox.AutoSize = true;
146 | this.v2rayTLSSecureCheckBox.Checked = true;
147 | this.v2rayTLSSecureCheckBox.CheckState = System.Windows.Forms.CheckState.Checked;
148 | this.v2rayTLSSecureCheckBox.Location = new System.Drawing.Point(267, 198);
149 | this.v2rayTLSSecureCheckBox.Name = "v2rayTLSSecureCheckBox";
150 | this.v2rayTLSSecureCheckBox.Size = new System.Drawing.Size(123, 21);
151 | this.v2rayTLSSecureCheckBox.TabIndex = 12;
152 | this.v2rayTLSSecureCheckBox.Text = "TLS 底层传输安全";
153 | this.v2rayTLSSecureCheckBox.UseVisualStyleBackColor = true;
154 | //
155 | // v2rayPathLabel
156 | //
157 | this.v2rayPathLabel.AutoSize = true;
158 | this.v2rayPathLabel.Location = new System.Drawing.Point(6, 114);
159 | this.v2rayPathLabel.Name = "v2rayPathLabel";
160 | this.v2rayPathLabel.Size = new System.Drawing.Size(44, 17);
161 | this.v2rayPathLabel.TabIndex = 11;
162 | this.v2rayPathLabel.Text = "路径:";
163 | //
164 | // v2rayPathTextBox
165 | //
166 | this.v2rayPathTextBox.Location = new System.Drawing.Point(81, 111);
167 | this.v2rayPathTextBox.Name = "v2rayPathTextBox";
168 | this.v2rayPathTextBox.Size = new System.Drawing.Size(309, 23);
169 | this.v2rayPathTextBox.TabIndex = 10;
170 | this.v2rayPathTextBox.Text = "/";
171 | this.v2rayPathTextBox.TextAlign = System.Windows.Forms.HorizontalAlignment.Center;
172 | //
173 | // v2rayTransferMethodComboBox
174 | //
175 | this.v2rayTransferMethodComboBox.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
176 | this.v2rayTransferMethodComboBox.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
177 | this.v2rayTransferMethodComboBox.FormattingEnabled = true;
178 | this.v2rayTransferMethodComboBox.Items.AddRange(new object[] {
179 | "TCP",
180 | "mKCP",
181 | "WebSockets",
182 | "HTTP/2",
183 | "QUIC"});
184 | this.v2rayTransferMethodComboBox.Location = new System.Drawing.Point(199, 81);
185 | this.v2rayTransferMethodComboBox.Name = "v2rayTransferMethodComboBox";
186 | this.v2rayTransferMethodComboBox.Size = new System.Drawing.Size(191, 25);
187 | this.v2rayTransferMethodComboBox.TabIndex = 9;
188 | //
189 | // v2rayTransferMethodLabel
190 | //
191 | this.v2rayTransferMethodLabel.AutoSize = true;
192 | this.v2rayTransferMethodLabel.Location = new System.Drawing.Point(138, 85);
193 | this.v2rayTransferMethodLabel.Name = "v2rayTransferMethodLabel";
194 | this.v2rayTransferMethodLabel.Size = new System.Drawing.Size(68, 17);
195 | this.v2rayTransferMethodLabel.TabIndex = 8;
196 | this.v2rayTransferMethodLabel.Text = "传输方式:";
197 | //
198 | // v2rayServerPortTextBox
199 | //
200 | this.v2rayServerPortTextBox.Location = new System.Drawing.Point(329, 22);
201 | this.v2rayServerPortTextBox.Name = "v2rayServerPortTextBox";
202 | this.v2rayServerPortTextBox.Size = new System.Drawing.Size(61, 23);
203 | this.v2rayServerPortTextBox.TabIndex = 7;
204 | this.v2rayServerPortTextBox.TextAlign = System.Windows.Forms.HorizontalAlignment.Center;
205 | this.v2rayServerPortTextBox.KeyPress += new System.Windows.Forms.KeyPressEventHandler(this.v2rayServerPortTextBox_KeyPress);
206 | //
207 | // v2rayAlterIDTextBox
208 | //
209 | this.v2rayAlterIDTextBox.Location = new System.Drawing.Point(81, 82);
210 | this.v2rayAlterIDTextBox.Name = "v2rayAlterIDTextBox";
211 | this.v2rayAlterIDTextBox.Size = new System.Drawing.Size(56, 23);
212 | this.v2rayAlterIDTextBox.TabIndex = 5;
213 | this.v2rayAlterIDTextBox.Text = "0";
214 | this.v2rayAlterIDTextBox.TextAlign = System.Windows.Forms.HorizontalAlignment.Center;
215 | this.v2rayAlterIDTextBox.KeyPress += new System.Windows.Forms.KeyPressEventHandler(this.v2rayAlterIDTextBox_KeyPress);
216 | //
217 | // v2rayAlterIDLabel
218 | //
219 | this.v2rayAlterIDLabel.AutoSize = true;
220 | this.v2rayAlterIDLabel.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
221 | this.v2rayAlterIDLabel.Location = new System.Drawing.Point(6, 85);
222 | this.v2rayAlterIDLabel.Name = "v2rayAlterIDLabel";
223 | this.v2rayAlterIDLabel.Size = new System.Drawing.Size(61, 17);
224 | this.v2rayAlterIDLabel.TabIndex = 4;
225 | this.v2rayAlterIDLabel.Text = "额外 ID:";
226 | //
227 | // v2rayUserIDTextBox
228 | //
229 | this.v2rayUserIDTextBox.Location = new System.Drawing.Point(81, 51);
230 | this.v2rayUserIDTextBox.Name = "v2rayUserIDTextBox";
231 | this.v2rayUserIDTextBox.Size = new System.Drawing.Size(309, 23);
232 | this.v2rayUserIDTextBox.TabIndex = 3;
233 | this.v2rayUserIDTextBox.TextAlign = System.Windows.Forms.HorizontalAlignment.Center;
234 | //
235 | // v2rayUserIDLabel
236 | //
237 | this.v2rayUserIDLabel.AutoSize = true;
238 | this.v2rayUserIDLabel.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
239 | this.v2rayUserIDLabel.Location = new System.Drawing.Point(6, 54);
240 | this.v2rayUserIDLabel.Name = "v2rayUserIDLabel";
241 | this.v2rayUserIDLabel.Size = new System.Drawing.Size(61, 17);
242 | this.v2rayUserIDLabel.TabIndex = 2;
243 | this.v2rayUserIDLabel.Text = "用户 ID:";
244 | //
245 | // v2rayServerAddressTextBox
246 | //
247 | this.v2rayServerAddressTextBox.Location = new System.Drawing.Point(81, 22);
248 | this.v2rayServerAddressTextBox.Name = "v2rayServerAddressTextBox";
249 | this.v2rayServerAddressTextBox.Size = new System.Drawing.Size(241, 23);
250 | this.v2rayServerAddressTextBox.TabIndex = 1;
251 | this.v2rayServerAddressTextBox.TextAlign = System.Windows.Forms.HorizontalAlignment.Center;
252 | //
253 | // v2rayServerAddressLabel
254 | //
255 | this.v2rayServerAddressLabel.AutoSize = true;
256 | this.v2rayServerAddressLabel.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
257 | this.v2rayServerAddressLabel.Location = new System.Drawing.Point(7, 25);
258 | this.v2rayServerAddressLabel.Name = "v2rayServerAddressLabel";
259 | this.v2rayServerAddressLabel.Size = new System.Drawing.Size(80, 17);
260 | this.v2rayServerAddressLabel.TabIndex = 0;
261 | this.v2rayServerAddressLabel.Text = "服务器地址:";
262 | //
263 | // v2rayServerLabel
264 | //
265 | this.v2rayServerLabel.AutoSize = true;
266 | this.v2rayServerLabel.Location = new System.Drawing.Point(321, 25);
267 | this.v2rayServerLabel.Name = "v2rayServerLabel";
268 | this.v2rayServerLabel.Size = new System.Drawing.Size(11, 17);
269 | this.v2rayServerLabel.TabIndex = 6;
270 | this.v2rayServerLabel.Text = ":";
271 | //
272 | // TUNTAPConfigInfoGroupBox
273 | //
274 | this.TUNTAPConfigInfoGroupBox.Controls.Add(this.TUNTAPPointsTextBox);
275 | this.TUNTAPConfigInfoGroupBox.Controls.Add(this.TUNTAPPointsLabel);
276 | this.TUNTAPConfigInfoGroupBox.Controls.Add(this.TUNTAPDNSTextBox);
277 | this.TUNTAPConfigInfoGroupBox.Controls.Add(this.TUNTAPDNSLabel);
278 | this.TUNTAPConfigInfoGroupBox.Controls.Add(this.TUNTAPGatewayTextBox);
279 | this.TUNTAPConfigInfoGroupBox.Controls.Add(this.TUNTAPGatewayLabel);
280 | this.TUNTAPConfigInfoGroupBox.Controls.Add(this.TUNTAPAddressTextBox);
281 | this.TUNTAPConfigInfoGroupBox.Controls.Add(this.TUNTAPAddressLabel);
282 | this.TUNTAPConfigInfoGroupBox.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
283 | this.TUNTAPConfigInfoGroupBox.Location = new System.Drawing.Point(12, 242);
284 | this.TUNTAPConfigInfoGroupBox.Name = "TUNTAPConfigInfoGroupBox";
285 | this.TUNTAPConfigInfoGroupBox.Size = new System.Drawing.Size(399, 109);
286 | this.TUNTAPConfigInfoGroupBox.TabIndex = 2;
287 | this.TUNTAPConfigInfoGroupBox.TabStop = false;
288 | this.TUNTAPConfigInfoGroupBox.Text = "TUN/TAP 配置信息";
289 | //
290 | // TUNTAPPointsTextBox
291 | //
292 | this.TUNTAPPointsTextBox.Location = new System.Drawing.Point(46, 77);
293 | this.TUNTAPPointsTextBox.Name = "TUNTAPPointsTextBox";
294 | this.TUNTAPPointsTextBox.Size = new System.Drawing.Size(41, 23);
295 | this.TUNTAPPointsTextBox.TabIndex = 7;
296 | this.TUNTAPPointsTextBox.Text = "100";
297 | this.TUNTAPPointsTextBox.TextAlign = System.Windows.Forms.HorizontalAlignment.Center;
298 | this.TUNTAPPointsTextBox.KeyPress += new System.Windows.Forms.KeyPressEventHandler(this.TUNTAPPointsTextBox_KeyPress);
299 | //
300 | // TUNTAPPointsLabel
301 | //
302 | this.TUNTAPPointsLabel.AutoSize = true;
303 | this.TUNTAPPointsLabel.Location = new System.Drawing.Point(6, 80);
304 | this.TUNTAPPointsLabel.Name = "TUNTAPPointsLabel";
305 | this.TUNTAPPointsLabel.Size = new System.Drawing.Size(44, 17);
306 | this.TUNTAPPointsLabel.TabIndex = 6;
307 | this.TUNTAPPointsLabel.Text = "跃点:";
308 | //
309 | // TUNTAPDNSTextBox
310 | //
311 | this.TUNTAPDNSTextBox.Location = new System.Drawing.Point(46, 48);
312 | this.TUNTAPDNSTextBox.Name = "TUNTAPDNSTextBox";
313 | this.TUNTAPDNSTextBox.Size = new System.Drawing.Size(344, 23);
314 | this.TUNTAPDNSTextBox.TabIndex = 5;
315 | this.TUNTAPDNSTextBox.Text = "114.114.114.114,114.114.115.115";
316 | this.TUNTAPDNSTextBox.TextAlign = System.Windows.Forms.HorizontalAlignment.Center;
317 | //
318 | // TUNTAPDNSLabel
319 | //
320 | this.TUNTAPDNSLabel.AutoSize = true;
321 | this.TUNTAPDNSLabel.Location = new System.Drawing.Point(7, 51);
322 | this.TUNTAPDNSLabel.Name = "TUNTAPDNSLabel";
323 | this.TUNTAPDNSLabel.Size = new System.Drawing.Size(46, 17);
324 | this.TUNTAPDNSLabel.TabIndex = 4;
325 | this.TUNTAPDNSLabel.Text = "DNS:";
326 | //
327 | // TUNTAPGatewayTextBox
328 | //
329 | this.TUNTAPGatewayTextBox.Location = new System.Drawing.Point(237, 19);
330 | this.TUNTAPGatewayTextBox.Name = "TUNTAPGatewayTextBox";
331 | this.TUNTAPGatewayTextBox.Size = new System.Drawing.Size(153, 23);
332 | this.TUNTAPGatewayTextBox.TabIndex = 3;
333 | this.TUNTAPGatewayTextBox.Text = "10.0.100.1";
334 | this.TUNTAPGatewayTextBox.TextAlign = System.Windows.Forms.HorizontalAlignment.Center;
335 | //
336 | // TUNTAPGatewayLabel
337 | //
338 | this.TUNTAPGatewayLabel.AutoSize = true;
339 | this.TUNTAPGatewayLabel.Location = new System.Drawing.Point(199, 22);
340 | this.TUNTAPGatewayLabel.Name = "TUNTAPGatewayLabel";
341 | this.TUNTAPGatewayLabel.Size = new System.Drawing.Size(44, 17);
342 | this.TUNTAPGatewayLabel.TabIndex = 2;
343 | this.TUNTAPGatewayLabel.Text = "网关:";
344 | //
345 | // TUNTAPAddressTextBox
346 | //
347 | this.TUNTAPAddressTextBox.Location = new System.Drawing.Point(46, 19);
348 | this.TUNTAPAddressTextBox.Name = "TUNTAPAddressTextBox";
349 | this.TUNTAPAddressTextBox.Size = new System.Drawing.Size(153, 23);
350 | this.TUNTAPAddressTextBox.TabIndex = 1;
351 | this.TUNTAPAddressTextBox.Text = "10.0.100.10";
352 | this.TUNTAPAddressTextBox.TextAlign = System.Windows.Forms.HorizontalAlignment.Center;
353 | //
354 | // TUNTAPAddressLabel
355 | //
356 | this.TUNTAPAddressLabel.AutoSize = true;
357 | this.TUNTAPAddressLabel.Location = new System.Drawing.Point(8, 22);
358 | this.TUNTAPAddressLabel.Name = "TUNTAPAddressLabel";
359 | this.TUNTAPAddressLabel.Size = new System.Drawing.Size(44, 17);
360 | this.TUNTAPAddressLabel.TabIndex = 0;
361 | this.TUNTAPAddressLabel.Text = "地址:";
362 | //
363 | // StatusLabel
364 | //
365 | this.StatusLabel.AutoSize = true;
366 | this.StatusLabel.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
367 | this.StatusLabel.Location = new System.Drawing.Point(12, 451);
368 | this.StatusLabel.Name = "StatusLabel";
369 | this.StatusLabel.Size = new System.Drawing.Size(141, 17);
370 | this.StatusLabel.TabIndex = 3;
371 | this.StatusLabel.Text = "当前状态:初始化完毕 ...";
372 | //
373 | // AdapterConfigInfoGroupBox
374 | //
375 | this.AdapterConfigInfoGroupBox.Controls.Add(this.AdapterGatewayComboBox);
376 | this.AdapterConfigInfoGroupBox.Controls.Add(this.AdapterGatewayLabel);
377 | this.AdapterConfigInfoGroupBox.Controls.Add(this.AdapterAddressComboBox);
378 | this.AdapterConfigInfoGroupBox.Controls.Add(this.AdapterAddressLabel);
379 | this.AdapterConfigInfoGroupBox.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
380 | this.AdapterConfigInfoGroupBox.Location = new System.Drawing.Point(12, 357);
381 | this.AdapterConfigInfoGroupBox.Name = "AdapterConfigInfoGroupBox";
382 | this.AdapterConfigInfoGroupBox.Size = new System.Drawing.Size(399, 86);
383 | this.AdapterConfigInfoGroupBox.TabIndex = 4;
384 | this.AdapterConfigInfoGroupBox.TabStop = false;
385 | this.AdapterConfigInfoGroupBox.Text = "适配器 配置信息";
386 | //
387 | // AdapterGatewayComboBox
388 | //
389 | this.AdapterGatewayComboBox.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
390 | this.AdapterGatewayComboBox.FormattingEnabled = true;
391 | this.AdapterGatewayComboBox.Location = new System.Drawing.Point(46, 53);
392 | this.AdapterGatewayComboBox.Name = "AdapterGatewayComboBox";
393 | this.AdapterGatewayComboBox.Size = new System.Drawing.Size(344, 25);
394 | this.AdapterGatewayComboBox.TabIndex = 2;
395 | //
396 | // AdapterGatewayLabel
397 | //
398 | this.AdapterGatewayLabel.AutoSize = true;
399 | this.AdapterGatewayLabel.Location = new System.Drawing.Point(6, 57);
400 | this.AdapterGatewayLabel.Name = "AdapterGatewayLabel";
401 | this.AdapterGatewayLabel.Size = new System.Drawing.Size(44, 17);
402 | this.AdapterGatewayLabel.TabIndex = 3;
403 | this.AdapterGatewayLabel.Text = "网关:";
404 | //
405 | // AdapterAddressComboBox
406 | //
407 | this.AdapterAddressComboBox.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
408 | this.AdapterAddressComboBox.FormattingEnabled = true;
409 | this.AdapterAddressComboBox.Location = new System.Drawing.Point(46, 22);
410 | this.AdapterAddressComboBox.Name = "AdapterAddressComboBox";
411 | this.AdapterAddressComboBox.Size = new System.Drawing.Size(344, 25);
412 | this.AdapterAddressComboBox.TabIndex = 0;
413 | //
414 | // AdapterAddressLabel
415 | //
416 | this.AdapterAddressLabel.AutoSize = true;
417 | this.AdapterAddressLabel.Location = new System.Drawing.Point(6, 26);
418 | this.AdapterAddressLabel.Name = "AdapterAddressLabel";
419 | this.AdapterAddressLabel.Size = new System.Drawing.Size(44, 17);
420 | this.AdapterAddressLabel.TabIndex = 1;
421 | this.AdapterAddressLabel.Text = "地址:";
422 | //
423 | // MainForm
424 | //
425 | this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
426 | this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
427 | this.ClientSize = new System.Drawing.Size(423, 480);
428 | this.Controls.Add(this.AdapterConfigInfoGroupBox);
429 | this.Controls.Add(this.StatusLabel);
430 | this.Controls.Add(this.TUNTAPConfigInfoGroupBox);
431 | this.Controls.Add(this.v2rayConfigInfoGroupBox);
432 | this.Controls.Add(this.ControlButton);
433 | this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle;
434 | this.MaximizeBox = false;
435 | this.Name = "MainForm";
436 | this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
437 | this.Text = "v2tap";
438 | this.Load += new System.EventHandler(this.MainForm_Load);
439 | this.v2rayConfigInfoGroupBox.ResumeLayout(false);
440 | this.v2rayConfigInfoGroupBox.PerformLayout();
441 | this.TUNTAPConfigInfoGroupBox.ResumeLayout(false);
442 | this.TUNTAPConfigInfoGroupBox.PerformLayout();
443 | this.AdapterConfigInfoGroupBox.ResumeLayout(false);
444 | this.AdapterConfigInfoGroupBox.PerformLayout();
445 | this.ResumeLayout(false);
446 | this.PerformLayout();
447 |
448 | }
449 |
450 | #endregion
451 |
452 | private System.Windows.Forms.Button ControlButton;
453 | private System.Windows.Forms.GroupBox v2rayConfigInfoGroupBox;
454 | private System.Windows.Forms.Label v2rayUserIDLabel;
455 | private System.Windows.Forms.Label v2rayServerAddressLabel;
456 | private System.Windows.Forms.TextBox v2rayAlterIDTextBox;
457 | private System.Windows.Forms.Label v2rayAlterIDLabel;
458 | private System.Windows.Forms.TextBox v2rayUserIDTextBox;
459 | private System.Windows.Forms.TextBox v2rayServerPortTextBox;
460 | private System.Windows.Forms.Label v2rayServerLabel;
461 | private System.Windows.Forms.ComboBox v2rayTransferMethodComboBox;
462 | private System.Windows.Forms.Label v2rayTransferMethodLabel;
463 | private System.Windows.Forms.TextBox v2rayServerAddressTextBox;
464 | private System.Windows.Forms.Label v2rayPathLabel;
465 | private System.Windows.Forms.TextBox v2rayPathTextBox;
466 | private System.Windows.Forms.CheckBox v2rayTLSSecureCheckBox;
467 | private System.Windows.Forms.GroupBox TUNTAPConfigInfoGroupBox;
468 | private System.Windows.Forms.TextBox TUNTAPGatewayTextBox;
469 | private System.Windows.Forms.Label TUNTAPGatewayLabel;
470 | private System.Windows.Forms.TextBox TUNTAPAddressTextBox;
471 | private System.Windows.Forms.Label TUNTAPAddressLabel;
472 | private System.Windows.Forms.Label TUNTAPDNSLabel;
473 | private System.Windows.Forms.TextBox TUNTAPDNSTextBox;
474 | private System.Windows.Forms.Label StatusLabel;
475 | private System.Windows.Forms.GroupBox AdapterConfigInfoGroupBox;
476 | private System.Windows.Forms.Label AdapterAddressLabel;
477 | private System.Windows.Forms.TextBox TUNTAPPointsTextBox;
478 | private System.Windows.Forms.Label TUNTAPPointsLabel;
479 | private System.Windows.Forms.ComboBox AdapterGatewayComboBox;
480 | private System.Windows.Forms.Label AdapterGatewayLabel;
481 | private System.Windows.Forms.ComboBox AdapterAddressComboBox;
482 | private System.Windows.Forms.Label v2rayDefaultDNSLabel;
483 | private System.Windows.Forms.Label v2rayChinaDNSLabel;
484 | private System.Windows.Forms.TextBox v2rayChinaDNSTextBox;
485 | private System.Windows.Forms.TextBox v2rayDefaultDNSTextBox;
486 | }
487 | }
488 |
489 |
--------------------------------------------------------------------------------
/v2tap/MainForm.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Diagnostics;
3 | using System.IO;
4 | using System.Net;
5 | using System.Net.NetworkInformation;
6 | using System.Net.Sockets;
7 | using System.Text;
8 | using System.Threading;
9 | using System.Threading.Tasks;
10 | using System.Windows.Forms;
11 |
12 | namespace v2tap
13 | {
14 | public partial class MainForm : Form
15 | {
16 | public static string status = "初始化完毕,等待命令下发中";
17 |
18 | public MainForm()
19 | {
20 | InitializeComponent();
21 | }
22 |
23 | private void MainForm_Load(object sender, EventArgs e)
24 | {
25 | if (!File.Exists("eula.txt"))
26 | {
27 | string eula = "" +
28 | "1. 软件由 Holli_Freed 制作并开源与 GitHub 上\n" +
29 | "\n" +
30 | "GitHub:https://github.com/hacking001/v2tap\n" +
31 | "\n" +
32 | "最终解释权归 Holli_Freed 所有!" +
33 | "";
34 | MessageBox.Show(eula, "免责声明", MessageBoxButtons.OK, MessageBoxIcon.Information);
35 |
36 | File.WriteAllText("eula.txt", "");
37 | }
38 |
39 | v2rayUserIDTextBox.Text = Guid.NewGuid().ToString();
40 | v2rayTransferMethodComboBox.SelectedIndex = 2;
41 |
42 | using (UdpClient client = new UdpClient("114.114.114.114", 53))
43 | {
44 | IPAddress address = ((IPEndPoint)client.Client.LocalEndPoint).Address;
45 |
46 | int addressCount = 0;
47 | int gatewayCount = 0;
48 | bool addressGeted = false;
49 |
50 | NetworkInterface[] adapters = NetworkInterface.GetAllNetworkInterfaces();
51 | foreach (NetworkInterface adapter in adapters)
52 | {
53 | IPInterfaceProperties properties = adapter.GetIPProperties();
54 |
55 | foreach (UnicastIPAddressInformation information in properties.UnicastAddresses)
56 | {
57 | if (information.Address.AddressFamily == AddressFamily.InterNetwork)
58 | {
59 | string IP = information.Address.ToString();
60 |
61 | if (IP.StartsWith("10.") || IP.StartsWith("172.") || IP.StartsWith("192."))
62 | {
63 | if (Equals(information.Address, address))
64 | {
65 | addressGeted = true;
66 | }
67 | else
68 | {
69 | if (!addressGeted)
70 | {
71 | addressCount++;
72 | }
73 | }
74 |
75 | AdapterAddressComboBox.Items.Add(IP);
76 | }
77 | }
78 | }
79 |
80 | foreach (GatewayIPAddressInformation information in properties.GatewayAddresses)
81 | {
82 | if (information.Address.AddressFamily == AddressFamily.InterNetwork)
83 | {
84 | string IP = information.Address.ToString();
85 |
86 | if (IP.StartsWith("10.") || IP.StartsWith("172.") || IP.StartsWith("192."))
87 | {
88 | if (!addressGeted)
89 | {
90 | gatewayCount++;
91 | }
92 |
93 | AdapterGatewayComboBox.Items.Add(IP);
94 | }
95 | }
96 | }
97 | }
98 | AdapterAddressComboBox.SelectedIndex = addressCount;
99 | AdapterGatewayComboBox.SelectedIndex = gatewayCount;
100 | }
101 |
102 | if (Process.GetProcessesByName("tun2socks").Length == 1 && Process.GetProcessesByName("wv2ray").Length == 1)
103 | {
104 | status = "检测到 tun2socks 和 v2ray 服务已启动!";
105 |
106 | ControlButton.Text = "关闭";
107 | }
108 | else
109 | {
110 | Utils.SharedUtils.ExecuteCommand("TASKKILL /F /T /IM tun2socks.exe");
111 | Utils.SharedUtils.ExecuteCommand("TASKKILL /F /T /IM wv2ray.exe");
112 | }
113 |
114 | Task.Factory.StartNew(() =>
115 | {
116 | while (true)
117 | {
118 | try
119 | {
120 | Invoke((MethodInvoker)delegate
121 | {
122 | Text = "v2tap - " + DateTime.Now.ToString();
123 | });
124 |
125 | StatusLabel.Invoke((MethodInvoker)delegate
126 | {
127 | StatusLabel.Text = "当前状态:" + status;
128 | });
129 | }
130 | catch
131 | {
132 |
133 | }
134 |
135 | Thread.Sleep(100);
136 | }
137 | });
138 | }
139 |
140 | private void v2rayServerPortTextBox_KeyPress(object sender, KeyPressEventArgs e)
141 | {
142 | if ((e.KeyChar >= '0' && e.KeyChar <= '9') || e.KeyChar == 8)
143 | {
144 | e.Handled = false;
145 | }
146 | else
147 | {
148 | e.Handled = true;
149 | }
150 | }
151 |
152 | private void v2rayAlterIDTextBox_KeyPress(object sender, KeyPressEventArgs e)
153 | {
154 | if ((e.KeyChar >= '0' && e.KeyChar <= '9') || e.KeyChar == 8)
155 | {
156 | e.Handled = false;
157 | }
158 | else
159 | {
160 | e.Handled = true;
161 | }
162 | }
163 |
164 | private void TUNTAPPointsTextBox_KeyPress(object sender, KeyPressEventArgs e)
165 | {
166 | if ((e.KeyChar >= '0' && e.KeyChar <= '9') || e.KeyChar == 8)
167 | {
168 | e.Handled = false;
169 | }
170 | else
171 | {
172 | e.Handled = true;
173 | }
174 | }
175 |
176 | private void ControlButton_Click(object sender, EventArgs e)
177 | {
178 | if (ControlButton.Text.Contains("启动"))
179 | {
180 | if (v2rayServerAddressTextBox.Text != "" && v2rayServerPortTextBox.Text != "" && v2rayUserIDTextBox.Text != "" && v2rayAlterIDTextBox.Text != "" && TUNTAPAddressTextBox.Text != "" && TUNTAPGatewayTextBox.Text != "" && TUNTAPDNSTextBox.Text != "" && TUNTAPPointsTextBox.Text != "")
181 | {
182 | status = "启动中 ...";
183 | ControlButton.Enabled = false;
184 | ControlButton.Text = "稍等 ...";
185 |
186 | string adapterAddress = AdapterAddressComboBox.Text;
187 | string adapterGateway = AdapterGatewayComboBox.Text;
188 | string v2rayDefaultDNS = v2rayDefaultDNSTextBox.Text;
189 | string v2rayChinaDNS = v2rayChinaDNSTextBox.Text;
190 | string v2rayServerAddress = v2rayServerAddressTextBox.Text;
191 | string v2rayServerPort = v2rayServerPortTextBox.Text;
192 | string v2rayUserID = v2rayUserIDTextBox.Text;
193 | string v2rayAlterID = v2rayAlterIDTextBox.Text;
194 | string v2rayTransferMethod;
195 | switch (v2rayTransferMethodComboBox.Text)
196 | {
197 | case "TCP":
198 | v2rayTransferMethod = "tcp";
199 | break;
200 | case "mKCP":
201 | v2rayTransferMethod = "kcp";
202 | break;
203 | case "WebSockets":
204 | v2rayTransferMethod = "ws";
205 | break;
206 | case "HTTP/2":
207 | v2rayTransferMethod = "http";
208 | break;
209 | case "QUIC":
210 | v2rayTransferMethod = "quic";
211 | break;
212 | default:
213 | v2rayTransferMethod = "ws";
214 | break;
215 | }
216 | string v2rayTLSSecure = (v2rayTLSSecureCheckBox.Checked) ? "tls" : "none";
217 | string v2rayPath = v2rayPathTextBox.Text;
218 |
219 | string TUNTAPGateway = TUNTAPGatewayTextBox.Text;
220 | string TUNTAPAddress = TUNTAPAddressTextBox.Text;
221 | string TUNTAPDNS = TUNTAPDNSTextBox.Text;
222 | string TUNTAPPoints = TUNTAPPointsTextBox.Text;
223 |
224 | Task.Factory.StartNew(() =>
225 | {
226 | status = "正在生成 v2ray 配置文件 ...";
227 | string config = Encoding.UTF8.GetString(Convert.FromBase64String(v2tap.config));
228 | config = config.Replace("adapterIPAddress", adapterAddress);
229 | config = config.Replace("v2rayDefaultDNS", v2rayDefaultDNS);
230 | config = config.Replace("v2rayChinaDNS", v2rayChinaDNS);
231 | config = config.Replace("v2rayServerAddress", v2rayServerAddress);
232 | config = config.Replace("v2rayServerPort", v2rayServerPort);
233 | config = config.Replace("v2rayUserID", v2rayUserID);
234 | config = config.Replace("v2rayAlterID", v2rayAlterID);
235 | config = config.Replace("v2rayTransferMethod", v2rayTransferMethod);
236 | config = config.Replace("v2rayTLSSecure", v2rayTLSSecure);
237 | config = config.Replace("v2rayPath", v2rayPath);
238 | File.WriteAllText("config.json", config);
239 |
240 | Thread.Sleep(1000);
241 | status = "正在启动 v2ray 服务 ...";
242 | Utils.SharedUtils.ExecuteCommand("wv2ray.exe -config config.json");
243 |
244 | Thread.Sleep(1000);
245 | status = "正在启动 tun2socks 服务 ...";
246 | Utils.SharedUtils.ExecuteCommand("RunHiddenConsole.exe tun2socks.exe -tun-gw " + TUNTAPGateway + " -tun-address " + TUNTAPAddress + " -tun-dns " + TUNTAPDNS + " -enable-dns-cache -public-only -local-socks-addr 127.0.0.1:1099");
247 |
248 | Thread.Sleep(1000);
249 | status = "正在配置 路由表 ...";
250 | Utils.SharedUtils.ExecuteCommand("ROUTE CHANGE 0.0.0.0 MASK 0.0.0.0 " + adapterGateway + " METRIC 1000");
251 | Utils.SharedUtils.ExecuteCommand("ROUTE ADD " + v2rayDefaultDNS + " MASK 255.255.255.255 " + adapterGateway + " METRIC 10");
252 | Utils.SharedUtils.ExecuteCommand("ROUTE ADD " + v2rayChinaDNS + " MASK 255.255.255.255 " + adapterGateway + " METRIC 10");
253 | if (TUNTAPDNS.Contains(","))
254 | {
255 | foreach (string IP in TUNTAPDNS.Split(",".ToCharArray()))
256 | {
257 | Utils.SharedUtils.ExecuteCommand("ROUTE ADD " + IP + " MASK 255.255.255.255 " + adapterGateway + " METRIC 10");
258 | }
259 | }
260 | else
261 | {
262 | Utils.SharedUtils.ExecuteCommand("ROUTE ADD " + TUNTAPDNS + " MASK 255.255.255.255 " + adapterGateway + " METRIC 10");
263 | }
264 | Utils.SharedUtils.ExecuteCommand("ROUTE ADD 0.0.0.0 MASK 0.0.0.0 " + TUNTAPGateway + " METRIC " + TUNTAPPoints);
265 |
266 | Thread.Sleep(1000);
267 | ControlButton.Invoke((MethodInvoker)delegate
268 | {
269 | ControlButton.Enabled = true;
270 | ControlButton.Text = "停止";
271 | });
272 | status = "启动完毕 ...";
273 |
274 | try
275 | {
276 | File.Delete("config.json");
277 | }
278 | catch
279 | {
280 |
281 | }
282 | });
283 | }
284 | else
285 | {
286 | MessageBox.Show("配置信息不可为空", "配置错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
287 | }
288 | }
289 | else
290 | {
291 | status = "停止中 ...";
292 | ControlButton.Enabled = false;
293 | ControlButton.Text = "稍等 ...";
294 |
295 | string v2rayDefaultDNS = v2rayDefaultDNSTextBox.Text;
296 | string v2rayChinaDNS = v2rayChinaDNSTextBox.Text;
297 |
298 | string TUNTAPDNS = TUNTAPDNSTextBox.Text;
299 |
300 | Task.Factory.StartNew(() =>
301 | {
302 | Thread.Sleep(1000);
303 | status = "正在关闭 v2ray 服务 ...";
304 | Utils.SharedUtils.ExecuteCommand("TASKKILL /F /T /IM wv2ray.exe");
305 |
306 | Thread.Sleep(1000);
307 | status = "正在关闭 tun2socks 服务 ...";
308 | Utils.SharedUtils.ExecuteCommand("TASKKILL /F /T /IM tun2socks.exe");
309 |
310 | Thread.Sleep(1000);
311 | status = "正在重置 路由表 ...";
312 | Utils.SharedUtils.ExecuteCommand("ROUTE DELETE " + v2rayDefaultDNS);
313 | Utils.SharedUtils.ExecuteCommand("ROUTE DELETE " + v2rayChinaDNS);
314 | if (TUNTAPDNS.Contains(","))
315 | {
316 | foreach (string IP in TUNTAPDNS.Split(",".ToCharArray()))
317 | {
318 | Utils.SharedUtils.ExecuteCommand("ROUTE DELETE " + IP);
319 | }
320 | }
321 | else
322 | {
323 | Utils.SharedUtils.ExecuteCommand("ROUTE DELETE " + TUNTAPDNS);
324 | }
325 |
326 | Thread.Sleep(1000);
327 | ControlButton.Invoke((MethodInvoker)delegate
328 | {
329 | ControlButton.Enabled = true;
330 | ControlButton.Text = "启动";
331 | });
332 | status = "停止完毕 ...";
333 | });
334 | }
335 | }
336 | }
337 | }
338 |
--------------------------------------------------------------------------------
/v2tap/MainForm.resx:
--------------------------------------------------------------------------------
1 |
2 |
3 |
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 |
87 |
88 |
89 |
90 |
91 |
92 |
93 |
94 |
95 |
96 |
97 |
98 |
99 |
100 |
101 |
102 |
103 |
104 |
105 |
106 |
107 |
108 |
109 | text/microsoft-resx
110 |
111 |
112 | 2.0
113 |
114 |
115 | System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
116 |
117 |
118 | System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
119 |
120 |
--------------------------------------------------------------------------------
/v2tap/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Runtime.CompilerServices;
3 | using System.Runtime.InteropServices;
4 |
5 | // 有关程序集的一般信息由以下
6 | // 控制。更改这些特性值可修改
7 | // 与程序集关联的信息。
8 | [assembly: AssemblyTitle("v2tap")]
9 | [assembly: AssemblyDescription("")]
10 | [assembly: AssemblyConfiguration("")]
11 | [assembly: AssemblyCompany("")]
12 | [assembly: AssemblyProduct("v2tap")]
13 | [assembly: AssemblyCopyright("Copyright © 2018")]
14 | [assembly: AssemblyTrademark("")]
15 | [assembly: AssemblyCulture("")]
16 |
17 | // 将 ComVisible 设置为 false 会使此程序集中的类型
18 | //对 COM 组件不可见。如果需要从 COM 访问此程序集中的类型
19 | //请将此类型的 ComVisible 特性设置为 true。
20 | [assembly: ComVisible(false)]
21 |
22 | // 如果此项目向 COM 公开,则下列 GUID 用于类型库的 ID
23 | [assembly: Guid("2df9c9cb-74e0-42c5-a8bc-038be6fe5869")]
24 |
25 | // 程序集的版本信息由下列四个值组成:
26 | //
27 | // 主版本
28 | // 次版本
29 | // 生成号
30 | // 修订号
31 | //
32 | // 可以指定所有值,也可以使用以下所示的 "*" 预置版本号和修订号
33 | // 方法是按如下所示使用“*”: :
34 | // [assembly: AssemblyVersion("1.0.*")]
35 | [assembly: AssemblyVersion("1.0.0.0")]
36 | [assembly: AssemblyFileVersion("1.0.0.0")]
37 |
--------------------------------------------------------------------------------
/v2tap/Properties/Resources.Designer.cs:
--------------------------------------------------------------------------------
1 | //------------------------------------------------------------------------------
2 | //
3 | // 此代码由工具生成。
4 | // 运行时版本: 4.0.30319.42000
5 | //
6 | // 对此文件的更改可能导致不正确的行为,如果
7 | // 重新生成代码,则所做更改将丢失。
8 | //
9 | //------------------------------------------------------------------------------
10 |
11 | namespace v2tap.Properties
12 | {
13 |
14 |
15 | ///
16 | /// 强类型资源类,用于查找本地化字符串等。
17 | ///
18 | // 此类是由 StronglyTypedResourceBuilder
19 | // 类通过类似于 ResGen 或 Visual Studio 的工具自动生成的。
20 | // 若要添加或删除成员,请编辑 .ResX 文件,然后重新运行 ResGen
21 | // (以 /str 作为命令选项),或重新生成 VS 项目。
22 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")]
23 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
24 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
25 | internal class Resources
26 | {
27 |
28 | private static global::System.Resources.ResourceManager resourceMan;
29 |
30 | private static global::System.Globalization.CultureInfo resourceCulture;
31 |
32 | [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
33 | internal Resources()
34 | {
35 | }
36 |
37 | ///
38 | /// 返回此类使用的缓存 ResourceManager 实例。
39 | ///
40 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
41 | internal static global::System.Resources.ResourceManager ResourceManager
42 | {
43 | get
44 | {
45 | if ((resourceMan == null))
46 | {
47 | global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("v2tap.Properties.Resources", typeof(Resources).Assembly);
48 | resourceMan = temp;
49 | }
50 | return resourceMan;
51 | }
52 | }
53 |
54 | ///
55 | /// 覆盖当前线程的 CurrentUICulture 属性
56 | /// 使用此强类型的资源类的资源查找。
57 | ///
58 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
59 | internal static global::System.Globalization.CultureInfo Culture
60 | {
61 | get
62 | {
63 | return resourceCulture;
64 | }
65 | set
66 | {
67 | resourceCulture = value;
68 | }
69 | }
70 | }
71 | }
72 |
--------------------------------------------------------------------------------
/v2tap/Properties/Resources.resx:
--------------------------------------------------------------------------------
1 |
2 |
3 |
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 |
87 |
88 |
89 |
90 |
91 |
92 |
93 |
94 |
95 |
96 |
97 |
98 |
99 |
100 |
101 |
102 |
103 |
104 |
105 |
106 | text/microsoft-resx
107 |
108 |
109 | 2.0
110 |
111 |
112 | System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
113 |
114 |
115 | System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
116 |
117 |
--------------------------------------------------------------------------------
/v2tap/Properties/Settings.Designer.cs:
--------------------------------------------------------------------------------
1 | //------------------------------------------------------------------------------
2 | //
3 | // This code was generated by a tool.
4 | // Runtime Version:4.0.30319.42000
5 | //
6 | // Changes to this file may cause incorrect behavior and will be lost if
7 | // the code is regenerated.
8 | //
9 | //------------------------------------------------------------------------------
10 |
11 | namespace v2tap.Properties
12 | {
13 |
14 |
15 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
16 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "11.0.0.0")]
17 | internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase
18 | {
19 |
20 | private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
21 |
22 | public static Settings Default
23 | {
24 | get
25 | {
26 | return defaultInstance;
27 | }
28 | }
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/v2tap/Properties/Settings.settings:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/v2tap/Utils/SharedUtils.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Diagnostics;
4 | using System.Linq;
5 | using System.Text;
6 | using System.Threading.Tasks;
7 |
8 | namespace v2tap.Utils
9 | {
10 | public static class SharedUtils
11 | {
12 | public static void ExecuteCommand(string text)
13 | {
14 | Process process = new Process();
15 | process.StartInfo.FileName = "cmd.exe";
16 | process.StartInfo.Arguments = "/c " + text;
17 | process.StartInfo.WindowStyle = ProcessWindowStyle.Hidden;
18 | process.Start();
19 | }
20 | }
21 | }
22 |
--------------------------------------------------------------------------------
/v2tap/v2tap.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.IO;
3 | using System.Security.Principal;
4 | using System.Windows.Forms;
5 |
6 | namespace v2tap
7 | {
8 | public static class v2tap
9 | {
10 | // tun2socks: https://github.com/eycorsican/go-tun2socks
11 | // v2ray: https://github.com/v2ray/v2ray-core
12 |
13 | public static string[] files = new string[]
14 | {
15 | "RunHiddenConsole.exe",
16 | "tun2socks.exe",
17 | "wv2ray.exe",
18 | "v2ray.exe",
19 | "v2ctl.exe",
20 | "geoip.dat",
21 | "geosite.dat"
22 | };
23 |
24 | public static string config = "ewoJImRucyI6IHsKCQkiY2xpZW50SVAiOiAiYWRhcHRlcklQQWRkcmVzcyIsCgkJImhvc3RzIjogewoJCQkibG9jYWxob3N0IjogIjEyNy4wLjAuMSIsCgkJCSJkb21haW46bGFuIjogIjEyNy4wLjAuMSIsCgkJCSJkb21haW46YXJwYSI6ICIxMjcuMC4wLjEiLAoJCQkiZG9tYWluOmxvY2FsIjogIjEyNy4wLjAuMSIKCQl9LAoJCSJzZXJ2ZXJzIjogWwoJCQkidjJyYXlEZWZhdWx0RE5TIiwKCQkJewoJCQkJImFkZHJlc3MiOiAidjJyYXlDaGluYUROUyIsCgkJCQkicG9ydCI6IDUzLAoJCQkJImRvbWFpbnMiOiBbCgkJCQkJImdlb3NpdGU6Y24iCgkJCQldCgkJCX0KCQldCgl9LAoJInJvdXRpbmciOiB7CgkJInN0cmF0ZWd5IjogInJ1bGVzIiwKCQkic2V0dGluZ3MiOiB7CgkJCSJkb21haW5TdHJhdGVneSI6ICJJUElmTm9uTWF0Y2giLAoJCQkicnVsZXMiOiBbCgkJCQl7CgkJCQkJInR5cGUiOiAiZmllbGQiLAoJCQkJCSJkb21haW4iOiBbCgkJCQkJCSJnZW9zaXRlOmNuIgoJCQkJCV0sCgkJCQkJIm91dGJvdW5kVGFnIjogImRpcmVjdE91dGJvdW5kIgoJCQkJfSwKCQkJCXsKCQkJCQkidHlwZSI6ICJmaWVsZCIsCgkJCQkJImlwIjogWwoJCQkJCQkiZ2VvaXA6Y24iLAoJCQkJCQkiZ2VvaXA6cHJpdmF0ZSIKCQkJCQldLAoJCQkJCSJvdXRib3VuZFRhZyI6ImRpcmVjdE91dGJvdW5kIgoJCQkJfQoJCQldCgkJfQoJfSwKCSJpbmJvdW5kcyI6IFsKCQl7CgkJCSJsaXN0ZW4iOiAiMTI3LjAuMC4xIiwKCQkJInBvcnQiOiAxMDk5LAoJCQkicHJvdG9jb2wiOiAic29ja3MiLAoJCQkic2V0dGluZ3MiOiB7fSwKCQkJImRvbWFpbk92ZXJyaWRlIjogWwoJCQkJImh0dHAiLAoJCQkJInRscyIKCQkJXSwKCQkJInRhZyI6ICJkZWZhdWx0SW5ib3VuZCIKCQl9CgldLAoJIm91dGJvdW5kcyI6IFsKCQl7CgkJCSJzZW5kVGhyb3VnaCI6ICJhZGFwdGVySVBBZGRyZXNzIiwKCQkJInByb3RvY29sIjogInZtZXNzIiwKCQkJInNldHRpbmdzIjogewoJCQkJInZuZXh0IjogWwoJCQkJCXsKCQkJCQkJImFkZHJlc3MiOiAidjJyYXlTZXJ2ZXJBZGRyZXNzIiwKCQkJCQkJInBvcnQiOiB2MnJheVNlcnZlclBvcnQsCgkJCQkJCSJ1c2VycyI6IFsKCQkJCQkJCXsKCQkJCQkJCQkiaWQiOiAidjJyYXlVc2VySUQiLAoJCQkJCQkJCSJhbHRlcklkIjogdjJyYXlBbHRlcklELAoJCQkJCQkJCSJzZWN1cml0eSI6ICJhdXRvIgoJCQkJCQkJfQoJCQkJCQldCgkJCQkJfQoJCQkJXQoJCQl9LAoJCQkic3RyZWFtU2V0dGluZ3MiOiB7CgkJCQkibmV0d29yayI6ICJ2MnJheVRyYW5zZmVyTWV0aG9kIiwKCQkJCSJzZWN1cml0eSI6ICJ2MnJheVRMU1NlY3VyZSIsCgkJCQkid3NTZXR0aW5ncyI6IHsKCQkJCQkicGF0aCI6ICJ2MnJheVBhdGgiCgkJCQl9LAoJCQkJImh0dHBTZXR0aW5ncyI6IHsKCQkJCQkicGF0aCI6ICJ2MnJheVBhdGgiCgkJCQl9CgkJCX0sCgkJCSJ0YWciOiAiZGVmYXVsdE91dGJvdW5kIgoJCX0sCgkJewoJCQkic2VuZFRocm91Z2giOiAiYWRhcHRlcklQQWRkcmVzcyIsCgkJCSJwcm90b2NvbCI6ICJmcmVlZG9tIiwKCQkJInNldHRpbmdzIjoge30sCgkJCSJ0YWciOiAiZGlyZWN0T3V0Ym91bmQiCgkJfQoJXQp9";
25 |
26 | ///
27 | /// 应用程序的主入口点。
28 | ///
29 | [STAThread]
30 | public static void Main(string[] args)
31 | {
32 | if (!new WindowsPrincipal(WindowsIdentity.GetCurrent()).IsInRole(WindowsBuiltInRole.Administrator))
33 | {
34 | MessageBox.Show("请右键选择 以管理员身份运行 !", "权限错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
35 |
36 | Environment.Exit(1);
37 | }
38 |
39 | foreach (string file in files)
40 | {
41 | if (!File.Exists(file))
42 | {
43 | MessageBox.Show("缺失重要文件:" + file, "文件缺失", MessageBoxButtons.OK, MessageBoxIcon.Error);
44 |
45 | Environment.Exit(1);
46 | }
47 | }
48 |
49 | Application.EnableVisualStyles();
50 | Application.SetCompatibleTextRenderingDefault(false);
51 | Application.Run(new MainForm());
52 | }
53 | }
54 | }
55 |
--------------------------------------------------------------------------------
/v2tap/v2tap.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Debug
6 | AnyCPU
7 | {2DF9C9CB-74E0-42C5-A8BC-038BE6FE5869}
8 | WinExe
9 | v2tap
10 | v2tap
11 | v4.7.2
12 | 512
13 | true
14 | true
15 | publish\
16 | true
17 | Disk
18 | false
19 | Foreground
20 | 7
21 | Days
22 | false
23 | false
24 | true
25 | 0
26 | 1.0.0.%2a
27 | false
28 | false
29 | true
30 |
31 |
32 | AnyCPU
33 | true
34 | full
35 | false
36 | bin\Debug\
37 | DEBUG;TRACE
38 | prompt
39 | 4
40 |
41 |
42 | AnyCPU
43 | pdbonly
44 | true
45 | bin\Release\
46 | TRACE
47 | prompt
48 | 4
49 |
50 |
51 | v2tap.v2tap
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 | Form
70 |
71 |
72 | MainForm.cs
73 |
74 |
75 |
76 |
77 |
78 | MainForm.cs
79 |
80 |
81 | ResXFileCodeGenerator
82 | Resources.Designer.cs
83 | Designer
84 |
85 |
86 | True
87 | Resources.resx
88 |
89 |
90 | SettingsSingleFileGenerator
91 | Settings.Designer.cs
92 |
93 |
94 | True
95 | Settings.settings
96 | True
97 |
98 |
99 |
100 |
101 |
102 |
103 |
104 | False
105 | Microsoft .NET Framework 4.7.2 %28x86 和 x64%29
106 | true
107 |
108 |
109 | False
110 | .NET Framework 3.5 SP1
111 | false
112 |
113 |
114 |
115 |
--------------------------------------------------------------------------------