From 90c263d618cbefa075275333c217995964b4456b Mon Sep 17 00:00:00 2001 From: Andres Gomez Date: Tue, 5 Apr 2022 22:46:50 +0300 Subject: [PATCH] server: enable TFTP port from CLI --- README.md | 1 + example_cfg.json | 1 + pypxe/server.py | 3 +++ 3 files changed, 5 insertions(+) diff --git a/README.md b/README.md index f9ba7b6..af53ea1 100644 --- a/README.md +++ b/README.md @@ -77,6 +77,7 @@ The following are arguments that can be passed to `pypxe.server` when running fr |Argument|Description|Default| |---|---|---| |__`--tftp-server-ip TFTP_SERVER_IP`__|Specify TFTP server IP address|`0.0.0.0`| +|__`--tftp-port TFTP_PORT`__|Specify TFTP server Port|69| ##### HTTP Service Arguments diff --git a/example_cfg.json b/example_cfg.json index f97c74e..a80573f 100644 --- a/example_cfg.json +++ b/example_cfg.json @@ -27,6 +27,7 @@ "STATIC_CONFIG": "", "SYSLOG_PORT": 514, "SYSLOG_SERVER": null, + "TFTP_PORT": 69, "TFTP_SERVER_IP": "192.168.2.2", "USE_DHCP": true, "USE_HTTP": false, diff --git a/pypxe/server.py b/pypxe/server.py index 89ee15d..4c1767f 100755 --- a/pypxe/server.py +++ b/pypxe/server.py @@ -38,6 +38,7 @@ 'STATIC_CONFIG':'', 'SYSLOG_SERVER':None, 'SYSLOG_PORT':514, + 'TFTP_PORT':69, 'TFTP_SERVER_IP':'0.0.0.0', 'USE_IPXE':False, 'USE_HTTP':False, @@ -118,6 +119,7 @@ def parse_cli_arguments(): # TFTP server arguments tftp_group = parser.add_argument_group(title = 'TFTP', description = 'Arguments relevant to the TFTP server') + tftp_group.add_argument('--tftp-port', action = 'store', dest = 'TFTP_PORT', help = 'TFTP Server Port', default = SETTINGS['TFTP_PORT']) tftp_group.add_argument('--tftp-server-ip', action = 'store', dest = 'TFTP_SERVER_IP', help = 'TFTP Server IP', default = SETTINGS['TFTP_SERVER_IP']) return parser.parse_args() @@ -225,6 +227,7 @@ def main(): mode_verbose = do_verbose('tftp'), logger = tftp_logger, netboot_directory = args.NETBOOT_DIR, + port = args.TFTP_PORT, ip = args.TFTP_SERVER_IP) tftpd = threading.Thread(target = tftp_server.listen) tftpd.daemon = True