kopia lustrzana https://github.com/snarfed/bridgy-fed
add temporary python eval debugging endpoint to all three services
rodzic
9682b599cf
commit
a5371582b1
|
|
@ -22,6 +22,7 @@ import activitypub, atproto, web
|
|||
import atproto_firehose
|
||||
import common
|
||||
import models
|
||||
import pages
|
||||
|
||||
# as of 2024-07-10
|
||||
BSKY_TEAM_CIDRS = (
|
||||
|
|
|
|||
|
|
@ -7,14 +7,17 @@ dispatch:
|
|||
- url: "*/queue/atproto-commit"
|
||||
service: atproto-hub
|
||||
|
||||
- url: "*/hub/*"
|
||||
service: atproto-hub
|
||||
|
||||
- url: "*/queue/*"
|
||||
service: router
|
||||
|
||||
- url: "*/cron/*"
|
||||
service: router
|
||||
|
||||
- url: "*/router/*"
|
||||
service: router
|
||||
|
||||
- url: "*/xrpc/com.atproto.sync.subscribeRepos"
|
||||
service: atproto-hub
|
||||
|
||||
# - url: "*/xrpc/com.atproto.sync.getRepo"
|
||||
# service: atproto-sync
|
||||
|
|
|
|||
22
pages.py
22
pages.py
|
|
@ -449,3 +449,25 @@ def memcache_command():
|
|||
resp = memcache.memcache.raw_command(request.get_data(as_text=True),
|
||||
end_tokens='END\r\n')
|
||||
return resp.decode(), {'Content-Type': 'text/plain'}
|
||||
|
||||
|
||||
@app.post('/eval/<any(app,hub,router):which>')
|
||||
def python_eval(which=None):
|
||||
if request.headers.get('Authorization') != app.config['SECRET_KEY']:
|
||||
return '', 401
|
||||
|
||||
import contextlib, io, traceback
|
||||
|
||||
input = request.get_data(as_text=True)
|
||||
logger.info(f'python_eval got: {input}')
|
||||
|
||||
out = io.StringIO()
|
||||
with contextlib.redirect_stdout(out), contextlib.redirect_stderr(out):
|
||||
try:
|
||||
exec(input)
|
||||
except BaseException as e:
|
||||
traceback.print_exception(e, file=out)
|
||||
finally:
|
||||
output = out.getvalue()
|
||||
logger.info(f'python_eval out: {output}')
|
||||
return output, {'Content-Type': 'text/plain'}
|
||||
|
|
|
|||
|
|
@ -13,6 +13,7 @@ from oauth_dropins.webutil import (
|
|||
import activitypub, atproto, web
|
||||
import common
|
||||
import models
|
||||
import pages
|
||||
import protocol
|
||||
|
||||
models.reset_protocol_properties()
|
||||
|
|
|
|||
Ładowanie…
Reference in New Issue