panelpage

package
v0.13.0 Latest Latest
Warning

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

Go to latest
Published: Nov 26, 2026 License: MIT Imports: 13 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 panelpage serves the desk nudge's panel page on 127.0.0.1, behind a Host check and a cookie that a one-use code buys. Any page open in a browser can send a request to 127.0.0.1, so a request is answered only where its Host names this listener, which stops DNS rebinding, and where it carries the cookie, which a cross-site request never does. Jupyter trades its token for a cookie the same way.

Index

Constants

View Source
const (
	// CodeLifetime is how long a minted code opens the page. The window loads
	// its URL within it, and a code seen in an argv afterwards opens nothing.
	CodeLifetime = 10 * time.Second
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Page

type Page struct {
	// contains filtered or unexported fields
}

Page serves the built page at / and the watch's routes under /api/.

func New

func New(api http.Handler, now func() time.Time) *Page

New is a page over api, the watch's routes, on the clock now.

func (*Page) Listen

func (p *Page) Listen(ctx context.Context) error

Listen serves the page on a port of 127.0.0.1 that the system picks now, until Stop.

func (*Page) Mint

func (p *Page) Mint() (string, time.Time)

Mint is the page's URL carrying a fresh one-use code, and when the code stops opening it.

func (*Page) ServeHTTP

func (p *Page) ServeHTTP(response http.ResponseWriter, request *http.Request)

ServeHTTP refuses a foreign Host, trades a fresh code for the cookie, and answers a request that carries the cookie.

func (*Page) Stop

func (p *Page) Stop(ctx context.Context)

Stop ends the listener, and waits for requests under way until ctx ends.

Jump to

Keyboard shortcuts

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