Skip to content

bastion,cmd/litebastion: add option to accept HTTP on localhost only - #39

Merged
FiloSottile merged 1 commit into
mainfrom
push-tzsuorpmnxxs
Nov 18, 2025
Merged

bastion,cmd/litebastion: add option to accept HTTP on localhost only#39
FiloSottile merged 1 commit into
mainfrom
push-tzsuorpmnxxs

Conversation

@FiloSottile

Copy link
Copy Markdown
Owner

Closes #38

@rgdd rgdd left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, just dropped two minor comments.

Also tested that my witness is able to connect to a bastion running this version, both with and without the -listen-http option. And when -listen-http is on, I'm failing to send non-backend queries on the public endpoint (but it works on the local endpoint).

(And agreed your patch looks better -- thanks for cleaning it up!)

Comment thread cmd/litebastion/README.md
arbitrary requests from the internet, you can accept request on localhost.
This is for example useful when running a bastion for your own log.

-listen-http PORT

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Renamed to -listen-http

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's what the README says? PORT is the placeholder.

serveGroup.Go(func() error {
<-ctx.Done()
slog.Info("shutting down bastion listener")
l.Close()

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor comment, but seeing this in the logs on ctrl-c shutdown:

time=2025-11-18T14:24:10.378Z level=INFO msg="shutting down bastion listener"
time=2025-11-18T14:24:10.378Z level=INFO msg="shutting down HTTP server"
time=2025-11-18T14:24:10.378Z level=INFO msg=exiting err="accept tcp ***.***.***.***:443: use of closed network connection"

I suppose because l is closed before hs? If i change the order I instead see:

time=2025-11-18T14:27:31.362Z level=INFO msg="shutting down HTTP server"
time=2025-11-18T14:27:31.362Z level=INFO msg="shutting down bastion listener"
time=2025-11-18T14:27:31.362Z level=INFO msg=exiting err="http: Server closed"

Which looks better? Anyway -- pick the order you prefer but at least wanted to call it out!

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Made it surface the signal context cancellation error, instead, and mailed https://go-review.googlesource.com/c/go/+/721700 upstream to make it more helpful.

Closes #38

Co-authored-by: Rasmus Dahlberg <rasmus@rgdd.se>
@FiloSottile
FiloSottile marked this pull request as ready for review November 18, 2025 16:29
@FiloSottile
FiloSottile merged commit 4324df3 into main Nov 18, 2025
16 checks passed
@FiloSottile
FiloSottile deleted the push-tzsuorpmnxxs branch November 18, 2025 17:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants