python-library-lan-router 0.1.1__tar.gz → 0.1.2__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.
@@ -0,0 +1,21 @@
1
+ __pycache__/
2
+ *.pyc
3
+ *.pyo
4
+ *.egg-info/
5
+ dist/
6
+ build/
7
+ .venv/
8
+ .env
9
+ .env.*
10
+ !.env.example
11
+ # packages 示例本地密钥(*.example 为模板,可提交)
12
+ packages/**/examples/**/.env
13
+ !packages/**/examples/**/.env.example
14
+ packages/**/examples/**/mcp.json
15
+ !packages/**/examples/**/mcp.json.example
16
+ packages/**/examples/**/.sandbox/
17
+ .pytest_cache/
18
+ config.yaml
19
+ logs/
20
+ .cursor/
21
+ uv.lock
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: python-library-lan-router
3
- Version: 0.1.1
3
+ Version: 0.1.2
4
4
  Requires-Python: >=3.10
5
5
  Requires-Dist: pydantic>=2.0.0
6
6
  Requires-Dist: tplinkrouterc6u>=0.1.0
@@ -1,12 +1,26 @@
1
+ from tplinkrouterc6u import TPLinkXDRClient
2
+
1
3
  from .base import BaseRouter
2
4
  from .device import Device
3
- from tplinkrouterc6u import TPLinkXDRClient
4
5
 
5
- class TPLinkRouter(BaseRouter):
6
- _router: TPLinkXDRClient = None
7
6
 
8
- def model_post_init(self,ctx):
9
- self._router = TPLinkXDRClient(self.hostname, self.username, self.password)
7
+ class _TPLinkXDRClientNoProxy(TPLinkXDRClient):
8
+ """TP-Link 客户端;忽略 HTTP_PROXY 等环境变量,内网路由器应直连。"""
9
+
10
+ def __init__(self, *args, **kwargs) -> None:
11
+ super().__init__(*args, **kwargs)
12
+ self._session.trust_env = False
13
+
14
+
15
+ class TPLinkRouter(BaseRouter):
16
+ _router: TPLinkXDRClient | None = None
17
+
18
+ def model_post_init(self, ctx) -> None:
19
+ self._router = _TPLinkXDRClientNoProxy(
20
+ self.hostname,
21
+ self.username,
22
+ self.password,
23
+ )
10
24
 
11
25
  def login(self):
12
26
  self._router.authorize()
@@ -4,7 +4,7 @@ build-backend = "hatchling.build"
4
4
 
5
5
  [project]
6
6
  name = "python-library-lan-router"
7
- version = "0.1.1"
7
+ version = "0.1.2"
8
8
  requires-python = ">=3.10"
9
9
  dependencies = [
10
10
  "tplinkrouterc6u>=0.1.0",
@@ -21,6 +21,16 @@ class LanRouterTests(unittest.TestCase):
21
21
  self.assertEqual(d.ip, "192.168.0.1")
22
22
  self.assertFalse(d.active)
23
23
 
24
+ def test_tplink_router_ignores_http_proxy_env(self) -> None:
25
+ router = create_router(
26
+ "tplink",
27
+ hostname="192.168.1.1",
28
+ username="admin",
29
+ password="secret",
30
+ )
31
+ assert router._router is not None
32
+ self.assertFalse(router._router._session.trust_env)
33
+
24
34
 
25
35
  if __name__ == "__main__":
26
36
  unittest.main()
@@ -1,13 +0,0 @@
1
- __pycache__/
2
- *.pyc
3
- *.pyo
4
- *.egg-info/
5
- dist/
6
- build/
7
- .venv/
8
- .env
9
- .pytest_cache/
10
- config.yaml
11
- logs/
12
- .cursor/
13
- uv.lock