Documentation
¶
Index ¶
- Constants
- func Validate(cfg *Config) error
- func WriteBase(path string, homeDir string) error
- func WriteDefaultForEnv(path string, noCwd bool, homeDir, cwd string) error
- type Config
- type DefaultMount
- type EnvVar
- type Environ
- type Firewall
- type HostPort
- type Mount
- type Net
- type PublishedPort
- type Toggle
Constants ¶
const ( RuntimeNative = "native" RuntimeGvisor = "gvisor" )
const ( NetModeOff = "off" NetModeIsolated = "isolated" )
Variables ¶
This section is empty.
Functions ¶
func WriteDefaultForEnv ¶
WriteDefaultForEnv writes a default config file for a new drop environment to path.
The config by default shares the cwd if sharing of cwd does not expose the home dir (cwd is homeDir or a parent of it). cwd sharing can be disabled by setting noCwd to true.
Types ¶
type Config ¶
type Config struct {
Extends string `toml:"extends"`
Runtime string `toml:"runtime"`
Mounts []Mount `toml:"mounts"`
BlockedPaths []string `toml:"blocked_paths"`
Environ Environ `toml:"environ"`
Net Net `toml:"net"`
}
func (*Config) IsGvisorRuntime ¶ added in v0.1.8
type DefaultMount ¶ added in v0.1.3
func (DefaultMount) IsHeader ¶ added in v0.3.0
func (d DefaultMount) IsHeader() bool
type EnvVar ¶
func (*EnvVar) UnmarshalTOML ¶
type Firewall ¶ added in v0.3.2
type Firewall struct {
// ToggleUnset when no config file sets it, which leaves the firewall
// enabled if the [net.firewall] table is present.
Enabled Toggle `toml:"enabled"`
// An action when no rule matches: "allow", "deny" or "ask".
DefaultAction string `toml:"default_action"`
// What to do with if "ask" prompt cannot be shown: "allow" or
// "deny".
AskFallback string `toml:"ask_fallback"`
// Files with rules. Relative paths are resolved relative to the
// directory where config file which includes the rules is placed.
RuleFiles []string `toml:"rule_files"`
// File where "always allow" and "always deny" decisions are
// saved. Used as a rule file automatically (no need to list it in
// rule_files).
SavedRulesFile string `toml:"saved_rules_file"`
// Inline rules.
Rules []string `toml:"rules"`
}
Firewall configures filtering of outgoing connections in the isolated network mode.
type HostPort ¶
Different from PublishedPort because Pasta, contrary to its man page, doesn't seem to support HostIP for ports forwarded from host to the namespace.
func ParseHostPort ¶
ParseHostPort parses host port string. Like ParsePublishedPort, but does not allow to specify hostIP/, only HOST_PORT[:DROP_PORT] or "auto".
func (*HostPort) UnmarshalTOML ¶
Custom toml.Unmarshaler for HostPort field. Input is a string in the format hostPort[:guestPort] or "auto" for automatic port forwarding of all ports.
type Mount ¶
func ParseMountCompact ¶
ParseMountCompact parses mount configuration from a string of a form source:target:options, where target and options are optional. If target is not given or empty, it equals source. Options are comma separated and can be "rw" and "overlay". Valid strings: "~/go", "~/go:~/host-go" "~/go:~/host-go:rw", "~/go::rw,overlay
func (*Mount) UnmarshalTOML ¶
Custom toml.Unmarshaler for mount field which is of mixed type (TOML 1.0 feature). In TOML mount entry can be either a single Docker-style mount string source:target:option (like "~/go:~/host-go:ro"), or a more verbose TOML table {source = "~/go", target = "~/host-go", rw = true, overlay = false}, where target is optional and defaults to source if not specified.
type Net ¶
type Net struct {
Mode string `toml:"mode"`
Firewall *Firewall `toml:"firewall"`
TCPPublishedPorts []PublishedPort `toml:"tcp_published_ports"`
TCPHostPorts []HostPort `toml:"tcp_host_ports"`
UDPPublishedPorts []PublishedPort `toml:"udp_published_ports"`
UDPHostPorts []HostPort `toml:"udp_host_ports"`
}
func (*Net) IsFirewallEnabled ¶ added in v0.3.2
type PublishedPort ¶
func ParsePublishedPort ¶
func ParsePublishedPort(spec string) (*PublishedPort, error)
ParsePublishedPort parses and validates a published port string.
To keep things simple and keep an option of using a different connectivity tool, only the simplest Pasta mapping expressions are allowed.
Supported format of forwardSpecs items:
- port (e.g., "8080") -> publishes Drop port 8080 as host port 8080 bound to 127.0.0.1 only
- hostPort:guestPort (e.g., "8080:80") -> publishes Drop port 80 as host port 8080 bound to 127.0.0.1 only
- hostIP/hostPort:guestPort (e.g., "192.168.0.3/8080:80") -> published Drop port 80 as host port 8080 bound to IP address 192.168.0.3
- "127.0.0.1/auto" -> automatically publishes all open ports, binds them to localhost only
- "auto" -> automatically publishes all open ports, binds them to ALL available IP addresses
func (*PublishedPort) UnmarshalTOML ¶
func (p *PublishedPort) UnmarshalTOML(data any) error
Custom toml.Unmarshaler for PublishedPort field. Input entry is a string in the format [hostIP/][hostPort:]guestPort or "auto" for automatic port forwarding of all ports.
type Toggle ¶ added in v0.3.2
type Toggle uint8
Toggle is an optional boolean setting. Used instead of *bool, because gob, which passes config between Drop processes, doesn't send a pointer to false and makes it indistinguishable from nil.