mirror of
https://github.com/chatmail/relay.git
synced 2026-05-19 12:28:06 +00:00
report back on ip determination -- deal with failure to obtain ip address
This commit is contained in:
@@ -15,7 +15,7 @@ from subprocess import CalledProcessError, check_output
|
|||||||
|
|
||||||
|
|
||||||
def shell(command, fail_ok=False):
|
def shell(command, fail_ok=False):
|
||||||
log(f"$ {command}")
|
print(f"$ {command}")
|
||||||
try:
|
try:
|
||||||
return check_output(command, shell=True).decode().rstrip()
|
return check_output(command, shell=True).decode().rstrip()
|
||||||
except CalledProcessError:
|
except CalledProcessError:
|
||||||
@@ -56,7 +56,14 @@ def get_dkim_entry(mail_domain, dkim_selector):
|
|||||||
def get_ip_address(typ):
|
def get_ip_address(typ):
|
||||||
sock = socket.socket(typ, socket.SOCK_DGRAM)
|
sock = socket.socket(typ, socket.SOCK_DGRAM)
|
||||||
sock.settimeout(0)
|
sock.settimeout(0)
|
||||||
sock.connect(("notifications.delta.chat", 1))
|
host_port = "notifications.delta.chat", 443
|
||||||
|
try:
|
||||||
|
sock.connect(host_port)
|
||||||
|
except OSError:
|
||||||
|
print(f"failed to connect to: {host_port}")
|
||||||
|
return None
|
||||||
|
else:
|
||||||
|
print(f"successfully connected to: {host_port}")
|
||||||
return sock.getsockname()[0]
|
return sock.getsockname()[0]
|
||||||
|
|
||||||
|
|
||||||
@@ -96,7 +103,7 @@ def check_zonefile(zonefile):
|
|||||||
|
|
||||||
if __name__ == "__channelexec__":
|
if __name__ == "__channelexec__":
|
||||||
|
|
||||||
def log(item):
|
def print(item):
|
||||||
channel.send(("log", item)) # noqa
|
channel.send(("log", item)) # noqa
|
||||||
|
|
||||||
while 1:
|
while 1:
|
||||||
|
|||||||
Reference in New Issue
Block a user