glide setup and dependencies addition

This commit is contained in:
Steve Brunton
2017-08-27 23:27:11 -04:00
commit b0e0be5688
74 changed files with 11533 additions and 0 deletions

114
vendor/gopkg.in/routeros.v2/examples/listen/main.go generated vendored Normal file
View File

@@ -0,0 +1,114 @@
package main
import (
"flag"
"log"
"strings"
"time"
"gopkg.in/routeros.v2"
)
var (
command = flag.String("command", "/ip/firewall/address-list/listen", "RouterOS command")
address = flag.String("address", "127.0.0.1:8728", "RouterOS address and port")
username = flag.String("username", "admin", "User name")
password = flag.String("password", "admin", "Password")
timeout = flag.Duration("timeout", 10*time.Second, "Cancel after")
async = flag.Bool("async", false, "Call Async()")
useTLS = flag.Bool("tls", false, "Use TLS")
)
func dial() (*routeros.Client, error) {
if *useTLS {
return routeros.DialTLS(*address, *username, *password, nil)
}
return routeros.Dial(*address, *username, *password)
}
func main() {
flag.Parse()
c, err := dial()
if err != nil {
log.Fatal(err)
}
defer c.Close()
c.Queue = 100
if *async {
explicitAsync(c)
} else {
implicitAsync(c)
}
}
func explicitAsync(c *routeros.Client) {
errC := c.Async()
go func() {
l, err := c.ListenArgs(strings.Split(*command, " "))
if err != nil {
log.Fatal(err)
}
go func() {
time.Sleep(*timeout)
log.Print("Cancelling the RouterOS command...")
_, err := l.Cancel()
if err != nil {
log.Fatal(err)
}
}()
log.Print("Waiting for !re...")
for sen := range l.Chan() {
log.Printf("Update: %s", sen)
}
err = l.Err()
if err != nil {
log.Fatal(err)
}
log.Print("Done!")
c.Close()
}()
err := <-errC
if err != nil {
log.Fatal(err)
}
}
func implicitAsync(c *routeros.Client) {
l, err := c.ListenArgs(strings.Split(*command, " "))
if err != nil {
log.Fatal(err)
}
go func() {
time.Sleep(*timeout)
log.Print("Cancelling the RouterOS command...")
_, err := l.Cancel()
if err != nil {
log.Fatal(err)
}
}()
log.Print("Waiting for !re...")
for sen := range l.Chan() {
log.Printf("Update: %s", sen)
}
err = l.Err()
if err != nil {
log.Fatal(err)
}
log.Print("Done!")
c.Close()
}

46
vendor/gopkg.in/routeros.v2/examples/run/main.go generated vendored Normal file
View File

@@ -0,0 +1,46 @@
package main
import (
"flag"
"log"
"strings"
"gopkg.in/routeros.v2"
)
var (
command = flag.String("command", "/system/resource/print", "RouterOS command")
address = flag.String("address", "127.0.0.1:8728", "RouterOS address and port")
username = flag.String("username", "admin", "User name")
password = flag.String("password", "admin", "Password")
async = flag.Bool("async", false, "Use async code")
useTLS = flag.Bool("tls", false, "Use TLS")
)
func dial() (*routeros.Client, error) {
if *useTLS {
return routeros.DialTLS(*address, *username, *password, nil)
}
return routeros.Dial(*address, *username, *password)
}
func main() {
flag.Parse()
c, err := dial()
if err != nil {
log.Fatal(err)
}
defer c.Close()
if *async {
c.Async()
}
r, err := c.RunArgs(strings.Split(*command, " "))
if err != nil {
log.Fatal(err)
}
log.Print(r)
}

45
vendor/gopkg.in/routeros.v2/examples/tab/main.go generated vendored Normal file
View File

@@ -0,0 +1,45 @@
package main
import (
"flag"
"fmt"
"log"
"strings"
"time"
"gopkg.in/routeros.v2"
)
var (
address = flag.String("address", "192.168.0.1:8728", "Address")
username = flag.String("username", "admin", "Username")
password = flag.String("password", "admin", "Password")
properties = flag.String("properties", "name,rx-byte,tx-byte,rx-packet,tx-packet", "Properties")
interval = flag.Duration("interval", 1*time.Second, "Interval")
)
func main() {
flag.Parse()
c, err := routeros.Dial(*address, *username, *password)
if err != nil {
log.Fatal(err)
}
for {
reply, err := c.Run("/interface/print", "?disabled=false", "?running=true", "=.proplist="+*properties)
if err != nil {
log.Fatal(err)
}
for _, re := range reply.Re {
for _, p := range strings.Split(*properties, ",") {
fmt.Print(re.Map[p], "\t")
}
fmt.Print("\n")
}
fmt.Print("\n")
time.Sleep(*interval)
}
}