You've already forked ztchooks-py
mirror of
https://github.com/zerotier/ztchooks-py.git
synced 2026-05-22 16:29:44 -07:00
20 lines
543 B
Python
20 lines
543 B
Python
from flask import Flask, request, Response
|
|
from ztchooks.hook import verify_hook_signature
|
|
from datetime import timedelta
|
|
|
|
app = Flask(__name__)
|
|
|
|
psk = bytes.fromhex('<insert_your_pre_shared_key_here')
|
|
|
|
@app.route("/webhook", methods=['POST'])
|
|
def webhook():
|
|
sigHeader = request.headers['X-ZTC-Signature']
|
|
body = request.data
|
|
|
|
print("HEADER: ", sigHeader)
|
|
print("BODY: ", body)
|
|
|
|
if verify_hook_signature(psk, sigHeader, body, timedelta(weeks=65535)):
|
|
return Response(status=200)
|
|
|
|
return Response(status=403) |