Accept a list of host strings; return (exact_set, suffix_tuple).
(raw)
| 75 | |
| 76 | |
| 77 | def load_host_rules(raw) -> tuple[set[str], tuple[str, ...]]: |
| 78 | """Accept a list of host strings; return (exact_set, suffix_tuple).""" |
| 79 | exact: set[str] = set() |
| 80 | suffixes: list[str] = [] |
| 81 | for item in raw or []: |
| 82 | host = str(item).strip().lower().rstrip(".") |
| 83 | if not host: |
| 84 | continue |
| 85 | if host.startswith("."): |
| 86 | suffixes.append(host) |
| 87 | else: |
| 88 | exact.add(host) |
| 89 | return exact, tuple(suffixes) |
| 90 | |
| 91 | |
| 92 | def host_matches_rules(host: str, rules: tuple[set[str], tuple[str, ...]]) -> bool: |
no outgoing calls