Skip to content

Commit 22723de

Browse files
committed
feat: metadata service: make turnserver socket path configurable
1 parent 26a13fb commit 22723de

4 files changed

Lines changed: 10 additions & 5 deletions

File tree

chatmaild/src/chatmaild/config.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ def __init__(self, inipath, params):
6666
self.acme_email = params.get("acme_email", "")
6767
self.imap_rawlog = params.get("imap_rawlog", "false").lower() == "true"
6868
self.imap_compress = params.get("imap_compress", "false").lower() == "true"
69+
self.turn_socket_path = params.get("turn_socket_path", "/run/chatmail-turn/turn.socket")
6970
if "iroh_relay" not in params:
7071
self.iroh_relay = "https://" + raw_domain
7172
self.enable_iroh_relay = True

chatmaild/src/chatmaild/ini/chatmail.ini.f

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,10 @@
6363
# Deployment Details
6464
#
6565

66-
# SMTP outgoing filtermail and reinjection
66+
# Path to the TURN server Unix socket
67+
turn_socket_path = /run/chatmail-turn/turn.socket
68+
69+
# SMTP outgoing filtermail and reinjection
6770
filtermail_smtp_port = 10080
6871
postfix_reinject_port = 10025
6972

chatmaild/src/chatmaild/metadata.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,12 +79,13 @@ def get_tokens_for_addr(self, addr):
7979

8080

8181
class MetadataDictProxy(DictProxy):
82-
def __init__(self, notifier, metadata, iroh_relay=None, turn_hostname=None):
82+
def __init__(self, notifier, metadata, iroh_relay=None, turn_hostname=None, turn_socket_path):
8383
super().__init__()
8484
self.notifier = notifier
8585
self.metadata = metadata
8686
self.iroh_relay = iroh_relay
8787
self.turn_hostname = turn_hostname
88+
self.turn_socket_path = turn_socket_path
8889

8990
def handle_lookup(self, parts):
9091
# Lpriv/43f5f508a7ea0366dff30200c15250e3/devicetoken\tlkj123poi@c2.testrun.org
@@ -101,7 +102,7 @@ def handle_lookup(self, parts):
101102
return f"O{self.iroh_relay}\n"
102103
case "turn":
103104
try:
104-
res = turn_credentials()
105+
res = turn_credentials(self.turn_socket_path)
105106
except Exception:
106107
logging.exception("failed to get TURN credentials")
107108
return "N\n"

chatmaild/src/chatmaild/turnserver.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22
import socket
33

44

5-
def turn_credentials() -> str:
5+
def turn_credentials(turn_socket_path) -> str:
66
with socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) as client_socket:
77
client_socket.settimeout(5)
8-
client_socket.connect("/run/chatmail-turn/turn.socket")
8+
client_socket.connect(turn_socket_path)
99
with client_socket.makefile("rb") as file:
1010
return file.readline().decode("utf-8").strip()

0 commit comments

Comments
 (0)