Git Product home page Git Product logo

routeros's Introduction

RouterOS Client for the Go language

Go library for accessing Mikrotik devices using the RouterOS API.

Look in the examples directory to learn how to use this library: run, listen, tab.

API documentation is available at godoc.org. Page on the Mikrotik Wiki.

Released versions: v2 v1

routeros's People

Contributors

andre-luiz-dos-santos avatar archaron avatar go-routeros avatar im-kulikov avatar v12 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

routeros's Issues

There is no response to the sent command.

I am writing a program that should disable devices. But when the command is sent, the microtik responds "!done @ []" and nothing happens.
reply, _:= clientROS.Run("/ip/dhcp-server/lease/set", "?disabled=yes", "?numbers="+id)
where "id" is obtained as id = re.Map [". id"]
I tried and so
reply, _:= clientROS.Run("/ip/dhcp-server/lease/disable", "?numbers="+id)

What am I doing wrong?

[question] how to modify code for reuterOS v6

For API v6 request /ip/firewall/address-list/listen looks like /ip firewall address-list listen

when I change line 13 master/examples/listen/main.go

to

command  = flag.String("command", "/ip firewall address-list listen", "RouterOS command")

I have error

from RouterOS device: no such command
exit status 1

slice bounds out of range ... with capacity 4096

Good day.
When using this library, an error occurs:

panic: runtime error: slice bounds out of range [:4380] with capacity 4096

goroutine 11 [running]:
bufio.(*Reader).Read(0xc0000556e0, 0xc0028c6a4e, 0x1, 0x1, 0x0, 0x0, 0x0)
        C:/Go/src/bufio/bufio.go:238 +0x3da
io.ReadAtLeast(0xa1da20, 0xc0000065b8, 0xc0028c6a4e, 0x1, 0x1, 0x1, 0x9, 0x1acac200a28, 0x30)
        C:/Go/src/io/io.go:328 +0x8e
io.ReadFull(...)
        C:/Go/src/io/io.go:347
gopkg.in/routeros.v2/proto.(*reader).readNumber(0xc0000065b8, 0x1, 0x5321d8, 0x100000000000030, 0x1acd1a77e68)
        C:/Users/root/go/src/github.com/rid-lin/gomtc/vendor/gopkg.in/routeros.v2/proto/reader.go:62 +0x85
gopkg.in/routeros.v2/proto.(*reader).readLength(0xc0000065b8, 0xc0028c6a40, 0x9, 0xc000046c01)
        C:/Users/root/go/src/github.com/rid-lin/gomtc/vendor/gopkg.in/routeros.v2/proto/reader.go:74 +0x3f
gopkg.in/routeros.v2/proto.(*reader).readWord(0xc0000065b8, 0xc001b096e0, 0xc0028c6a40, 0x9, 0xc00329c1c8, 0x1)
        C:/Users/root/go/src/github.com/rid-lin/gomtc/vendor/gopkg.in/routeros.v2/proto/reader.go:100 +0x36
gopkg.in/routeros.v2/proto.(*reader).ReadSentence(0xc0000065b8, 0xc001d64e20, 0x0, 0xcaa5c8)
        C:/Users/root/go/src/github.com/rid-lin/gomtc/vendor/gopkg.in/routeros.v2/proto/reader.go:28 +0x8f
gopkg.in/routeros%2ev2.(*Client).readReply(0xc000055740, 0x0, 0x0, 0xc0018ab5e0)
        C:/Users/root/go/src/github.com/rid-lin/gomtc/vendor/gopkg.in/routeros.v2/reply.go:29 +0x62
gopkg.in/routeros%2ev2.(*Client).endCommandSync(0xc000055740, 0xc0018ab5a0, 0x1d, 0x0)
        C:/Users/root/go/src/github.com/rid-lin/gomtc/vendor/gopkg.in/routeros.v2/run.go:42 +0x7c
gopkg.in/routeros%2ev2.(*Client).RunArgs(0xc000055740, 0xc0032298a0, 0x3, 0x3, 0xe, 0xc0018ab5a0, 0x1d)
        C:/Users/root/go/src/github.com/rid-lin/gomtc/vendor/gopkg.in/routeros.v2/run.go:26 +0x171

What can you advise?

run cmd question

in terminal i run “interface print stats” ,

in this lib ,what write ?

"/interface/print/stats" return faslse

Merge master into v2

As a lot of people may be using v2, the plain login commit should be merged in v2.

And in fact, looking at all the other changes in master, there is no breaking API stuff between master and v2, so you can just as will merge all commits to v2.

Higher level api

Hello,

Any chance of making a bit higher level API as well?

like

// Create new mikrotik api client
client := mikrotik.NewClientApi("192.168.88.1:8728")
if err := client.Connect("admin", ""); err != nil {
    log.Fatalf("Failed to connect: %s", err.Error())
}
defer client.Close()

// Obtain system information
system, err := client.System()
check(err)

// Obtain system resource information
resources, err := system.Resources();
check(err)

// Print some system resources
log.Printf("Uptime: %s", resources.Uptime)
log.Printf("Version: %s", resources.Version)
log.Printf("Build-time: %s", resources.BuildTime)
// ..

// Obtain information about interfaces
iface,  err := client.Interface()
check(err)

// Print basic info about each interface
for idx, iface := range iface.ToArray() {
    log.Printf("Interface: #%d %s Type: %s Mac: %s", idx, iface.Name, iface.Type, iface.MacAddress)
}

keep alive for 24 hours

hi
can we keep it connect for example for 24 hours ?
how can we detect it disconnect and reconnect again?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.