Skip to content
This repository has been archived by the owner on Oct 26, 2023. It is now read-only.

Commit

Permalink
Expose TFTP server listen address in config file and command line
Browse files Browse the repository at this point in the history
argument. resolves #151
  • Loading branch information
icb- committed Mar 13, 2017
2 parents 6cc6b51 + e026a4b commit 1a0b7a4
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 1 deletion.
5 changes: 5 additions & 0 deletions README.md
Expand Up @@ -74,6 +74,11 @@ The following are arguments that can be passed to `pypxe.server` when running fr
|__`--dhcp-fileserver-ip DHCP_FILESERVER_IP`__|Specify DHCP file server IP address|`192.168.2.2`|
|__`--dhcp-whitelist`__|Only serve clients specified in the static lease file (`--static-config`)|`False`|

##### TFTP Service Arguments

|Argument|Description|Default|
|---|---|---|
|__`--tftp-server-ip TFTP_SERVER_IP`__|Specify TFTP server IP address|`0.0.0.0`|

##### File Name/Directory Arguments

Expand Down
1 change: 1 addition & 0 deletions example_cfg.json
Expand Up @@ -25,6 +25,7 @@
"STATIC_CONFIG": "",
"SYSLOG_PORT": 514,
"SYSLOG_SERVER": null,
"TFTP_SERVER_IP": "192.168.2.2",
"USE_DHCP": true,
"USE_HTTP": false,
"USE_IPXE": false,
Expand Down
13 changes: 12 additions & 1 deletion pypxe/server.py
Expand Up @@ -35,6 +35,7 @@
'STATIC_CONFIG':'',
'SYSLOG_SERVER':None,
'SYSLOG_PORT':514,
'TFTP_SERVER_IP':'0.0.0.0',
'USE_IPXE':False,
'USE_HTTP':False,
'USE_TFTP':True,
Expand Down Expand Up @@ -108,6 +109,11 @@ def parse_cli_arguments():
nbd_group.add_argument('--nbd-server', action = 'store', dest = 'NBD_SERVER_IP', help = 'NBD Server IP', default = SETTINGS['NBD_SERVER_IP'])
nbd_group.add_argument('--nbd-port', action = 'store', dest = 'NBD_PORT', help = 'NBD Server Port', default = SETTINGS['NBD_PORT'])

# TFTP server arguments
tftp_group = parser.add_argument_group(title = 'TFTP', description = 'Arguments relevant to the TFTP server')
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()

def do_debug(service):
Expand Down Expand Up @@ -224,7 +230,12 @@ def main():
sys_logger.info('Starting TFTP server...')

# setup the thread
tftp_server = tftp.TFTPD(mode_debug = do_debug('tftp'), mode_verbose = do_verbose('tftp'), logger = tftp_logger, netboot_directory = args.NETBOOT_DIR)
tftp_server = tftp.TFTPD(
mode_debug = do_debug('tftp'),
mode_verbose = do_verbose('tftp'),
logger = tftp_logger,
netboot_directory = args.NETBOOT_DIR,
ip = args.TFTP_SERVER_IP)
tftpd = threading.Thread(target = tftp_server.listen)
tftpd.daemon = True
tftpd.start()
Expand Down

0 comments on commit 1a0b7a4

Please sign in to comment.