fix(netproxy): resolve the proxy address per request
ProxyFunc parsed system.networkProxy once, when a client was built, and baked the result into the transport. Editing the proxy address therefore had no effect on any client that already existed: ntfy, the outgoing webhook, NapCat's HTTP API, Telegram's polling and the NapCat WebSocket dialer all kept the address they were built with, and Email's SMTP dialer did the same. Only a controller rebuild would pick up a new one, and that fires only when controllerMethod changes — so the address was effectively fixed until a restart. Resolve it inside the returned function instead. A transport proxy function that returns a nil URL asks for a direct connection, so this also covers clearing the setting: a channel built while a proxy was configured now falls back to dialing directly rather than retrying a dead address. Opting out is now the only case where ProxyFunc returns nil. That is deliberate: a function resolved to nothing at construction time is exactly what pinned the address in the first place. DialWithTimeout reads the address per dial for the same reason, which is what lets the gomail NetDialTimeout hook follow a settings change.
This commit is contained in:
@@ -303,7 +303,7 @@ Saving settings applies most of them immediately. How each group takes effect:
|
||||
| `controllerMethod` (all five channels) | Every channel is **rebuilt**: the running controllers are stopped and a fresh set is built from the new settings. A channel that owns a connection reconnects — Telegram re-runs its `getMe` handshake, NapCat opens a new WebSocket — so notifications sent during the swap are lost. The rebuild only happens when this section actually changed; saving a message template does not disturb the channels. |
|
||||
| `controllerMessage`, `debug`, `bot_user_config.json`, `bot_node_config.json`, `webhook.endpoints` | Picked up as they are used; nothing is restarted. |
|
||||
| `system.debugMode` | Applies to both behavior and log filtering. |
|
||||
| `system.networkProxy` | Read when a channel builds its connection, so a channel only sees a new value once it is rebuilt. Changing this key **alone** does not trigger the rebuild above — change a `controllerMethod` value as well, or restart. |
|
||||
| `system.networkProxy` | Read on every request and every dial, so a new address reaches channels that are already running. Only the per-channel `networkUseProxy` opt-in is fixed when a channel is built, so toggling that still needs the rebuild above. |
|
||||
| `system.listenAddr` / `listenPort`, `webhook.enabled` / `listenAddr` / `listenPort`, `dataPath`, `dbPath`, `komari.dashboardURL` | **Applied at startup only.** Saving them changes the file and the in-memory configuration but not the running listener, database or Komari client — restart to apply. |
|
||||
|
||||
## API
|
||||
|
||||
Reference in New Issue
Block a user