Documentation
¶
Index ¶
- func GetConnectionInfo() (server, token string, err error)
- func GetSpaceId() (string, error)
- func IsAgentRunning() bool
- func NewScriptLogger(service string) logger.Logger
- func NewUplinkLogger(service string) logger.Logger
- func SendWithResponseMsg(commandType CommandType, payload interface{}, response interface{}) error
- func SetMethodsScriptRunner(fn func(content string, args []string) error)
- func StartCommandSocket(agentClientObj *agent_client.AgentClient) chan struct{}
- func StopCommandSocket()
- type CommandMsg
- type CommandType
- type ConnectResponse
- type ForwardPortRequest
- type ListPortForwardsResponse
- type ListTunnelsResponse
- type LogRequest
- type PortForwardInfo
- type RegisterMethodsFileRequest
- type RegisterMethodsRequest
- type RegisterMethodsResponse
- type RunCommandRequest
- type RunCommandResponse
- type SpaceFieldRequest
- type SpaceGetFieldRequest
- type SpaceGetFieldResponse
- type SpaceNoteRequest
- type StartTunnelRequest
- type StartTunnelResponse
- type StopPortForwardRequest
- type StopTunnelRequest
- type ThrottlePortRequest
- type TunnelInfo
- type UplinkLogger
- func (l *UplinkLogger) Debug(message string, keysAndValues ...any)
- func (l *UplinkLogger) Error(message string, keysAndValues ...any)
- func (l *UplinkLogger) Fatal(message string, keysAndValues ...any)
- func (l *UplinkLogger) Info(message string, keysAndValues ...any)
- func (l *UplinkLogger) Trace(message string, keysAndValues ...any)
- func (l *UplinkLogger) Warn(message string, keysAndValues ...any)
- func (l *UplinkLogger) With(key string, value any) logger.Logger
- func (l *UplinkLogger) WithError(err error) logger.Logger
- func (l *UplinkLogger) WithGroup(group string) logger.Logger
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GetConnectionInfo ¶ added in v0.23.0
func GetSpaceId ¶ added in v0.25.0
func IsAgentRunning ¶ added in v0.21.0
func IsAgentRunning() bool
func NewScriptLogger ¶ added in v0.28.0
NewScriptLogger returns the appropriate logger for an interactive CLI sub-process running inside a space: an UplinkLogger (with stderr fallback) when the agent daemon is reachable, otherwise a plain stderr logger for standalone use.
func NewUplinkLogger ¶ added in v0.28.0
NewUplinkLogger returns a logger that streams to the agent daemon. Callers should generally use NewScriptLogger, which falls back to a plain stderr logger when no agent is running.
func SendWithResponseMsg ¶
func SendWithResponseMsg(commandType CommandType, payload interface{}, response interface{}) error
func SetMethodsScriptRunner ¶ added in v0.28.0
SetMethodsScriptRunner installs the daemon-side script runner used by handleRegisterMethodsScript. The agent daemon calls this at startup with a closure that creates a scriptling env, wires knot.methods.SetMethodsRegistrar to agentClient.RegisterMethods, and evaluates the supplied script content.
func StartCommandSocket ¶
func StartCommandSocket(agentClientObj *agent_client.AgentClient) chan struct{}
func StopCommandSocket ¶
func StopCommandSocket()
Types ¶
type CommandMsg ¶
type CommandMsg struct {
Command CommandType `msgpack:"c"`
Payload []byte `msgpack:"p"`
}
func (*CommandMsg) Unmarshal ¶
func (c *CommandMsg) Unmarshal(v interface{}) error
type CommandType ¶
type CommandType int
const ( CommandNil CommandType = iota CommandConnect CommandSpaceNote CommandSpaceSetField CommandSpaceGetField CommandSpaceStop CommandSpaceRestart CommandForwardPort CommandListPortForwards CommandStopPortForward CommandRegisterMethods CommandRegisterMethodsTOML CommandRegisterMethodsScript CommandUnregisterMethods CommandLog CommandStartTunnel CommandStopTunnel CommandListTunnels CommandThrottlePort )
type ConnectResponse ¶
type ForwardPortRequest ¶ added in v0.22.0
type ListPortForwardsResponse ¶ added in v0.22.0
type ListPortForwardsResponse struct {
Forwards []PortForwardInfo `json:"forwards" msgpack:"forwards"`
}
type ListTunnelsResponse ¶ added in v0.29.0
type ListTunnelsResponse struct {
Tunnels []TunnelInfo `json:"tunnels" msgpack:"tunnels"`
}
type LogRequest ¶ added in v0.28.0
type LogRequest struct {
Service string `json:"service" msgpack:"service"`
Level byte `json:"level" msgpack:"level"`
Message string `json:"message" msgpack:"message"`
}
LogRequest carries a single log line from a CLI sub-process (e.g. `knot run-script`) to the agent daemon, which forwards it upstream via the agent client's log channel. Level is a msg.LogLevel byte value.
type PortForwardInfo ¶ added in v0.22.0
type PortForwardInfo struct {
LocalPort uint16 `json:"local_port" msgpack:"local_port"`
Space string `json:"space" msgpack:"space"`
RemotePort uint16 `json:"remote_port" msgpack:"remote_port"`
Persistent bool `json:"persistent" msgpack:"persistent"`
Mode string `json:"mode" msgpack:"mode"`
LatencyMs int `json:"latency_ms" msgpack:"latency_ms"`
JitterMs int `json:"jitter_ms" msgpack:"jitter_ms"`
BandwidthKB int `json:"bandwidth_kb" msgpack:"bandwidth_kb"`
TimeoutMs int `json:"timeout_ms" msgpack:"timeout_ms"`
Down bool `json:"down" msgpack:"down"`
}
type RegisterMethodsFileRequest ¶ added in v0.28.0
type RegisterMethodsFileRequest struct {
Content string `json:"content" msgpack:"content"`
Args []string `json:"args,omitempty" msgpack:"args,omitempty"`
}
RegisterMethodsFileRequest ships a raw file from the CLI to the agent daemon for processing. Content is the file body. Args is optional and only used by the script variant (passed in as sys.argv).
type RegisterMethodsRequest ¶ added in v0.28.0
type RegisterMethodsRequest struct {
Registration methods.Registration `json:"registration" msgpack:"registration"`
}
type RegisterMethodsResponse ¶ added in v0.28.0
type RunCommandRequest ¶ added in v0.19.0
type RunCommandResponse ¶ added in v0.19.0
type SpaceFieldRequest ¶ added in v0.21.5
type SpaceGetFieldRequest ¶ added in v0.21.5
type SpaceGetFieldRequest struct {
Name string `json:"name" msgpack:"name"`
}
type SpaceGetFieldResponse ¶ added in v0.21.5
type SpaceGetFieldResponse struct {
Value string `json:"value" msgpack:"value"`
}
type SpaceNoteRequest ¶
type SpaceNoteRequest struct {
Note string `json:"note" msgpack:"note"`
}
type StartTunnelRequest ¶ added in v0.29.0
type StartTunnelRequest struct {
Protocol string `json:"protocol" msgpack:"protocol"`
Port uint16 `json:"port" msgpack:"port"`
Name string `json:"name" msgpack:"name"`
TlsName string `json:"tls_name,omitempty" msgpack:"tls_name,omitempty"`
TlsSkipVerify bool `json:"tls_skip_verify,omitempty" msgpack:"tls_skip_verify,omitempty"`
}
type StartTunnelResponse ¶ added in v0.29.0
type StopPortForwardRequest ¶ added in v0.22.0
type StopPortForwardRequest struct {
LocalPort uint16 `json:"local_port" msgpack:"local_port"`
}
type StopTunnelRequest ¶ added in v0.29.0
type StopTunnelRequest struct {
Name string `json:"name" msgpack:"name"`
}
type ThrottlePortRequest ¶ added in v0.31.0
type ThrottlePortRequest struct {
LocalPort uint16 `json:"local_port" msgpack:"local_port"`
LatencyMs int `json:"latency_ms" msgpack:"latency_ms"`
JitterMs int `json:"jitter_ms" msgpack:"jitter_ms"`
BandwidthKB int `json:"bandwidth_kb" msgpack:"bandwidth_kb"`
TimeoutMs int `json:"timeout_ms" msgpack:"timeout_ms"`
Down bool `json:"down" msgpack:"down"`
Reset bool `json:"reset" msgpack:"reset"`
}
type TunnelInfo ¶ added in v0.29.0
type UplinkLogger ¶ added in v0.28.0
type UplinkLogger struct {
// contains filtered or unexported fields
}
UplinkLogger is a logger.Logger that forwards log lines from a CLI sub-process (e.g. `knot run-script`) to the agent daemon over the command socket; the daemon then ships them upstream to the knot server via the agent client's log channel. If the uplink is unavailable, lines are written to stderr so logs are never silently lost.
func (*UplinkLogger) Debug ¶ added in v0.28.0
func (l *UplinkLogger) Debug(message string, keysAndValues ...any)
func (*UplinkLogger) Error ¶ added in v0.28.0
func (l *UplinkLogger) Error(message string, keysAndValues ...any)
func (*UplinkLogger) Fatal ¶ added in v0.28.0
func (l *UplinkLogger) Fatal(message string, keysAndValues ...any)
func (*UplinkLogger) Info ¶ added in v0.28.0
func (l *UplinkLogger) Info(message string, keysAndValues ...any)
func (*UplinkLogger) Trace ¶ added in v0.28.0
func (l *UplinkLogger) Trace(message string, keysAndValues ...any)
func (*UplinkLogger) Warn ¶ added in v0.28.0
func (l *UplinkLogger) Warn(message string, keysAndValues ...any)
func (*UplinkLogger) With ¶ added in v0.28.0
func (l *UplinkLogger) With(key string, value any) logger.Logger
Source Files
¶
- client.go
- handle_connect.go
- handle_forward_port.go
- handle_list_port_forwards.go
- handle_list_tunnels.go
- handle_log.go
- handle_register_methods.go
- handle_register_methods_file.go
- handle_space_getfield.go
- handle_space_note.go
- handle_space_restart.go
- handle_space_setfield.go
- handle_space_stop.go
- handle_start_tunnel.go
- handle_stop_port_forward.go
- handle_stop_tunnel.go
- handle_throttle_port.go
- handle_unregister_methods.go
- msg.go
- msg_structs.go
- server.go
- uplink_logger.go