[Enhance] Restrict download by user's purchase

- An option `DOWNLOAD_FORBID_WHEN_NO_ITEM` has been added to the config file to make that users cannot download the songs' files if they has not bought them when the `songlist` file exists. (Experimental)

#128
This commit is contained in:
Lost-MSth
2023-09-08 11:38:46 +08:00
parent 04c6d1a0e0
commit f373c7b052
6 changed files with 108 additions and 21 deletions

View File

@@ -1,4 +1,4 @@
import binascii
# import binascii
import logging
import socketserver
import threading
@@ -56,9 +56,13 @@ class UDP_handler(socketserver.BaseRequestHandler):
class TCP_handler(socketserver.StreamRequestHandler):
def handle(self):
self.data = self.rfile.readline().strip()
try:
self.data = self.rfile.readline().strip()
message = self.data.decode('utf-8')
except Exception as e:
logging.error(e)
return None
message = self.data.decode('utf-8')
if Config.DEBUG:
logging.info(f'TCP-From-{self.client_address[0]}-{message}')
data = message.split('|')