本文整理汇总了Golang中github.com/soniah/gosnmp.GoSNMP.SecurityModel方法的典型用法代码示例。如果您正苦于以下问题:Golang GoSNMP.SecurityModel方法的具体用法?Golang GoSNMP.SecurityModel怎么用?Golang GoSNMP.SecurityModel使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/soniah/gosnmp.GoSNMP
的用法示例。
在下文中一共展示了GoSNMP.SecurityModel方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: configureSNMP
// configureSNMP sets the various version and auth settings.
func (c Module) configureSNMP(g *gosnmp.GoSNMP) {
switch c.Version {
case 1:
g.Version = gosnmp.Version1
case 2:
g.Version = gosnmp.Version2c
case 3:
g.Version = gosnmp.Version3
}
g.Community = c.Auth.Community
// v3 security settings.
g.SecurityModel = gosnmp.UserSecurityModel
switch c.Auth.SecurityLevel {
case "noAuthNoPriv":
g.MsgFlags = gosnmp.NoAuthNoPriv
case "authNoPriv":
g.MsgFlags = gosnmp.AuthNoPriv
case "authPriv":
g.MsgFlags = gosnmp.AuthPriv
}
usm := &gosnmp.UsmSecurityParameters{
UserName: c.Auth.Username,
AuthenticationPassphrase: c.Auth.Password,
PrivacyPassphrase: c.Auth.PrivPassword,
}
switch c.Auth.AuthProtocol {
case "SHA":
usm.AuthenticationProtocol = gosnmp.SHA
case "MD5":
usm.AuthenticationProtocol = gosnmp.MD5
}
switch c.Auth.PrivProtocol {
case "DES":
usm.PrivacyProtocol = gosnmp.DES
case "AES":
usm.PrivacyProtocol = gosnmp.AES
}
g.SecurityParameters = usm
}