Documentation
¶
Index ¶
- func FindActiveProxy() (string, bool)
- func FreePort() (int, error)
- func GetJobProxy() (string, bool)
- func LocalPidFilePath() string
- func LocalSockPath() string
- func PidFilePath() string
- func ProxyAlive(host string, port int) bool
- func ProxyEnvList(httpURL string) []string
- func RemovePidFile()
- func ResolveViaHost(flagVia string) (string, error)
- func RunDaemon(sshDest string, port int, localOnly bool, reportFd int) error
- func RunProxy(ctx context.Context, listenAddr string, dial DialFunc) error
- func SockPath() string
- func StartOnNode(host, via string, port int) error
- func WillSurviveLogout() (survives, killUserProcesses, linger bool)
- func WritePidFileAt(path string, ps ProxyState) error
- type DialFunc
- type ProxyState
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func FindActiveProxy ¶
FindActiveProxy returns the proxy URL to use for the current job. Checks the local per-job PID file first, then the shared NFS PID file.
func GetJobProxy ¶
GetJobProxy returns the active proxy URL for injection into container envs and HTTP clients inside a scheduler job. Returns "", false on login nodes — they have direct internet access and need no proxy. Result is cached after the first call.
func LocalPidFilePath ¶
func LocalPidFilePath() string
LocalPidFilePath returns the node-local proxy PID file path (per-job mode). Uses utils.GetTmpDir() which respects SLURM_TMPDIR, PBS_TMPDIR, etc.
func LocalSockPath ¶
func LocalSockPath() string
LocalSockPath returns the Unix socket path for the per-job SSH SOCKS5 tunnel. Lives in the node-local tmpdir alongside LocalPidFilePath.
func PidFilePath ¶
func PidFilePath() string
PidFilePath returns the NFS-shared proxy PID file path (shared mode).
func ProxyAlive ¶
ProxyAlive checks if the SOCKS5 proxy is reachable at host:port.
func ProxyEnvList ¶
ProxyEnvList returns env var assignments for an http:// proxy URL. Both http:// and socks5:// point to the same dual-protocol port.
func ResolveViaHost ¶
ResolveViaHost resolves the SSH server to tunnel through for a per-job proxy. Uses the --via flag value, or returns an error if not provided.
func RunDaemon ¶
RunDaemon starts a dual-protocol (SOCKS5 + HTTP CONNECT) proxy on the visible port. It creates an SSH tunnel and runs a Go dual-protocol proxy in front of it.
localOnly=false: shared mode — visible proxy binds 0.0.0.0:port, NFS PID file. localOnly=true: per-job mode — visible proxy binds 127.0.0.1:port, node-local PID file.
reportFd, if > 0, is a file descriptor for a pipe back to the parent process: the daemon closes it (EOF) once the tunnel and PID file are ready, or writes an error message before closing if startup fails. The parent blocks on this pipe instead of polling the PID file.
The daemon blocks until SIGTERM/SIGINT, then cleans up the PID file and socket.
func RunProxy ¶
RunProxy listens on listenAddr and serves both SOCKS5 and HTTP CONNECT, forwarding connections through dial. Stops when ctx is cancelled.
func SockPath ¶
func SockPath() string
SockPath returns the Unix socket path for the shared-mode SSH SOCKS5 tunnel. Lives in the state dir (same node as the daemon; not accessed by compute nodes).
func StartOnNode ¶
StartOnNode SSHes to host and runs "condatainer proxy start" there (delegation). Passes --via and --port if set. Waits up to 10s for the NFS PID file to appear.
func WillSurviveLogout ¶
func WillSurviveLogout() (survives, killUserProcesses, linger bool)
WillSurviveLogout returns true if the proxy daemon is expected to survive user logout. Safe when KillUserProcesses=no OR Linger=yes. Returns (survives, killUserProcesses, linger).
func WritePidFileAt ¶
func WritePidFileAt(path string, ps ProxyState) error
WritePidFileAt writes proxy state to an arbitrary PID file path as JSON.
Types ¶
type DialFunc ¶
DialFunc dials a network connection to addr. Compatible with net.Dialer.DialContext and http.Transport.DialContext.
func DialGoSSH ¶
DialGoSSH dials sshDest using the Go SSH library with all available non-interactive auth methods. Returns a DialFunc (wrapping client.Dial), a stop closer, and a done channel closed when the connection drops.
func DialSystemSSH ¶
DialSystemSSH dials a remote service by spawning `ssh -W node:port node` for each connection, piping the subprocess stdin/stdout as a net.Conn. This serves as a fallback when DialGoSSH fails (e.g. GSSAPI/Kerberos auth, strict known_hosts). The returned done channel is closed only on explicit stop(), not on connection drop, because there is no persistent underlying connection to monitor.
type ProxyState ¶
type ProxyState struct {
Host string `json:"host"`
Via string `json:"via"`
Port int `json:"port"`
PID int `json:"pid"`
}
ProxyState holds the state written to a proxy PID file.
func ReadLocalPidFile ¶
func ReadLocalPidFile() (*ProxyState, error)
ReadLocalPidFile reads the node-local per-job proxy PID file.
func ReadPidFile ¶
func ReadPidFile() (*ProxyState, error)
ReadPidFile reads the shared NFS proxy PID file.
func ReadPidFileAt ¶
func ReadPidFileAt(path string) (*ProxyState, error)
ReadPidFileAt reads and parses a JSON proxy PID file.