This commit is contained in:
quackerd 2021-02-01 02:06:02 -05:00
parent 62b3ec0c24
commit 9c2918178b
Signed by: d
GPG Key ID: F73412644EDE357A
2 changed files with 16 additions and 2 deletions

View File

@ -22,12 +22,14 @@ server:
clients:
# name: the name of the client, cannot be null
- name: example_user1
# id: the password(uuid) of each user
# id: the password(uuid) of each user, this can either be a string or an UUID. Please read the "comment" and "IMPORTANT" sections.
# default: auto-generated random string
# comment: for a managed environment we recommend hardcoding the id
# the generated id does NOT currently back-propagate to this file
# you WILL lose existing users if you run configure.py multiple times with blank ids as they will be regenerated with random ids
# NOTE THAT id DOES NOT have to be UUID, can be any string (supported by upstream xray)
#
# ! IMPORTANT !: id DOES NOT have to be UUID, can be any string of length 1-30. This is supported by xray but not by some v2ray clients
# if the script detects that id is not a valid UUID, it will also output the equivalent UUID of that string
id:
# flow: the flow parameter of each user
# default: xtls-rprx-direct

View File

@ -26,6 +26,17 @@ DEFAULT_WATCHTOWER_ENABLE = False
DEFAULT_CLIENT_PORT = 1080
DEFAULT_USER_FLOW = "xtls-rprx-direct"
DEFAULT_LOGLEVEL= "warning"
UUID_NAMESPACE = uuid.UUID('00000000-0000-0000-0000-000000000000')
def calc_uuid5(val):
return str(uuid.uuid5(UUID_NAMESPACE, val))
def is_valid_uuid(val):
try:
uuid.UUID(str(val))
return True
except ValueError:
return False
def yaml_key_exists_else(mapping : [], name : str, other_val = None, nullable = True):
if (name in mapping) and (mapping[name] != None):
@ -54,6 +65,7 @@ class Client:
print(pre + "{")
print(pre + " id: " + self.id)
print(pre + " uuid: " + (self.id if is_valid_uuid(self.id) else calc_uuid5(self.id)))
print(pre + " flow: " + self.flow)
print(pre + " port: " + str(self.port))
print(pre + "}")