diff --git a/README.md b/README.md index 16472b9..a977c5d 100644 --- a/README.md +++ b/README.md @@ -46,13 +46,16 @@ Enter the project's directory, then install the required packages by running: pip install -r requirements.txt ``` -While in the directory of the project, run ` python server.py` to start the server. Pass in as parameters the IP address `--ip` of the ATEM switcher and a simple passphrase `--passphrase` for high level authentication. +While in the directory of the project, run ` python server.py` to start the server. Pass in as parameters the IP address `--ip` of the ATEM switcher, optionally a simple passphrase `--passphrase` for high level authentication, and optionally the port `--port` to run the server on (defaults to `5555`). The passphrase is optional. If you do not include a passphrase, one will not be required. If you do use a passphrase, make sure to pass it in with your requests in the Authorization header (see below for an example). +The port is also optional. If you do not include a port, the server will run on port `5555`. If running via Docker, you can also map the port to a different port on the host machine using docker. + + ```bash -python server.py --ip 127.0.0.1 --passphrase Password1` -```` +python server.py --ip 127.0.0.1 --passphrase Password1 --port 5555 +``` > [!WARNING] > Passing sensitive data in the command line will result in the passphrase being in plaintext in command line history logs such as in `.bash_history`, other Linux/Mac shell histories, or `$env:APPDATA\Microsoft\Windows\PowerShell\PSReadLine` in Windows. This probably doesn't matter for most users, but if you're concerned about it, you can use the following methods to pass in sensitive data: diff --git a/server.py b/server.py index 9270068..b3758b8 100644 --- a/server.py +++ b/server.py @@ -107,12 +107,14 @@ def main(): parser = argparse.ArgumentParser() parser.add_argument('--ip', help='switcher IP address') parser.add_argument('--passphrase', help='passphrase to compare requests to', type=str, default='') + parser.add_argument('--port', help='port to start server on', type=int, default=5555) args = parser.parse_args() # set global variables global passphrase, ip passphrase = os.environ.get('PASSPHRASE', args.passphrase) ip = os.environ.get('SERVER_IP', args.ip) + preferred_port = os.environ.get('PORT', args.port) # if no ip is provided, exit if ip is None: @@ -123,6 +125,11 @@ def main(): log.info("No passphrase provided, using no passphrase") passphrase = '' + if preferred_port is None: + # if the default port is not + log.info("No port provided, using default port 5555") + preferred_port = 5555 + log.info("Initializing switcher") switcher.setLogLevel(logging.INFO) # Set switcher verbosity (try DEBUG to see more) switcher.connect(ip) @@ -135,7 +142,7 @@ def main(): # this is the object which take port # number and the server-name # for running the server - port = ThreadingHTTPServer(('', 5555), GFG) + port = ThreadingHTTPServer(('', preferred_port), GFG) # this is used for running our # server as long as we wish