Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[vnet] install and run windows service #50468

Draft
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

nklaassen
Copy link
Contributor

This commit adds a Windows service for VNet. It adds support for automatically installing and running the service when the user runs tsh vnet, and adds a command to manually uninstall/delete the service.

The service creates the TUN interface and establishes an IPC connection with the user process over a named pipe, but for now does not actually handle any networking, the rest will come in later PRs.

If you want to test this out on a Windows machine/VM, you should be able to run tsh vnet and see that:

  1. A service TeleportVNet is installed and runs sc.exe query state=all | grep -A3 Teleport
  2. The service writes logs to logs.txt in the directory where tsh is installed (this is temporary until I find a better place for logs).
  3. A TUN interface is created netsh interface show interface
  4. The service stops and the interface is cleaned up when the user process exits.

Unfortunately this PR does not include any unit tests. Most of the functionality here needs to be able to escalate to administrator with a UAC prompt and needs to run on Windows, this is exactly the kind of unit test that is very hard to write and would never actually be able to run in CI.
But, any part of this that's broken would immediately break VNet on Windows, and this should be caught in any test plan.

This commit adds a Windows service for VNet. It adds support for
automatically installing and running the service when the user runs
`tsh vnet`, and adds a command to manually uninstall/delete the service.

The service creates the TUN interface and establishes an IPC connection
with the user process over a named pipe, but for now does not actually
handle any networking, the rest will come in later PRs.

If you want to test this out on a Windows machine/VM, you should be able
to run `tsh vnet` and see that:
1. A service TeleportVNet is installed and runs
   `sc.exe query state=all | grep -A3 Teleport`
2. The service writes logs to `logs.txt` in the directory where `tsh` is
   installed (this is temporary until I find a better place for logs).
3. A TUN interface is created `netsh interface show interface`
4. The service stops and the interface is cleaned up when the user
   process exits.

Unfortunately this PR does not include any unit tests. Most of the
functionality here needs to be able to escalate to administrator with a
UAC prompt and needs to run on Windows, this is exactly the kind of unit
test that is very hard to write and would never actually be able to run
in CI.
But, any part of this that's broken would immediately break VNet on
Windows, and this should be caught in any test plan.
@nklaassen nklaassen added the no-changelog Indicates that a PR does not require a changelog entry label Dec 20, 2024
@nklaassen
Copy link
Contributor Author

cc @ravicious, I'm once again refactoring a bunch of stuff

@github-actions github-actions bot added size/md tsh tsh - Teleport's command line tool for logging into nodes running Teleport. labels Dec 20, 2024
@ravicious ravicious self-requested a review December 20, 2024 08:35
@nklaassen nklaassen marked this pull request as draft December 28, 2024 01:18
@nklaassen
Copy link
Contributor Author

converting back to draft, i'll probably end up closing this, thinking i will switch to a COM service and a TCP socket

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
no-changelog Indicates that a PR does not require a changelog entry size/md tsh tsh - Teleport's command line tool for logging into nodes running Teleport.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant