add denylist implementation

This commit is contained in:
Sean Breckenridge 2023-02-21 01:28:53 -08:00
parent ce2a42c45a
commit 2fa0b5cef8
5 changed files with 279 additions and 5 deletions

View file

@ -24,7 +24,7 @@ class LocationProtocol(Protocol):
# converted from namedtuple to a dataclass so datasource field can be added optionally
# if we want, can eventually be converted back to a namedtuple when all datasources are compliant
@dataclass
@dataclass(frozen=True, eq=True)
class Location(LocationProtocol):
lat: float
lon: float

View file

@ -36,6 +36,7 @@ class FallbackLocation(LocationProtocol):
@classmethod
def from_end_date(
cls,
*,
lat: float,
lon: float,
dt: datetime,

View file

@ -14,8 +14,8 @@ from datetime import datetime
class config(location.via_ip):
# no real science to this, just a guess of ~15km accuracy for IP addresses
accuracy: float = 15_000.0
for_duration: float = 60 * 10 # default to being accurate for ~10 minutes
# default to being accurate for ~10 minutes
for_duration: float = 60 * 10
from typing import Iterator
@ -41,7 +41,7 @@ def fallback_locations() -> Iterator[FallbackLocation]:
# for compatibility with my.location.via_ip, this shouldnt be used by other modules
def locations() -> Iterator[Location]:
medium("via_ip.locations is deprecated, use via_ip.fallback_locations instead")
medium("locations is deprecated, should use fallback_locations or estimate_location")
yield from map(FallbackLocation.to_location, fallback_locations())