Skip to content
This repository was archived by the owner on Nov 24, 2024. It is now read-only.

Commit 92ed445

Browse files
committed
code refactor
1 parent 9a45317 commit 92ed445

File tree

1 file changed

+33
-23
lines changed

1 file changed

+33
-23
lines changed

V2RayGen.py

Lines changed: 33 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -572,13 +572,15 @@ def create_key():
572572
)
573573
print(reset)
574574

575+
575576
def clearcmd() -> None:
576577
version = platform.system()
577-
if version in ("Linux","Darwin"):
578+
if version in ("Linux", "Darwin"):
578579
subprocess.run("clear")
579580
elif version == "Windows":
580581
subprocess.run("cls")
581582

583+
582584
# def websocket_domaincheck(url = args.domain,t = 10) :
583585
# """
584586
# when using the domain for WebSocket the status code should be 400
@@ -672,7 +674,9 @@ def xray_make():
672674

673675
print(blue + f"! {name} Config Generated." + reset)
674676
if args.vless:
675-
print("{}! By default TLS is being used for this Protocol{}".format(yellow,reset))
677+
print(
678+
"{}! By default TLS is being used for this Protocol{}".format(yellow, reset)
679+
)
676680

677681

678682
def xray_config(outband, protocol) -> str:
@@ -681,8 +685,10 @@ def xray_config(outband, protocol) -> str:
681685
"""
682686
global NETSTREAM
683687

684-
if args.xtls :
685-
print("{}! XTLS only supports (TCP,mKCP). Using TCP mode{}".format(yellow,reset))
688+
if args.xtls:
689+
print(
690+
"{}! XTLS only supports (TCP,mKCP). Using TCP mode{}".format(yellow, reset)
691+
)
686692

687693
if args.http:
688694
networkstream = http()
@@ -1009,13 +1015,13 @@ def tlssettings() -> str:
10091015
"""
10101016
tls security settings for protocols with tls
10111017
"""
1012-
if args.xtls :
1018+
if args.xtls:
10131019
server_security = "xtls"
10141020
tls_server_type = "xtlsSettings"
1015-
else :
1021+
else:
10161022
server_security = "tls"
10171023
tls_server_type = "tlsSettings"
1018-
1024+
10191025
tls = """
10201026
"security": "%s",
10211027
"%s": {
@@ -1406,10 +1412,10 @@ def client_side_configuration(protocol):
14061412
HTTPPORT,
14071413
)
14081414

1409-
if args.xtls :
1415+
if args.xtls:
14101416
tls_client_type = "xtlsSettings"
14111417
security = "xtls"
1412-
else :
1418+
else:
14131419
tls_client_type = "tlsSettings"
14141420
security = "tls"
14151421

@@ -1422,7 +1428,10 @@ def client_side_configuration(protocol):
14221428
],
14231429
"fingerprint": ""
14241430
}
1425-
""" %(security,tls_client_type)
1431+
""" % (
1432+
security,
1433+
tls_client_type,
1434+
)
14261435

14271436
if args.http:
14281437
network = "http"
@@ -2179,17 +2188,17 @@ def shadowsocks_check():
21792188

21802189
if args.ssmethod not in methodlist:
21812190
print("Select one method :")
2182-
print("{}XRay Ciphers :{}".format(yellow,reset))
2191+
print("{}XRay Ciphers :{}".format(yellow, reset))
21832192

21842193
for xmethods in range(len(xraymethod)):
21852194
print(green + xraymethod[xmethods] + reset)
21862195

2187-
print("{}V2ray Ciphers : {}".format(yellow,reset))
2196+
print("{}V2ray Ciphers : {}".format(yellow, reset))
21882197
for vmethods in range(len(v2raymethod)):
21892198
print(green + v2raymethod[vmethods] + reset)
21902199
sys.exit(2)
21912200

2192-
elif args.ssmethod in (methodlist[0:2] , methodlist[-1]):
2201+
elif args.ssmethod in (methodlist[0:2], methodlist[-1]):
21932202
print(
21942203
"{}{} are only useable in xray-core{}".format(yellow, args.ssmethod, reset)
21952204
)
@@ -2235,8 +2244,9 @@ def base_error(err):
22352244

22362245
if args.agent:
22372246
clearcmd()
2238-
subprocess_command = "curl -s {url} --output {path} && python3 {path}"\
2239-
.format(url = AGENT_URL, path = AGENT_PATH)
2247+
subprocess_command = "curl -s {url} --output {path} && python3 {path}".format(
2248+
url=AGENT_URL, path=AGENT_PATH
2249+
)
22402250
subprocess.run(subprocess_command, check=True, shell=True)
22412251
os.remove(AGENT_PATH)
22422252

@@ -2343,11 +2353,11 @@ def base_error(err):
23432353
# link security method
23442354
if args.tls:
23452355
TLSTYPE = "tls"
2346-
2347-
elif args.xtls :
2356+
2357+
elif args.xtls:
23482358
TLSTYPE = "xtls"
23492359

2350-
elif args.vless :
2360+
elif args.vless:
23512361
TLSTYPE = "tls"
23522362

23532363
if args.http:
@@ -2363,7 +2373,7 @@ def base_error(err):
23632373
elif args.vless and args.xtls:
23642374
net = "tcp"
23652375
path = "/"
2366-
header = "http"
2376+
header = "http"
23672377

23682378
else:
23692379
net = "ws"
@@ -2378,11 +2388,11 @@ def base_error(err):
23782388
if args.linkname == None:
23792389
args.linkname = linkname
23802390

2381-
if args.vmess and args.xtls :
2382-
sys.exit("{}! XTLS doesn't supports VMess for now.{}".format(error,reset))
2391+
if args.vmess and args.xtls:
2392+
sys.exit("{}! XTLS doesn't supports VMess for now.{}".format(error, reset))
23832393

2384-
if args.http and args.xtls :
2385-
sys.exit("{}! XTLS doesn't supports HTTP mode{}".format(error,reset))
2394+
if args.http and args.xtls:
2395+
sys.exit("{}! XTLS doesn't supports HTTP mode{}".format(error, reset))
23862396

23872397
# Quick VMess Setup
23882398
if all((args.vmess, args.tls)):

0 commit comments

Comments
 (0)