Documentation
¶
Index ¶
- Constants
- Variables
- func AcceptUpdate() bool
- func GetTaskStatus(cfg *config.CommonConfig) error
- func NewCoreExit(localIP string, udpIdle time.Duration) coreapi.Exit
- func NewCoreHealth(sink coreapi.HealthSink) coreapi.HealthRunner
- func NewCorePeerExit(base coreapi.Exit) func(coreapi.LinkPolicy) (coreapi.Exit, error)
- func NewCorePuncher(localIP string, quicConfig func(*quic.Config) *quic.Config) coreapi.Puncher
- func RegisterLocalIP(cfg *config.CommonConfig, hours int) error
- func RunConfigOnce(ctx context.Context, cnf *config.Config, issued string) (string, error)
- func RunCoreProfile(ctx context.Context, cfg *config.CommonConfig, autoReconnect bool) error
- func StartFromFile(pCtx context.Context, path string) error
- func UpdateEnabled() bool
- func WithReconnect(ctx context.Context, r *Reconnect) context.Context
- type Closer
- type FileServerManager
- type HealthChecker
- type Reconnect
- type SecretManager
Constants ¶
const DefaultUDP5ExitIdle = 300 * time.Second
DefaultUDP5ExitIdle is the exit's SOCKS5 UDP idle backstop.
Variables ¶
var AutoReconnect = true
var CoreOuter func(cfg *config.CommonConfig, server string) (coreapi.Outer, error)
CoreOuter makes the outer session of cfg's profile to server on the new protocol. The command wires it (internal/coreproto/connect), so that the client sees the protocol only through coreapi.
var LocalIPForward = false
var NowStatus atomic.Int32
NowStatus is 1 while a session to the server is up.
var QuicConfig = &quic.Config{ KeepAlivePeriod: 10 * time.Second, MaxIdleTimeout: 30 * time.Second, MaxIncomingStreams: 100000, }
QuicConfig is the base of the QUIC configuration of a direct path.
var ReconnectFirst = time.Second
ReconnectFirst is the wait after the first failure in a row; each further failure doubles it up to reconnectMax.
var RemoteUpdate func() error
RemoteUpdate updates npc to the latest release and restarts it when the server requests it. Nil, the default, makes npc ignore such requests.
Functions ¶
func AcceptUpdate ¶ added in v0.35.0
func AcceptUpdate() bool
AcceptUpdate starts the update the server asked for, and reports whether it did: refused by default, and while one is running.
func GetTaskStatus ¶
func GetTaskStatus(cfg *config.CommonConfig) error
GetTaskStatus prints the tunnels and hosts the server runs for cfg's key.
func NewCoreExit ¶ added in v0.35.0
NewCoreExit returns the exit of npc on the core protocol; it dials targets as the old protocol's client does. udpIdle is the exit's own backstop for a SOCKS5 UDP association without traffic, the entry's timeout being the one that normally ends it; zero or negative is DefaultUDP5ExitIdle.
func NewCoreHealth ¶ added in v0.35.0
func NewCoreHealth(sink coreapi.HealthSink) coreapi.HealthRunner
NewCoreHealth makes the runner of one session's health checks.
func NewCorePeerExit ¶ added in v0.35.0
NewCorePeerExit makes the exit of a link this client provides: base, under the link's policy.
func NewCorePuncher ¶ added in v0.35.0
NewCorePuncher returns the puncher of localIP; quicConfig completes the QUIC configuration of a direct path.
func RegisterLocalIP ¶ added in v0.35.0
func RegisterLocalIP(cfg *config.CommonConfig, hours int) error
RegisterLocalIP registers this host's address with the server for hours.
func RunConfigOnce ¶ added in v0.35.0
RunConfigOnce runs cnf until the session closes or ctx ends and returns the issued key to pass to the next run, for a public key once the server gave one. Local servers run until ctx ends or one of them fails to start.
func RunCoreProfile ¶ added in v0.35.0
RunCoreProfile hosts cfg's profile on the new protocol: it keeps the session, which serves what the server asks of this client, until ctx ends or, without autoReconnect, the session ends. The visitors of the process to the same server share the session and it is not closed while this runs. The error is a profile that cannot be made.
func StartFromFile ¶
StartFromFile runs the client configured in path until pCtx ends, and then returns nil. It returns an error when the config cannot be loaded or when the session ended and reconnecting is turned off.
func UpdateEnabled ¶ added in v0.35.0
func UpdateEnabled() bool
UpdateEnabled reports whether npc can act on an update request: remote update is not disabled and the process can restart itself. It is what npc advertises as the update capability.
Types ¶
type FileServerManager ¶ added in v0.29.5
type FileServerManager struct {
// contains filtered or unexported fields
}
func NewFileServerManager ¶ added in v0.29.5
func NewFileServerManager(parentCtx context.Context) *FileServerManager
func (*FileServerManager) CloseAll ¶ added in v0.29.5
func (fsm *FileServerManager) CloseAll()
func (*FileServerManager) Services ¶ added in v0.35.0
func (fsm *FileServerManager) Services() []coreapi.LocalService
Services are the file servers running, as virtual services (§8): a file tunnel is a virtual listener named by its key.
func (*FileServerManager) StartFileServer ¶ added in v0.29.5
func (fsm *FileServerManager) StartFileServer(t *model.Tunnel)
type HealthChecker ¶ added in v0.29.5
type HealthChecker struct {
// contains filtered or unexported fields
}
HealthChecker runs the checks of the groups the server gave, and reports to the server when a target goes down or comes up.
Nothing here waits on the network: callbacks and the signal reader queue reports, and one goroutine writes them. It is the only writer of reports in npc, so messages never interleave.
func NewHealthChecker ¶ added in v0.29.5
func NewHealthChecker(parentCtx context.Context, sink healthSink) *HealthChecker
func (*HealthChecker) Stop ¶ added in v0.29.5
func (hc *HealthChecker) Stop()
Stop ends all checks and reports, waiting for a report being written.
type Reconnect ¶ added in v0.35.3
type Reconnect struct {
// contains filtered or unexported fields
}
Reconnect paces the reconnects of one client profile: exponential backoff with jitter, reset by a session that stayed up, and a wait in [0, reconnectDrainWindow) after a stable session the server drained (its restart). It is the one pacing of every reconnect loop of the core protocol client; the session loop reports into the Reconnect its context carries (WithReconnect).
func NewReconnect ¶ added in v0.35.3
func NewReconnect() *Reconnect
NewReconnect returns the pacing of a profile that has not failed yet.
type SecretManager ¶ added in v0.35.0
type SecretManager struct {
// contains filtered or unexported fields
}
SecretManager runs the point-to-point access sections of a visitor: their listeners and one visitor per secret task (password) and conn_mode, which the sections with both share.
func NewSecretManager ¶ added in v0.35.0
func NewSecretManager(pCtx context.Context, pCancel context.CancelFunc, cfg *config.CommonConfig) *SecretManager
NewSecretManager runs local servers until pCtx ends. With AutoReconnect off it gives up on the first failed server connection by calling pCancel; the owner of pCtx decides what follows.
func (*SecretManager) Close ¶ added in v0.35.0
func (mgr *SecretManager) Close()
Close stops the listeners, the direct paths and the relay tunnel, and waits for the direct paths' goroutines.
func (*SecretManager) StartLocalServer ¶ added in v0.35.0
func (mgr *SecretManager) StartLocalServer(l *config.LocalServer) (err error)
func (*SecretManager) UseCore ¶ added in v0.35.0
func (mgr *SecretManager) UseCore() error
UseCore makes the local sections of the manager reach their tasks over the new protocol, through the session of its CommonConfig that the process shares with the other users of that session. It is called before the sections start.
Source Files
¶
Directories
¶
| Path | Synopsis |
|---|---|
|
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.
|
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. |
|
Package legacyclient is the old protocol as npc spoke it: a client for tests of a server that accepts old npc; npc itself no longer links it.
|
Package legacyclient is the old protocol as npc spoke it: a client for tests of a server that accepts old npc; npc itself no longer links it. |