client

package
v0.35.0 Latest Latest
Warning

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

Go to latest
Published: Nov 9, 2026 License: GPL-3.0 Imports: 44 Imported by: ? 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

Index

Constants

View Source
const DefaultUDP5ExitIdle = 300 * time.Second

DefaultUDP5ExitIdle is the exit's SOCKS5 UDP idle backstop.

Variables

View Source
var AutoReconnect = true
View Source
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.

View Source
var LocalIPForward = false
View Source
var NowStatus atomic.Int32

NowStatus is 1 while a session to the server is up.

View Source
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.

View Source
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

func NewCoreExit(localIP string, udpIdle time.Duration) coreapi.Exit

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

func NewCorePeerExit(base coreapi.Exit) func(coreapi.LinkPolicy) (coreapi.Exit, error)

NewCorePeerExit makes the exit of a link this client provides: base, under the link's policy.

func NewCorePuncher added in v0.35.0

func NewCorePuncher(localIP string, quicConfig func(*quic.Config) *quic.Config) coreapi.Puncher

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

func RunConfigOnce(ctx context.Context, cnf *config.Config, issued string) (string, error)

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

func RunCoreProfile(ctx context.Context, cfg *config.CommonConfig, autoReconnect bool) error

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

func StartFromFile(pCtx context.Context, path string) error

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.

func WaitReconnect added in v0.35.0

func WaitReconnect(ctx context.Context) bool

WaitReconnect waits for the time before the next connection attempt. It returns false if ctx ended first.

Types

type Closer added in v0.29.5

type Closer interface{ Close() error }

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 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) 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.

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.

Jump to

Keyboard shortcuts

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