Allow http server ports can be modified

This commit is contained in:
SuperSonic 2020-10-20 21:03:04 +08:00
parent 734d6aeb93
commit 107996cd47
No known key found for this signature in database
GPG key ID: E511B80256C9F20D
5 changed files with 18 additions and 11 deletions

View file

@ -48,6 +48,8 @@ class Yuuki_Config:
"Admin": [],
"Advanced": False,
"WebAdmin": False, # Advanced Mode Required
"MDS_Port": 2019,
"WebAdmin_Port": 2020,
"SecurityService": False,
"Hour_KickLimit": 10,
"Hour_CancelLimit": 10,

View file

@ -69,8 +69,9 @@ class Yuuki_Data:
initHeader = "<title>{} - SYB</title>" \
"<meta charset='utf-8' />"
def __init__(self, threading):
def __init__(self, threading, mds_port):
self.threading = threading
self.mds_port = mds_port
self.ThreadControl = Yuuki_Thread()
self.MdsThreadControl = Yuuki_Multiprocess()
self._Data_Initialize()
@ -97,8 +98,8 @@ class Yuuki_Data:
def _MDS_Initialize(self):
if self.threading:
mds = PythonMDS()
self.mdsHost = "http://localhost:2019/"
mds = PythonMDS(self.mds_port)
self.mdsHost = "http://localhost:{}/".format(self.mds_port)
self.mdsCode = "{}.{}".format(random.random(), time.time())
self.MdsThreadControl.add(mds.mds_listen, (self.mdsCode,))

View file

@ -59,13 +59,14 @@ class PythonMDS:
server = HTTPServer(app)
async_lock = IOLoop.current()
def __init__(self):
def __init__(self, port):
_work["UPT"] = self._update
_work["DEL"] = self._delete
_work["GET"] = self._query
_work["SYC"] = self._sync
_work["YLD"] = self._yuuki_limit_decrease
_work["EXT"] = self._shutdown
self.port = port
def _query(self, data):
query_data = data["path"]
@ -119,5 +120,5 @@ class PythonMDS:
def mds_listen(self, code):
global auth_code
auth_code = code
self.server.listen(2019)
self.server.listen(self.port)
self.async_lock.start()

View file

@ -51,11 +51,12 @@ class Yuuki_WebAdmin:
Bootstrap(wa_app)
http_server = None
def __init__(self, Yuuki):
def __init__(self, Yuuki, port):
global Yuuki_Handle, Yuuki_Handle_Data, Yuuki_APIHandle_Data
Yuuki_Handle = Yuuki
Yuuki_Handle_Data = Yuuki.data
Yuuki_APIHandle_Data = Yuuki_WebDataReader(Yuuki_Handle_Data)
self.port = port
@staticmethod
def set_password(code):
@ -63,7 +64,7 @@ class Yuuki_WebAdmin:
password = code
def wa_listen(self):
self.http_server = WSGIServer(('', 2020), wa_app)
self.http_server = WSGIServer(('', self.port), wa_app)
self.http_server.serve_forever()
# HTML Server

View file

@ -92,7 +92,8 @@ class Yuuki:
self.Security = Yuuki_Security(self).action
self.Callback = Yuuki_Callback(self).action
self.data = Yuuki_Data(self.Threading)
mds_port = self.YuukiConfigs["MDS_Port"]
self.data = Yuuki_Data(self.Threading, mds_port)
self.data.updateData(["Global", "GroupJoined"], self.client.getGroupIdsJoined())
self.data.updateData(["Global", "SecurityService"], self.YuukiConfigs["SecurityService"])
@ -114,14 +115,15 @@ class Yuuki:
def _Setup_WebAdmin(self):
if self.Threading and self.YuukiConfigs.get("WebAdmin"):
wa_port = self.YuukiConfigs["WebAdmin_Port"]
password = str(hash(random.random()))
self.web_admin = Yuuki_WebAdmin(self)
self.web_admin = Yuuki_WebAdmin(self, wa_port)
self.web_admin.set_password(password)
self.Thread_Control.add(self.web_admin.wa_listen)
print(
"<*> Yuuki WebAdmin - Enable\n"
"<*> http://localhost:2020\n"
"<*> Password: {}\n".format(password)
"<*> http://localhost:{}\n"
"<*> Password: {}\n".format(wa_port, password)
)
else:
print("<*> Yuuki WebAdmin - Disable\n")