Documentation
¶
Overview ¶
Package host owns Chrome independently of the runtime's lifetime.
Index ¶
- Constants
- Variables
- func AllowedNavigation(raw string) bool
- func Main(args []string) error
- func PrivateDir(dir string) error
- func Refusal(raw string) string
- func Run(ctx context.Context, cfg Config) error
- func Running(dir string) bool
- func SocketPath(runDir, profile string) string
- func Start(executable string, cfg Config) error
- func Stop(ctx context.Context, dir, socket string) error
- type Config
Constants ¶
const DefaultDownloadLimit = 100 << 20
DefaultDownloadLimit is the largest file a page may download unless the runtime says otherwise.
const HelloMethod = "Host.hello"
HelloMethod is answered by the host itself, never by Chrome: {"build": "..."}. A host too old to know it answers with Chrome's "method not found", which is a different build too.
const LogLimit = 4 << 20
LogLimit caps the persistent host log in bytes.
Variables ¶
var Build = "dev"
Build is the runtime's build (set by the runtime's main): a host answers it to Host.hello, and a runtime of another build replaces the host, so an update reaches the browser too.
var BuildID = sync.OnceValue(func() string { if Build != "dev" { return Build } if exe, err := os.Executable(); err == nil { if st, err := os.Stat(exe); err == nil { return Build + "+" + strconv.FormatInt(st.ModTime().UnixNano(), 36) } } return Build })
BuildID is Build, with the executable's time for a dev build: every rebuild is another build.
Functions ¶
func AllowedNavigation ¶
AllowedNavigation says whether a page may be opened at raw: an http(s) address without a user name, or about:blank. file:, chrome:, javascript:, data:, view-source: and the rest never become a page of the agent's Chrome; the relay refuses them for every client (Page.navigate, Target.createTarget), whatever the tool that asked.
func PrivateDir ¶
PrivateDir creates an owner-only directory and rejects foreign ownership or symlinks.
func Refusal ¶
Refusal says why the agent's browser will not open raw, in the words of a failed navigation ("" when it may). The egress refuses the same at the network; checked before, the agent learns why instead of reading a 403 page.
func SocketPath ¶
SocketPath keeps room for the terminating NUL on both Linux and Darwin.
Types ¶
type Config ¶
type Config struct {
ProfileDir, Socket, Chrome, Mode string
NoSandbox *bool
// Idle closes the host once no runtime has been connected for this long (0: never). The runtime closes an idle
// browser it is connected to itself; this is for a runtime that went away (an update, a crash) and left it behind.
Idle time.Duration
// MaxTabs bounds Chrome's renderer processes (--renderer-process-limit); 0 leaves Chrome's own bound.
MaxTabs int
// Nice lowers Chrome's and Xvfb's priority (0 keeps it).
Nice int
// DownloadLimit is the largest file a page may download into the profile's downloads/; 0 refuses downloads.
DownloadLimit int64
}
Config contains the paths and display mode for one profile host.