Skip to content

Commit

Permalink
Update getVless.py
Browse files Browse the repository at this point in the history
  • Loading branch information
Kourva authored Aug 25, 2023
1 parent f213fdc commit 001ca41
Showing 1 changed file with 48 additions and 36 deletions.
84 changes: 48 additions & 36 deletions getVless.py
Original file line number Diff line number Diff line change
@@ -1,30 +1,40 @@
#!/usr/bin/env python3

# -*- coding: utf-8 -*-

# This tool will create Vless proxies with popular servers


# Imports
import requests, time, sys

# Printer
def printer(message: str) -> None:
for char in message:
sys.stdout.write(char)
sys.stdout.flush()
time.sleep(0.01)
print()

# Gets servers
def get_servers():
names = []
addrs = []
def get_servers() -> zip:
names, addrs = [], []

# Servers from sudoer.net
respones = requests.get("http://bot.sudoer.net/best.cf.iran")
if respones.status_code == 200:
for server in respones.text.split("\n"):
try:
names.append(server.split()[0])
addrs.append(server.split()[1])
except:
continue

# Servers from Isegaro : Thank you so much for your help <3
# Follow him on Twitter: https://twitter.com/iSegaro
try:
respones = requests.get("http://bot.sudoer.net/best.cf.iran", timeout=5)
if respones.status_code == 200:
for server in respones.text.split("\n"):
try:
names.append(server.split()[0])
addrs.append(server.split()[1])
except:
continue

# Handle exception
except:
printer("\33[2;31mContinue without getting servers from sudoer.net!\33[m")

finally:
# Servers from Isegaro (https://twitter.com/iSegaro)
for addrss, name in [
("isegaro.ddns.net", "Isegaro1"),
("ip.isegaro.click", "Isegaro2"),
Expand All @@ -47,25 +57,30 @@ def get_servers():
addrs.append(addrss)
names.append(name)

# return results
return zip(names, addrs)
raise SystemExit("Can't get servers!")

# Raise SystemExit if any error happened
raise SystemExit("Can't get servers!")

# Vless generator
def vless_generator():
def vless_generator() -> list:

# Open config file and extract config
with open(sys.argv[1].strip(), "r") as config:
lines = config.read()
lines = config.read().split("\n")

worker = lines.split("\n")[1]
doprax = lines.split("\n")[4]
uuid = lines.split("\n")[7]
path = lines.split("\n")[10]
alias = lines.split("\n")[16]
worker = lines[1]
doprax = lines[4]
uuid = lines[7]
path = lines[10]
alias = lines[16]

# Base vless url
vless_url = "vless://{uuid}@{addrs}:443?encryption=none&security=tls&sni={worker_host}&alpn=http%2F1.1&type=ws&host={worker_host}&path={path}#{alias}"
names, addrs = [], []
result = []
names, addrsm, result = [], [], []

# Make vless url for each server
worker_host = worker.split("/")[2]
for name, addrs in get_servers():
result.append(
Expand All @@ -74,23 +89,23 @@ def vless_generator():
addrs=addrs,
worker_host=worker_host,
path=path,
alias=alias + "-" + name,
alias=f"{alias}-{name}",
)
)
return result

# Return result
return result

# Main function
def main():

# Save urls to file
with open("data/result.txt", "a") as result:
for proxy in vless_generator():
result.write(proxy + "\n\n")
for char in "\033[2;34mResults saved in data/result.txt\033[m\n":
print(char, end="", flush=True)
time.sleep(0.01)
printer("\033[2;34mResults saved in data/result.txt\033[m\n")


# Run the program
# Main
if __name__ == "__main__":
if len(sys.argv) != 1:
if sys.argv[1] in ["-h", "--help"]:
Expand All @@ -108,6 +123,3 @@ def main():
print("Invalid argument! run with -h")
else:
print("No argument! run with -h")


# EOF

0 comments on commit 001ca41

Please sign in to comment.