httpts

package module
v0.0.0-...-57d97e3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 30, 2024 License: BSD-3-Clause Imports: 16 Imported by: 0

README

httpts is a Go package to make it easy to serve http on a tailnet

Documentation

Overview

Package httpts provides an HTTP server that runs on a Tailscale tailnet.

Every http.Request context served by this package has httpts.Who attached to it, telling you who is calling.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CreateAuthKey

func CreateAuthKey(ctx context.Context, clientSecret string, deviceCaps tailscale.KeyDeviceCreateCapabilities) (string, error)

Types

type Server

type Server struct {
	// Handler answers requests from the tailnet.
	Handler http.Handler

	// FunnelHandler, if non-nil, answers requsts from the internet via Tailscale Funnel.
	// Unused if InsecureLocalPortOnly is true.
	FunnelHandler http.Handler

	// InsecureLocalPortOnly, if non-zero, means that no tsnet server is started
	// and instead the server listens over http:// on the specified 127.0.0.1 port.
	// It is insecure because all localhost handling is passed to Handler.
	InsecureLocalPortOnly int

	// StateStore, if non-nil, is used to store state for the tailscale client.
	StateStore ipn.StateStore

	AdvertiseTags []string

	// OauthClientSecret is used to authenticate the node if it is not already.
	// Create one at https://login.tailscale.com/admin/settings/oauth.
	// The client must be created with a tag that matches AdvertiseTags.
	// Note that the client secret must start with `tskey-client-`.
	//
	// Ignored if AuthKey is non-empty.
	//
	// Do not pass an OauthClientSecret to a server that you do not trust
	// to add nodes to your tailnet.
	OauthClientSecret string

	// AuthKey, if non-empty, is the auth key to create the node.
	AuthKey string
	// contains filtered or unexported fields
}

Server is a drop-in for http.Server that serves a Handler on a tailnet.

func (*Server) Dial

func (s *Server) Dial(ctx context.Context, network, address string) (net.Conn, error)

Dial dials the address on the tailnet.

func (*Server) Serve

func (s *Server) Serve(tsHostname string) error

Serve serves :443 and a :80 redirect on a tailnet.

func (*Server) Shutdown

func (s *Server) Shutdown(ctx context.Context) error

Shutdown shuts down the HTTP server and Tailscale client.

type Who

type Who struct {
	LoginName string
	PeerCap   tailcfg.PeerCapMap
}

Who is attached to every http.Request context naming the HTTP client.

func WhoFromCtx

func WhoFromCtx(ctx context.Context) *Who

Directories

Path Synopsis
cmd
tailweb
The tailweb command serves out the current directory to your tailnet.
The tailweb command serves out the current directory to your tailnet.
internal
tsnet
Package tsnet provides Tailscale as a library.
Package tsnet provides Tailscale as a library.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL