8000 Device tracker: SNMPv3 by T3m3z · Pull Request #3961 · home-assistant/core · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Device tracker: SNMPv3 #3961

8000
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

Merged
merged 5 commits into from
Oct 21, 2016
Merged

Conversation

T3m3z
Copy link
Contributor
@T3m3z T3m3z commented Oct 20, 2016

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):

device_tracker:
  - platform: snmp
    host: 192.168.0.1
    community: "community"
    authkey: "pass1234"
    privkey: "pass1234"
    baseoid: 1.3.6.1.2.1.4.22.1.2

Checklist:

If user exposed functionality or configuration variables are added/changed:

If the code communicates with devices, web services, or third-party tools:

  • Local tests with tox run successfully. Your PR cannot be merged unless tests pass
  • New dependencies have been added to the REQUIREMENTS variable (example).
  • New dependencies are only imported inside functions that use them (example).
  • New dependencies have been added to requirements_all.txt by running script/gen_requirements_all.py.
  • New files were added to .coveragerc.

@mention-bot
Copy link

@T3m3z, thanks for your PR! By analyzing the history of the files in this pull request, we identified @tomduijf, @kellerza and @fabaff to be potential reviewers.

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,
Copy link
Member

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:
Copy link
Member

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

@T3m3z
Copy link
Contributor Author
T3m3z commented Oct 20, 2016

Thanks @kellerza ! I added that vol.Inclusive to PR and removed those unnecessary parts of the code. That self.version part was stupid brainfart :)

@kellerza
Copy link
Member

Looks good! 🐬

Will you please create a PR on the snmp docs?

@T3m3z
Copy link
Contributor Author
T3m3z commented Oct 20, 2016

Of course! I don't have time today/tomorrow but probably during weekend I can make it.

@balloob balloob merged commit 9f6d1c4 into home-assistant:dev Oct 21, 2016
@T3m3z T3m3z deleted the device_tracker_snmpv3 branch October 22, 2016 06:52
@home-assistant home-assistant locked and limited conversation to collaborators Mar 17, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants
0