Documentation
¶
Overview ¶
Package routeros is a pure Go client library for accessing Mikrotik devices using the RouterOS API.
Index ¶
- Variables
- type Client
- func Dial(address, username, password string) (*Client, error)
- func DialContext(ctx context.Context, address, username, password string) (*Client, error)
- func DialTLS(address, username, password string, tlsConfig *tls.Config) (*Client, error)
- func DialTLSContext(ctx context.Context, 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) AsyncContext(ctx context.Context) <-chan error
- func (c *Client) Close() error
- func (c *Client) IsAsync() bool
- func (c *Client) Listen(sentence ...string) (*ListenReply, error)
- func (c *Client) ListenArgs(sentence []string) (*ListenReply, error)
- func (c *Client) ListenArgsContext(ctx context.Context, sentence []string) (*ListenReply, error)
- func (c *Client) ListenArgsQueue(sentence []string, queueSize int) (*ListenReply, error)
- func (c *Client) ListenArgsQueueContext(ctx context.Context, sentence []string, queueSize int) (*ListenReply, error)
- func (c *Client) ListenContext(ctx context.Context, sentence ...string) (*ListenReply, error)
- func (c *Client) Login(username, password string) error
- func (c *Client) LoginContext(ctx context.Context, username, password string) error
- func (c *Client) Run(sentences ...string) (*Reply, error)
- func (c *Client) RunArgs(sentences []string) (*Reply, error)
- func (c *Client) RunArgsContext(ctx context.Context, sentences []string) (*Reply, error)
- func (c *Client) RunContext(ctx context.Context, sentences ...string) (*Reply, error)
- func (c *Client) SetLogHandler(handler LogHandler)
- type DeviceError
- type ListenReply
- type LogHandler
- type Reply
- type UnknownReplyError
Constants ¶
This section is empty.
Variables ¶
var ( ErrNoChallengeReceived = errors.New("no ret (challenge) received") ErrInvalidChallengeReceived = errors.New("invalid ret (challenge) hex string received") )
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 DialContext ¶
DialContext connects and logs in to a RouterOS device using context.
func DialTLSContext ¶
func DialTLSContext(ctx context.Context, address, username, password string, tlsConfig *tls.Config) (*Client, error)
DialTLSContext connects and logs in to a RouterOS device using TLS and context.
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 with timeout.
func NewClient ¶
func NewClient(rwc io.ReadWriteCloser) (*Client, error)
NewClient returns a new Client over rwc. Login must be called.
func (*Client) AsyncContext ¶
AsyncContext starts asynchronous mode with context 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) ListenArgsContext ¶
ListenArgsContext 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) ListenArgsQueueContext ¶
func (c *Client) ListenArgsQueueContext(ctx context.Context, sentence []string, queueSize int) (*ListenReply, error)
ListenArgsQueueContext sends a sentence to the RouterOS device and returns immediately.
func (*Client) ListenContext ¶
ListenContext simply calls ListenArgsQueue() with queueSize set to c.Queue.
func (*Client) LoginContext ¶
LoginContext runs the /login command. DialContext and DialTLSContext call this automatically.
func (*Client) RunArgsContext ¶
RunArgsContext sends a sentence to the RouterOS device and waits for the reply.
func (*Client) RunContext ¶
RunContext simply calls RunArgsContext().
func (*Client) SetLogHandler ¶
func (c *Client) SetLogHandler(handler LogHandler)
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) CancelContext ¶
func (l *ListenReply) CancelContext(ctx context.Context) (*Reply, error)
CancelContext sends a cancel command to the RouterOS device with context.
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 LogHandler ¶
type UnknownReplyError ¶
UnknownReplyError records the sentence whose Word is unknown.
func (*UnknownReplyError) Error ¶
func (err *UnknownReplyError) Error() string