Better log format
This commit is contained in:
@@ -10,9 +10,6 @@ apps = Blueprint("matrix_appservice", __name__)
|
||||
# Endpoints invoked by the homeserver are put
|
||||
# lower than ones invoked by the appservice.
|
||||
|
||||
# This code is untested! Please test with
|
||||
# another homeserver and appservice, thanks!
|
||||
|
||||
|
||||
# https://spec.matrix.org/v1.16/application-service-api/#pinging
|
||||
# https://spec.matrix.org/v1.16/application-service-api/#pinging-1
|
||||
|
||||
@@ -459,8 +459,7 @@ async def upload_device_signing_keys():
|
||||
|
||||
@client.route('/_matrix/client/v3/keys/query', methods=['POST'])
|
||||
async def query_keys():
|
||||
# Should be replaced with
|
||||
# something proper eventually.
|
||||
# Should be replaced eventually
|
||||
return jsonify({})
|
||||
|
||||
|
||||
|
||||
20
src/main.py
20
src/main.py
@@ -1,4 +1,6 @@
|
||||
from flask import Flask, jsonify, request, redirect
|
||||
from datetime import datetime
|
||||
import logging
|
||||
import globals
|
||||
import config
|
||||
|
||||
@@ -9,6 +11,9 @@ from policy import policy
|
||||
from c2s import client
|
||||
from s2s import server
|
||||
|
||||
logging.getLogger("werkzeug").disabled = True
|
||||
logging.getLogger("flask").disabled = True
|
||||
|
||||
app = Flask(__name__)
|
||||
|
||||
app.register_blueprint(identity)
|
||||
@@ -18,6 +23,21 @@ app.register_blueprint(custom)
|
||||
app.register_blueprint(server)
|
||||
app.register_blueprint(apps)
|
||||
|
||||
@app.after_request
|
||||
async def handle_logging(response):
|
||||
try:
|
||||
if "Authorization" in request.headers:
|
||||
if request.headers["Authorization"].split()[0] == "X-Matrix":
|
||||
origin = request.headers["Authorization"].split('origin="')[1].split('"')[0]
|
||||
else:
|
||||
origin = "client"
|
||||
else:
|
||||
origin = "unknown"
|
||||
except:
|
||||
origin = "unknown"
|
||||
|
||||
print(f"[{origin}] [{request.remote_addr}] [{datetime.now().strftime('%d/%b/%Y:%H:%M:%S')}] {request.method} {request.path} {response.status_code}")
|
||||
return response
|
||||
|
||||
# Landing page
|
||||
@app.route("/")
|
||||
|
||||
14
src/s2s.py
14
src/s2s.py
@@ -1,4 +1,4 @@
|
||||
from flask import Flask, jsonify, Response, request, send_file, abort, Blueprint
|
||||
from flask import jsonify, Response, request, send_file, abort, Blueprint
|
||||
from config import *
|
||||
import globals
|
||||
import httpx
|
||||
@@ -356,8 +356,18 @@ def user_profile():
|
||||
|
||||
return jsonify({"avatar_url": f"mxc://{server_name}/cat","displayname": "Vona"})
|
||||
|
||||
|
||||
# https://spec.matrix.org/v1.16/server-server-api/#device-management
|
||||
@server.route('/_matrix/federation/v1/user/devices/<user>')
|
||||
def user_devices(user):
|
||||
async def user_devices(user):
|
||||
return jsonify({
|
||||
"devices": [],
|
||||
"stream_id": the_funny_number,
|
||||
"user_id": f"@vona:{server_name}"
|
||||
})
|
||||
|
||||
@server.route(f'/_matrix/federation/v1/user/devices/@/:{server_name}')
|
||||
async def user_devices_fuck_flask():
|
||||
return jsonify({
|
||||
"devices": [],
|
||||
"stream_id": the_funny_number,
|
||||
|
||||
Reference in New Issue
Block a user