Add Windows Service support for TCP tunnel #479
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
Adds support for running Pomerium CLI TCP tunnel as a Windows service.
When built for Windows, this adds two new modes for the TCP tunnel.
When executed as a Windows service, it will setup the appropriate event loop to work as a windows service.
When launched from the CLI with the flag
-service
it will run as if it was running as a service to allow for debugging service scenarios.This allows for an idiomatic way to run a long-lived Pomerium CLI session. Naturally, if it is run as a system service it won't be able to launch a browser to sign-in so it probably only makes sense for routes that are unauthenticated.
The motivating use-case for this is to allow access to a service, behind a Pomerium server that requires mTLS but no further authentication, to clients that don't implement client cert authentication.
It does not change any existing functionality, neither on Windows or other platforms.
Code structure
First we move almost all code from
tcp.go
totcp_impl.go
.Then we make a slight refactoring to create the context outside the runTcp function and pass it as an argument instead.
Then we break out the init function and Cobra command definition to platform specific files.
The non-Windows one is essentially unchanged, except that move back the common parts of init to
tcp_impl.go
.The Windows variant adds code for handling the service and service emulation modes.
Related issues
None
Checklist
improvement
/bug
/ etc)