Skip to content

Commit

Permalink
Make bound host configurable (#60)
Browse files Browse the repository at this point in the history
Was about to run this in a coffee shop and realised it's binding to all
addresses by default :P

Not sure if worthwhile just making the default 127.0.0.1 as well, so
binding further is an explicit move. Happy to adjust, I think that'd
make sense to me as well but would be a breaking change
  • Loading branch information
Ianyliu authored Oct 20, 2024
2 parents 9f271b0 + 5c6b000 commit 9092f19
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -84,12 +84,12 @@ blast-radius --serve /path/to/terraform/directory

And you will shortly be rewarded with a browser link http://127.0.0.1:5000/.

[//]: # (You can specify the port number with the `--port` flag:)
[//]: # (You can specify the host and/or port number with the `--host` and --port` flags:)

[//]: # ()
[//]: # (```)

[//]: # (blast-radius --serve /path/to/terraform/directory --port=8080)
[//]: # (blast-radius --serve /path/to/terraform/directory --host 127.0.0.1 --port=8080)

[//]: # (```)

Expand Down Expand Up @@ -179,6 +179,7 @@ minikube service k8-blast-radius-service
* Directory: Defaults to `$PWD` or current directory. The directory in which to look for Terraform files.
This is required if the user wants to use a Terraform project as input
(instead of uploading a file or pasting DOT script).
* `--host`: Defaults to 0.0.0.0. The IP address to bind to, to access the app (http://HOST:5000)
* `--port`: Defaults to 5000. The port to access the app (http://localhost:PORT)
Any valid localhost port is allowed.
* `--serve`: Starts a webserver locally with Terraform's interactive graph
Expand Down
5 changes: 3 additions & 2 deletions bin/blast-radius
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ def main():

parser = parser = argparse.ArgumentParser(description='blast-radius: Interactive Terraform Graph Visualizations')
parser.add_argument('directory', type=str, help='terraform configuration directory', default=os.getcwd(), nargs='?')
parser.add_argument('--host', type=str, help='specify an IP to bind to other than the default 0.0.0.0', default=os.getenv('BLAST_RADIUS_HOST','0.0.0.0'))
parser.add_argument('--port', type=int, help='specify a port other than the default 5000', default=os.getenv('BLAST_RADIUS_PORT',5000))

output_group = parser.add_mutually_exclusive_group()
Expand All @@ -47,11 +48,11 @@ def main():
if args.serve:
if args.graph == sys.stdin:
os.chdir(args.directory)
app.run(host='0.0.0.0',port=args.port)
app.run(host=args.host,port=args.port)
sys.exit(0)
else:
os.chdir(args.directory)
app.run(host='0.0.0.0',port=args.port)
app.run(host=args.host,port=args.port)
sys.exit(0)

elif args.json or args.dot or args.svg:
Expand Down

0 comments on commit 9092f19

Please sign in to comment.