imperialwool commited on
Commit
3a32016
1 Parent(s): 7814f6f

new signatures generation and live system

Browse files
routes/config.json CHANGED
@@ -5,5 +5,5 @@
5
  "static-path": "/app/static",
6
  "previews-path": "/app/static/previews",
7
  "signatures-db": "/app/signatures.db",
8
- "buildVersion": "1.0 build57"
9
  }
 
5
  "static-path": "/app/static",
6
  "previews-path": "/app/static/previews",
7
  "signatures-db": "/app/signatures.db",
8
+ "buildVersion": "1.0 build58"
9
  }
routes/helpers.py CHANGED
@@ -41,16 +41,15 @@ def configFile():
41
  return config
42
 
43
  # Signatures check!!! Wow!!!
44
- def checkSignature(request, signature: str):
45
  config = configFile()
46
  db = EazySQLite3(config['signatures-db'])
47
- query = db.query(f"SELECT * FROM `table` WHERE `key`=\"{signature}\" AND `endtime`>{time.time()}")
48
  if len(query['details']) == 0: return False
49
-
50
- ip = hashlib.md5(request.remote_addr.encode()).hexdigest()
51
- creatorKey = hashlib.md5(f"IP={ip};DATE={time.strftime('%Y-%m-%d')}".encode()).hexdigest()
52
  for row in query['details']:
53
- if creatorKey == row[2]: return True
 
 
54
  return False
55
 
56
  # Hook for yt-dlp
 
41
  return config
42
 
43
  # Signatures check!!! Wow!!!
44
+ def checkSignature(signature: str):
45
  config = configFile()
46
  db = EazySQLite3(config['signatures-db'])
47
+ query = db.query(f"SELECT * FROM `table` WHERE `key` LIKE \"{signature}\" AND `endtime`>{time.time()}")
48
  if len(query['details']) == 0: return False
 
 
 
49
  for row in query['details']:
50
+ if signature == row[0]:
51
+ db.query(f"UPDATE `table` SET `endtime`={round(time.time())+3600} WHERE `key`=\"{signature}\"")
52
+ return True
53
  return False
54
 
55
  # Hook for yt-dlp
routes/osuApi/findSong.py CHANGED
@@ -7,7 +7,7 @@ def findSong(request):
7
  if request.method == 'POST': signature = request.form['signature']
8
  else: signature = request.args['signature']
9
  except: return {"status": "error", "details": { "error_code": 103, "error_details": "No signature" }}
10
- if not helpers.checkSignature(request, signature): return {"status": "error", "details": { "error_code": 105, "error_details": "Invalid signature" }}
11
 
12
  try:
13
  if request.method == 'POST': query = request.form['query']
 
7
  if request.method == 'POST': signature = request.form['signature']
8
  else: signature = request.args['signature']
9
  except: return {"status": "error", "details": { "error_code": 103, "error_details": "No signature" }}
10
+ if not helpers.checkSignature(signature): return {"status": "error", "details": { "error_code": 105, "error_details": "Invalid signature" }}
11
 
12
  try:
13
  if request.method == 'POST': query = request.form['query']
routes/osuApi/getFull.py CHANGED
@@ -9,7 +9,7 @@ def getFull(request):
9
  if request.method == 'POST': signature = request.form['signature']
10
  else: signature = request.args['signature']
11
  except: return {"status": "error", "details": { "error_code": 103, "error_details": "No signature" }}
12
- if not helpers.checkSignature(request, signature): return {"status": "error", "details": { "error_code": 105, "error_details": "Invalid signature" }}
13
 
14
  try:
15
  if request.method == 'POST': beatmapId = request.form['beatmapId']
 
9
  if request.method == 'POST': signature = request.form['signature']
10
  else: signature = request.args['signature']
11
  except: return {"status": "error", "details": { "error_code": 103, "error_details": "No signature" }}
12
+ if not helpers.checkSignature(signature): return {"status": "error", "details": { "error_code": 105, "error_details": "Invalid signature" }}
13
 
14
  try:
15
  if request.method == 'POST': beatmapId = request.form['beatmapId']
routes/osuApi/getPreview.py CHANGED
@@ -7,7 +7,7 @@ def getPreview(request):
7
  if request.method == 'POST': signature = request.form['signature']
8
  else: signature = request.args['signature']
9
  except: return {"status": "error", "details": { "error_code": 103, "error_details": "No signature" }}
10
- if not helpers.checkSignature(request, signature): return {"status": "error", "details": { "error_code": 105, "error_details": "Invalid signature" }}
11
 
12
  try:
13
  if request.method == 'POST': beatmapId = request.form['beatmapId']
 
7
  if request.method == 'POST': signature = request.form['signature']
8
  else: signature = request.args['signature']
9
  except: return {"status": "error", "details": { "error_code": 103, "error_details": "No signature" }}
