Documentation
¶
Overview ¶
Package remote runs commands on the server xtune manages: over SSH from a client, or directly when xtune runs on the server itself. Everything that changes the server goes through Helper, which runs the embedded helper.sh as root.
Index ¶
- Constants
- func Installed() bool
- func Quote(s string) string
- type Conn
- type Prompter
- type Server
- func (r *Server) Close()
- func (r *Server) Console(cmd string) error
- func (r *Server) Exec(cmd, stdin string, sudo bool) (string, string, error)
- func (r *Server) Helper(args ...string) (string, error)
- func (r *Server) Lock() func()
- func (r *Server) Name() string
- func (r *Server) Root(cmd string) (string, error)
- func (r *Server) Status() (Status, error)
- func (r *Server) Stream(ctx context.Context, cmd string, fn func(string)) error
- func (r *Server) Upload(dst string, content []byte, mode string) error
- type Status
- type Transport
Constants ¶
const Dir = "/opt/xray-autotune"
Dir is where xtune keeps everything on the server.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Conn ¶
type Conn struct {
Name string `json:"name"`
Host string `json:"host"`
Port int `json:"port"`
User string `json:"user"`
KeyPath string `json:"key,omitempty"`
Password string `json:"-"`
}
Conn describes how to reach a server. Secrets are never written to disk.
type Server ¶
type Server struct {
Transport Transport
Conn Conn
Local bool // xtune is running on the server itself
}
Server is the machine xtune manages. Commands that need root go through Root/Upload/Helper.
func OpenLocal ¶
OpenLocal manages the server xtune is running on. It needs root, like the helper it runs.
func (*Server) Console ¶
Console runs cmd on the server in an interactive terminal; this is how a client reaches the server-side TUI. sudo, when needed, prompts inside that terminal.
func (*Server) Helper ¶
Helper uploads helper.sh and runs it as root with args, each shell-quoted; it returns trimmed stdout.
func (*Server) Lock ¶
func (r *Server) Lock() func()
Lock serializes state changes between local xtune processes on the server (TUI, CLI and the enforce timer). Changes a client makes over SSH are not locked; the next enforce run heals them.
type Status ¶
type Status struct {
Arch, Xray, Unit string // isolated xtune Xray
HasState bool // a deployment exists
Xtune, XtuneSHA string // server copy of xtune ("none" when missing)
Sub, Timer, Bot string // subscription server, enforce timer and Telegram bot (systemctl is-active)
Tunnels string // SSH and DNS tunnel server
AWG string // AmneziaWG server
Relay string // multi-hop relay to another server (xray-autotune-relay)
FW string // active host firewall: ufw | firewalld | none
}
Status is what `helper.sh status` reports about the server.
type Transport ¶
type Transport interface {
Exec(cmd, stdin string, sudo bool) (string, string, error)
Stream(ctx context.Context, cmd string, fn func(string)) error
Close()
}
Transport runs shell commands on the managed server: over SSH from a client, or directly when xtune runs on the server itself.