https://github.com/loft-sh/tunnel
This is a library that simplifies the implementation and integration of a Tailscale control server into your Go application.
https://github.com/loft-sh/tunnel
loft tailscale tailscale-control-server
Last synced: 9 months ago
JSON representation
This is a library that simplifies the implementation and integration of a Tailscale control server into your Go application.
- Host: GitHub
- URL: https://github.com/loft-sh/tunnel
- Owner: loft-sh
- License: apache-2.0
- Archived: true
- Created: 2023-10-06T12:10:57.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2025-02-03T00:43:08.000Z (11 months ago)
- Last Synced: 2025-02-23T03:31:42.886Z (11 months ago)
- Topics: loft, tailscale, tailscale-control-server
- Language: Go
- Homepage:
- Size: 6.41 MB
- Stars: 8
- Watchers: 8
- Forks: 0
- Open Issues: 5
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Tailscale Coordinator Library
This is a library that simplifies the implementation and integration of a control
server for Tailscale into your Go application.
## Disclaimer
This project is not affiliated with Tailscale or Tailscale Inc., and it is not an
official Tailscale or Tailscale Inc. project.
## Installation
You can install the library using the `go get` command:
```bash
go get github.com/loft-sh/tunnel
```
## Usage
There are two main ways to use this library: as a standalone library in your Go
code, or as an in-memory coordinator for end-to-end testing.
### Using the Library in Your Go Code
To use the library in your Go code, you'll need to import it and implement the
Tailscale coordinator interface.
```go
package main
import (
"net/http"
"github.com/loft-sh/tunnel"
"github.com/loft-sh/tunnel/handlers"
)
func main() {
coordinator := NewCoordinator()
router := http.NewServeMux()
router.Handle("/", handlers.CoordinatorHandler(coordinator))
if err := http.ListenAndServe(":3000", router); err != nil {
panic(err)
}
}
func NewCoordinator() tunnel.Coordinator {
// Your coordinator implementation gets instantiated here
// ...
}
```
### Using the In-Memory Coordinator
We also provide an in-memory control server, which is useful for running end-to-end
tests in a continuous integration or test environment. This server comes with
pre-configured profiles and nodes.
You can find an example of this server in the [examples/coordinator/](./examples/coordinator/)
directory.
To configure the server, edit the [config file](./examples/coordinator/config.json).
Then, run the server with the following commands:
```bash
cd examples/coordinator
go run server.go
```
## Inspiration
This project was inspired by open-source Tailscale control server implementations
such as [Headscale](https://headscale.net) and [Ionscale](https://jsiebens.github.io/ionscale/).