Skip to content

Commit

Permalink
feat: Allow updating proxy settings after installation for options fl…
Browse files Browse the repository at this point in the history
…ow (#6)

feat: Allow updating proxy settings at runtime for options flow
  • Loading branch information
lhw authored Jun 9, 2024
1 parent cf812ea commit 0bd95e2
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 8 deletions.
18 changes: 10 additions & 8 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -1,15 +1,17 @@

{
"name": "aiocloudweather",
"image": "mcr.microsoft.com/devcontainers/python:1-3.12-bookworm",
"postCreateCommand": "pip3 install -e .",
"runArgs": ["-e", "GIT_EDITOR=code --wait", "--privileged"],
"runArgs": [
"-e",
"GIT_EDITOR=code --wait",
"--privileged"
],
"customizations": {
"extensions": [
"ms-python.python",
"github.vscode-pull-request-github",
"ryanluker.vscode-coverage-gutters",
"ms-python.vscode-pylance"
"ms-python.vscode-pylance",
"ms-python.black-formatter"
],
"settings": {
"terminal.integrated.profiles.linux": {
Expand All @@ -30,8 +32,8 @@
"python.formatting.provider": "black",
"python.formatting.blackPath": "/usr/local/py-utils/bin/black",
"python.linting.pylintArgs": [
"--disable=C0114,C0115,C0116"
"--disable=C0114,C0115,C0116"
]
}
}
}
}
}
10 changes: 10 additions & 0 deletions aiocloudweather/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,16 @@ def __init__(
# storage
self.stations: list[str] = []

def update_config(
self,
proxy_sinks: list[DataSink] | None = None,
dns_servers: list[str] | None = None,
) -> None:
"""Update the proxy configuration."""
self.proxy_enabled = proxy_sinks and len(proxy_sinks) > 0
if self.proxy_enabled:
self.proxy = CloudWeatherProxy(proxy_sinks, dns_servers or ["9.9.9.9"])

async def _new_dataset_cb(self, dataset: WeatherStation) -> None:
"""Internal new sensor callback
Expand Down

0 comments on commit 0bd95e2

Please sign in to comment.