Skip to content

Commit

Permalink
Update randomVless.py
Browse files Browse the repository at this point in the history
  • Loading branch information
Kourva authored Aug 25, 2023
1 parent b41bf6c commit e22bc10
Showing 1 changed file with 40 additions and 32 deletions.
72 changes: 40 additions & 32 deletions randomVless.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,18 @@
#!/usr/bin/env python3

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

# This tool will create random Vless proxies with random servers


# Imports
import requests, string, random, time, sys

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

# Random server name generator
def random_name() -> str:
Expand All @@ -15,37 +21,44 @@ def random_name() -> str:


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

# Servers from database
with open("ip/all_result.txt") as data:
targets = [url.split("\n")[0] for url in data.readlines()]
for i in range(int(sys.argv[2])):
addrs.append(targets[random.randint(0, len(targets) - 1)])
names.append(random_name())
try:
# Get servers from database
with open("ip/all_result.txt") as data:
targets = [
url.split("\n")[0] for url in data.readlines()
]
for i in range(int(sys.argv[2])):
addrs.append(targets[random.randint(0, len(targets) - 1)])
names.append(random_name())

return zip(names, addrs)

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

# Handle exception
except Exception as ex:
raise SystemExit(f"Can't get servers due to '{ex}' (run with -h)!")

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

# Open config file
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, addrs, result = [], [], []

# Make vless proxies
worker_host = worker.split("/")[2]
for name, addrs in get_servers():
result.append(
Expand All @@ -57,22 +70,20 @@ def vless_generator():
alias=alias + "-" + name,
)
)
return result

# Return result
return result

# Main function
def main():
with open("data/random_result.txt", "a") as result:
for proxy in vless_generator():
result.write(proxy + "\n\n")
for char in "\033[2;34m{} Servers saved in data/random_result.txt\033[m\n".format(
int(sys.argv[2])
):
print(char, end="", flush=True)
time.sleep(0.01)

printer(
f"\033[2;34m{int(sys.argv[2])} Servers saved in data/random_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 @@ -90,6 +101,3 @@ def main():
print("Invalid argument! run with -h")
else:
print("No argument! run with -h")


# EOF

0 comments on commit e22bc10

Please sign in to comment.