-
-
Notifications
You must be signed in to change notification settings - Fork 33.7k
Device tracker: SNMPv3 #3961
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Device tracker: SNMPv3 #3961
Conversation
vol.Required(CONF_COMMUNITY): cv.string, | ||
vol.Optional(CONF_COMMUNITY, default=DEFAULT_COMMUNITY): cv.string, | ||
vol.Optional(CONF_AUTHKEY, default=None): cv.string, | ||
vol.Optional(CONF_PRIVKEY, default=None): cv.string, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we try to tighten this a bit with vol.Inclusive(CONF_someKEY, 'keygroup
)` on the two keys? That should require them both at the same time.
There is also a vol.Exclusive
, but I'm not 100% sure how to combine the two...
@@ -94,8 +113,12 @@ def get_snmp_data(self): | |||
"""Fetch MAC addresses from access point via SNMP.""" | |||
devices = [] | |||
|
|||
errindication, errstatus, errindex, restable = self.snmp.nextCmd( | |||
self.community, self.host, self.baseoid) | |||
if self.version == 3: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you use the same variable above, say self.request
, instead of self.community
and self.userdata
then you don't require this if statement. You also don't need the self.version
Thanks @kellerza ! I added that |
Looks good! 🐬 Will you please create a PR on the snmp docs? |
Of course! I don't have time today/tomorrow but probably during weekend I can make it. |
Description:
Original SNMP device tracker only supported SNMPv1 where security is non-existent. This PR adds support for SNMPv3 with authorization using SHA and privacy using AES.
Functionality was tested using Mikrotik router. Component tries to use SNMPv3 if both authkey (key for authentication) and privkey (key for encrypting data) are provided. Otherwise it will revert back to older SNMP version and use only community-string.
Example entry for
configuration.yaml
(if applicable):Checklist:
If user exposed functionality or configuration variables are added/changed:
If the code communicates with devices, web services, or third-party tools:
tox
run successfully. Your PR cannot be merged unless tests passREQUIREMENTS
variable (example).requirements_all.txt
by runningscript/gen_requirements_all.py
..coveragerc
.