Device management

This commit is contained in:
Magnus Åhall 2026-02-26 21:37:26 +01:00
parent 5635c2af1a
commit b9a5437909
6 changed files with 294 additions and 9 deletions

View file

@ -58,6 +58,7 @@ func (dev *RouterosDevice) Init() { // {{{
// query sends a RouterOS REST API query and returns the unparsed body.
func (dev RouterosDevice) query(method, path string, reqBody []byte) (body []byte, err error) { // {{{
logger.Debug("FOO", "port", dev.Port)
url := fmt.Sprintf("https://%s:%d/rest%s", dev.Host, dev.Port, path)
logger.Info("URL", "method", method, "url", url)
@ -150,7 +151,7 @@ func (dev *RouterosDevice) UpdateDNSEntry(record DNSEntry) (entry DNSEntry, err
err = json.Unmarshal(body, &entry)
return
}// }}}
func (dev *RouterosDevice) DeleteDNSEntry(id string) (err error) {
func (dev *RouterosDevice) DeleteDNSEntry(id string) (err error) {// {{{
_, err = dev.query("DELETE", "/ip/dns/static/"+id, []byte{})
if err != nil {
rosError := struct{ Detail string }{}
@ -162,7 +163,7 @@ func (dev *RouterosDevice) DeleteDNSEntry(id string) (err error) {
return
}
return
}
}// }}}
/*
// FillPeerDetails retrieves RouterOS resource ID, allowed-address and comment from the router