Documentation ¶
Index ¶
- Constants
- func SSHConfigPassword(username, password string) *ssh.ClientConfig
- type Capability
- type Client
- type RPCError
- type RPCMessage
- type RPCMethod
- type RPCMethodRaw
- type RPCReply
- type Session
- type Transport
- type TransportHelloMessage
- type TransportReadWriteCloser
- type TransportSSH
- func (t *TransportSSH) Close() error
- func (t *TransportSSH) ReceiveHello() (*TransportHelloMessage, error)
- func (t *TransportSSH) Recieve() ([]byte, error)
- func (t *TransportSSH) Send(data []byte) error
- func (t *TransportSSH) SendHello(msg *TransportHelloMessage) error
- func (t *TransportSSH) WaitForBytes(b []byte) ([]byte, error)
- func (t *TransportSSH) WaitForFunc(fn TransportWaitFunc) ([]byte, error)
- func (t *TransportSSH) WaitForString(s string) (string, error)
- type TransportWaitFunc
Constants ¶
const ( SSHDefaultNetconfPort = 830 SSHNetconfSubsystem = "netconf" )
const (
CapabilityNetconfBase = "urn:ietf:params:xml:ns:netconf:base:1.0"
)
const (
TransportMessageSeparator = "]]>]]>"
)
Variables ¶
This section is empty.
Functions ¶
func SSHConfigPassword ¶
func SSHConfigPassword(username, password string) *ssh.ClientConfig
SSH config including authentication information
Types ¶
type Capability ¶
type Capability string
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client works quite a lot like SFTP, which is also a subsystem of SSH
func NewClient ¶
NewClient is the constructor for Client. It creates a Client with stdin and stdout as the Reader and WriteCloser
func NewClientPipe ¶
func NewClientPipe(sshClient *ssh.Client, sshSession *ssh.Session, r io.Reader, w io.WriteCloser) (*Client, error)
NewClientPipe creates a Client using the given Reader and WriteCloser
type RPCError ¶
type RPCError struct { Type string `xml:"error-type"` Tag string `xml:"error-tag"` Severity string `xml:"error-severity"` Path string `xml:"error-path"` Message string `xml:"error-message"` Info string `xml:",innerxml"` }
an error returned over the course of RPC communication
type RPCMessage ¶
a message to send to the remote
func NewRPCMessage ¶
func NewRPCMessage(methods []RPCMethod) *RPCMessage
func (*RPCMessage) MarshalXML ¶
func (m *RPCMessage) MarshalXML(e *xml.Encoder, start xml.StartElement) error
type RPCMethod ¶
type RPCMethod interface {
MarshalRPCMethod() string
}
func MethodGetConfig ¶
func MethodUnlock ¶
func RPCMethodLock ¶
type RPCMethodRaw ¶
type RPCMethodRaw string
a raw RPC method is just a plain string
func (RPCMethodRaw) MarshalRPCMethod ¶
func (m RPCMethodRaw) MarshalRPCMethod() string
type RPCReply ¶
type RPCReply struct { XMLName xml.Name `xml:"rpc-reply"` Errors []RPCError `xml:"rpc-error,omitempty"` Data string `xml:",innerxml"` Ok bool `xml:",omitempty"` RawReply string `xml:"-"` }
the remote's response to valid RPC messages
type Session ¶
type Session struct { ID int ServerCapabilities []Capability Transport Transport ErrOnWarnings bool }
func NewSession ¶
type Transport ¶
type Transport interface { Send(data []byte) error Recieve() ([]byte, error) Close() error SendHello(*TransportHelloMessage) error ReceiveHello() (*TransportHelloMessage, error) }
type TransportHelloMessage ¶
type TransportHelloMessage struct { XMLName xml.Name `xml:"hello"` Capabilities []Capability `xml:"capabilities>capability"` SessionID int `xml:"session-id,omitempty"` }
type TransportReadWriteCloser ¶
type TransportReadWriteCloser struct { io.Reader io.WriteCloser }
we implement ReadWriteCloser here so we can use the result of things like SSH dialing as io.ReadWriteCloser
func NewTransportReadWriteCloser ¶
func NewTransportReadWriteCloser(r io.Reader, w io.WriteCloser) *TransportReadWriteCloser
type TransportSSH ¶
type TransportSSH struct { SSHClient *ssh.Client SSHSession *ssh.Session // contains filtered or unexported fields }
func TransportSSHFromSSHClient ¶
func TransportSSHFromSSHClient(client *ssh.Client, session *ssh.Session) *TransportSSH
func (*TransportSSH) Close ¶
func (t *TransportSSH) Close() error
func (*TransportSSH) ReceiveHello ¶
func (t *TransportSSH) ReceiveHello() (*TransportHelloMessage, error)
func (*TransportSSH) Send ¶
Send a well formatted RPC message, including framing delimiters where applicable
func (*TransportSSH) SendHello ¶
func (t *TransportSSH) SendHello(msg *TransportHelloMessage) error
func (*TransportSSH) WaitForBytes ¶
wait for byte subsequence
func (*TransportSSH) WaitForFunc ¶
func (t *TransportSSH) WaitForFunc(fn TransportWaitFunc) ([]byte, error)
func (*TransportSSH) WaitForString ¶
wait for string -- extends wait for bytes
type TransportWaitFunc ¶
a transport wait func allows us to control the way we read input using a lambda function