Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Allow updating proxy settings after installation for options flow #6

Merged
merged 1 commit into from
Jun 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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