|
|
@ -7,7 +7,7 @@ import time
|
|
|
|
|
|
|
|
|
|
|
|
# Easy debug
|
|
|
|
# Easy debug
|
|
|
|
from icecream import ic
|
|
|
|
from icecream import ic
|
|
|
|
# ic.disable() # Turn off
|
|
|
|
#ic.disable() # Turn off
|
|
|
|
|
|
|
|
|
|
|
|
# Limit for requests
|
|
|
|
# Limit for requests
|
|
|
|
LTIME = cur_time = time.monotonic()
|
|
|
|
LTIME = cur_time = time.monotonic()
|
|
|
@ -23,6 +23,33 @@ def kbv(dict_, value):
|
|
|
|
from listwork import *
|
|
|
|
from listwork import *
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# Work with tokens
|
|
|
|
|
|
|
|
import json
|
|
|
|
|
|
|
|
global tokens
|
|
|
|
|
|
|
|
def tokens_load():
|
|
|
|
|
|
|
|
with open('tokens.json', 'r') as openfile:
|
|
|
|
|
|
|
|
return json.load(openfile)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# (Re)generate tokens
|
|
|
|
|
|
|
|
def tokens_regen():
|
|
|
|
|
|
|
|
import hashlib
|
|
|
|
|
|
|
|
from random import randint as ri
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
tokens = tokens_load()
|
|
|
|
|
|
|
|
tokens["admin"] = hashlib.sha256(str.encode( str(ri(2443, 6543)) + tokens["secret"] )).hexdigest()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
tokens["premium"] = []
|
|
|
|
|
|
|
|
for i in range(10):
|
|
|
|
|
|
|
|
tokens["premium"].append( hashlib.sha256(str.encode( str(ri(2443, 6543)) + tokens["secret"] )).hexdigest() )
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
js = json.dumps(tokens, indent=2)
|
|
|
|
|
|
|
|
with open("tokens.json", "w") as outfile:
|
|
|
|
|
|
|
|
outfile.write(js)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# Uncomment to regen
|
|
|
|
|
|
|
|
#tokens_regen()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class RequestHandler(BaseHTTPRequestHandler):
|
|
|
|
class RequestHandler(BaseHTTPRequestHandler):
|
|
|
|
MATRIX_SIZE = (720, 1280)
|
|
|
|
MATRIX_SIZE = (720, 1280)
|
|
|
|
|
|
|
|
|
|
|
@ -76,11 +103,24 @@ class RequestHandler(BaseHTTPRequestHandler):
|
|
|
|
params = parse_qs(body.decode('utf-8'))["main"][0]
|
|
|
|
params = parse_qs(body.decode('utf-8'))["main"][0]
|
|
|
|
ic(params)
|
|
|
|
ic(params)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# Parse token
|
|
|
|
|
|
|
|
ic( parse_qs(body.decode('utf-8')) )
|
|
|
|
|
|
|
|
token = parse_qs(body.decode('utf-8'))["token"][0]
|
|
|
|
|
|
|
|
|
|
|
|
#Set limit pixels for 1 response
|
|
|
|
#Set limit pixels for 1 response
|
|
|
|
ic(len(params))
|
|
|
|
ic(len(params))
|
|
|
|
if len(params) > 5685:
|
|
|
|
if len(params) > 6700:
|
|
|
|
|
|
|
|
# Get tokens
|
|
|
|
|
|
|
|
tokens = tokens_load()
|
|
|
|
|
|
|
|
# Admin's token
|
|
|
|
|
|
|
|
if token[0] == tokens["admin"][0]:
|
|
|
|
|
|
|
|
pass
|
|
|
|
|
|
|
|
elif token[0] in tokens["premium"] and len(params) < 10000:
|
|
|
|
|
|
|
|
pass
|
|
|
|
|
|
|
|
else:
|
|
|
|
return 0
|
|
|
|
return 0
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
matrix = self.get_matrix()
|
|
|
|
matrix = self.get_matrix()
|
|
|
|
|
|
|
|
|
|
|
|
ll = unpack(params)
|
|
|
|
ll = unpack(params)
|
|
|
|