shadow-tools 0.2.3__tar.gz → 0.2.4__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (24) hide show
  1. {shadow_tools-0.2.3 → shadow_tools-0.2.4}/PKG-INFO +3 -2
  2. {shadow_tools-0.2.3 → shadow_tools-0.2.4}/README.md +2 -1
  3. {shadow_tools-0.2.3 → shadow_tools-0.2.4}/pyproject.toml +1 -1
  4. shadow_tools-0.2.4/release-0.2.3/shadow_tools-0.2.3-py3-none-any.whl +0 -0
  5. shadow_tools-0.2.4/release-0.2.3/shadow_tools-0.2.3.tar.gz +0 -0
  6. {shadow_tools-0.2.3 → shadow_tools-0.2.4}/src/shadowtools/__init__.py +1 -1
  7. {shadow_tools-0.2.3 → shadow_tools-0.2.4}/src/shadowtools/network.py +10 -5
  8. {shadow_tools-0.2.3 → shadow_tools-0.2.4}/tests/test_core.py +2 -1
  9. {shadow_tools-0.2.3 → shadow_tools-0.2.4}/.gitignore +0 -0
  10. {shadow_tools-0.2.3 → shadow_tools-0.2.4}/LICENSE +0 -0
  11. {shadow_tools-0.2.3 → shadow_tools-0.2.4}/release-0.2.0/shadow_tools-0.2.0-py3-none-any.whl +0 -0
  12. {shadow_tools-0.2.3 → shadow_tools-0.2.4}/release-0.2.0/shadow_tools-0.2.0.tar.gz +0 -0
  13. {shadow_tools-0.2.3 → shadow_tools-0.2.4}/release-0.2.1/shadow_tools-0.2.1-py3-none-any.whl +0 -0
  14. {shadow_tools-0.2.3 → shadow_tools-0.2.4}/release-0.2.1/shadow_tools-0.2.1.tar.gz +0 -0
  15. {shadow_tools-0.2.3 → shadow_tools-0.2.4}/release-0.2.2/shadow_tools-0.2.2-py3-none-any.whl +0 -0
  16. {shadow_tools-0.2.3 → shadow_tools-0.2.4}/release-0.2.2/shadow_tools-0.2.2.tar.gz +0 -0
  17. {shadow_tools-0.2.3 → shadow_tools-0.2.4}/src/shadowtools/ai.py +0 -0
  18. {shadow_tools-0.2.3 → shadow_tools-0.2.4}/src/shadowtools/async_tools.py +0 -0
  19. {shadow_tools-0.2.3 → shadow_tools-0.2.4}/src/shadowtools/cli.py +0 -0
  20. {shadow_tools-0.2.3 → shadow_tools-0.2.4}/src/shadowtools/data.py +0 -0
  21. {shadow_tools-0.2.3 → shadow_tools-0.2.4}/src/shadowtools/files.py +0 -0
  22. {shadow_tools-0.2.3 → shadow_tools-0.2.4}/src/shadowtools/http.py +0 -0
  23. {shadow_tools-0.2.3 → shadow_tools-0.2.4}/src/shadowtools/validation.py +0 -0
  24. {shadow_tools-0.2.3 → shadow_tools-0.2.4}/src/shadowtools/websocket.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.5
2
2
  Name: shadow-tools
3
- Version: 0.2.3
3
+ Version: 0.2.4
4
4
  Summary: A practical all-in-one Python toolkit for HTTP, WebSockets, files, data, validation, async work, and CLIs.
5
5
  Project-URL: Homepage, https://github.com/WilliamLaurento/shadow-tools
6
6
  Project-URL: Issues, https://github.com/WilliamLaurento/shadow-tools/issues
@@ -64,8 +64,9 @@ from shadowtools import generate_random_ips, generate_test_ips, make_subdomain,
64
64
  print(make_subdomain("api", "example.com")) # api.example.com
65
65
  print(resolve_dns("example.com"))
66
66
  print(generate_test_ips(2)) # safe documentation-only addresses
67
- print(generate_random_ips(5)) # mixed private, public, and special IPv4 addresses
67
+ print(generate_random_ips(5)) # globally routable public IPv4 addresses only
68
68
  print(generate_random_ips(3, family=6))
