feat: add LAN access configuration for desktop app, allowing users to enable public API access with corresponding UI updates and translations
This commit is contained in:
+25
-3
@@ -7,9 +7,11 @@ import (
|
||||
|
||||
// App holds Wails-bound state for the desktop shell.
|
||||
type App struct {
|
||||
ctx context.Context
|
||||
backendURL string
|
||||
shutdownCh chan struct{}
|
||||
ctx context.Context
|
||||
backendURL string
|
||||
apiLanBaseURL string
|
||||
listenPublic bool
|
||||
shutdownCh chan struct{}
|
||||
}
|
||||
|
||||
// NewApp creates a new App application struct.
|
||||
@@ -46,3 +48,23 @@ func (a *App) GetDesktopHTTPPortSetting() int {
|
||||
func (a *App) SetDesktopHTTPPortSetting(port int) error {
|
||||
return SaveDesktopHTTPPortPreference(port)
|
||||
}
|
||||
|
||||
// GetDesktopHTTPBindPublicSetting returns whether API listens on all interfaces (0.0.0.0).
|
||||
func (a *App) GetDesktopHTTPBindPublicSetting() bool {
|
||||
return LoadDesktopHTTPBindPublic()
|
||||
}
|
||||
|
||||
// SetDesktopHTTPBindPublicSetting saves LAN/public listen preference. Restart the app for it to take effect.
|
||||
func (a *App) SetDesktopHTTPBindPublicSetting(v bool) error {
|
||||
return SaveDesktopHTTPBindPublicPreference(v)
|
||||
}
|
||||
|
||||
// GetAPILanBaseURL returns a suggested base URL for other devices on the LAN (…/api/v1), or empty if not in bind-public mode or IP detection failed.
|
||||
func (a *App) GetAPILanBaseURL() string {
|
||||
return a.apiLanBaseURL
|
||||
}
|
||||
|
||||
// GetDesktopListenPublicActive is true when this session’s API server is listening on all interfaces (runtime), not the saved preference.
|
||||
func (a *App) GetDesktopListenPublicActive() bool {
|
||||
return a.listenPublic
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user