feat(ipc): prevent redundant data path updates and fix socket path typo#334
feat(ipc): prevent redundant data path updates and fix socket path typo#334garmr-ulfr merged 1 commit intomainfrom
Conversation
|
Minor fix. Merging. |
There was a problem hiding this comment.
Pull request overview
This pull request corrects the Unix socket path for the VPN daemon IPC server and adds an optimization to prevent redundant settings path updates. The socket path change aligns the filename with the daemon's name (lanternd), and the optimization attempts to skip unnecessary operations when the settings path hasn't changed.
Changes:
- Updated default socket path from
/var/run/lantern/lantern.sockto/var/run/lantern/lanternd.sockto match the daemon name - Added early return in
setSettingsPathHandlerto avoid redundant operations when the settings path is unchanged
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| vpn/ipc/socket.go | Corrected socket filename to match daemon name (lanternd.sock) |
| vpn/ipc/set.go | Added early return optimization when settings path unchanged |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| if old == opt.SettingsPath { | ||
| w.WriteHeader(http.StatusOK) | ||
| return | ||
| } |
There was a problem hiding this comment.
The early return optimization may not work correctly in all cases. The comparison checks if old == opt.SettingsPath, but lines 54-58 show that opt.SettingsPath may be modified to append a filename before being stored. This means:
- If
oldis/home/user/.config/lantern/settings.yamlandopt.SettingsPathis/home/user/.config/lantern, the early return won't trigger. - However, after the path manipulation at lines 56-58, the final path would become
/home/user/.config/lantern/settings.yaml, which is identical toold. - This would cause unnecessary operations (settings update and reload) even though the path hasn't actually changed.
The comparison should be performed after the path manipulation logic, or the comparison should account for both the directory and file path forms. Consider moving the early return check to after line 58, comparing old with the potentially modified path variable instead.
This pull request introduces a couple of targeted improvements to the VPN IPC server codebase. The changes focus on correcting the default socket path and optimizing the settings update logic to avoid unnecessary operations.
Socket Path Correction:
_socketPathinsocket.gofrom/var/run/lantern/lantern.sockto/var/run/lantern/lanternd.sockto ensure the server uses the correct Unix socket file.Settings Update Optimization:
setSettingsPathHandlerinset.goto immediately return a 200 OK response if the requested settings path is already set, preventing redundant updates and unnecessary log entries.