Command option to bind to an ip address

main
Bob Mottram 2024-09-14 13:56:48 +01:00
parent caae61d33f
commit 5ce8e1e101
3 changed files with 19 additions and 7 deletions

View File

@ -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:

View File

@ -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)

View File

@ -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: