tweak logging and minor fixes
This commit is contained in:
parent
34833acae5
commit
6cf1c4a446
|
@ -2,7 +2,7 @@ from os.path import dirname, abspath
|
|||
from IzzyLib import logging, template
|
||||
|
||||
|
||||
logging.setConfig({'level': 'debug'})
|
||||
logging.setConfig({'level': 'info'})
|
||||
logging.debug(f'Config: {logging.getConfig()}')
|
||||
|
||||
templates = abspath(dirname(__file__))+'/templates'
|
||||
|
|
|
@ -8,7 +8,7 @@ from envbash import load_envbash
|
|||
from IzzyLib import logging
|
||||
from IzzyLib.misc import boolean
|
||||
|
||||
VERSION = '0.2.2'
|
||||
VERSION = '0.3.0b'
|
||||
|
||||
full_path = abspath(sys.executable) if getattr(sys, 'frozen', False) else abspath(__file__)
|
||||
script_path = getattr(sys, '_MEIPASS', dirname(abspath(__file__)))
|
||||
|
|
|
@ -52,7 +52,7 @@ auth_paths = [
|
|||
async def passthrough(request, headers):
|
||||
mastohost = PAWSCONFIG['mastohost']
|
||||
data = await request.read() if request.body_exists else None
|
||||
is_json = True if request.get('reqtype') == 'json' else False
|
||||
is_json = request.get('jsonreq', False)
|
||||
|
||||
try:
|
||||
async with aiohttp.request(request.method, f'http://{mastohost}{request.path}?{request.query_string}', headers=headers, data=data) as resp:
|
||||
|
@ -67,13 +67,13 @@ async def passthrough(request, headers):
|
|||
err_msg = f'Recieved error {resp.status} from Mastodon'
|
||||
logging.debug(err_msg)
|
||||
|
||||
return error(resp.status, f'Failed to forward request. {err_msg}')
|
||||
return error(request, resp.status, f'Failed to forward request')
|
||||
|
||||
return aiohttp.web.HTTPOk(body=data, content_type=resp.content_type)
|
||||
|
||||
except ClientConnectorError:
|
||||
traceback.print_exc()
|
||||
return error(504, f'Failed to connect to Mastodon')
|
||||
return error(request, 504, f'Failed to connect to Mastodon')
|
||||
|
||||
|
||||
async def http_filter(app, handler):
|
||||
|
@ -108,17 +108,17 @@ async def http_filter(app, handler):
|
|||
# block nazis and general garbage
|
||||
for agent in blocked_agents:
|
||||
if agent in ua:
|
||||
logging.info(f'Blocked garbage: {domain}')
|
||||
logging.debug(f'Blocked garbage: {domain}')
|
||||
return error(request, 418, '418 This teapot kills fascists')
|
||||
|
||||
# block any suspended instances
|
||||
if ban_check(domain):
|
||||
logging.info(f'Blocked instance: {domain}')
|
||||
logging.debug(f'Blocked instance: {domain}')
|
||||
return error(request, 403, 'Forbidden')
|
||||
|
||||
# block any suspended users
|
||||
if banned_user_check(user):
|
||||
logging.info(f'Blocked user: {domain}')
|
||||
logging.debug(f'Blocked user: {domain}')
|
||||
return error(request, 403, 'Access Denied')
|
||||
|
||||
if any(map(request.path.startswith, auth_paths)) and request.method == 'GET':
|
||||
|
@ -128,7 +128,7 @@ async def http_filter(app, handler):
|
|||
actor = parse_sig(signature)
|
||||
|
||||
if not (await validate(actor, request)):
|
||||
logging.info(f'Signature validation failed for: {actor}')
|
||||
logging.warning(f'Signature validation failed for: {actor}')
|
||||
return error(request, 401, 'signature check failed, signature did not match key')
|
||||
|
||||
elif real_ip == ua_ip and wl_check(domain):
|
||||
|
@ -153,7 +153,7 @@ async def http_filter(app, handler):
|
|||
logging.warning(f'{domain} has started signing requests and can be removed from the whitelist')
|
||||
|
||||
if not signature and real_ip == ua_ip and wl_check(domain) and request.method == 'GET':
|
||||
logging.info(f'Signing fetch for whitelisted instance: {domain}')
|
||||
logging.debug(f'Signing fetch for whitelisted instance: {domain}')
|
||||
|
||||
HEADERS = {
|
||||
'(request-target)': f'get {request.path}',
|
||||
|
|
|
@ -53,7 +53,7 @@ def build_signing_string(headers, used_headers):
|
|||
|
||||
|
||||
def sign_signing_string(sigstring, key):
|
||||
if sigstring not in cache.sigstrings.items:
|
||||
if sigstring not in cache.sigstrings:
|
||||
pkcs = PKCS1_v1_5.new(key)
|
||||
h = SHA256.new()
|
||||
h.update(sigstring.encode('ascii'))
|
||||
|
@ -107,7 +107,7 @@ async def fetch_actor(uri, force=False):
|
|||
|
||||
|
||||
async def fetch_actor_key(actor):
|
||||
if actor not in cache.keys.items:
|
||||
if actor not in cache.keys:
|
||||
actor_data = await fetch_actor(actor)
|
||||
|
||||
if not actor_data:
|
||||
|
|
|
@ -71,8 +71,6 @@ async def get_login(request):
|
|||
token = request.cookies.get('paws_token')
|
||||
numid = random.randint(1*1000000, 10*1000000-1)
|
||||
|
||||
logging.warning(token)
|
||||
|
||||
if token and pawsdb.users.get(query.token == token):
|
||||
return aiohttp.web.HTTPFound('/paws')
|
||||
|
||||
|
@ -132,8 +130,6 @@ async def get_auth(request):
|
|||
if None in [numid, code]:
|
||||
return error(request, 500, 'Missing temporary userid or auth code')
|
||||
|
||||
logging.warning(redir)
|
||||
|
||||
if redir in ['', 'None', None]:
|
||||
redir = '/paws'
|
||||
|
||||
|
|
Loading…
Reference in a new issue