Documentation ¶
Overview ¶
Package routeros is a pure Go client library for accessing Mikrotik devices using the RouterOS API.
Index ¶
- type Client
- func Dial(address, username, password string) (*Client, error)
- func DialTLS(address, username, password string, tlsConfig *tls.Config) (*Client, error)
- func DialTLSTimeout(address, username, password string, tlsConfig *tls.Config, ...) (*Client, error)
- func DialTimeout(address, username, password string, timeout time.Duration) (*Client, error)
- func NewClient(rwc io.ReadWriteCloser) (*Client, error)
- func (c *Client) Async() <-chan error
- func (c *Client) Close()
- func (c *Client) Listen(sentence ...string) (*ListenReply, error)
- func (c *Client) ListenArgs(sentence []string) (*ListenReply, error)
- func (c *Client) ListenArgsQueue(sentence []string, queueSize int) (*ListenReply, error)
- func (c *Client) Login(username, password string) error
- func (c *Client) Run(sentence ...string) (*Reply, error)
- func (c *Client) RunArgs(sentence []string) (*Reply, error)
- type DeviceError
- type ListenReply
- type Reply
- type UnknownReplyError
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client struct { Queue int // contains filtered or unexported fields }
Client is a RouterOS API client.
func Dial ¶
Dial connects and logs in to a RouterOS device.
func DialTLS ¶
DialTLS connects and logs in to a RouterOS device using TLS.
func DialTLSTimeout ¶
func DialTLSTimeout(address, username, password string, tlsConfig *tls.Config, timeout time.Duration) (*Client, error)
DialTLSTimeout connects and logs in to a RouterOS device using TLS with timeout.
func DialTimeout ¶
DialTimeout connects and logs in to a RouterOS device.
func NewClient ¶
func NewClient(rwc io.ReadWriteCloser) (*Client, error)
NewClient returns a new Client over rwc. Login must be called.
func (*Client) Async ¶
Async starts asynchronous mode and returns immediately.
func (*Client) Listen ¶
func (c *Client) Listen(sentence ...string) (*ListenReply, error)
Listen simply calls ListenArgsQueue() with queueSize set to c.Queue.
func (*Client) ListenArgs ¶
func (c *Client) ListenArgs(sentence []string) (*ListenReply, error)
ListenArgs simply calls ListenArgsQueue() with queueSize set to c.Queue.
func (*Client) ListenArgsQueue ¶
func (c *Client) ListenArgsQueue(sentence []string, queueSize int) (*ListenReply, error)
ListenArgsQueue sends a sentence to the RouterOS device and returns immediately.
func (*Client) Login ¶
Login runs the /login command. Dial and DialTLS call this automatically.
func (*Client) Run ¶
Run simply calls RunArgs().
type DeviceError ¶
DeviceError records the sentence containing the error received from the device. The sentence may have Word !trap or !fatal.
func (*DeviceError) Error ¶
func (err *DeviceError) Error() string
type ListenReply ¶
ListenReply is the struct returned by the Listen*() functions. When the channel returned by Chan() is closed, Done is set to the RouterOS sentence that caused it to be closed.
func (*ListenReply) Cancel ¶
func (l *ListenReply) Cancel() (*Reply, error)
Cancel sends a cancel command to the RouterOS device.
func (*ListenReply) Chan ¶
func (l *ListenReply) Chan() <-chan *proto.Sentence
Chan returns a channel for receiving !re RouterOS sentences. To close the channel, call Cancel() on l.
type Reply ¶
Reply has all the sentences from a reply.