Documentation
¶
Overview ¶
Package pageserver puts the desktop page in front of the service: Proxy forwards the page's API calls to the service's socket (the desktop app's web view and a Server both use it), and a Server serves the page itself to a browser, on a loopback port only whoever holds its link can use.
The service never listens on a network port; a Server does, for the page, so it lets in only requests that carry its cookie, which a one-time link (OpenURL) hands out. Requests must also name the Server's own address as their host (no DNS rebinding) and, when they say where they come from, come from the page (no other site, not even another port on 127.0.0.1, whose requests a browser would send the cookie with).
Index ¶
Constants ¶
const HostPrefix = "/host/"
HostPrefix is where Options.Host answers: what the page asks of the program serving it (opening folders, the service's controls).
const TicketTTL = time.Minute
TicketTTL is how long a link from OpenURL lasts unused.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Options ¶
type Options struct {
// Page is the page's files, index.html at the root.
Page fs.FS
// Socket is the service's socket, for Proxy.
Socket string
// Host answers under HostPrefix (nil: not found).
Host http.Handler
// Addr is where to listen: 127.0.0.1:0 (any free port) by default.
// Only a loopback address is allowed.
Addr string
}
Options are what a Server serves.
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
Server is the page on a loopback port. Close it when done.
func (*Server) OpenURL ¶
OpenURL is a link that opens the page once: it lets the browser in (a cookie) and then goes to the page, so the link in the address bar and the history is the page's, not one that would let anyone in again.
func (*Server) Origin ¶
Origin is the page's origin: http://127.0.0.1:port.