Documentation
¶
Overview ¶
Package launch resolves what npc is told to start into one model, a list of Profile: launch links, configuration files, -L accesses and the flags and file forms of earlier versions (compat.go) all end there and run the same way.
A connection is configuration text parsed by lib/config, so that package stays the only definition of the configuration keys.
Index ¶
- Variables
- func CheckValue(input string) error
- func Pack(ctx context.Context, path string) (string, error)
- func Show(ctx context.Context, sources []Source, locals []Local, reveal bool) (string, error)
- func Supervise(ctx context.Context, load func(context.Context) (Plan, error), ...) error
- type Access
- type Account
- type CommandLine
- type Composer
- type Local
- type Options
- type Plan
- type Profile
- type RemoteError
- type Source
Constants ¶
This section is empty.
Variables ¶
var ( SourceRetry = 30 * time.Second SourcePause = 5 * time.Minute )
How long a remote source that failed is left alone.
var URLAccess bool
URLAccess lets content fetched from a URL define access too (-launch_url_access). Only the local user sets it; the keys that reach local files stay refused either way.
Functions ¶
func CheckValue ¶
CheckValue checks the form of a -launch value without reading or fetching what it refers to.
func Pack ¶
Pack returns the content of the file at path as a -launch value, gzip and base64. The value holds every secret of the file in the clear.
func Show ¶
Show prints what sources and locals amount to in the current form, one argument per connection and access; reveal false masks vkeys and access keys.
func Supervise ¶
func Supervise( ctx context.Context, load func(context.Context) (Plan, error), run func(context.Context, Profile) error, ) error
Supervise keeps each connection of the plan running, independently of the others: when one stops it is started again once its reconnect pacing (client.Reconnect) allows, by loading the plan again and starting whatever is not running. The first load must be valid; a later invalid one is logged and tried again. It returns nil when ctx ends and an error when npc cannot continue.
Types ¶
type Access ¶
type Access struct {
Access string `json:"access"`
Target string `json:"target"`
LocalType string `json:"local_type"`
LocalPort int `json:"local_port"`
LocalIP string `json:"local_ip"`
ConnMode string `json:"conn_mode"`
LocalProxy bool `json:"local_proxy"`
Auth []Account `json:"auth"`
}
Access is one local access, however it was written: a -L URL or an entry of a configuration file. It compiles to a config.LocalServer, so the access has one path from here on.
type CommandLine ¶
type CommandLine struct {
Server, VKey, Type, Proxy, LocalIP string
Config []string // npc.conf paths
Password, LocalType, ConnMode, Target string
LocalPort int
LocalProxy bool
}
CommandLine is the connection and access flags of earlier versions.
func (CommandLine) Sources ¶
func (f CommandLine) Sources() ([]Source, error)
Sources converts the flags into launch sources. An access by -password replaces the other forms, as it always has.
type Composer ¶
type Composer struct {
// contains filtered or unexported fields
}
Composer merges the sources and the -L accesses into a Plan, remembering the last good content of each remote source.
func NewComposer ¶
NewComposer makes a Composer.
type Local ¶
type Local struct {
Access Access
Via string // the name of a connection; empty when there is only one
Source string // where it was written, for messages
}
Local is one parsed -L: the access and the connection it goes over.
func ParseLocal ¶
ParseLocal reads one -L value, scheme://[user:pass@]host:port?access=..&target=.. Errors never contain the value: it holds the access key.
func ParseLocals ¶
ParseLocals reads the -L values in order; a value @path is a file with one value per line (blank lines and lines starting with # are skipped), which is how an installed service keeps them off its command line.
type Plan ¶
Plan is what should run now. Retry is positive while a remote source has nothing to offer: load again after it.
type Profile ¶
type Profile struct {
Name string
Direct bool
// Hosting: besides its local accesses the connection runs as an
// ordinary client, because its role says both or an access-less
// writing shares it.
Hosting bool
Config *config.Config
// Source says where the profile was written, for messages; it holds no secret.
Source string
// contains filtered or unexported fields
}
Profile is one runnable client. A direct profile connects with an existing client vkey; otherwise Config is sent to the server or runs local servers.
type RemoteError ¶
RemoteError reports that a URL payload could not be fetched or used, so a later attempt may succeed. Revoked means the source answered 410 Gone: the configuration it served earlier must not be used any more.
func (*RemoteError) Error ¶
func (e *RemoteError) Error() string
func (*RemoteError) Unwrap ¶
func (e *RemoteError) Unwrap() error