Skip to content
This repository has been archived by the owner on Aug 27, 2022. It is now read-only.

Commit

Permalink
Fix issue with default exclude list
Browse files Browse the repository at this point in the history
  • Loading branch information
ludeeus committed Jul 30, 2019
1 parent 4423b2f commit 894b962
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 9 deletions.
5 changes: 1 addition & 4 deletions .devcontainer/configuration.yaml
Expand Up @@ -6,7 +6,4 @@ logger:


sensor:
- platform: authenticated
exclude:
- 8.8.8.8
- 1.1.1.1
- platform: authenticated
12 changes: 7 additions & 5 deletions custom_components/authenticated/sensor.py
Expand Up @@ -48,9 +48,7 @@
vol.Optional(CONF_PROVIDER, default="ipapi"): vol.In(PROVIDERS),
vol.Optional(CONF_LOG_LOCATION, default=""): cv.string,
vol.Optional(CONF_NOTIFY, default=True): cv.boolean,
vol.Optional(CONF_EXCLUDE, default="None"): vol.All(
cv.ensure_list, [cv.string]
),
vol.Optional(CONF_EXCLUDE, default=[]): vol.All(cv.ensure_list, [cv.string]),
}
)

Expand Down Expand Up @@ -321,7 +319,9 @@ def load_authentications(authfile, exclude):
for token in tokens:
try:
for excludeaddress in exclude:
if ValidateIP(token["last_used_ip"]) in ip_network(excludeaddress, False):
if ValidateIP(token["last_used_ip"]) in ip_network(
excludeaddress, False
):
break
else:
if token["last_used_ip"] in tokens_cleaned:
Expand All @@ -332,7 +332,9 @@ def load_authentications(authfile, exclude):
tokens_cleaned[token["last_used_ip"]]["last_used_at"] = token[
"last_used_at"
]
tokens_cleaned[token["last_used_ip"]]["user_id"] = token["user_id"]
tokens_cleaned[token["last_used_ip"]]["user_id"] = token[
"user_id"
]
else:
tokens_cleaned[token["last_used_ip"]] = {}
tokens_cleaned[token["last_used_ip"]]["last_used_at"] = token[
Expand Down

0 comments on commit 894b962

Please sign in to comment.