TailscaleTransport
View SourceA transport for ThousandIsland that allows exposing services directly to your tailnet.
An example application can be found in tschat.
In addition to the transport itself, this package also provides an
authentication plug TailscaleTransport.Plug
which gets information about
connecting clients using Tailscales LocalAPI.
This module is based in the libtailscale
NIF
wrapper and
gen_tailscale
.
Everything in this chain of packages should be considered proof of concept at
this point and should not be used for anything important. Especially
gen_tailscale
, which has been constructed by crudely hacking the original
gen_tcp
module to use libtailscale
and could use a total rewrite at some
point. However, it works well enough that my example application
tschat
is able to accept connections
from different Tailscale users and show their username by retrieving data from
the Tailscale connection.
Installation
The package can be installed by adding tailscale_transport
to your list of
dependencies in mix.exs
:
def deps do
[
{:tailscale_transport, "~> 0.1.0"}
]
end
Usage
In your config/config.exs
, when defining your endpoint, specify that you want
to use the TailscaleTransport
module as the transport module for
ThousandIsland
:
config :my_app, MyAppWeb.Endpoint,
url: [host: "my-app"],
adapter: Bandit.PhoenixAdapter,
...
http: [
thousand_island_options: [
transport_module: TailscaleTransport,
transport_options: [hostname: "my-app"]
]
]
Notice that you need to specify the same hostname in the url
parameter and as
the hostname
parameter to the transport_options
option.