69
+ print(generate_random_ips(3, include_private=True, include_special=True))
69
70
  ```
70
71
 
71
72
  Reverse-DNS lookup for IP addresses:
@@ -40,8 +40,9 @@ from shadowtools import generate_random_ips, generate_test_ips, make_subdomain,
40
40
  print(make_subdomain("api", "example.com")) # api.example.com
41
41
  print(resolve_dns("example.com"))
42
42
  print(generate_test_ips(2)) # safe documentation-only addresses
43
- print(generate_random_ips(5)) # mixed private, public, and special IPv4 addresses
43
+ print(generate_random_ips(5)) # globally routable public IPv4 addresses only
44
44
  print(generate_random_ips(3, family=6))
45
+ print(generate_random_ips(3, include_private=True, include_special=True))
45
46
  ```
46
47
 
47
48
  Reverse-DNS lookup for IP addresses:
@@ -4,7 +4,7 @@ build-backend = "hatchling.build"
4
4
 
5
5
  [project]
6
6
  name = "shadow-tools"
7
- version = "0.2.3"
7
+ version = "0.2.4"
8
8
  description = "A practical all-in-one Python toolkit for HTTP, WebSockets, files, data, validation, async work, and CLIs."
9
9
  readme = "README.md"
10
10
  requires-python = ">=3.10"
@@ -6,7 +6,7 @@ from .http import get, request
6
6
  from .network import generate_random_ips, generate_test_ips, is_subdomain_of, make_subdomain, resolve_dns, reverse_dns
7
7
  from .validation import is_email, is_url, require_keys
8
8
 
9
- __version__ = "0.2.3"
9
+ __version__ = "0.2.4"
10
10
 
11
11
  __all__ = [
12
12
  "append_text", "ensure_dir", "generate_random_ips", "generate_test_ips", "get", "is_email", "is_subdomain_of", "is_url", "make_subdomain", "read_csv",
@@ -59,18 +59,23 @@ def generate_test_ips(count: int = 1, *, family: int = 4) -> list[str]:
59
59
 
60
60
 
61
61
  def generate_random_ips(count: int = 1, *, family: int = 4,
62
- include_special: bool = True) -> list[str]:
62
+ include_private: bool = False,
63
+ include_special: bool = False) -> list[str]:
63
64
  """Generate random IPv4 or IPv6 addresses for test data and mock inputs.
64
65
 
65
- When ``include_special`` is true, the results can include private, public,
66
- loopback, link-local, unspecified, and (for IPv4) broadcast addresses.
67
- This function only creates address strings; it never connects to them.
66
+ By default, results are globally routable public addresses only. Set
67
+ ``include_private=True`` to include private ranges, or
68
+ ``include_special=True`` to include loopback, link-local, unspecified, and
69
+ broadcast-style addresses. This function only creates address strings; it
70
+ never connects to them.
68
71
  """
69
72
  if not 1 <= count <= 10_000:
70
73
  raise ValueError("count must be between 1 and 10,000")
71
74
  if family not in (4, 6):
72
75
  raise ValueError("family must be 4 or 6")
73
- kinds = ["private", "public"]
76
+ kinds = ["public"]
77
+ if include_private:
78
+ kinds.append("private")
74
79
  if include_special:
75
80
  kinds += ["loopback", "link_local", "unspecified"]
76
81
  if family == 4:
@@ -1,4 +1,5 @@
1
1
  import asyncio
2
+ import ipaddress
2
3
 
3
4
  import pytest
4
5
 
@@ -41,7 +42,7 @@ def test_network_and_ai_helpers():
41
42
  assert make_subdomain("API", "Example.COM") == "api.example.com"
42
43
  assert is_subdomain_of("api.example.com", "example.com")
43
44
  assert generate_test_ips(1)[0].startswith("192.0.2.")
44
- assert len(generate_random_ips(3)) == 3
45
+ assert all(ipaddress.ip_address(ip).is_global for ip in generate_random_ips(3))
45
46
  assert len(generate_random_ips(2, family=6)) == 2
46
47
  assert reverse_dns("0.0.0.0")["hostname"] is None
47
48
  assert len(reverse_dns(["0.0.0.0", "127.0.0.1"])) == 2
File without changes
File without changes