-
Notifications
You must be signed in to change notification settings - Fork 62
/
Copy pathapi.go
1729 lines (1522 loc) · 41.6 KB
/
api.go
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
/*
本类为所有动态库导出函数集合
*/
package main
import "C"
import (
"errors"
"github.com/qtgolang/SunnyNet/Api"
"github.com/qtgolang/SunnyNet/src/dns"
"github.com/qtgolang/SunnyNet/src/public"
"unsafe"
)
/*
GetSunnyVersion 获取SunnyNet版本
*/
//export GetSunnyVersion
func GetSunnyVersion() uintptr {
return Api.GetSunnyVersion()
}
/*
Free 释放指针
*/
//export Free
func Free(ptr uintptr) {
public.Free(ptr)
}
/*
CreateSunnyNet 创建Sunny中间件对象,可创建多个
*/
//export CreateSunnyNet
func CreateSunnyNet() int {
return Api.CreateSunnyNet()
}
/*
ReleaseSunnyNet ReleaseSunnyNet 释放SunnyNet
*/
//export ReleaseSunnyNet
func ReleaseSunnyNet(SunnyContext int) bool {
return Api.ReleaseSunnyNet(SunnyContext)
}
/*
SunnyNetStart 启动Sunny中间件 成功返回true
*/
//export SunnyNetStart
func SunnyNetStart(SunnyContext int) bool {
return Api.SunnyNetStart(SunnyContext)
}
/*
SunnyNetSetPort 设置指定端口 Sunny中间件启动之前调用
*/
//export SunnyNetSetPort
func SunnyNetSetPort(SunnyContext, Port int) bool {
return Api.SunnyNetSetPort(SunnyContext, Port)
}
/*
SunnyNetClose 关闭停止指定Sunny中间件
*/
//export SunnyNetClose
func SunnyNetClose(SunnyContext int) bool {
return Api.SunnyNetClose(SunnyContext)
}
/*
SunnyNetSetCert 设置自定义证书
*/
//export SunnyNetSetCert
func SunnyNetSetCert(SunnyContext, CertificateManagerId int) bool {
return Api.SunnyNetSetCert(SunnyContext, CertificateManagerId)
}
/*
SunnyNetInstallCert 安装证书 将证书安装到Windows系统内
*/
//export SunnyNetInstallCert
func SunnyNetInstallCert(SunnyContext int) uintptr {
return Api.SunnyNetInstallCert(SunnyContext)
}
/*
SunnyNetSetCallback 设置中间件回调地址 httpCallback
*/
//export SunnyNetSetCallback
func SunnyNetSetCallback(SunnyContext, httpCallback, tcpCallback, wsCallback, udpCallback int) bool {
return Api.SunnyNetSetCallback(SunnyContext, httpCallback, tcpCallback, wsCallback, udpCallback)
}
/*
SunnyNetSocket5AddUser 添加 S5代理需要验证的用户名
*/
//export SunnyNetSocket5AddUser
func SunnyNetSocket5AddUser(SunnyContext int, User, Pass *C.char) bool {
return Api.SunnyNetSocket5AddUser(SunnyContext, C.GoString(User), C.GoString(Pass))
}
/*
SunnyNetVerifyUser 开启身份验证模式
*/
//export SunnyNetVerifyUser
func SunnyNetVerifyUser(SunnyContext int, open bool) bool {
return Api.SunnyNetVerifyUser(SunnyContext, open)
}
/*
SunnyNetSocket5DelUser 删除 S5需要验证的用户名
*/
//export SunnyNetSocket5DelUser
func SunnyNetSocket5DelUser(SunnyContext int, User *C.char) bool {
return Api.SunnyNetSocket5DelUser(SunnyContext, C.GoString(User))
}
/*
SunnyNetGetSocket5User 开启身份验证模式后 获取授权的S5账号,注意UDP请求无法获取到授权的s5账号
*/
//export SunnyNetGetSocket5User
func SunnyNetGetSocket5User(Theology int) uintptr {
return Api.SunnyNetGetSocket5User(Theology)
}
/*
SunnyNetMustTcp 设置中间件是否开启强制走TCP
*/
//export SunnyNetMustTcp
func SunnyNetMustTcp(SunnyContext int, open bool) {
Api.SunnyNetMustTcp(SunnyContext, open)
}
/*
CompileProxyRegexp 设置中间件上游代理使用规则
*/
//export CompileProxyRegexp
func CompileProxyRegexp(SunnyContext int, Regexp *C.char) bool {
return Api.CompileProxyRegexp(SunnyContext, C.GoString(Regexp))
}
/*
SetMustTcpRegexp 设置强制走TCP规则,如果 打开了全部强制走TCP状态,本功能则无效
*/
//export SetMustTcpRegexp
func SetMustTcpRegexp(SunnyContext int, Regexp *C.char, RulesAllow bool) bool {
return Api.SetMustTcpRegexp(SunnyContext, C.GoString(Regexp), RulesAllow)
}
/*
SunnyNetError 获取中间件启动时的错误信息
*/
//export SunnyNetError
func SunnyNetError(SunnyContext int) uintptr {
return Api.SunnyNetError(SunnyContext)
}
/*
SetGlobalProxy 设置全局上游代理 仅支持Socket5和http 例如 socket5://admin:123456@127.0.0.1:8888 或 http://admin:123456@127.0.0.1:8888
*/
//
//export SetGlobalProxy
func SetGlobalProxy(SunnyContext int, ProxyAddress *C.char, outTime int) bool {
return Api.SetGlobalProxy(SunnyContext, C.GoString(ProxyAddress), outTime)
}
/*
GetRequestProto 获取 HTTPS 请求的协议版本
*/
//export GetRequestProto
func GetRequestProto(MessageId int) uintptr {
return Api.GetRequestProto(MessageId)
}
/*
GetResponseProto 获取 HTTPS 响应的协议版本
*/
//export GetResponseProto
func GetResponseProto(MessageId int) uintptr {
return Api.GetResponseProto(MessageId)
}
/*
ExportCert 导出已设置的证书
*/
//export ExportCert
func ExportCert(SunnyContext int) uintptr {
return Api.ExportCert(SunnyContext)
}
/*
SetHTTPRequestMaxUpdateLength 设置HTTP请求,提交数据,最大的长度
*/
//export SetHTTPRequestMaxUpdateLength
func SetHTTPRequestMaxUpdateLength(SunnyContext int, i int64) bool {
return Api.SetHTTPRequestMaxUpdateLength(SunnyContext, i)
}
/*
SetIeProxy 设置IE代理 ,Windows 有效
*/
//export SetIeProxy
func SetIeProxy(SunnyContext int) bool {
return Api.SetIeProxy(SunnyContext)
}
/*
CancelIEProxy 取消设置的IE代理,Windows 有效
*/
//export CancelIEProxy
func CancelIEProxy(SunnyContext int) bool {
return Api.CancelIEProxy(SunnyContext)
}
/*
SetRequestCookie 修改、设置 HTTP/S当前请求数据中指定Cookie
*/
//export SetRequestCookie
func SetRequestCookie(MessageId int, name, val *C.char) {
Api.SetRequestCookie(MessageId, C.GoString(name), C.GoString(val))
}
/*
SetRequestAllCookie 修改、设置 HTTP/S当前请求数据中的全部Cookie
*/
//export SetRequestAllCookie
func SetRequestAllCookie(MessageId int, val *C.char) {
Api.SetRequestAllCookie(MessageId, C.GoString(val))
}
/*
GetRequestCookie 获取 HTTP/S当前请求数据中指定的Cookie
*/
//export GetRequestCookie
func GetRequestCookie(MessageId int, name *C.char) uintptr {
r := Api.GetRequestCookie(MessageId, C.GoString(name))
if r == "" {
return 0
}
return public.PointerPtr(r)
}
/*
GetRequestALLCookie 获取 HTTP/S 当前请求全部Cookie
*/
//export GetRequestALLCookie
func GetRequestALLCookie(MessageId int) uintptr {
r := Api.GetRequestALLCookie(MessageId)
if r == "" {
return 0
}
return public.PointerPtr(r)
}
/*
DelResponseHeader 删除HTTP/S返回数据中指定的协议头
*/
//export DelResponseHeader
func DelResponseHeader(MessageId int, name *C.char) {
Api.DelResponseHeader(MessageId, C.GoString(name))
}
/*
DelRequestHeader 删除HTTP/S请求数据中指定的协议头
*/
//export DelRequestHeader
func DelRequestHeader(MessageId int, name *C.char) {
Api.DelRequestHeader(MessageId, C.GoString(name))
}
/*
SetRequestOutTime 请求设置超时-毫秒
*/
//export SetRequestOutTime
func SetRequestOutTime(MessageId int, times int) {
Api.SetRequestOutTime(MessageId, times)
}
/*
SetRequestALLHeader SetRequestALLHeader 设置HTTP/ S请求体中的全部协议头
*/
//export SetRequestALLHeader
func SetRequestALLHeader(MessageId int, val *C.char) {
Api.SetRequestALLHeader(MessageId, C.GoString(val))
}
/*
SetRequestHeader 设置HTTP/S请求体中的协议头
*/
//export SetRequestHeader
func SetRequestHeader(MessageId int, name, val *C.char) {
Api.SetRequestHeader(MessageId, C.GoString(name), C.GoString(val))
}
/*
RandomRequestCipherSuites RandomRequestCipherSuites 随机设置请求 CipherSuites
*/
//export RandomRequestCipherSuites
func RandomRequestCipherSuites(MessageId int) bool {
return Api.SetRequestCipherSuites(MessageId)
}
/*
SetRequestHTTP2Config 设置HTTP 2.0 请求指纹配置 (若服务器支持则使用,若服务器不支持,设置了也不会使用)
*/
//export SetRequestHTTP2Config
func SetRequestHTTP2Config(MessageId int, h2Config *C.char) bool {
return Api.SetRequestHTTP2Config(MessageId, C.GoString(h2Config))
}
/*
SetResponseHeader 修改、设置 HTTP/S当前返回数据中的指定协议头
*/
//export SetResponseHeader
func SetResponseHeader(MessageId int, name *C.char, val *C.char) {
Api.SetResponseHeader(MessageId, C.GoString(name), C.GoString(val))
}
/*
GetRequestHeader 获取 HTTP/S当前请求数据中的指定协议头
*/
//export GetRequestHeader
func GetRequestHeader(MessageId int, name *C.char) uintptr {
r := Api.GetRequestHeader(MessageId, C.GoString(name))
if r == "" {
return 0
}
return public.PointerPtr(r)
}
/*
GetResponseHeader 获取 HTTP/S 当前返回数据中指定的协议头
*/
//export GetResponseHeader
func GetResponseHeader(MessageId int, name *C.char) uintptr {
r := Api.GetResponseHeader(MessageId, C.GoString(name))
if r == "" {
return 0
}
return public.PointerPtr(r)
}
/*
GetResponseServerAddress 获取 HTTP/S 相应的服务器地址
*/
//export GetResponseServerAddress
func GetResponseServerAddress(MessageId int) uintptr {
r := Api.GetResponseServerAddress(MessageId)
if r == "" {
return 0
}
return public.PointerPtr(r)
}
/*
SetResponseAllHeader 修改、设置 HTTP/S当前返回数据中的全部协议头,例如设置返回两条Cookie 使用本命令设置 使用设置、修改 单条命令无效
*/
//export SetResponseAllHeader
func SetResponseAllHeader(MessageId int, value *C.char) {
Api.SetResponseAllHeader(MessageId, C.GoString(value))
}
/*
GetResponseAllHeader 获取 HTTP/S 当前返回全部协议头
*/
//export GetResponseAllHeader
func GetResponseAllHeader(MessageId int) uintptr {
r := Api.GetResponseAllHeader(MessageId)
if r == "" {
return 0
}
return public.PointerPtr(r)
}
/*
GetRequestAllHeader 获取 HTTP/S 当前请求数据全部协议头
*/
//export GetRequestAllHeader
func GetRequestAllHeader(MessageId int) uintptr {
r := Api.GetRequestAllHeader(MessageId)
if r == "" {
return 0
}
return public.PointerPtr(r)
}
/*
SetRequestProxy 设置HTTP/S请求代理,仅支持Socket5和http 例如 socket5://admin:123456@127.0.0.1:8888 或 http://admin:123456@127.0.0.1:8888
*/
//
//export SetRequestProxy
func SetRequestProxy(MessageId int, ProxyUrl *C.char, outTime int) bool {
return Api.SetRequestProxy(MessageId, C.GoString(ProxyUrl), outTime)
}
/*
GetResponseStatusCode 获取HTTP/S返回的状态码
*/
//export GetResponseStatusCode
func GetResponseStatusCode(MessageId int) int {
return Api.GetResponseStatusCode(MessageId)
}
/*
GetRequestClientIp 获取当前HTTP/S请求由哪个IP发起
*/
//export GetRequestClientIp
func GetRequestClientIp(MessageId int) uintptr {
r := Api.GetRequestClientIp(MessageId)
if r == "" {
return 0
}
return public.PointerPtr(r)
}
/*
GetResponseStatus 获取HTTP/S返回的状态文本 例如 [200 OK]
*/
//export GetResponseStatus
func GetResponseStatus(MessageId int) uintptr {
r := Api.GetResponseStatus(MessageId)
if r == "" {
return 0
}
return public.PointerPtr(r)
}
/*
SetResponseStatus 修改HTTP/S返回的状态码
*/
//export SetResponseStatus
func SetResponseStatus(MessageId, code int) {
Api.SetResponseStatus(MessageId, code)
}
/*
SetRequestUrl 修改HTTP/S当前请求的URL
*/
//export SetRequestUrl
func SetRequestUrl(MessageId int, URI *C.char) bool {
return Api.SetRequestUrl(MessageId, C.GoString(URI))
}
/*
GetRequestBodyLen 获取 HTTP/S 当前请求POST提交数据长度
*/
//export GetRequestBodyLen
func GetRequestBodyLen(MessageId int) int {
return Api.GetRequestBodyLen(MessageId)
}
/*
GetResponseBodyLen 获取 HTTP/S 当前返回 数据长度
*/
//export GetResponseBodyLen
func GetResponseBodyLen(MessageId int) int {
return Api.GetResponseBodyLen(MessageId)
}
/*
SetResponseData 设置、修改 HTTP/S 当前请求返回数据 如果再发起请求时调用本命令,请求将不会被发送,将会直接返回 data=数据指针 dataLen=数据长度
*/
//export SetResponseData
func SetResponseData(MessageId int, data uintptr, dataLen int) bool {
return Api.SetResponseData(MessageId, public.CStringToBytes(data, dataLen))
}
/*
SetRequestData 设置、修改 HTTP/S 当前请求POST提交数据 data=数据指针 dataLen=数据长度
*/
//export SetRequestData
func SetRequestData(MessageId int, data uintptr, dataLen int) bool {
return Api.SetRequestData(MessageId, public.CStringToBytes(data, dataLen))
}
/*
GetRequestBody 获取 HTTP/S 当前POST提交数据 返回 数据指针
*/
//export GetRequestBody
func GetRequestBody(MessageId int) uintptr {
bs := Api.GetRequestBody(MessageId)
if bs == nil {
return 0
}
return public.PointerPtr(bs)
}
/*
IsRequestRawBody 此请求是否为原始body 如果是 将无法修改提交的Body,请使用 RawRequestDataToFile 命令来储存到文件
*/
//export IsRequestRawBody
func IsRequestRawBody(MessageId int) bool {
return Api.IsRequestRawBody(MessageId)
}
/*
RawRequestDataToFile 获取 HTTP/ S 当前POST提交数据原始Data,传入保存文件名路径,例如"c:\1.txt"
*/
//export RawRequestDataToFile
func RawRequestDataToFile(MessageId int, saveFileName uintptr, len int) bool {
return Api.RawRequestDataToFile(MessageId, string(public.CStringToBytes(saveFileName, len)))
}
/*
GetResponseBody 获取 HTTP/S 当前返回数据 返回 数据指针
*/
//export GetResponseBody
func GetResponseBody(MessageId int) uintptr {
bs := Api.GetResponseBody(MessageId)
if bs == nil {
return 0
}
return public.PointerPtr(bs)
}
/*
GetWebsocketBodyLen 获取 WebSocket消息长度
*/
//export GetWebsocketBodyLen
func GetWebsocketBodyLen(MessageId int) int {
return Api.GetWebsocketBodyLen(MessageId)
}
/*
CloseWebsocket 主动关闭Websocket
*/
//export CloseWebsocket
func CloseWebsocket(Theology int) bool {
return Api.CloseWebsocket(Theology)
}
/*
GetWebsocketBody 获取 WebSocket消息 返回数据指针
*/
//export GetWebsocketBody
func GetWebsocketBody(MessageId int) uintptr {
bs := Api.GetWebsocketBody(MessageId)
if bs == nil {
return 0
}
return public.PointerPtr(bs)
}
/*
SetWebsocketBody 修改 WebSocket消息 data=数据指针 dataLen=数据长度
*/
//export SetWebsocketBody
func SetWebsocketBody(MessageId int, data uintptr, dataLen int) bool {
return Api.SetWebsocketBody(MessageId, public.CStringToBytes(data, dataLen))
}
/*
SendWebsocketBody 主动向Websocket服务器发送消息 MessageType=WS消息类型 data=数据指针 dataLen=数据长度
*/
//export SendWebsocketBody
func SendWebsocketBody(Theology, MessageType int, data uintptr, dataLen int) bool {
bs := public.CStringToBytes(data, dataLen)
return Api.SendWebsocketBody(Theology, MessageType, bs)
}
/*
SendWebsocketClientBody SendWebsocketClientBody 主动向Websocket客户端发送消息 MessageType=WS消息类型 data=数据指针 dataLen=数据长度
*/
//export SendWebsocketClientBody
func SendWebsocketClientBody(Theology, MessageType int, data uintptr, dataLen int) bool {
bs := public.CStringToBytes(data, dataLen)
return Api.SendWebsocketClientBody(Theology, MessageType, bs)
}
/*
SetTcpBody 修改 TCP消息数据 MsgType=1 发送的消息 MsgType=2 接收的消息 如果 MsgType和MessageId不匹配,将不会执行操作 data=数据指针 dataLen=数据长度
*/
//export SetTcpBody
func SetTcpBody(MessageId, MsgType int, data uintptr, dataLen int) bool {
return Api.SetTcpBody(MessageId, MsgType, public.CStringToBytes(data, dataLen))
}
/*
SetTcpAgent 给当前TCP连接设置代理 仅限 TCP回调 即将连接时使用 仅支持S5代理 例如 socket5://admin:123456@127.0.0.1:8888
*/
//
//export SetTcpAgent
func SetTcpAgent(MessageId int, ProxyUrl *C.char) bool {
return Api.SetTcpAgent(MessageId, C.GoString(ProxyUrl))
}
/*
TcpCloseClient 根据唯一ID关闭指定的TCP连接 唯一ID在回调参数中
*/
//export TcpCloseClient
func TcpCloseClient(theology int) bool {
return Api.TcpCloseClient(theology)
}
/*
SetTcpConnectionIP 给指定的TCP连接 修改目标连接地址 目标地址必须带端口号 例如 baidu.com:443
*/
//export SetTcpConnectionIP
func SetTcpConnectionIP(MessageId int, address *C.char) bool {
return Api.SetTcpConnectionIP(MessageId, C.GoString(address))
}
/*
TcpSendMsg 指定的TCP连接 模拟客户端向服务器端主动发送数据
*/
//export TcpSendMsg
func TcpSendMsg(theology int, data uintptr, dataLen int) int {
return Api.TcpSendMsg(theology, public.CStringToBytes(data, dataLen))
}
/*
TcpSendMsgClient 指定的TCP连接 模拟服务器端向客户端主动发送数据
*/
//export TcpSendMsgClient
func TcpSendMsgClient(theology int, data uintptr, dataLen int) int {
return Api.TcpSendMsgClient(theology, public.CStringToBytes(data, dataLen))
}
//export HexDump
func HexDump(data uintptr, dataLen int) uintptr {
return Api.HexDump(data, dataLen)
}
/*
BytesToInt 将Go int的Bytes 转为int
*/
//export BytesToInt
func BytesToInt(data uintptr, dataLen int) int {
return Api.BytesToInt(data, dataLen)
}
/*
GzipUnCompress Gzip解压缩
*/
//export GzipUnCompress
func GzipUnCompress(data uintptr, dataLen int) uintptr {
return Api.GzipUnCompress(data, dataLen)
}
/*
BrUnCompress br解压缩
*/
//export BrUnCompress
func BrUnCompress(data uintptr, dataLen int) uintptr {
return Api.BrUnCompress(data, dataLen)
}
/*
BrCompress br压缩
*/
//export BrCompress
func BrCompress(data uintptr, dataLen int) uintptr {
return Api.BrCompress(data, dataLen)
}
/*
ZSTDDecompress ZSTD解压缩
*/
//export ZSTDDecompress
func ZSTDDecompress(data uintptr, dataLen int) uintptr {
return Api.ZSTDDecompress(data, dataLen)
}
/*
ZSTDCompress ZSTD压缩
*/
//export ZSTDCompress
func ZSTDCompress(data uintptr, dataLen int) uintptr {
return Api.ZSTDCompress(data, dataLen)
}
/*
BrCompress br压缩
*/
//export BrotliCompress
func BrotliCompress(data uintptr, dataLen int) uintptr {
return Api.BrCompress(data, dataLen)
}
/*
GzipCompress Gzip压缩
*/
//export GzipCompress
func GzipCompress(data uintptr, dataLen int) uintptr {
return Api.GzipCompress(data, dataLen)
}
/*
ZlibCompress Zlib压缩
*/
//export ZlibCompress
func ZlibCompress(data uintptr, dataLen int) uintptr {
return Api.ZlibCompress(data, dataLen)
}
/*
ZlibUnCompress Zlib解压缩
*/
//export ZlibUnCompress
func ZlibUnCompress(data uintptr, dataLen int) uintptr {
return Api.ZlibUnCompress(data, dataLen)
}
/*
DeflateUnCompress Deflate解压缩 (可能等同于zlib解压缩)
*/
//export DeflateUnCompress
func DeflateUnCompress(data uintptr, dataLen int) uintptr {
return Api.DeflateUnCompress(data, dataLen)
}
/*
DeflateCompress Deflate压缩 (可能等同于zlib压缩)
*/
//export DeflateCompress
func DeflateCompress(data uintptr, dataLen int) uintptr {
bin := public.CStringToBytes(data, dataLen)
bx := Api.DeflateCompress(bin)
if bx == nil {
return 0
}
bx = public.BytesCombine(public.IntToBytes(len(bx)), bx)
return public.PointerPtr(string(bx))
}
/*
WebpToJpegBytes Webp图片转JEG图片字节数组 SaveQuality=质量(默认75)
*/
//export WebpToJpegBytes
func WebpToJpegBytes(data uintptr, dataLen int, SaveQuality int) uintptr {
_webp := public.CStringToBytes(data, dataLen)
bs := Api.WebpToJpegBytes(_webp, SaveQuality)
bn := public.BytesCombine(public.IntToBytes(len(bs)), bs)
return public.PointerPtr(string(bn))
}
/*
WebpToPngBytes Webp图片转Png图片字节数组
*/
//export WebpToPngBytes
func WebpToPngBytes(data uintptr, dataLen int) uintptr {
_webp := public.CStringToBytes(data, dataLen)
bs := Api.WebpToPngBytes(_webp)
if bs == nil {
return 0
}
bn := public.BytesCombine(public.IntToBytes(len(bs)), bs)
return public.PointerPtr(string(bn))
}
/*
WebpToJpeg Webp图片转JEG图片 根据文件名 SaveQuality=质量(默认75)
*/
//export WebpToJpeg
func WebpToJpeg(webpPath, savePath *C.char, SaveQuality int) bool {
return Api.WebpToJpeg(C.GoString(webpPath), C.GoString(savePath), SaveQuality)
}
/*
WebpToPng Webp图片转Png图片 根据文件名
*/
//export WebpToPng
func WebpToPng(webpPath, savePath *C.char) bool {
return Api.WebpToPng(C.GoString(webpPath), C.GoString(savePath))
}
/*
OpenDrive 开启进程代理/打开驱动
*/
//export OpenDrive
func OpenDrive(SunnyContext int, isNf bool) bool {
return Api.OpenDrive(SunnyContext, isNf)
}
/*
UnDrive 卸载驱动,仅Windows 有效【需要管理权限】执行成功后会立即重启系统,若函数执行后没有重启系统表示没有管理员权限
*/
//export UnDrive
func UnDrive(SunnyContext int) {
Api.UnDrive(SunnyContext)
}
/*
ProcessAddName 进程代理 添加进程名
*/
//export ProcessAddName
func ProcessAddName(SunnyContext int, Name *C.char) {
Api.ProcessAddName(SunnyContext, C.GoString(Name))
}
/*
ProcessDelName 进程代理 删除进程名
*/
//export ProcessDelName
func ProcessDelName(SunnyContext int, Name *C.char) {
Api.ProcessDelName(SunnyContext, C.GoString(Name))
}
/*
ProcessAddPid 进程代理 添加PID
*/
//export ProcessAddPid
func ProcessAddPid(SunnyContext, pid int) {
Api.ProcessAddPid(SunnyContext, pid)
}
/*
ProcessDelPid 进程代理 删除PID
*/
//export ProcessDelPid
func ProcessDelPid(SunnyContext, pid int) {
Api.ProcessDelPid(SunnyContext, pid)
}
/*
ProcessCancelAll 进程代理 取消全部已设置的进程名
*/
//export ProcessCancelAll
func ProcessCancelAll(SunnyContext int) {
Api.ProcessCancelAll(SunnyContext)
}
/*
ProcessALLName 进程代理 设置是否全部进程通过
*/
//export ProcessALLName
func ProcessALLName(SunnyContext int, open, StopNetwork bool) {
Api.ProcessALLName(SunnyContext, open, StopNetwork)
}
//================================================================================================
/*
GetCommonName 证书管理器 获取证书 CommonName 字段
*/
//export GetCommonName
func GetCommonName(Context int) uintptr {
return public.PointerPtr(Api.GetCommonName(Context))
}
/*
ExportP12 证书管理器 导出为P12
*/
//export ExportP12
func ExportP12(Context int, path, pass *C.char) bool {
return Api.ExportP12(Context, C.GoString(path), C.GoString(pass))
}
/*
ExportPub 证书管理器 导出公钥
*/
//export ExportPub
func ExportPub(Context int) uintptr {
p := Api.ExportPub(Context)
if p == "" {
return 0
}
return public.PointerPtr(p)
}
/*
ExportKEY 证书管理器 导出私钥
*/
//export ExportKEY
func ExportKEY(Context int) uintptr {
return public.PointerPtr(Api.ExportKEY(Context))
}
/*
ExportCA 证书管理器 导出证书
*/
//export ExportCA
func ExportCA(Context int) uintptr {
return public.PointerPtr(Api.ExportCA(Context))
}
/*
CreateCA 证书管理器 创建证书
*/
//export CreateCA
func CreateCA(Context int, Country, Organization, OrganizationalUnit, Province, CommonName, Locality *C.char, bits, NotAfter int) bool {
return Api.CreateCA(Context, C.GoString(Country), C.GoString(Organization), C.GoString(OrganizationalUnit), C.GoString(Province), C.GoString(CommonName), C.GoString(Locality), bits, NotAfter)
}
/*
AddClientAuth 证书管理器 设置ClientAuth
*/
//export AddClientAuth
func AddClientAuth(Context, val int) bool {
return Api.AddClientAuth(Context, val)
}
/*
SetCipherSuites SetCipherSuites 证书管理器 设置CipherSuites
*/
//export SetCipherSuites
func SetCipherSuites(Context int, val *C.char) bool {
return Api.SetCipherSuites(Context, C.GoString(val))
}
/*
AddCertPoolText 证书管理器 设置信任的证书 从 文本
*/
//export AddCertPoolText
func AddCertPoolText(Context int, cer *C.char) bool {
return Api.AddCertPoolText(Context, C.GoString(cer))
}
/*
AddCertPoolPath 证书管理器 设置信任的证书 从 文件
*/
//export AddCertPoolPath
func AddCertPoolPath(Context int, cer *C.char) bool {
return Api.AddCertPoolPath(Context, C.GoString(cer))
}
/*
GetServerName 证书管理器 取ServerName
*/
//export GetServerName
func GetServerName(Context int) uintptr {
return public.PointerPtr(Api.GetServerName(Context))
}
/*
SetServerName 证书管理器 设置ServerName
*/
//export SetServerName
func SetServerName(Context int, name *C.char) bool {
return Api.SetServerName(Context, C.GoString(name))
}
/*
SetInsecureSkipVerify 证书管理器 设置跳过主机验证
*/
//export SetInsecureSkipVerify
func SetInsecureSkipVerify(Context int, b bool) bool {
return Api.SetInsecureSkipVerify(Context, b)
}
/*
LoadX509Certificate 证书管理器 载入X509证书
*/
//export LoadX509Certificate
func LoadX509Certificate(Context int, Host, CA, KEY *C.char) bool {
return Api.LoadX509Certificate(Context, C.GoString(Host), C.GoString(CA), C.GoString(KEY))
}
/*
LoadX509KeyPair 证书管理器 载入X509证书2
*/
//export LoadX509KeyPair
func LoadX509KeyPair(Context int, CaPath, KeyPath *C.char) bool {
return Api.LoadX509KeyPair(Context, C.GoString(CaPath), C.GoString(KeyPath))
}
/*
LoadP12Certificate 证书管理器 载入p12证书
*/
//export LoadP12Certificate
func LoadP12Certificate(Context int, Name, Password *C.char) bool {
return Api.LoadP12Certificate(Context, C.GoString(Name), C.GoString(Password))
}
/*
RemoveCertificate 释放 证书管理器 对象
*/
//export RemoveCertificate
func RemoveCertificate(Context int) {
Api.RemoveCertificate(Context)
}
/*
CreateCertificate 创建 证书管理器 对象
*/
//export CreateCertificate
func CreateCertificate() int {
return Api.CreateCertificate()
}
//================================================ go map 相关 ==========================================================
/*
KeysWriteStr GoMap 写字符串
*/
//export KeysWriteStr
func KeysWriteStr(KeysHandle int, name *C.char, val uintptr, len int) {
Api.KeysWriteStr(KeysHandle, C.GoString(name), val, len)
}
/*
KeysGetJson GoMap 转为JSON字符串
*/
//export KeysGetJson
func KeysGetJson(KeysHandle int) uintptr {
return Api.KeysGetJson(KeysHandle)
}
/*