Documentation ¶
Overview ¶
`msg.go` contains the logic for building, reading, accessing, and serializing RouterOS M2 messages.
`webfig.go` implements encryption negotiation and authentication against the web interface (webfig) of RouterOS v6.45+.
`winbox.go` contains the logic for sending unencrypted M2 messages to the RouterOS Winbox port (8291)
Index ¶
- Constants
- func FileUpload(webfigURL string, filename string, contents string, session *WebfigSession) bool
- func Login(webfigURL string, username string, password string, session *WebfigSession) bool
- func NegotiateEncryption(webfigURL string, session *WebfigSession) bool
- func ParseM2Message(data []byte, msg *M2Message) bool
- func ReceiveM2(conn net.Conn, msg *M2Message) bool
- func SendM2(conn net.Conn, msg *M2Message) bool
- type M2Message
- func (msg M2Message) AddBool(varname uint32, data bool)
- func (msg M2Message) AddRaw(varname uint32, data []byte)
- func (msg M2Message) AddString(varname uint32, data []byte)
- func (msg M2Message) AddU32(varname uint32, data uint32)
- func (msg M2Message) AddU32Array(varname uint32, data []uint32)
- func (msg M2Message) GetSessionID() uint32
- func (msg M2Message) Serialize() []byte
- func (msg M2Message) SetCommand(command uint32)
- func (msg M2Message) SetReplyExpected(expected bool)
- func (msg M2Message) SetRequestID(id uint32)
- func (msg M2Message) SetSessionID(id uint32)
- func (msg M2Message) SetTo(to uint32, handler uint32)
- type WebfigSession
Constants ¶
Variables ¶
This section is empty.
Functions ¶
func FileUpload ¶
func FileUpload(webfigURL string, filename string, contents string, session *WebfigSession) bool
Upload a file via webfig. The expected url is: http[s]://<address>:<port>/jsproxy The file will be written to /rw/disk and be viewable from the Webfig disk menu.
func Login ¶
func Login(webfigURL string, username string, password string, session *WebfigSession) bool
Given a username and password, this function will authenticate with the remote router.
func NegotiateEncryption ¶
func NegotiateEncryption(webfigURL string, session *WebfigSession) bool
Negotiates encryption with the remote Webfig described by `webfigURL`. Note that `webfigURL` is generally created like so:
webfigURL := protocol.GenerateURL(conf.Rhost, conf.Rport, conf.SSL, "/jsproxy")
But we didn't want to introduce a config dependency here.
func ParseM2Message ¶
this switch is cursed. it needs to be broke into manageable functions.
Types ¶
type M2Message ¶
type M2Message struct { Bools map[uint32]bool U32s map[uint32]uint32 Strings map[uint32][]byte Raw map[uint32][]byte ArrayU32 map[uint32][]uint32 ArrayM2 map[uint32][]*M2Message }
func NewM2Message ¶
func NewM2Message() *M2Message
func SendEncrypted ¶
func SendEncrypted(webfigURL string, msg *M2Message, session *WebfigSession) (*M2Message, bool)
Provided an M2Message this function will apply the various paddings/headers, encrypt it, and send it to the remote target described by `webfigURL`. The function returns the router's M2Message response.