diff --git a/daemon.py b/daemon.py index c16fb94d8..b8bc46efd 100644 --- a/daemon.py +++ b/daemon.py @@ -643,7 +643,8 @@ def run_daemon(accounts_data_dir: str, manual_follower_approval: bool, watermark_width_percent: int, watermark_position: str, - watermark_opacity: int) -> None: + watermark_opacity: int, + bind_to_ip_address: str) -> None: if len(domain) == 0: domain = 'localhost' if '.' not in domain: @@ -657,7 +658,10 @@ def run_daemon(accounts_data_dir: str, server_address = (domain, proxy_port) pub_handler = partial(PubServerUnitTest) else: - server_address = ('', proxy_port) + if not bind_to_ip_address: + server_address = ('', proxy_port) + else: + server_address = (bind_to_ip_address, proxy_port) pub_handler = partial(PubServer) if accounts_data_dir: diff --git a/epicyon.py b/epicyon.py index 932a6c2ac..dd1c8f5bc 100644 --- a/epicyon.py +++ b/epicyon.py @@ -251,6 +251,9 @@ def _command_options() -> None: parser.add_argument('-p', '--port', dest='port', type=int, default=None, help='Port number to run on') + parser.add_argument('--bind', dest='bind_to_ip_address', type=str, + default='', + help='Bind the HTTP server to an IP address') parser.add_argument('--expiryDays', dest='expiryDays', type=int, default=None, help='Number of days after which posts expire ' + @@ -4147,4 +4150,5 @@ if __name__ == "__main__": not argb2.noapproval, argb2.watermark_width_percent, argb2.watermark_position, - argb2.watermark_opacity) + argb2.watermark_opacity, + argb2.bind_to_ip_address) diff --git a/tests.py b/tests.py index 3a0fc7ccb..0c3981015 100644 --- a/tests.py +++ b/tests.py @@ -897,6 +897,7 @@ def create_server_alice(path: str, domain: str, port: int, watermark_width_percent = 30 watermark_position = 'east' watermark_opacity = 10 + bind_to_ip_address = '' print('Server running: Alice') run_daemon(accounts_data_dir, no_of_books, public_replies_unlisted, @@ -929,7 +930,7 @@ def create_server_alice(path: str, domain: str, port: int, domain_max_posts_per_day, account_max_posts_per_day, allow_deletion, True, True, False, send_threads, False, watermark_width_percent, - watermark_position, watermark_opacity) + watermark_position, watermark_opacity, bind_to_ip_address) def create_server_bob(path: str, domain: str, port: int, @@ -1087,6 +1088,7 @@ def create_server_bob(path: str, domain: str, port: int, watermark_width_percent = 30 watermark_position = 'east' watermark_opacity = 10 + bind_to_ip_address = '' print('Server running: Bob') run_daemon(accounts_data_dir, no_of_books, public_replies_unlisted, @@ -1119,7 +1121,7 @@ def create_server_bob(path: str, domain: str, port: int, domain_max_posts_per_day, account_max_posts_per_day, allow_deletion, True, True, False, send_threads, False, watermark_width_percent, - watermark_position, watermark_opacity) + watermark_position, watermark_opacity, bind_to_ip_address) def create_server_eve(path: str, domain: str, port: int, federation_list: [], @@ -1185,6 +1187,7 @@ def create_server_eve(path: str, domain: str, port: int, federation_list: [], watermark_width_percent = 30 watermark_position = 'east' watermark_opacity = 10 + bind_to_ip_address = '' print('Server running: Eve') run_daemon(accounts_data_dir, no_of_books, public_replies_unlisted, @@ -1239,7 +1242,7 @@ def create_server_eve(path: str, domain: str, port: int, federation_list: [], send_threads, False, watermark_width_percent, watermark_position, - watermark_opacity) + watermark_opacity, bind_to_ip_address) def create_server_group(path: str, domain: str, port: int, @@ -1307,6 +1310,7 @@ def create_server_group(path: str, domain: str, port: int, watermark_width_percent = 30 watermark_position = 'east' watermark_opacity = 10 + bind_to_ip_address = '' print('Server running: Group') run_daemon(accounts_data_dir, no_of_books, public_replies_unlisted, @@ -1339,7 +1343,7 @@ def create_server_group(path: str, domain: str, port: int, domain_max_posts_per_day, account_max_posts_per_day, allow_deletion, True, True, False, send_threads, False, watermark_width_percent, - watermark_position, watermark_opacity) + watermark_position, watermark_opacity, bind_to_ip_address) def test_post_message_between_servers(base_dir: str) -> None: