remote

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Nov 1, 2026 License: MIT Imports: 22 Imported by: 0 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

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

View Source
const Dir = "/opt/xray-autotune"

Dir is where xtune keeps everything on the server.

Variables

This section is empty.

Functions

func Installed

func Installed() bool

Installed reports whether this machine is an xtune-managed server.

func Quote

func Quote(s string) string

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 Prompter

type Prompter func(label string, secret bool) (string, error)

Prompter asks the user for a value; secret input is not echoed.

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 Dial

func Dial(cfg Conn, ask Prompter) (*Server, error)

func OpenLocal

func OpenLocal() (*Server, error)

OpenLocal manages the server xtune is running on. It needs root, like the helper it runs.

func (*Server) Close

func (r *Server) Close()

func (*Server) Console

func (r *Server) Console(cmd string) error

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

func (r *Server) Exec(cmd, stdin string, sudo bool) (string, string, error)

Exec runs cmd and returns stdout/stderr; stdin is fed to the command.

func (*Server) Helper

func (r *Server) Helper(args ...string) (string, error)

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.

func (*Server) Name

func (r *Server) Name() string

Name is how the server is shown in titles.

func (*Server) Root

func (r *Server) Root(cmd string) (string, error)

Root runs cmd as root and returns stdout.

func (*Server) Status

func (r *Server) Status() (Status, error)

Status reports what is installed and running on the server.

func (*Server) Stream

func (r *Server) Stream(ctx context.Context, cmd string, fn func(string)) error

Stream runs cmd as root and sends each output line to fn until ctx is cancelled or the command exits.

func (*Server) Upload

func (r *Server) Upload(dst string, content []byte, mode string) error

Upload writes content to path as root, atomically, with the given octal mode.

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.

Jump to

Keyboard shortcuts

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