forked from sg3des/mikrotik
-
Notifications
You must be signed in to change notification settings - Fork 0
/
helpers.go
60 lines (46 loc) · 1.31 KB
/
helpers.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
package mikrotik
import (
"crypto/tls"
"time"
routeros "gopkg.in/routeros.v2"
)
//Dial to mikrotik router
func Dial(addr, user, pass string) (*Mikrotik, error) {
c, err := routeros.Dial(addr, user, pass)
if err != nil {
return nil, err
}
mik := &Mikrotik{Conn: c}
mik.setMikrotikCommands()
return mik, nil
}
//DialTimeout dial to mikrotik router with timeout
func DialTimeout(addr, user, pass string, timeout time.Duration) (*Mikrotik, error) {
c, err := routeros.DialTimeout(addr, user, pass, timeout)
if err != nil {
return nil, err
}
mik := &Mikrotik{Conn: c}
mik.setMikrotikCommands()
return mik, nil
}
//DialTLSTimeout dial to mikrotik router with timeout and TLS
func DialTLSTimeout(addr, user, pass string, tlsConfig *tls.Config, timeout time.Duration) (*Mikrotik, error) {
c, err := routeros.DialTLSTimeout(addr, user, pass, tlsConfig, timeout)
if err != nil {
return nil, err
}
mik := &Mikrotik{Conn: c}
mik.setMikrotikCommands()
return mik, nil
}
//DialTLS to mikrotik router with TLS
func DialTLS(addr, user, pass string, tlsConfig *tls.Config) (*Mikrotik, error) {
c, err := routeros.DialTLS(addr, user, pass, tlsConfig)
if err != nil {
return nil, err
}
mik := &Mikrotik{Conn: c}
mik.setMikrotikCommands()
return mik, nil
}