remote

package
v0.2.10 Latest Latest
Warning

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

Go to latest
Published: Nov 19, 2026 License: AGPL-3.0 Imports: 29 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package remote makes a home server reachable from the internet without router setup: it asks the router to forward a port (UPnP or NAT-PMP), gets a Let's Encrypt certificate for the router's public IP address, and serves the API over HTTPS there. The apps learn the address while at home (GET /api/v1/server) and use it when they're away.

When the router won't open ports, an admin can forward one by hand (SetForwardedPort). While it's ready, the server registers its address with the connect service, so the apps can find it after the address changes (internal/connect). Media never goes through anything but this port: when the internet provider shares one public address among customers, or a second router is in the way, Status says what to change.

Index

Constants

View Source
const (
	StateOff     = "off"
	StateWorking = "working"
	StateReady   = "ready"
	StateFailed  = "failed"
)
View Source
const (
	ConnectNone     = "none"
	ConnectCheckout = "checkout"
	ConnectActive   = "active"
	ConnectEnded    = "ended"
)

Variables

View Source
var (
	ErrNoBilling    = errors.New("this server doesn't use Matinee Connect")
	ErrNoSubscriber = errors.New("this server has no Matinee Connect subscription bought in its settings")
)

Errors for Settings.

Functions

This section is empty.

Types

type ConnectStatus added in v0.1.1

type ConnectStatus struct {
	// State is none, checkout (waiting for payment), active, or ended.
	State string     `json:"state"`
	Until *time.Time `json:"until,omitempty"`
	// Checkout is the open checkout's page, while it's open.
	Checkout string `json:"checkout,omitempty"`
	Problem  string `json:"problem,omitempty"`
}

ConnectStatus is what Settings shows about the subscription.

type Manager

type Manager struct {
	Addr    string       // the HTTPS listen address, such as :7443
	Dir     string       // keeps the certificate and the CA account key
	Handler http.Handler // serves the API
	Log     *slog.Logger
	// Connect is the service the apps look this server up with; nil for
	// none, which also rules out a port forwarded by hand.
	Connect *connect.Client
	// Billing is where Matinee Connect is bought, for Yeix's service;
	// nil for one that needs no subscription.
	Billing *connect.Billing

	// For tests: the ACME directory (default Let's Encrypt), an HTTP client
	// for it, a router, challenges to try, and accepting private addresses.
	CA           string
	HTTPClient   *http.Client
	FindRouter   func(context.Context) (router, error)
	Challenges   []challenge
	AllowPrivate bool
	// contains filtered or unexported fields
}

Manager keeps remote access going while it's on.

func (*Manager) ConnectStatus added in v0.1.1

func (m *Manager) ConnectStatus() *ConnectStatus

ConnectStatus reports the subscription, or nil when the server doesn't use the paid service.

func (*Manager) Findable added in v0.1.1

func (m *Manager) Findable() bool

Findable reports whether the apps can look this server up right now.

func (*Manager) Lookup added in v0.1.1

func (m *Manager) Lookup() (id, url string)

Lookup is this server's id with the connect service and the address the apps look it up at, or "" without the service.

func (*Manager) ManageURL added in v0.1.1

func (m *Manager) ManageURL(ctx context.Context) (string, error)

ManageURL opens Stripe's page for changing the card or cancelling.

func (*Manager) Plans added in v0.1.1

func (m *Manager) Plans(ctx context.Context) ([]connect.Plan, error)

Plans lists what Matinee Connect costs.

func (*Manager) Run

func (m *Manager) Run(ctx context.Context)

Run keeps remote access up while it's on, until ctx ends; then it takes the router's forward down.

func (*Manager) SetEnabled

func (m *Manager) SetEnabled(on bool)

SetEnabled turns remote access on or off; Run does the work.

func (*Manager) SetForwardedPort added in v0.1.1

func (m *Manager) SetForwardedPort(ext int)

SetForwardedPort says the admin forwarded the router's port ext (443 or 80) to this server's remote access port by hand; 0 goes back to asking the router.

func (*Manager) Status

func (m *Manager) Status() Status

Status reports how remote access is doing.

func (*Manager) Subscribe added in v0.1.1

func (m *Manager) Subscribe(ctx context.Context, plan string) (string, error)

Subscribe opens a checkout for this server on plan and returns its page.

func (*Manager) URL

func (m *Manager) URL() string

URL is the address the apps use away from home, or "" while there's none.

type Status

type Status struct {
	Enabled bool `json:"enabled"`
	// State is off, working (setting up), ready, or failed (see Problem).
	State string `json:"state"`
	// URL is the address the apps use away from home.
	URL string `json:"url,omitempty"`
	// Router is how the port was opened: UPnP or NAT-PMP.
	Router   string `json:"router,omitempty"`
	PublicIP string `json:"publicIP,omitempty"`
	// Problem says, for people, what stands in the way.
	Problem string `json:"problem,omitempty"`
	// SharedAddress means the router has no public address of its own (the
	// provider shares one, or another router sits in front), which only a
	// relay can get around.
	SharedAddress bool `json:"sharedAddress,omitempty"`
	// ForwardedPort is the router port an admin forwarded by hand; 0 means
	// the router is asked to open one.
	ForwardedPort int `json:"forwardedPort,omitempty"`
	// ListenPort is this server's remote access port, where a port
	// forwarded by hand should go.
	ListenPort int `json:"listenPort,omitempty"`
	// Findable means the connect service knows the current address, so
	// the apps find this server even after the address changes.
	Findable bool `json:"findable,omitempty"`
	// Connect is the Matinee Connect subscription that pays for that;
	// nil when the server uses a service that needs none.
	Connect            *ConnectStatus `json:"connect,omitempty"`
	CertificateExpires *time.Time     `json:"certificateExpires,omitempty"`
	CheckedAt          *time.Time     `json:"checkedAt,omitempty"`
}

Status is what Settings shows about remote access.

Jump to

Keyboard shortcuts

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