Documentation ¶
Index ¶
- Variables
- func SSHConfigPubKeyFile(user string, file string, passphrase string) (*ssh.ClientConfig, error)
- func SplitChunked(endOfMessage func()) bufio.SplitFunc
- type ReadWriteCloser
- type Session
- type Transport
- type TransportSSH
- func (t *TransportSSH) Chunked(b []byte) ([]byte, error)
- func (t *TransportSSH) Close() error
- func (t *TransportSSH) Dial(target string, config *ssh.ClientConfig) error
- func (t *TransportSSH) Receive() ([]byte, error)
- func (t *TransportSSH) Send(data []byte) error
- func (t *TransportSSH) SetVersion(version string)
- func (t *TransportSSH) WaitForBytes(b []byte) ([]byte, error)
- func (t *TransportSSH) WaitForFunc(f func([]byte) (int, error)) ([]byte, error)
- func (t *TransportSSH) WaitForRegexp(re *regexp.Regexp) ([]byte, [][]byte, error)
- func (t *TransportSSH) WaitForString(s string) (string, error)
- func (t *TransportSSH) Writeln(b []byte) (int, error)
Constants ¶
This section is empty.
Variables ¶
var DefaultCapabilities = []string{ message.NetconfVersion10, message.NetconfVersion11, }
DefaultCapabilities sets the default capabilities of the client library
var ErrBadChunk = errors.New("bad chunk")
ErrBadChunk indicates a chunked framing protocol error occurred
Functions ¶
func SSHConfigPubKeyFile ¶
SSHConfigPubKeyFile is a convenience function that takes a username, private key and passphrase and returns a new ssh.ClientConfig setup to pass credentials to DialSSH
func SplitChunked ¶
SplitChunked returns a bufio.SplitFunc suitable for decoding "chunked framing" NETCONF transport streams.
endOfMessage will be called at the end of each NETCONF message, and must not be nil.
It must only be used with bufio.Scanner who have a buffer of at least 16 bytes (rarely is this a concern).
Types ¶
type ReadWriteCloser ¶
type ReadWriteCloser struct { io.Reader io.WriteCloser }
ReadWriteCloser represents a combined IO Reader and WriteCloser
func NewReadWriteCloser ¶
func NewReadWriteCloser(r io.Reader, w io.WriteCloser) *ReadWriteCloser
NewReadWriteCloser creates a new combined IO Reader and WriteCloser from the provided objects
type Session ¶
Session represents a NETCONF sessions with a remote NETCONF server
func DialSSH ¶
func DialSSH(target string, config *ssh.ClientConfig) (*Session, error)
DialSSH creates a new NETCONF session using an SSH Transport. See TransportSSH.Dial for arguments.
func DialSSHTimeout ¶
func DialSSHTimeout(target string, config *ssh.ClientConfig, timeout time.Duration) (*Session, error)
DialSSHTimeout creates a new NETCONF session using an SSH Transport with timeout. See TransportSSH.Dial for arguments. The timeout value is used for both connection establishment and Read/Write operations.
func NewSession ¶
NewSession creates a new NETCONF session using the provided transport layer.
func (*Session) ReceiveHello ¶ added in v1.1.1
ReceiveHello is the first message received when connecting to a NETCONF server. It provides the supported capabilities of the server.
type Transport ¶
type Transport interface { Send([]byte) error Receive() ([]byte, error) Close() error SetVersion(version string) }
Transport interface defines what characteristics make up a NETCONF transport layer object.
type TransportSSH ¶
type TransportSSH struct {
// contains filtered or unexported fields
}
TransportSSH maintains the information necessary to communicate with the remote device over SSH
func (*TransportSSH) Close ¶
func (t *TransportSSH) Close() error
Close closes an existing SSH session and socket if they exist.
func (*TransportSSH) Dial ¶
func (t *TransportSSH) Dial(target string, config *ssh.ClientConfig) error
Dial connects and establishes SSH sessions
target can be an IP address (e.g.) 172.16.1.1 which utilizes the default NETCONF over SSH port of 830. Target can also specify a port with the following format <host>:<port (e.g. 172.16.1.1:22)
config takes a ssh.ClientConfig connection. See documentation for go.crypto/ssh for documentation. There is a helper function SSHConfigPassword thar returns a ssh.ClientConfig for simple username/password authentication
func (*TransportSSH) Send ¶
Send a well formatted NETCONF rpc message as a slice of bytes adding on the necessary framing messages.
func (*TransportSSH) SetVersion ¶
func (t *TransportSSH) SetVersion(version string)