Skip to content

Commit 2e3e1e9

Browse files
authored
Moved to forked version of GoSNMPServer (#38)
* Moving to thorsager/GoSNMPServer v0.3.0-beta.1 * Fixed typo in README.md
1 parent 64649d0 commit 2e3e1e9

4 files changed

Lines changed: 35 additions & 12 deletions

File tree

README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,3 +74,9 @@ Possible values are
7474
- `match` Will break the matching if the conversation matches.
7575

7676
An example of usage can be found in [config.yaml](_examples/configuration/config.yaml) in the "fake-auth" conversation.
77+
78+
79+
# Thank You
80+
This project builds on [slayercat/GoSNMPServer](https://github.com/slayercat/GoSNMPServer) for all the SNMP serving _(I
81+
have made a [fork](https://github.com/thorsager/GoSNMPServer) for maintenance)_ and the [gliderlabs/ssh](https://github.com/gliderlabs/ssh)
82+
for SSH serving.

go.mod

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,15 @@ module github.com/thorsager/mockdev
22

33
go 1.18
44

5+
replace github.com/slayercat/GoSNMPServer => github.com/thorsager/GoSNMPServer v0.3.0-beta.1
6+
57
require (
68
github.com/docker/docker v20.10.17+incompatible
79
github.com/gliderlabs/ssh v0.3.4
810
github.com/gosnmp/gosnmp v1.35.0
911
github.com/sirupsen/logrus v1.8.1
1012
github.com/slayercat/GoSNMPServer v0.1.2
11-
github.com/slayercat/gosnmp v1.24.0
13+
github.com/slayercat/gosnmp v1.24.1-0.20200225080903-29819b7774e5
1214
gopkg.in/yaml.v2 v2.4.0
1315
)
1416

@@ -22,5 +24,5 @@ require (
2224
github.com/tklauser/numcpus v0.5.0 // indirect
2325
github.com/yusufpapurcu/wmi v1.2.2 // indirect
2426
golang.org/x/crypto v0.0.0-20220525230936-793ad666bf5e // indirect
25-
golang.org/x/sys v0.0.0-20220614162138-6c1b26c55098 // indirect
27+
golang.org/x/sys v0.0.0-20220615213510-4f61da869c0c // indirect
2628
)

go.sum

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,8 @@ github.com/slayercat/GoSNMPServer v0.1.2 h1:JnKksP32zVXqUADZ0jKPCAe0qykADsUnfrzt
3434
github.com/slayercat/GoSNMPServer v0.1.2/go.mod h1:pAsvl4cV65krDY5CNy7IFDTIZ5V56nK3y3PvWOqV2IY=
3535
github.com/slayercat/gosnmp v1.24.0 h1:VpnKTvW1BqG/rvQBf/I1y2t8HEnhjnF7pP7tBvz3TDk=
3636
github.com/slayercat/gosnmp v1.24.0/go.mod h1:tB/loGhNgiSxOZzz02TRKKhUPUzDrGrkYQSXxD3KfqM=
37+
github.com/slayercat/gosnmp v1.24.1-0.20200225080903-29819b7774e5 h1:Zq1YuJvWWpmrHqdIBK95DFgI7+pZXL/zejuLxRljL2I=
38+
github.com/slayercat/gosnmp v1.24.1-0.20200225080903-29819b7774e5/go.mod h1:tB/loGhNgiSxOZzz02TRKKhUPUzDrGrkYQSXxD3KfqM=
3739
github.com/soniah/gosnmp v1.27.0 h1:nfmGlwMe/VvpRE5U2Llnt7ytaqT+qIzDzWbm/C75MjQ=
3840
github.com/soniah/gosnmp v1.27.0/go.mod h1:nD71O9B+i/ueeBWp44G03aIY1Y4GJhF/gKK/KyaTzxU=
3941
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
@@ -43,6 +45,16 @@ github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UV
4345
github.com/stretchr/testify v1.4.1-0.20200129000828-ea72eb91592e/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA=
4446
github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA=
4547
github.com/stretchr/testify v1.7.1 h1:5TQK59W5E3v0r2duFAb7P95B6hEeOyEnHRa8MjYSMTY=
48+
github.com/thorsager/GoSNMPServer v0.1.3-0.20220615134933-855a6b052a72 h1:zxFnTbrySs/j2y53nQLiOrZVK0Z1pGkdNShi+YYtXBc=
49+
github.com/thorsager/GoSNMPServer v0.1.3-0.20220615134933-855a6b052a72/go.mod h1:YvvAhBahK+tzkw9yenaNXXftZDR+T3y3OqLL1q4/3pU=
50+
github.com/thorsager/GoSNMPServer v0.1.3-0.20220617064021-50803377c927 h1:34Eq2bZaLzJ3045Sx1jWwS85JgHGQmQJs+qyAOx7/Tw=
51+
github.com/thorsager/GoSNMPServer v0.1.3-0.20220617064021-50803377c927/go.mod h1:Lrn2n2hsaKLpAme03eIeoGgE3qH0j9DkGtp6ZqqcngE=
52+
github.com/thorsager/GoSNMPServer v0.1.3-0.20220617100047-644e271aa5aa h1:NU8cfx083z3/NKOe5c96ZtHV3bs9HKNPKFR6SDkytts=
53+
github.com/thorsager/GoSNMPServer v0.1.3-0.20220617100047-644e271aa5aa/go.mod h1:Lrn2n2hsaKLpAme03eIeoGgE3qH0j9DkGtp6ZqqcngE=
54+
github.com/thorsager/GoSNMPServer v0.1.3-0.20220618205517-7650fd7ef16a h1:gsPLpfN+7/D1EIFIMRI0SnZ1ZnCTAkjBjPw/FV08r0s=
55+
github.com/thorsager/GoSNMPServer v0.1.3-0.20220618205517-7650fd7ef16a/go.mod h1:Lrn2n2hsaKLpAme03eIeoGgE3qH0j9DkGtp6ZqqcngE=
56+
github.com/thorsager/GoSNMPServer v0.3.0-beta.1 h1:KWwS3BBxchcLmmNEAkD5X9mUbg3BvnPMKaFmCLTw+wI=
57+
github.com/thorsager/GoSNMPServer v0.3.0-beta.1/go.mod h1:Lrn2n2hsaKLpAme03eIeoGgE3qH0j9DkGtp6ZqqcngE=
4658
github.com/tklauser/go-sysconf v0.3.10 h1:IJ1AZGZRWbY8T5Vfk04D9WOA5WSejdflXxP03OUqALw=
4759
github.com/tklauser/go-sysconf v0.3.10/go.mod h1:C8XykCvCb+Gn0oNCWPIlcb0RuglQTYaQ2hGm7jmxEFk=
4860
github.com/tklauser/numcpus v0.4.0/go.mod h1:1+UI3pD8NW14VMwdgJNJ1ESk2UnwhAnz5hMwiKKqXCQ=
@@ -71,6 +83,8 @@ golang.org/x/sys v0.0.0-20220128215802-99c3d69c2c27/go.mod h1:oPkhp1MJrh7nUepCBc
7183
golang.org/x/sys v0.0.0-20220503163025-988cb79eb6c6/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
7284
golang.org/x/sys v0.0.0-20220614162138-6c1b26c55098 h1:PgOr27OhUx2IRqGJ2RxAWI4dJQ7bi9cSrB82uzFzfUA=
7385
golang.org/x/sys v0.0.0-20220614162138-6c1b26c55098/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
86+
golang.org/x/sys v0.0.0-20220615213510-4f61da869c0c h1:aFV+BgZ4svzjfabn8ERpuB4JI4N6/rdy1iusx77G3oU=
87+
golang.org/x/sys v0.0.0-20220615213510-4f61da869c0c/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
7488
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1 h1:v+OssWQX+hTHEmOBgwxdZxK4zHq3yOs8F9J7mk0PY8E=
7589
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
7690
golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=

snmpsup/pdu_encode_decode.go

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -22,22 +22,23 @@ func (p *NeutralPDU) String() string {
2222
var v string
2323
switch t := p.Value.(type) {
2424
case string:
25-
{
26-
s := p.Value.(string)
27-
if isAsciiPrintable(s) {
28-
tp = fmt.Sprintf("%T", t)
29-
v = s
30-
} else {
31-
tp = fmt.Sprintf("hex-%T", t)
32-
v = hex.EncodeToString([]byte(s))
33-
}
34-
}
25+
tp, v = encodeString(p.Value.(string))
26+
case []uint8:
27+
b := p.Value.([]uint8)
28+
s := string(b)
29+
tp, v = encodeString(s)
3530
default:
3631
v = fmt.Sprintf("%v", p.Value)
3732
tp = fmt.Sprintf("%T", t)
3833
}
3934
return fmt.Sprintf("%s/%d/%s/%s", p.Oid, p.Asn1BER, tp, v)
4035
}
36+
func encodeString(s string) (string, string) {
37+
if isAsciiPrintable(s) {
38+
return "string", s
39+
}
40+
return "hex-string", hex.EncodeToString([]byte(s))
41+
}
4142

4243
func ParseNeutralPDU(s string) (*NeutralPDU, error) {
4344
parts := strings.SplitN(s, "/", 4)

0 commit comments

Comments
 (0)