This repository has been archived by the owner on Aug 22, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
LoCyanFrpMSApp.cpp
2056 lines (2045 loc) · 49.3 KB
/
LoCyanFrpMSApp.cpp
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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
#include <bitset>
#include <cctype>
#include <cerrno>
#include <clocale>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring> // string
#include <ctime>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <limits>
#include <io.h>
#include <list>
#include <map>
#include <stdlib.h>
#include <iomanip>
#include <io.h>
#include <ios>
#include <iosfwd>
#include <iostream> // cin / cout
#include <istream>
#include <ostream> // file in / out
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <utility>
#include <vector>
#include <cwchar>
#include <cwctype>
#include <Urlmon.h>
#include <windows.h> // cmd
#include <cstdio> // scanf / printf
#include <conio.h> // 识别按键模块
#include <direct.h> // 文件夹创建模块
#include "requests.h" // 爬取网页模块
#include "utils.h" // requests.h 的前置
#define VERSION (string)"Version 1.4"
#pragma comment(lib, "Urlmon.lib")
using namespace std; // cin / cout 定义模块
using namespace requests; // requests 定义模块
ofstream fout;
ifstream fin;
fstream _file;
inline void main2(); // 隧道管理选择模块
inline void main3(); // 映射选项选择模块
inline void main4(); // 关于界面功能选择模块
inline void login(); // 登录模块
inline void Unlogin(); // 登出模块
inline void PrintGUI1(); // 显示 GUI
inline void PrintGUI2(); // 显示隧道管理模块 GUI
inline void PrintGUI3(); // 显示映射选项模块 GUI
inline void PrintGUI4(); // 显示关于模块 GUI
inline void PrintNodeList(); // 打印节点列表
inline void PrintTunnelList(bool must_online, bool must_offline); // 打印隧道列表
inline void GetNode(); // 获取节点列表
inline void GetTunnel(); // 获取隧道列表
inline void Delete(); // 删除隧道模块
inline void Create(); // 创建隧道模块
inline void Start(); // 启动映射模块
inline void End(); // 关闭映射模块
inline void color(short attr); // 输出彩色文字
inline void Cout(int x, char a); // 连续输出 x 次 a
inline void print(string s, int a, int b); // 输出提示语
inline bool file(string filename); // 判断文件是否存在
inline bool ifTunnel(int id); // 判断隧道是否存在
inline bool ifNode(int id); // 判断节点是否存在 True
inline bool ifOnline(int id); // 获取隧道在线状态
inline int FromIDFindNodeLen(int id); // 根据节点 ID 找在数组中的下标
inline int numlen(int num); // 获取一个数字的长度(位数)
inline int FromIDFindNodeID(int id); // 根据隧道 ID 找节点 ID
inline int FromIDFindTTunnelLen(int id); // 根据隧道 ID 找数组下标
inline string DEC(string url, char c); // 删除转义符
inline string Json(string json, string project); // 获取 Json 某个项的值
inline string FromIDFindNodeName(int id); // 根据节点 ID 找名字
inline string FromIDFindNodeUrl(int id); // 根据节点 ID 找地址
inline string FromIDFindTunnelName(int id); // 根据隧道 ID 找名字
inline string FromIDFindProtocol(int id); // 根据隧道 ID 找隧道协议
inline string LTS(string s); // 大写转小写
inline string UTF8ToANSI(string s); // 编码转换
inline string ANSItoUTF8(string strAnsi); // 将 ANSI 编码转换为 UTF-8
inline LPCWSTR stringToLPCWSTR(string orig); // LPCWSTR -> String
string UserInternalID/* FrpToken */, name/* 用户名 */, password/* 密码 */, Temp/* 更新缓存 */;
bool ifLogin = false/* 是否已登录 */, ifAuxiliary = false /* 有没有下载辅助模块 */;
int StartingTunnelList[100010], Node_quantity/* 节点数量 */, MyTunnelLen/* 用户的隧道数量 */, TestLen = 0/* 特殊情况下 PrintTunnelList 输出的隧道数 */, OnlineLen = 0/* 在线隧道数 */, Online[100010] = {}/* 在线隧道 */, UnusefulNodeLen = 0;
struct Nodeinfo // 节点信息
{
bool use;
int ID = 0;
string Name, IP, RealIP;
}Node[100010];
struct Tunnelinfo
{
bool online = false;
int ID = 0, Node = 0, a = 0, b = 0;
string Name, Protocol, IP, url, internal_port, external_port;
}Tunnel[1000010];
int main() // 主函数模块
{
print("正在初始化程序", 51, 52);
SetConsoleTitle(L"LoCyanFrp 智能控制面板"); // 设置标题
HWND hWnd = GetConsoleWindow();
RECT rc;
GetWindowRect(hWnd, &rc);
SetWindowLongPtr(hWnd, GWL_STYLE, GetWindowLong(hWnd, GWL_STYLE) & ~WS_THICKFRAME & ~WS_MAXIMIZEBOX & ~WS_MINIMIZEBOX);
SetWindowPos(hWnd, NULL, rc.left, rc.top, rc.right - rc.left, rc.bottom - rc.top, NULL); // 设置窗口长宽高
auto hStdin = ::GetStdHandle(STD_INPUT_HANDLE);
DWORD mode;
::GetConsoleMode(hStdin, &mode); // 禁止左键选择
mode &= ~ENABLE_QUICK_EDIT_MODE;
::SetConsoleMode(hStdin, mode);
system("mode con cols=119 lines=30"); // 设置窗口长宽高
system("cls");
print("正在执行初始化", 51, 52);
Temp = Get("https://api.locyanfrp.cn/LoCyanFrpMSApp/MSApp_update?version=" + VERSION).GetText();
if (Json(Temp, "needupdate") == "1")
{
string Return = Json(Temp, "important");
if (Return == "1")
{
print("正在更新中", 53, 54);
string download_url = Json(Temp, "download_url");
download_url = DEC(download_url, '\\');
URLDownloadToFile(nullptr, stringToLPCWSTR(download_url), L"UpdateTEMP", 0, nullptr);
fout.open("Update.bat"); // 创建并打开文件
fout << "@echo off\nif \"%1\" == \"h\" goto begin\nmshta vbscript:createobject(\"wscript.shell\").run(\"\"\"%~nx0\"\" h\",0)(window.close)&&exit\n:begin\nREM\ntaskkill /f /im LoCyanFrpMSApp.exe\ndel /f /s /q LoCyanFrpMSApp.exe\nrename UpdateTEMP LoCyanFrpMSApp.exe\nstart LoCyanFrpMSApp.exe";
fout.close();
system("start Update.bat");
return 0;
}
else {
system("cls");
Cout(119, '-');
cout << "|";
Cout(117, ' ');
cout << "|\n|";
Cout(48, ' ');
color(14);
cout << "有新版本!是否更新?";
color(9);
Cout(49, ' ');
cout << "|\n|";
Cout(43, ' ');
color(2);
cout << "是(按 Y)";
color(9);
cout << " | ";
color(4);
cout << "否(按 N)";
color(9);
Cout(43, ' ');
cout << "|\n|";
Cout(117, ' ');
cout << "|\n";
Cout(119, '-');
while (true)
{
if (_kbhit()) // 判断是否有按按键
{
char a = _getch(); // 判断按了啥键
switch (a)
{
case 'y': {
print("正在更新中", 53, 54);
string download_url = Json(Temp, "download_url");
download_url = DEC(download_url, '\\');
URLDownloadToFile(nullptr, stringToLPCWSTR(download_url), L"UpdateTEMP", 0, nullptr);
fout.open("Update.bat"); // 创建并打开文件
fout << "@echo off\nif \"%1\" == \"h\" goto begin\nmshta vbscript:createobject(\"wscript.shell\").run(\"\"\"%~nx0\"\" h\",0)(window.close)&&exit\n:begin\nREM\ntaskkill /f /im LoCyanFrpMSApp.exe\ndel /f /s /q LoCyanFrpMSApp.exe\nrename UpdateTEMP LoCyanFrpMSApp.exe\nstart LoCyanFrpMSApp.exe";
fout.close();
system("start Update.bat");
return 0;
}
case 'n':print("正在执行初始化", 51, 52); goto Go;
case 'Y': {
print("正在更新中", 53, 54);
string download_url = Json(Temp, "download_url");
download_url = DEC(download_url, '\\');
URLDownloadToFile(nullptr, stringToLPCWSTR(download_url), L"UpdateTEMP", 0, nullptr);
fout.open("Update.bat"); // 创建并打开文件
fout << "@echo off\nif \"%1\" == \"h\" goto begin\nmshta vbscript:createobject(\"wscript.shell\").run(\"\"\"%~nx0\"\" h\",0)(window.close)&&exit\n:begin\nREM\ntaskkill /f /im LoCyanFrpMSApp.exe\ndel /f /s /q LoCyanFrpMSApp.exe\nrename UpdateTEMP LoCyanFrpMSApp.exe\nstart LoCyanFrpMSApp.exe";
fout.close();
system("start Update.bat");
return 0;
}
case 'N':print("正在执行初始化", 51, 52); goto Go;
}
}
Sleep(20); // 防止卡 / 占用过多资源
}
}
}
Go:;
if (file("AppLogin.dll")) // 判断 FrpAuxiliaryApp.exe 是否存在,存在就读取
{
fin.open("AppLogin.dll"); // 打开文件
fin >> ifLogin; // 获取是否登录
if (ifLogin)
{
fin >> UserInternalID >> name >> password; // 如已登录,获取 Frp 的 Token
}
fin.close();
GetTunnel();
if (file("OnlineTunnel.list"))
{
fin.open("OnlineTunnel.list"); // 打开文件
fin >> OnlineLen; // 获取是否登录
for (int i = 0; i < OnlineLen; i++)
{
fin >> Online[i];
if (ifOnline(Online[i]))
{
Tunnel[FromIDFindTTunnelLen(Online[i])].online = true;
}
else {
OnlineLen--;
}
}
fin.close();
}
}
GetNode();
system("cls");
PrintGUI1(); // 打印 GUI
while (true)
{
if (_kbhit()) // 判断是否有按按键
{
char a = _getch(); // 判断按了啥键
switch (a)
{
case '1':login(); PrintGUI1(); break;
case '2':Unlogin(); PrintGUI1(); break;
case '3':main2(); PrintGUI1(); break;
case '4':main4(); PrintGUI1(); break;
case '5':return 0; break;
}
}
Sleep(20); // 防止卡 / 占用过多资源
}
return 0;
}
inline void main2() // 隧道管理选择模块
{
system("cls");
if (!ifLogin)
{
Cout(119, '-');
cout << "|";
Cout(117, ' ');
cout << "|\n|";
Cout(50, ' ');
color(4);
cout << "您当前尚未登录!";
color(9);
Cout(51, ' ');
cout << "|\n|";
Cout(117, ' ');
cout << "|\n";
Cout(119, '-');
Sleep(2000);
system("cls");
return;
}
PrintGUI2();
while (true)
{
if (_kbhit())
{
char a = _getch();
switch (a)
{
case 'D': Delete(); PrintGUI2(); break;
case 'C': Create(); PrintGUI2(); break;
case 'O': main3(); PrintGUI2(); break;
case 'R': system("cls"); return;
case 'd': Delete(); PrintGUI2(); break;
case 'c': Create(); PrintGUI2(); break;
case 'o': main3(); PrintGUI2(); break;
case 'r': system("cls"); return;
}
}
Sleep(20);
}
return;
}
inline void main3() // 映射选项选择模块
{
system("cls");
if (MyTunnelLen == 0)
{
print("您没有任何一个隧道!", 48, 49);
Sleep(2000);
system("cls");
return;
}
if (!file("FrpAuxiliaryApp.exe") && !ifAuxiliary) // 判断 FrpAuxiliaryApp.exe 是否存在,不存在就下载
{
Cout(119, '-');
cout << "|";
Cout(117, ' ');
cout << "|\n|";
Cout(49, ' ');
color(4);
cout << "正在下载辅助模块...";
color(9);
Cout(49, ' ');
cout << "|\n|";
Cout(117, ' ');
cout << "|\n";
Cout(119, '-');
string download_url = Json(Get("https://api.locyanfrp.cn/LoCyanFrpMSApp/AuxiliaryApp_update?version=114514").GetText(), "download_url"); // 获取下载地址
download_url = DEC(download_url, '\\'); // 删除转义符
URLDownloadToFile(nullptr, stringToLPCWSTR(download_url), L"DownLoadTEMP", 0, nullptr); // 下载
system("rename DownLoadTEMP FrpAuxiliaryApp.exe"); // 成功
system("cls");
}
ifAuxiliary = true;
PrintGUI3();
while (true)
{
if (_kbhit())
{
char a = _getch();
switch (a)
{
case 'S': Start(); PrintGUI3(); break;
case 'F': End(); PrintGUI3(); break;
case 'R': system("cls"); return;
case 's': Start(); PrintGUI3(); break;
case 'f': End(); PrintGUI3(); break;
case 'r': system("cls"); return;
}
}
Sleep(20);
}
return;
}
inline void main4() // 关于界面功能选择模块
{
PrintGUI4();
while (true)
{
if (_kbhit()) // 判断是否有按按键
{
char a = _getch(); // 判断按了啥键
switch (a)
{
case 'R':system("cls"); return;
case 'r':system("cls"); return;
}
}
Sleep(20); // 防止卡 / 占用过多资源
}
return;
}
inline void login() // 登录模块
{
if (ifLogin) // 如果已登录
{
system("cls");
Cout(119, '-');
cout << "|";
Cout(117, ' ');
cout << "|\n|";
Cout(53, ' ');
color(4);
cout << "您已登录!";
color(9);
Cout(54, ' ');
cout << "|\n|";
Cout(117, ' ');
cout << "|\n";
Cout(119, '-');
Sleep(2000); // 等待一会-让用户看清提示语
system("cls");
return;
}
while (true) // 死循环保持在登录界面
{
system("cls");
color(9);
Cout(48, '-');
color(5);
cout << "LoCyan Frp 智能控制面板";
color(9);
Cout(48, '-');
cout << "|";
Cout(117, ' ');
cout << "|\n|";
Cout(117, ' ');
cout << "|\n|";
Cout(117, ' ');
cout << "|\n|";
Cout(117, ' ');
cout << "|\n|";
Cout(117, ' ');
cout << "|\n|";
Cout(117, ' ');
cout << "|\n|";
Cout(117, ' ');
cout << "|\n|";
Cout(42, ' ');
color(4);
cout << "每项内容填好后请按 “回车” 键";
color(9);
Cout(45, ' ');
cout << "|\n|";
Cout(117, ' ');
cout << "|\n";
Cout(119, '-');
HANDLE hout;
COORD coord = { 47 , 3 };
hout = GetStdHandle(STD_OUTPUT_HANDLE);
SetConsoleCursorPosition(hout, coord); // 在第 47 行,第 3 列插入文字
cout << "用户名:";
cin >> name; // 用户名输入-以后要居中-待改进
name = ANSItoUTF8(name);
coord = { 47 , 5 };
hout = GetStdHandle(STD_OUTPUT_HANDLE);
SetConsoleCursorPosition(hout, coord); // 在第 47 行,第 5 列插入文字
cout << "密码:";
char ch;
password = "";
while ((ch = _getch()) != '\r') // 读取输入字符,直到回车键被按下
{
if (ch == '\b') // 处理退格键
{
if (!password.empty())
{
password.pop_back(); // 删除末尾的字符
_putch('\b'); // 退格
_putch(' '); // 输出空格覆盖原字符
_putch('\b'); // 退格回到原位置
}
}
else {
password.push_back(ch); // 将输入字符保存到字符串中
_putch('*'); // 在终端上显示的字符用 "*" 填充
}
}
password = ANSItoUTF8(password);
print("正在校验密码", 52, 53);
string Return = Json(Get("https://api.locyanfrp.cn/User/DoLogin?username=" + name + "&password=" + password).GetText(), "status"); // 查看密码是否正确
if (Return == "-1")
{
print("用户名或密码错误!", 49, 50);
Sleep(3000);
continue;
}
else {
string login_token = Json(Get("https://api.locyanfrp.cn/User/DoLogin?username=" + name + "&password=" + password).GetText(), "token"); // 获取用于登录的 Token
UserInternalID = Json(Get("https://api.locyanfrp.cn/Account/info?username=" + name + "&token=" + login_token).GetText(), "token"); // 获取用于 Frp 的 Token
fout.open("AppLogin.dll");
fout << 1 << " " << UserInternalID << " " << name << " " << password;
fout.close();
ifLogin = true;
print("正在获取隧道...", 51, 51);
GetTunnel();
print("登录成功!", 53, 54);
Sleep(2000);
system("cls");
return;
}
}
return;
}
inline void Unlogin() // 退出登录模块
{
if (!ifLogin) // 如果还没有登录
{
system("cls");
Cout(119, '-');
cout << "|";
Cout(117, ' ');
cout << "|\n|";
Cout(50, ' ');
color(4);
cout << "您当前尚未登录!";
color(9);
Cout(51, ' ');
cout << "|\n|";
Cout(117, ' ');
cout << "|\n";
Cout(119, '-');
Sleep(2000);
system("cls");
return;
}
print("正在退出登录", 52, 53);
Sleep(2000);
system("del /f /s /q AppLogin.dll>nul"); // 把登陆文件删了
system("del /f /s /q OnlineTunnel.list>nul"); // 把本地启动隧道列表删了
ifLogin = false; // 不要忘记再把变量清了
system("cls");
return;
}
inline void PrintGUI1() // 显示 GUI
{
color(9);
Cout(48, '-');
color(5);
cout << "LoCyan Frp 智能控制面板";
color(9);
Cout(48, '-');
cout << "|";
Cout(117, ' ');
cout << "|\n|";
Cout(117, ' ');
cout << "|\n|";
Cout(52, ' ');
color(6);
cout << "登录(按 1)";
color(9);
Cout(53, ' ');
cout << "|\n|";
Cout(117, ' ');
cout << "|\n|";
Cout(52, ' ');
color(6);
cout << "登出(按 2)";
color(9);
Cout(53, ' ');
cout << "|\n|";
Cout(117, ' ');
cout << "|\n|";
Cout(50, ' ');
color(6);
cout << "隧道管理(按 3)";
color(9);
Cout(51, ' ');
cout << "|\n|";
Cout(117, ' ');
cout << "|\n|";
Cout(52, ' ');
color(6);
cout << "关于(按 4)";
color(9);
Cout(53, ' ');
cout << "|\n|";
Cout(117, ' ');
cout << "|\n|";
Cout(50, ' ');
color(6);
cout << "退出程序(按 5)";
color(9);
Cout(51, ' ');
cout << "|\n|";
Cout(117, ' ');
cout << "|\n|";
Cout(117, ' ');
cout << "|\n";
color(9);
Cout(119, '-');
if (!ifLogin)
{
cout << "|";
Cout(117, ' ');
cout << "|\n|";
Cout(50, ' ');
color(4);
cout << "您当前尚未登录!";
color(9);
Cout(51, ' ');
cout << "|\n|";
Cout(117, ' ');
cout << "|\n";
Cout(119, '-');
}
return;
}
inline void PrintGUI2() // 显示隧道管理模块 GUI
{
color(9);
Cout(48, '-');
color(5);
cout << "LoCyan Frp 智能控制面板";
color(9);
Cout(48, '-');
cout << "|";
Cout(117, ' ');
cout << "|\n|";
Cout(117, ' ');
cout << "|\n|";
Cout(50, ' ');
color(6);
cout << "删除隧道(按 D)";
color(9);
Cout(51, ' ');
cout << "|\n|";
Cout(117, ' ');
cout << "|\n|";
Cout(50, ' ');
color(6);
cout << "创建隧道(按 C)";
color(9);
Cout(51, ' ');
cout << "|\n|";
Cout(117, ' ');
cout << "|\n|";
Cout(50, ' ');
color(6);
cout << "映射选项(按 O)";
color(9);
Cout(51, ' ');
cout << "|\n|";
Cout(117, ' ');
cout << "|\n|";
Cout(50, ' ');
color(6);
cout << "返回上级(按 R)";
color(9);
Cout(51, ' ');
cout << "|\n|";
Cout(117, ' ');
cout << "|\n|";
Cout(117, ' ');
cout << "|\n";
color(9);
Cout(119, '-');
return;
}
inline void PrintGUI3() // 显示映射选项模块 GUI
{
color(9);
Cout(48, '-');
color(5);
cout << "LoCyan Frp 智能控制面板";
color(9);
Cout(48, '-');
cout << "|";
Cout(117, ' ');
cout << "|\n|";
Cout(117, ' ');
cout << "|\n|";
Cout(50, ' ');
color(6);
cout << "启动映射(按 S)";
color(9);
Cout(51, ' ');
cout << "|\n|";
Cout(117, ' ');
cout << "|\n|";
Cout(50, ' ');
color(6);
cout << "关闭映射(按 F)";
color(9);
Cout(51, ' ');
cout << "|\n|";
Cout(117, ' ');
cout << "|\n|";
Cout(50, ' ');
color(6);
cout << "返回上级(按 R)";
color(9);
Cout(51, ' ');
cout << "|\n|";
Cout(117, ' ');
cout << "|\n|";
Cout(117, ' ');
cout << "|\n";
color(9);
Cout(119, '-');
return;
}
inline void PrintGUI4() // 显示关于模块 GUI
{
system("cls");
color(9);
Cout(48, '-');
color(5);
cout << "LoCyan Frp 智能控制面板";
color(9);
Cout(48, '-');
cout << "|";
Cout(117, ' ');
cout << "|\n|";
Cout(43, ' ');
color(14);
cout << "LoCyanFrp Manager and Start App";
color(9);
Cout(43, ' ');
cout << "|\n|";
Cout(38, ' ');
color(10);
cout << "一个小而精致的 LoCyanFrp 隧道启动、管理器";
color(9);
Cout(38, ' ');
cout << "|\n|";
Cout(49, ' ');
cout << "Powered by";
color(6);
cout << " C++ ";
color(9);
cout << "/";
color(6);
cout << " C";
color(9);
Cout(50, ' ');
cout << "|\n|";
Cout(37, ' ');
color(8);
cout << "开发人员:";
color(11);
cout << "Zhiyuan";
color(9);
cout << " | ";
color(8);
cout << "技术支持:";
color(11);
cout << "Daiyangcheng";
color(9);
Cout(38, ' ');
cout << "|\n|";
Cout(31, ' ');
cout << "开源地址:";
color(11);
cout << "https://github.com/LoCyan-Team/LoCyanFrpMSApp";
color(9);
Cout(31, ' ');
cout << "|\n";
Cout(119, '-');
cout << "|";
string ver = "软件版本:" + VERSION;
int len = ver.length();
if ((40 - len) % 2 == 0)
{
int k = (40 - len) / 2;
Cout(k - 1, ' ');
cout << "软件版本:";
color(14);
cout << VERSION;
color(9);
Cout(40 - k - len, ' ');
}
else {
int k = (40 - len - 1) / 2;
Cout(k, ' ');
cout << "软件版本:";
color(14);
cout << VERSION;
color(9);
Cout(40 - k - len - 1, ' ');
}
cout << "|";
string c;
bool temp = false;
len = c.length();
if (Json(Temp, "needupdate") == "1")
{
temp = true;
c = "有新版本!";
}
else {
c = "此程序为最新版本!";
}
if ((60 - len) % 2 == 0)
{
int k = (60 - len) / 2;
Cout(k - 1, ' ');
if (temp)
{
color(4);
}
else {
color(2);
}
cout << c;
color(9);
Cout(60 - k - len, ' ');
}
else {
int k = (60 - len - 1) / 2;
Cout(k, ' ');
if (temp)
{
color(4);
}
else {
color(2);
}
cout << c;
color(9);
Cout(60 - k - len - 1, ' ');
}
cout << "|";
Cout(119, '-');
cout << "\n|";
Cout(54, ' ');
color(4);
cout << "按 R 退出";
color(9);
Cout(54, ' ');
cout << "|\n";
Cout(119, '-');
return;
}
inline void PrintNodeList() // 打印节点列表
{
color(9);
Cout(48, '-');
color(5);
cout << "LoCyan Frp 智能控制面板";
color(9);
Cout(48, '-');
cout << endl;
string a = "节点 ID", b = "节点名称", c = "节点 IP";
int len = a.length();
cout << "|";
if ((15 - len) % 2 == 0)
{
int k = (15 - len) / 2;
Cout(k - 1, ' ');
cout << a;
Cout(15 - k - len, ' ');
}
else {
int k = (15 - len - 1) / 2;
Cout(k, ' ');
cout << a;
Cout(15 - k - len - 1, ' ');
}
cout << "|";
len = b.length();
if ((53 - len) % 2 == 0)
{
int k = (53 - len) / 2;
Cout(k - 1, ' ');
cout << b;
Cout(53 - k - len, ' ');
}
else {
int k = (53 - len - 1) / 2;
Cout(k, ' ');
cout << b;
Cout(53 - k - len - 1, ' ');
}
cout << "|";
len = c.length();
if ((50 - len) % 2 == 0)
{
int k = (50 - len) / 2;
Cout(k - 1, ' ');
cout << c;
Cout(50 - k - len, ' ');
}
else {
int k = (50 - len - 1) / 2;
Cout(k, ' ');
cout << c;
Cout(50 - k - len - 1, ' ');
}
cout << "|\n";
for (int i = 0; i < Node_quantity; i++)
{
if (!Node[i].use)
{
continue;
}
int len = numlen(Node[i].ID);
cout << "|";
color(12);
if ((15 - len) % 2 == 0)
{
int k = (15 - len) / 2;
Cout(k - 1, ' ');
cout << Node[i].ID;
Cout(15 - k - len, ' ');
}
else {
int k = (15 - len - 1) / 2;
Cout(k, ' ');
cout << Node[i].ID;
Cout(15 - k - len - 1, ' ');
}
color(9);
cout << "|";
color(13);
len = Node[i].Name.length();
if ((15 - len) % 2 == 0)
{
int k = (53 - len) / 2;
Cout(k - 1, ' ');
cout << Node[i].Name;
Cout(53 - k - len, ' ');
}
else {
int k = (53 - len - 1) / 2;
Cout(k, ' ');
cout << Node[i].Name;
Cout(53 - k - len - 1, ' ');
}
color(9);
cout << "|";
color(15);
len = Node[i].IP.length();
if ((15 - len) % 2 == 0)
{
int k = (50 - len) / 2;
Cout(k - 1, ' ');
cout << Node[i].IP;
Cout(50 - k - len, ' ');
}
else {
int k = (50 - len - 1) / 2;
Cout(k, ' ');
cout << Node[i].IP;
Cout(50 - k - len - 1, ' ');
}
color(9);
cout << "|\n";
}
Cout(119, '-');
cout << endl;
return;
}
inline void PrintTunnelList(bool must_online, bool must_offline) // 打印隧道列表
{
TestLen = 0;
color(9);
Cout(48, '-');
color(5);
cout << "LoCyan Frp 智能控制面板";
color(9);
Cout(48, '-');
cout << endl;
string a = "隧道 ID", b = "隧道名称", c = "隧道信息", d = "是否加密", e = "是否压缩", f = "使用节点";
int len = a.length();
cout << "|";
if ((7 - len) % 2 == 0)
{
int k = (7 - len) / 2;
Cout(k - 1, ' ');
cout << a;
Cout(7 - k - len, ' ');
}
else {
int k = (7 - len - 1) / 2;
Cout(k, ' ');
cout << a;
Cout(7 - k - len - 1, ' ');
}
cout << "|";
len = b.length();
if ((27 - len) % 2 == 0)
{
int k = (27 - len) / 2;
Cout(k - 1, ' ');
cout << b;
Cout(27 - k - len, ' ');
}
else {
int k = (27 - len - 1) / 2;
Cout(k, ' ');
cout << b;
Cout(27 - k - len - 1, ' ');
}
cout << "|";
len = f.length();
if ((38 - len) % 2 == 0)
{
int k = (38 - len) / 2;
Cout(k - 1, ' ');
cout << f;
Cout(38 - k - len, ' ');
}
else {
int k = (38 - len - 1) / 2;
Cout(k, ' ');
cout << f;
Cout(38 - k - len - 1, ' ');
}
cout << "|";
len = c.length();
if ((27 - len) % 2 == 0)
{
int k = (27 - len) / 2;
Cout(k - 1, ' ');
cout << c;
Cout(27 - k - len, ' ');
}
else {
int k = (27 - len - 1) / 2;
Cout(k, ' ');
cout << c;
Cout(27 - k - len - 1, ' ');