~95% on SimpleQA (e.g. Qwen3.6-27B on a 3090). Supports all local and cloud LLMs (llama.cpp, Ollama, Google, ...). 10+ search engines - arXiv, PubMed, your private documents. Everything Local & Encrypted.
Python academiaanthropicarxivbravedeep-researchencryptionhome-automationhomeserverlocallocal-deep-researchlocal-llmmistralollamaopenaipubmedresearchresearch-toolretrieval-augmented-generationsearxngself-hosted
fix: recognize private network IPs in URL normalization
LearningCircuit26fb7b51400c
diff --git a/src/local_deep_research/utilities/url_utils.py b/src/local_deep_research/utilities/url_utils.pyindex b5330ffbd0..d9305a6b17 100644--- a/src/local_deep_research/utilities/url_utils.py+++ b/src/local_deep_research/utilities/url_utils.py@@ -1,5 +1,34 @@"""URL utility functions for the local deep research application."""+import ipaddress+++def is_private_ip(hostname: str) -> bool:+ """Check if hostname is a private/local IP address.++ Args:+ hostname: The hostname or IP address to check++ Returns:+ True if the hostname is a private/local address, False otherwise+ """+ # Known localhost values+ if hostname in ("localhost", "127.0.0.1", "[::1]", "0.0.0.0"):+ return True++ # Handle bracketed IPv6+ if hostname.startswith("[") and hostname.endswith("]"):+ hostname = hostname[1:-1]++ try:+ ip = ipaddress.ip_address(hostname)+ # Check if private (includes 10.x, 172.16-31.x, 192.168.x, fc00::/7, etc.)+ # Also check loopback and link-local+ return ip.is_private or ip.is_loopback or ip.is_link_local+ except ValueError:+ # Not a valid IP address, check for .local domain (mDNS)+ return hostname.endswith(".local")+def normalize_url(raw_url: str) -> str:"""@@ -51,9 +80,7 @@ def normalize_url(raw_url: str) -> str:# Extract the IPv6 address including bracketshostname = raw_url.split("]")[0] + "]"- is_localhost = hostname in ("localhost", "127.0.0.1", "[::1]", "0.0.0.0")-- # Use http for localhost, https for external hosts- scheme = "http" if is_localhost else "https"+ # Use http for local/private addresses, https for external hosts+ scheme = "http" if is_private_ip(hostname) else "https"return f"{scheme}://{raw_url}"diff --git a/tests/test_url_utils.py b/tests/test_url_utils.pyindex 2196fb0f67..96b9d1c73a 100644--- a/tests/test_url_utils.py+++ b/tests/test_url_utils.py@@ -2,7 +2,7 @@import pytest-from local_deep_research.utilities.url_utils import normalize_url+from local_deep_research.utilities.url_utils import is_private_ip, normalize_urlclass TestNormalizeUrl:@@ -20,6 +20,31 @@ class TestNormalizeUrl:assert normalize_url("example.com:11434") == "https://example.com:11434"assert normalize_url("api.example.com") == "https://api.example.com"+ def test_private_ip_without_scheme(self):+ """Test that private network IPs get http:// prefix."""+ # 10.0.0.0/8 range+ assert normalize_url("10.0.0.1:8000") == "http://10.0.0.1:8000"+ assert (+ normalize_url("10.255.255.255:8000") == "http://10.255.255.255:8000"+ )+ # 172.16.0.0/12 range+ assert normalize_url("172.16.0.50:8000") == "http://172.16.0.50:8000"+ assert (+ normalize_url("172.31.255.255:8000") == "http://172.31.255.255:8000"+ )+ # 192.168.0.0/16 range+ assert (+ normalize_url("192.168.1.100:8000") == "http://192.168.1.100:8000"+ )+ assert (+ normalize_url("192.168.0.1:11434/v1")+ == "http://192.168.0.1:11434/v1"+ )+ # .local domain (mDNS)+ assert (+ normalize_url("myserver.local:8000") == "http://myserver.local:8000"+ )+def test_malformed_url_with_scheme(self):"""Test correction of malformed URLs like 'http:hostname'."""assert normalize_url("http:localhost:11434") == "http://localhost:11434"@@ -66,5 +91,42 @@ class TestNormalizeUrl:)+class TestIsPrivateIp:+ """Test cases for the is_private_ip function."""++ def test_localhost_values(self):+ """Test that localhost values are recognized as private."""+ assert is_private_ip("localhost") is True+ assert is_private_ip("127.0.0.1") is True+ assert is_private_ip("[::1]") is True+ assert is_private_ip("0.0.0.0") is True++ def test_private_ipv4_ranges(self):+ """Test that private IPv4 ranges are recognized."""+ # 10.0.0.0/8+ assert is_private_ip("10.0.0.1") is True+ assert is_private_ip("10.255.255.255") is True+ # 172.16.0.0/12+ assert is_private_ip("172.16.0.1") is True+ assert is_private_ip("172.31.255.255") is True+ # 192.168.0.0/16+ assert is_private_ip("192.168.0.1") is True+ assert is_private_ip("192.168.255.255") is True++ def test_public_ipv4(self):+ """Test that public IPv4 addresses are not recognized as private."""+ assert is_private_ip("8.8.8.8") is False+ assert is_private_ip("1.1.1.1") is False+ assert (+ is_private_ip("172.32.0.1") is False+ ) # Just outside 172.16.0.0/12++ def test_hostnames(self):+ """Test hostname handling."""+ assert is_private_ip("api.openai.com") is False+ assert is_private_ip("example.com") is False+ assert is_private_ip("myserver.local") is True # mDNS domain++if __name__ == "__main__":pytest.main([__file__, "-v"])