Documentation
¶
Index ¶
- Constants
- Variables
- func CanOpenBrowser() bool
- func CheckShells(preferredShell string) string
- func ConvertToBytes(input string) (int64, error)
- func CopyFields(src, dst interface{}, fields []string) error
- func DecryptSSHPrivateKey(encryptionKey string, privateKey string) string
- func DownloadUnpackTgz(downloadURL string, destDir string) error
- func FixListenAddress(address string) string
- func GenerateCertificate(dnsNames []string, ipAddresses []net.IP) (string, string, error)
- func GetGitHubKeys(username string) (string, error)
- func GetGitHubKeysArray(username string) ([]string, error)
- func GetLocalIP() (string, error)
- func HangUpShell(proc *os.Process, tty io.Reader, exited <-chan struct{})
- func HideConsoleIfOwned()
- func HostIP() string
- func InArray(slice []string, item string) bool
- func IsLocalURL(target string) bool
- func LocalRedirect(raw string) string
- func NewCopier(socket net.Conn, wsConnection *websocket.Conn) *copierConnections
- func OpenBrowser(url string) error
- func PrettyPrintJSON(v interface{}) error
- func PrintTable(table [][]string)
- func ReadSSHConfigAgentForwarding(alias string) (map[string]bool, error)
- func RedirectToSyslog(cmd *exec.Cmd)
- func RelaunchHidden() bool
- func ResolveHostIP(s string) string
- func SplitSSHPublicKeys(keys string) []string
- func StripKnotCookies(h http.Header)
- func UpdateAuthorizedKeys(keys []string, githubUsernames []string) error
- func UpdateSSHConfig(sshConfig string, alias string) error
- func UpdateSSHPrivateKey(privateKey string) error
- func UpgradeToWS(w http.ResponseWriter, r *http.Request) *websocket.Conn
- type CommandFrontmatter
- type SkillFrontmatter
Constants ¶
const HostIPToken = "${{ host_ip }}"
HostIPToken is a template function usable in any address value (e.g. server.agent_endpoint): `${{ host_ip }}:3010` renders to the host's IP address at startup. Agents run inside containers and cannot reach the host via 127.0.0.1, so endpoints advertised to them need the real interface IP. The ${{ }} delimiters match knot's template variable style (used to avoid clashing with Nomad interpolation); any spacing inside them works.
const KnotCookiePrefix = "__KNOT_"
KnotCookiePrefix starts the name of every cookie knot sets, after the "__Host-" prefix an https server adds.
const ShellStopTimeout = 2 * time.Second
ShellStopTimeout is how long a shell gets to exit after SIGHUP before it is killed.
Variables ¶
var Timezones = []string{}/* 575 elements not displayed */
Functions ¶
func CanOpenBrowser ¶ added in v0.41.0
func CanOpenBrowser() bool
CanOpenBrowser reports whether OpenBrowser is likely to show a browser to the person at this terminal. Over SSH, or on a Unix with no graphical session, xdg-open may fail or start a text browser that takes over the terminal, so callers should show the URL instead.
func CheckShells ¶
func ConvertToBytes ¶
func CopyFields ¶
CopyFields copies specified fields from src to dst using reflection.
func DecryptSSHPrivateKey ¶ added in v0.25.0
func DownloadUnpackTgz ¶
func FixListenAddress ¶
func GenerateCertificate ¶
GenerateCertificate generates a self-signed certificate and private key in PEM format.
func GetGitHubKeys ¶
Download the public keys from GitHub, https://github.com/<username>.keys
func GetGitHubKeysArray ¶
func GetLocalIP ¶
Get the local IP address of the machine we're running on, interfaces are checked for being up.
func HangUpShell ¶ added in v0.42.0
HangUpShell hangs up a shell whose terminal has gone away so it can save its history on the way out (bash, zsh and fish all do on SIGHUP), and only kills it if it hasn't exited within ShellStopTimeout. Killing it straight away would lose the session's history.
exited must be closed once the process has been waited on. The shell's pty must stay open until then: closing it first makes the kernel hang the session up underneath the shell and bash then exits without saving its history. Its output keeps being read (and discarded) meanwhile, as a shell that can't flush its output to a pty nobody is reading never gets as far as saving. Closing tty afterwards ends that reading.
func HideConsoleIfOwned ¶ added in v0.33.0
func HideConsoleIfOwned()
HideConsoleIfOwned is a no-op outside Windows.
func HostIP ¶ added in v0.33.0
func HostIP() string
HostIP returns the host's primary outbound IPv4 address. Physical interfaces are preferred — virtual interfaces (VPN/tailscale tunnels, docker/veth bridges) and their address ranges (CGNAT 100.64/10, link-local) are skipped first so advertised endpoints stay on durable addresses. If no physical candidate exists (e.g. a host only reachable via VPN) it falls back to the address the routing table would use for an external destination (UDP dial sends no packets), then to any non-loopback IPv4, then to loopback.
func IsLocalURL ¶ added in v0.41.1
IsLocalURL reports whether target is a path on this server, as LocalRedirect returns: it starts with a single "/", not "//" or "/\", and holds nothing browsers would turn into either.
func LocalRedirect ¶ added in v0.41.0
LocalRedirect reduces a user-supplied post-login redirect target to a path on this server: any scheme, host or fragment is dropped and only the path and query survive. It returns "" when the target can't safely be one, or is /logout.
The path stays percent-encoded, so feeding the result back in returns it unchanged: a target kept in a cookie and checked again later can't decode a second time into something else, such as "/%2509/evil.com" becoming "/\t/evil.com", which browsers read as "//evil.com".
func OpenBrowser ¶ added in v0.33.0
OpenBrowser opens the specified URL in the default browser of the user. On Windows rundll32 is used rather than `cmd /c start` because cmd is a console application and would flash (or leave) a console window every time the tray menu opens the UI.
func PrettyPrintJSON ¶ added in v0.19.0
func PrettyPrintJSON(v interface{}) error
func PrintTable ¶
func PrintTable(table [][]string)
func ReadSSHConfigAgentForwarding ¶ added in v0.39.0
ReadSSHConfigAgentForwarding reads the knot block for alias from ~/.ssh/config and reports, for each host in it, whether agent forwarding is on. A missing file or block gives an empty map.
func RedirectToSyslog ¶
func RelaunchHidden ¶ added in v0.33.0
func RelaunchHidden() bool
RelaunchHidden is a no-op outside Windows.
func ResolveHostIP ¶ added in v0.33.0
ResolveHostIP renders any template functions in an address using the address funcs (currently host_ip). knot-style `${{ func }}` delimiters are normalised to Go template actions first so the $ is consumed. Strings that are not templates — or that fail to parse or execute — are returned unchanged, so plain addresses pass through untouched.
func SplitSSHPublicKeys ¶ added in v0.25.0
func StripKnotCookies ¶ added in v0.41.0
StripKnotCookies removes knot's own cookies from a request headed for a space or tunnel. What runs there is the user's code: given the session cookie of whoever opened the page, it could act as them. The space's own cookies pass through unchanged.
func UpdateAuthorizedKeys ¶
func UpdateSSHConfig ¶
func UpdateSSHPrivateKey ¶ added in v0.25.0
func UpgradeToWS ¶
Upgrade the connection to a websocket connection
Types ¶
type CommandFrontmatter ¶ added in v0.29.0
type CommandFrontmatter struct {
Name string
Description string
ArgumentHint string
AllowedTools []string
}
func ParseCommandFrontmatter ¶ added in v0.29.0
func ParseCommandFrontmatter(content string) (*CommandFrontmatter, error)
type SkillFrontmatter ¶ added in v0.23.0
func ParseSkillFrontmatter ¶ added in v0.23.0
func ParseSkillFrontmatter(content string) (*SkillFrontmatter, error)
Source Files
¶
- address.go
- browser.go
- certifiicate.go
- checkshells.go
- console_other.go
- convert-to-bytes.go
- copier.go
- copy-fields.go
- downloadtgz.go
- frontmatter.go
- hangupshell.go
- hostip.go
- inarray.go
- json.go
- knotcookies.go
- localredirect.go
- printtable.go
- sshkeys.go
- sshprivatekey.go
- syslog.go
- timezones.go
- updateauthorizedkeys.go
- updatesshconfig.go
- updatesshprivatekey.go
- upgradews.go
Directories
¶
| Path | Synopsis |
|---|---|
|
Package excludes matches paths against exclude patterns, for the commands that copy directory trees: knot space mirror and knot file sync.
|
Package excludes matches paths against exclude patterns, for the commands that copy directory trees: knot space mirror and knot file sync. |
|
Package hostlabel makes the first label of a space's web hostnames, <user>--<name>--<port>, fit the 63 characters DNS allows a label: a longer label is never resolved, so the space could not be reached.
|
Package hostlabel makes the first label of a space's web hostnames, <user>--<name>--<port>, fit the 63 characters DNS allows a label: a longer label is never resolved, so the space could not be reached. |