-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathv2ray2json.py
1418 lines (1214 loc) · 43.5 KB
/
v2ray2json.py
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
import json
import base64
import argparse
import re
from urllib.parse import urlparse
from urllib.parse import parse_qs
from urllib.parse import unquote
DEFAULT_PORT = 443
DEFAULT_SECURITY = "auto"
DEFAULT_LEVEL = 8
DEFAULT_NETWORK = "tcp"
TLS = "tls"
REALITY = "reality"
HTTP = "http"
class EConfigType:
class VMESS:
protocolScheme = "vmess://"
protocolName = "vmess"
class CUSTOM:
protocolScheme = ""
protocolName = ""
class SHADOWSOCKS:
protocolScheme = "ss://"
protocolName = "ss"
class SOCKS:
protocolScheme = "socks://"
protocolName = "socks"
class VLESS:
protocolScheme = "vless://"
protocolName = "vless"
class TROJAN:
protocolScheme = "trojan://"
protocolName = "trojan"
class WIREGUARD:
protocolScheme = "wireguard://"
protocolName = "wireguard"
class FREEDOM:
protocolScheme = "freedom://"
protocolName = "freedom"
class BLACKHOLE:
protocolScheme = "blackhole://"
protocolName = "blackhole"
class DomainStrategy:
AsIs = "AsIs"
UseIp = "UseIp"
IpIfNonMatch = "IpIfNonMatch"
IpOnDemand = "IpOnDemand"
class Fingerprint:
randomized = "randomized"
randomizedalpn = "randomizedalpn"
randomizednoalpn = "randomizednoalpn"
firefox_auto = "firefox_auto"
chrome_auto = "chrome_auto"
ios_auto = "ios_auto"
android_11_okhttp = "android_11_okhttp"
edge_auto = "edge_auto"
safari_auto = "safari_auto"
_360_auto = "360_auto"
qq_auto = "qq_auto"
class LogBean:
access: str
error: str
loglevel: str
dnsLog: bool
def __init__(self, access: str, error: str, loglevel: str, dnsLog: bool) -> None:
self.access = access
self.error = error
self.loglevel = loglevel
self.dnsLog = dnsLog
class InboundBean:
class SniffingBean:
enabled: bool
destOverride: list[str] # str
metadataOnly: bool
def __init__(
self, enabled: bool, destOverride: list[str], metadataOnly: bool
) -> None:
self.enabled = enabled
self.destOverride = destOverride
self.metadataOnly = metadataOnly
class InSettingsBean:
auth: str = None
udp: bool = None
userLevel: int = None
address: str = None
port: int = None
network: str = None
def __init__(
self,
auth: str = None,
udp: bool = None,
userLevel: int = None,
address: str = None,
port: int = None,
network: str = None,
) -> None:
self.auth = auth
self.udp = udp
self.userLevel = userLevel
self.address = address
self.port = port
self.network = network
tag: str
port: int
protocol: str
listen: str
settings: any
sniffing: SniffingBean
streamSettings: any
allocate: any
def __init__(
self,
tag: str,
port: int,
protocol: str,
listen: str,
settings: any,
sniffing: SniffingBean,
streamSettings: any,
allocate: any,
) -> None:
self.tag = tag
self.port = port
self.protocol = protocol
self.listen = listen
self.settings = settings
self.sniffing = sniffing
self.streamSettings = streamSettings
self.allocate = allocate
class OutboundBean:
class OutSettingsBean:
class VnextBean:
class UsersBean:
id: str = ""
alterId: int = None
security: str = DEFAULT_SECURITY
level: int = DEFAULT_LEVEL
encryption: str = ""
flow: str = ""
def __init__(
self,
id: str = "",
alterId: int = None,
security: str = DEFAULT_SECURITY,
level: int = DEFAULT_LEVEL,
encryption: str = "",
flow: str = "",
) -> None:
self.id = id
self.alterId = alterId
self.security = security
self.level = level
self.encryption = encryption
self.flow = flow
address: str = ""
port: int = DEFAULT_PORT
users: list[UsersBean] # UsersBean
def __init__(
self,
address: str = "",
port: int = DEFAULT_PORT,
users: list[UsersBean] = [],
) -> None:
self.address = address
self.port = port
self.users = users
class ServersBean:
class SocksUsersBean:
user: str = ""
# @SerializedName("pass")
_pass: str = ""
level: int = DEFAULT_LEVEL
def __init__(
self, user: str = "", _pass: str = "", level: int = DEFAULT_LEVEL
) -> None:
self.user = user
self._pass = _pass
self.level = level
address: str = ""
method: str = "chacha20-poly1305"
ota: bool = False
password: str = ""
port: int = DEFAULT_PORT
level: int = DEFAULT_LEVEL
email: str = None
flow: str = None
ivCheck: bool = None
users: list[SocksUsersBean] = None # SocksUsersBean
def __init__(
self,
address: str = "",
method: str = "chacha20-poly1305",
ota: bool = False,
password: str = "",
port: int = DEFAULT_PORT,
level: int = DEFAULT_LEVEL,
email: str = None,
flow: str = None,
ivCheck: bool = None,
users: list[SocksUsersBean] = None,
) -> None:
self.address = address
self.method = method
self.ota = ota
self.password = password
self.port = port
self.level = level
self.email = email
self.flow = flow
self.ivCheck = ivCheck
self.users = users
class Response:
type: str
def __init__(self, type: str) -> None:
self.type = type
class WireGuardBean:
publicKey: str = ""
endpoint: str = ""
def __init__(self, publicKey: str = "", endpoint: str = "") -> None:
self.publicKey = publicKey
self.endpoint = endpoint
vnext: list[VnextBean] = None # VnextBean
servers: list[ServersBean] = None # ServersBean
response: Response = None
network: str = None
address: str = None
port: int = None
domainStrategy: str = None
redirect: str = None
userLevel: int = None
inboundTag: str = None
secretKey: str = None
peers: list[WireGuardBean] = None # WireGuardBean
def __init__(
self,
vnext: list[VnextBean] = None,
servers: list[ServersBean] = None,
response: Response = None,
network: str = None,
address: str = None,
port: int = None,
domainStrategy: str = None,
redirect: str = None,
userLevel: int = None,
inboundTag: str = None,
secretKey: str = None,
peers: list[WireGuardBean] = None,
) -> None:
self.vnext = vnext
self.servers = servers
self.response = response
self.network = network
self.address = address
self.port = port
self.domainStrategy = domainStrategy
self.redirect = redirect
self.userLevel = userLevel
self.inboundTag = inboundTag
self.secretKey = secretKey
self.peers = peers
class StreamSettingsBean:
class TcpSettingsBean:
class HeaderBean:
class RequestBean:
class HeadersBean:
Host: list[str] = [] # str
# @SerializedName("User-Agent")
userAgent: list[str] = None # str
# @SerializedName("Accept-Encoding")
acceptEncoding: list[str] = None # str
Connection: list[str] = None # str
Pragma: str = None
def __init__(
self,
Host: list[str] = [],
userAgent: list[str] = None,
acceptEncoding: list[str] = None,
Connection: list[str] = None,
Pragma: str = None,
) -> None:
self.Host = Host
self.userAgent = userAgent
self.acceptEncoding = acceptEncoding
self.Connection = Connection
self.Pragma = Pragma
path: list[str] = [] # str
headers: HeadersBean = HeadersBean()
version: str = None
method: str = None
def __init__(
self,
path: list[str] = [],
headers: HeadersBean = HeadersBean(),
version: str = None,
method: str = None,
) -> None:
self.path = path
self.headers = headers
self.version = version
self.method = method
type: str = "none"
request: RequestBean = None
def __init__(
self, type: str = "none", request: RequestBean = None
) -> None:
self.type = type
self.request = request
header: HeaderBean = HeaderBean()
acceptProxyProtocol: bool = None
def __init__(
self,
header: HeaderBean = HeaderBean(),
acceptProxyProtocol: bool = None,
) -> None:
self.header = header
self.acceptProxyProtocol = acceptProxyProtocol
class KcpSettingsBean:
class HeaderBean:
type: str = "none"
def __init__(self, type: str = "none") -> None:
self.type = type
mtu: int = 1350
tti: int = 50
uplinkCapacity: int = 12
downlinkCapacity: int = 100
congestion: bool = False
readBufferSize: int = 1
writeBufferSize: int = 1
header: HeaderBean = HeaderBean()
seed: str = None
def __init__(
self,
mtu: int = 1350,
tti: int = 50,
uplinkCapacity: int = 12,
downlinkCapacity: int = 100,
congestion: bool = False,
readBufferSize: int = 1,
writeBufferSize: int = 1,
header: HeaderBean = HeaderBean(),
seed: str = None,
) -> None:
self.mtu = mtu
self.tti = tti
self.uplinkCapacity = uplinkCapacity
self.downlinkCapacity = downlinkCapacity
self.congestion = congestion
self.readBufferSize = readBufferSize
self.writeBufferSize = writeBufferSize
self.header = header
self.seed = seed
class WsSettingsBean:
class HeadersBean:
Host: str = ""
def __init__(self, Host: str = "") -> None:
self.Host = Host
path: str = ""
headers: HeadersBean = HeadersBean()
maxEarlyData: int = None
useBrowserForwarding: bool = None
acceptProxyProtocol: bool = None
def __init__(
self,
path: str = "",
headers: HeadersBean = HeadersBean(),
maxEarlyData: int = None,
useBrowserForwarding: bool = None,
acceptProxyProtocol: bool = None,
) -> None:
self.path = path
self.headers = headers
self.maxEarlyData = maxEarlyData
self.useBrowserForwarding = useBrowserForwarding
self.acceptProxyProtocol = acceptProxyProtocol
class HttpSettingsBean:
host: list[str] = [] # str
path: str = ""
def __init__(self, host: list[str] = [], path: str = "") -> None:
self.host = host
self.path = path
class TlsSettingsBean:
allowInsecure: bool = False
serverName: str = ""
alpn: list[str] = None # str
minVersion: str = None
maxVersion: str = None
preferServerCipherSuites: bool = None
cipherSuites: str = None
fingerprint: str = None
certificates: list[any] = None # any
disableSystemRoot: bool = None
enableSessionResumption: bool = None
show: bool = False
publicKey: str = None
shortId: str = None
spiderX: str = None
def __init__(
self,
allowInsecure: bool = False,
serverName: str = "",
alpn: list[str] = None,
minVersion: str = None,
maxVersion: str = None,
preferServerCipherSuites: bool = None,
cipherSuites: str = None,
fingerprint: str = None,
certificates: list[any] = None,
disableSystemRoot: bool = None,
enableSessionResumption: bool = None,
show: bool = False,
publicKey: str = None,
shortId: str = None,
spiderX: str = None,
) -> None:
self.allowInsecure = allowInsecure
self.serverName = serverName
self.alpn = alpn
self.minVersion = minVersion
self.maxVersion = maxVersion
self.preferServerCipherSuites = preferServerCipherSuites
self.cipherSuites = cipherSuites
self.fingerprint = fingerprint
self.certificates = certificates
self.disableSystemRoot = disableSystemRoot
self.enableSessionResumption = enableSessionResumption
self.show = show
self.publicKey = publicKey
self.shortId = shortId
self.spiderX = spiderX
class QuicSettingBean:
class HeaderBean:
type: str = "none"
def __init__(self, type: str = "none") -> None:
self.type = type
security: str = "none"
key: str = ""
header: HeaderBean = HeaderBean()
def __init__(
self,
security: str = "none",
key: str = "",
header: HeaderBean = HeaderBean(),
) -> None:
self.security = security
self.key = key
self.header = header
class GrpcSettingsBean:
serviceName: str = ""
multiMode: bool = None
def __init__(self, serviceName: str = "", multiMode: bool = None) -> None:
self.serviceName = serviceName
self.multiMode = multiMode
network: str = DEFAULT_NETWORK
security: str = ""
tcpSettings: TcpSettingsBean = None
kcpSettings: KcpSettingsBean = None
wsSettings: WsSettingsBean = None
httpSettings: HttpSettingsBean = None
tlsSettings: TlsSettingsBean = None
quicSettings: QuicSettingBean = None
realitySettings: TlsSettingsBean = None
grpcSettings: GrpcSettingsBean = None
dsSettings: any = None
sockopt: any = None
def __init__(
self,
network: str = DEFAULT_NETWORK,
security: str = "",
tcpSettings: TcpSettingsBean = None,
kcpSettings: KcpSettingsBean = None,
wsSettings: WsSettingsBean = None,
httpSettings: HttpSettingsBean = None,
tlsSettings: TlsSettingsBean = None,
quicSettings: QuicSettingBean = None,
realitySettings: TlsSettingsBean = None,
grpcSettings: GrpcSettingsBean = None,
dsSettings: any = None,
sockopt: any = None,
) -> None:
self.network = network
self.security = security
self.tcpSettings = tcpSettings
self.kcpSettings = kcpSettings
self.wsSettings = wsSettings
self.httpSettings = httpSettings
self.tlsSettings = tlsSettings
self.quicSettings = quicSettings
self.realitySettings = realitySettings
self.grpcSettings = grpcSettings
self.dsSettings = dsSettings
self.sockopt = sockopt
def populateTransportSettings(
self,
transport: str,
headerType: str,
host: str,
path: str,
seed: str,
quicSecurity: str,
key: str,
mode: str,
serviceName: str,
) -> str:
sni = ""
self.network = transport
if self.network == "tcp":
tcpSetting = self.TcpSettingsBean()
if headerType == HTTP:
tcpSetting.header.type = HTTP
if host != "" or path != "":
requestObj = self.TcpSettingsBean.HeaderBean.RequestBean()
requestObj.headers.Host = (
"" if host == None else host.split(",")
)
requestObj.path = "" if path == None else path.split(",")
tcpSetting.header.request = requestObj
sni = (
requestObj.headers.Host[0]
if len(requestObj.headers.Host) > 0
else sni
)
else:
tcpSetting.header.type = "none"
sni = host if host != "" else ""
self.tcpSetting = tcpSetting
elif self.network == "kcp":
kcpsetting = self.KcpSettingsBean()
kcpsetting.header.type = headerType if headerType != None else "none"
if seed == None or seed == "":
kcpsetting.seed = None
else:
kcpsetting.seed = seed
self.kcpSettings = kcpsetting
elif self.network == "ws":
wssetting = self.WsSettingsBean()
wssetting.headers.Host = host if host != None else ""
sni = wssetting.headers.Host
wssetting.path = path if path != None else "/"
self.wsSettings = wssetting
elif self.network == "h2" or self.network == "http":
network = "h2"
h2Setting = self.HttpSettingsBean()
h2Setting.host = "" if host == None else host.split(",")
sni = h2Setting.host[0] if len(h2Setting.host) > 0 else sni
h2Setting.path = path if path != None else "/"
self.httpSettings = h2Setting
elif self.network == "quic":
quicsetting = self.QuicSettingBean()
quicsetting.security = quicSecurity if quicSecurity != None else "none"
quicsetting.key = key if key != None else ""
quicsetting.header.type = headerType if headerType != None else "none"
self.quicSettings = quicsetting
elif self.network == "grpc":
grpcSetting = self.GrpcSettingsBean()
grpcSetting.multiMode = mode == "multi"
grpcSetting.serviceName = serviceName if serviceName != None else ""
sni = host if host != None else ""
self.grpcSettings = grpcSetting
return sni
def populateTlsSettings(
self,
streamSecurity: str,
allowInsecure: bool,
sni: str,
fingerprint: str,
alpns: str,
publicKey: str,
shortId: str,
spiderX: str
):
self.security = streamSecurity
tlsSetting = self.TlsSettingsBean(
allowInsecure = allowInsecure,
serverName = sni,
fingerprint = fingerprint,
alpn = None if alpns == None or alpns == "" else alpns.split(","),
publicKey = publicKey,
shortId = shortId,
spiderX = spiderX
)
if self.security == TLS:
self.tlsSettings = tlsSetting
self.realitySettings = None
elif self.security == REALITY:
self.tlsSettings = None
self.realitySettings = tlsSetting
class MuxBean:
enabled: bool
concurrency: int
def __init__(self, enabled: bool, concurrency: int = 8):
self.enabled = enabled
self.concurrency = concurrency
tag: str = "proxy"
protocol: str
settings: OutSettingsBean = None
streamSettings: StreamSettingsBean = None
proxySettings: any = None
sendThrough: str = None
mux: MuxBean = MuxBean(False)
def __init__(
self,
tag: str = "proxy",
protocol: str = None,
settings: OutSettingsBean = None,
streamSettings: StreamSettingsBean = None,
proxySettings: any = None,
sendThrough: str = None,
mux: MuxBean = MuxBean(enabled=False),
):
self.tag = tag
self.protocol = protocol
self.settings = settings
self.streamSettings = streamSettings
self.proxySettings = proxySettings
self.sendThrough = sendThrough
self.mux = mux
class DnsBean:
class ServersBean:
address: str = ""
port: int = None
domains: list[str] = None # str
expectIPs: list[str] = None # str
clientIp: str = None
def __init__(
self,
address: str = "",
port: int = None,
domains: list[str] = None,
expectIPs: list[str] = None,
clientIp: str = None,
) -> None:
self.address = address
self.port = port
self.domains = domains
self.expectIPs = expectIPs
self.clientIp = clientIp
servers: list[any] = None # any
hosts: list = None # map(str, any)
clientIp: str = None
disableCache: bool = None
queryStrategy: str = None
tag: str = None
def __init__(
self,
servers: list[any] = None,
hosts: list = None,
clientIp: str = None,
disableCache: bool = None,
queryStrategy: str = None,
tag: str = None,
) -> None:
self.servers = servers
self.hosts = hosts
self.clientIp = clientIp
self.disableCache = disableCache
self.queryStrategy = queryStrategy
self.tag = tag
class RoutingBean:
class RulesBean:
type: str = ""
ip: list[str] = None # str
domain: list[str] = None # str
outboundTag: str = ""
balancerTag: str = None
port: str = None
sourcePort: str = None
network: str = None
source: list[str] = None # str
user: list[str] = None # str
inboundTag: list[str] = None # str
protocol: list[str] = None # str
attrs: str = None
domainMatcher: str = None
def __init__(
self,
type: str = "",
ip: list[str] = None,
domain: list[str] = None,
outboundTag: str = "",
balancerTag: str = None,
port: str = None,
sourcePort: str = None,
network: str = None,
source: list[str] = None,
user: list[str] = None,
inboundTag: list[str] = None,
protocol: list[str] = None,
attrs: str = None,
domainMatcher: str = None,
) -> None:
self.type = type
self.ip = ip
self.domain = domain
self.outboundTag = outboundTag
self.balancerTag = balancerTag
self.port = port
self.sourcePort = sourcePort
self.network = network
self.source = source
self.user = user
self.inboundTag = inboundTag
self.protocol = protocol
self.attrs = attrs
self.domainMatcher = domainMatcher
domainStrategy: str
domainMatcher: str = None
rules: list[RulesBean] # RulesBean
balancers: list[any] # any
def __init__(
self,
domainStrategy: str,
domainMatcher: str = None,
rules: list[RulesBean] = [],
balancers: list[any] = [],
) -> None:
self.domainStrategy = domainStrategy
self.domainMatcher = domainMatcher
self.rules = rules
self.balancers = balancers
class FakednsBean:
ipPool: str = "198.18.0.0/15"
poolSize: int = 10000
def __init__(self, ipPool: str = "198.18.0.0/15", poolSize: int = 10000) -> None:
self.ipPool = ipPool
self.poolSize = poolSize
class PolicyBean:
class LevelBean:
handshake: int = None
connIdle: int = None
uplinkOnly: int = None
downlinkOnly: int = None
statsUserUplink: bool = None
statsUserDownlink: bool = None
bufferSize: int = None
def __init__(
self,
handshake: int = None,
connIdle: int = None,
uplinkOnly: int = None,
downlinkOnly: int = None,
statsUserUplink: bool = None,
statsUserDownlink: bool = None,
bufferSize: int = None,
) -> None:
self.handshake = handshake
self.connIdle = connIdle
self.uplinkOnly = uplinkOnly
self.downlinkOnly = downlinkOnly
self.statsUserUplink = statsUserUplink
self.statsUserDownlink = statsUserDownlink
self.bufferSize = bufferSize
levels: list # map(str, LevelBean)
system: any = None
def __init__(self, levels: list, system: any = None) -> None:
self.levels = levels
self.system = system
class Comment:
remark: str = None
def __init__(self, remark: str = None) -> None:
self.remark = remark
class V2rayConfig:
_comment: Comment = None
stats: any = None
log: LogBean
policy: PolicyBean
inbounds: list[InboundBean] # InboundBean
outbounds: list[OutboundBean] # OutboundBean
dns: DnsBean
routing: RoutingBean
api: any = None
transport: any = None
reverse: any = None
fakedns: any = None
browserForwarder: any = None
def __init__(
self,
_comment: Comment = None,
stats: any = None,
log: LogBean = None,
policy: PolicyBean = None,
inbounds: list = None,
outbounds: list = None,
dns: DnsBean = None,
routing: RoutingBean = None,
api: any = None,
transport: any = None,
reverse: any = None,
fakedns: any = None,
browserForwarder: any = None,
) -> None:
self.stats = stats
self._comment = _comment
self.log = log
self.policy = policy
self.inbounds = inbounds
self.outbounds = outbounds
self.dns = dns
self.routing = routing
self.api = api
self.transport = transport
self.reverse = reverse
self.fakedns = fakedns
self.browserForwarder = browserForwarder
class VmessQRCode:
v: str = ""
ps: str = ""
add: str = ""
port: str = ""
id: str = ""
aid: str = "0"
scy: str = ""
net: str = ""
type: str = ""
host: str = ""
path: str = ""
tls: str = ""
sni: str = ""
alpn: str = ""
allowInsecure: str = ""
def __init__(
self,
v: str = "",
ps: str = "",
add: str = "",
port: str = "",
id: str = "",
aid: str = "0",
scy: str = "",
net: str = "",
type: str = "",
host: str = "",
path: str = "",
tls: str = "",
sni: str = "",
alpn: str = "",
allowInsecure: str = "",
fp: str = "",
):
self.v = v
self.ps = ps
self.add = add
self.port = port
self.id = id
self.aid = aid
self.scy = scy
self.net = net
self.type = type
self.host = host
self.path = path
self.tls = tls
self.sni = sni
self.alpn = alpn
self.allowInsecure = allowInsecure
self.fp = fp
def remove_nulls(d):
if isinstance(d, dict):
for k, v in list(d.items()):
if v is None:
del d[k]
else:
remove_nulls(v)
if isinstance(d, list):
for v in d:
remove_nulls(v)
return d
def get_log():
log = LogBean(access = "", error = "", loglevel = "error", dnsLog = False)
return log
def get_inbound():
inbound = InboundBean(
tag = "in_proxy",
port = 1080,
protocol = EConfigType.SOCKS.protocolName,
listen = "127.0.0.1",
settings = InboundBean.InSettingsBean(
auth = "noauth",
udp = True,
userLevel = 8,
),
sniffing = InboundBean.SniffingBean(
enabled = False,
destOverride = None,
metadataOnly = None,
),
streamSettings = None,