10
+ if not helpers.checkSignature(signature): return {"status": "error", "details": { "error_code": 105, "error_details": "Invalid signature" }}
11
 
12
  try:
13
  if request.method == 'POST': beatmapId = request.form['beatmapId']
routes/siteRoutes/sigGen.py CHANGED
@@ -13,7 +13,7 @@ def signatureGen(request):
13
  text = f"--START SIGNATURE-- {userKey}{endtime} --END SIGNATURE--"
14
  salt = hashlib.md5("funapi-salt".encode()).hexdigest()[0:16]
15
 
16
- creatorKey = hashlib.md5(f"USERKEY={userKey};DATE={time.strftime('%Y-%m-%d')}".encode()).hexdigest()
17
 
18
  key = hashlib.blake2b(text.encode(), key=userKey.encode(), salt=salt.encode()).hexdigest().upper()
19
 
 
13
  text = f"--START SIGNATURE-- {userKey}{endtime} --END SIGNATURE--"
14
  salt = hashlib.md5("funapi-salt".encode()).hexdigest()[0:16]
15
 
16
+ creatorKey = hashlib.md5(f"HOST-IP:{request.remote_addr};USERKEY={userKey};DATE={time.strftime('%Y-%m-%d')};".encode()).hexdigest()
17
 
18
  key = hashlib.blake2b(text.encode(), key=userKey.encode(), salt=salt.encode()).hexdigest().upper()
19
 
routes/witaiApi/recognizeVoice.py CHANGED
@@ -13,7 +13,7 @@ def recognizeVoice(request):
13
  if request.method == 'POST': signature = request.form['signature']
14
  else: signature = request.args['signature']
15
  except: return {"status": "error", "details": { "error_code": 103, "error_details": "No signature" }}
16
- if not helpers.checkSignature(request, signature): return {"status": "error", "details": { "error_code": 105, "error_details": "Invalid signature" }}
17
  try:
18
  if request.method == 'POST': extendInfo = request.form['extendInfo']
19
  else: extendInfo = request.args['extendInfo']
 
13
  if request.method == 'POST': signature = request.form['signature']
14
  else: signature = request.args['signature']
15
  except: return {"status": "error", "details": { "error_code": 103, "error_details": "No signature" }}
16
+ if not helpers.checkSignature(signature): return {"status": "error", "details": { "error_code": 105, "error_details": "Invalid signature" }}
17
  try:
18
  if request.method == 'POST': extendInfo = request.form['extendInfo']
19
  else: extendInfo = request.args['extendInfo']
routes/ytApi/get.py CHANGED
@@ -7,7 +7,7 @@ def get(request, check = "huh"):
7
  if request.method == 'POST': signature = request.form['signature']
8
  else: signature = request.args['signature']
9
  except: return {"status": "error", "details": { "error_code": 103, "error_details": "No signature" }}
10
- if not helpers.checkSignature(request, signature): return {"status": "error", "details": { "error_code": 105, "error_details": "Invalid signature" }}
11
 
12
  try:
13
  if request.method == 'POST': url = request.form['url']
 
7
  if request.method == 'POST': signature = request.form['signature']
8
  else: signature = request.args['signature']
9
  except: return {"status": "error", "details": { "error_code": 103, "error_details": "No signature" }}
10
+ if not helpers.checkSignature(signature): return {"status": "error", "details": { "error_code": 105, "error_details": "Invalid signature" }}
11
 
12
  try:
13
  if request.method == 'POST': url = request.form['url']
routes/ytApi/search.py CHANGED
@@ -13,7 +13,7 @@ def search(request):
13
  if request.method == 'POST': signature = request.form['signature']
14
  else: signature = request.args['signature']
15
  except: return {"status": "error", "details": { "error_code": 103, "error_details": "No signature" }}
16
- if not helpers.checkSignature(request, signature): return {"status": "error", "details": { "error_code": 105, "error_details": " signature" }}
17
  html = urllib.request.urlopen("https://www.youtube.com/results?search_query={}".format(urllib.parse.quote_plus(searchQuery)))
18
  videoList = re.findall(r"watch\?v=(\S{11})", html.read().decode())
19
  videoIds = dict()
 
13
  if request.method == 'POST': signature = request.form['signature']
14
  else: signature = request.args['signature']
15
  except: return {"status": "error", "details": { "error_code": 103, "error_details": "No signature" }}
16
+ if not helpers.checkSignature(signature): return {"status": "error", "details": { "error_code": 105, "error_details": " signature" }}
17
  html = urllib.request.urlopen("https://www.youtube.com/results?search_query={}".format(urllib.parse.quote_plus(searchQuery)))
18
  videoList = re.findall(r"watch\?v=(\S{11})", html.read().decode())
19
  videoIds = dict()