mirror of
https://github.com/chatmail/relay.git
synced 2026-05-19 20:38:05 +00:00
remove startup/socket setup from metadata
This commit is contained in:
@@ -23,7 +23,7 @@ class DictProxy:
|
|||||||
wfile.flush()
|
wfile.flush()
|
||||||
|
|
||||||
def handle_dovecot_request(self, msg):
|
def handle_dovecot_request(self, msg):
|
||||||
# see https://doc.dovecot.org/3.0/developer_manual/design/dict_protocol/
|
# see https://doc.dovecot.org/developer_manual/design/dict_protocol/#dovecot-dict-protocol
|
||||||
short_command = msg[0]
|
short_command = msg[0]
|
||||||
parts = msg[1:].split("\t")
|
parts = msg[1:].split("\t")
|
||||||
|
|
||||||
@@ -67,10 +67,7 @@ class DictProxy:
|
|||||||
self.transactions[transaction_id]["res"] = "F\n"
|
self.transactions[transaction_id]["res"] = "F\n"
|
||||||
|
|
||||||
def handle_commit_transaction(self, transaction_id, parts):
|
def handle_commit_transaction(self, transaction_id, parts):
|
||||||
# each set devicetoken operation persists directly
|
# return whatever "set" command(s) set as result.
|
||||||
# and does not wait until a "commit" comes
|
|
||||||
# because our dovecot config does not involve
|
|
||||||
# multiple set-operations in a single commit
|
|
||||||
return self.transactions.pop(transaction_id)["res"]
|
return self.transactions.pop(transaction_id)["res"]
|
||||||
|
|
||||||
def serve_forever_from_socket(self, socket):
|
def serve_forever_from_socket(self, socket):
|
||||||
|
|||||||
@@ -1,11 +1,5 @@
|
|||||||
import logging
|
import logging
|
||||||
import os
|
|
||||||
import sys
|
import sys
|
||||||
from socketserver import (
|
|
||||||
StreamRequestHandler,
|
|
||||||
ThreadingMixIn,
|
|
||||||
UnixStreamServer,
|
|
||||||
)
|
|
||||||
|
|
||||||
from .config import read_config
|
from .config import read_config
|
||||||
from .dictproxy import DictProxy
|
from .dictproxy import DictProxy
|
||||||
@@ -83,10 +77,6 @@ class MetadataDictProxy(DictProxy):
|
|||||||
self.transactions[transaction_id]["res"] = "F\n"
|
self.transactions[transaction_id]["res"] = "F\n"
|
||||||
|
|
||||||
|
|
||||||
class ThreadedUnixStreamServer(ThreadingMixIn, UnixStreamServer):
|
|
||||||
request_queue_size = 100
|
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
socket, config_path = sys.argv[1:]
|
socket, config_path = sys.argv[1:]
|
||||||
|
|
||||||
@@ -108,21 +98,4 @@ def main():
|
|||||||
notifier=notifier, metadata=metadata, iroh_relay=iroh_relay
|
notifier=notifier, metadata=metadata, iroh_relay=iroh_relay
|
||||||
)
|
)
|
||||||
|
|
||||||
class Handler(StreamRequestHandler):
|
dictproxy.serve_forever_from_socket(socket)
|
||||||
def handle(self):
|
|
||||||
try:
|
|
||||||
dictproxy.loop_forever(self.rfile, self.wfile)
|
|
||||||
except Exception:
|
|
||||||
logging.exception("Exception in the dovecot dictproxy handler")
|
|
||||||
raise
|
|
||||||
|
|
||||||
try:
|
|
||||||
os.unlink(socket)
|
|
||||||
except FileNotFoundError:
|
|
||||||
pass
|
|
||||||
|
|
||||||
with ThreadedUnixStreamServer(socket, Handler) as server:
|
|
||||||
try:
|
|
||||||
server.serve_forever()
|
|
||||||
except KeyboardInterrupt:
|
|
||||||
pass
|
|
||||||
|
|||||||
Reference in New Issue
Block a user