Commit 9fe5820
committed
util/network: cleanup, further alignment with stdlib
* Remove the constants LINK_LOCAL_NETWORKS and LOOPBACK_NETWORKS, as
they are currently unreferenced, due to the changes made by PR#102019.
* Replace the PRIVATE_NETWORKS check with stdlib's is_private() method.
Besides a reduction of code, this results in a more comprehensive
check, as stdlib includes additional address spaces that were not
covered before, and is ever evolving (see, for example,
python/cpython#113179).
* In contrast with CPython, loopbacks and link-locals are NOT included
in our definition of "private", so adjust the code to keep the
existing semantics
* However, this *does* change the semantics for some address spaces to
follow Python's interpretation of IANA, such as marking reserved
documentation spaces as "local". Invert the test cases for
198.51.100.0/24 (TEST-NET-2) and 2001:db8::/32 (Documentation)
accordingly.
* We now need a new globally reachable IP space to use as
EXTERNAL_ADDRESSES in test_auth. Use AS112's address space, as it is
reserved by IANA, but marked as Globally Reachable.
* Finally, inline the last remaining constant IPV6_IPV4_LOOPBACK, and
leave a comment that work is underway in CPython by yours truly to
reduce the need for it and have is_loopback() subsume it.
Further work is required to align the semantics of e.g. what "private"
means with stdlib, and replace these seldomly used util functions with
stdlib properties across the tree (as is already the case in several
integrations), but hopefully this provides a stepping stone towards this
direction.1 parent 10076e6 commit 9fe5820
File tree
5 files changed
+22
-38
lines changed- homeassistant/util
- tests
- components
- auth
- http
- util
5 files changed
+22
-38
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
7 | 7 | | |
8 | 8 | | |
9 | 9 | | |
10 | | - | |
11 | | - | |
12 | | - | |
13 | | - | |
14 | | - | |
15 | | - | |
16 | | - | |
17 | | - | |
18 | | - | |
19 | | - | |
20 | | - | |
21 | | - | |
22 | | - | |
23 | | - | |
24 | | - | |
25 | | - | |
26 | | - | |
27 | | - | |
28 | | - | |
29 | | - | |
30 | | - | |
31 | | - | |
32 | | - | |
33 | | - | |
34 | | - | |
35 | | - | |
36 | | - | |
37 | 10 | | |
38 | 11 | | |
39 | 12 | | |
40 | | - | |
| 13 | + | |
| 14 | + | |
41 | 15 | | |
42 | 16 | | |
43 | 17 | | |
44 | 18 | | |
45 | | - | |
| 19 | + | |
46 | 20 | | |
47 | 21 | | |
48 | 22 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
83 | 83 | | |
84 | 84 | | |
85 | 85 | | |
86 | | - | |
87 | | - | |
88 | 86 | | |
89 | 87 | | |
90 | 88 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
30 | 30 | | |
31 | 31 | | |
32 | 32 | | |
33 | | - | |
34 | | - | |
| 33 | + | |
| 34 | + | |
35 | 35 | | |
36 | 36 | | |
37 | 37 | | |
| |||
81 | 81 | | |
82 | 82 | | |
83 | 83 | | |
84 | | - | |
85 | | - | |
| 84 | + | |
| 85 | + | |
86 | 86 | | |
87 | 87 | | |
88 | 88 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
53 | 53 | | |
54 | 54 | | |
55 | 55 | | |
56 | | - | |
| 56 | + | |
57 | 57 | | |
58 | 58 | | |
59 | 59 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
43 | 43 | | |
44 | 44 | | |
45 | 45 | | |
| 46 | + | |
46 | 47 | | |
| 48 | + | |
47 | 49 | | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
48 | 53 | | |
| 54 | + | |
49 | 55 | | |
| 56 | + | |
50 | 57 | | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
51 | 65 | | |
52 | | - | |
53 | | - | |
54 | 66 | | |
55 | 67 | | |
56 | 68 | | |
| |||
0 commit comments