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

Temporary workaround for Windows layout distortion and some other updates #1204

Merged
merged 35 commits into from
Oct 4, 2024
Merged
Show file tree
Hide file tree
Changes from 21 commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
100ee4b
updates to immediately exit app after clean-up
atavism Oct 3, 2024
8802cea
updates to immediately exit app after clean-up
atavism Oct 3, 2024
693b420
clean-ups
atavism Oct 3, 2024
8431050
Add SafeArea around home component
atavism Oct 3, 2024
d282559
await waitUntilReadyToShow
atavism Oct 3, 2024
34fb2e0
move intiialization to start
atavism Oct 3, 2024
62eec88
move intiialization to start
atavism Oct 3, 2024
2f129fe
testing initialization updates
atavism Oct 3, 2024
2991a8e
Additional clean-ups, delay pro client init until running the app
atavism Oct 3, 2024
ac88ae7
revert changes to temporarily silence notifications
atavism Oct 3, 2024
809c39c
move call to super.initState in Home widget
atavism Oct 3, 2024
4ceb6cc
move call to super.initState in Home widget
atavism Oct 3, 2024
8b00421
don't call _initWindowManager in addPostFrameCallback
atavism Oct 3, 2024
4aaffc4
fix integration test
atavism Oct 3, 2024
d494290
update order we destroy resources when exiting the app
atavism Oct 3, 2024
1fc04af
fix integration test
atavism Oct 3, 2024
2cce267
Update ordering of exit functions
atavism Oct 3, 2024
eb76a97
move LanternFFI.exit to end
atavism Oct 3, 2024
96ff955
clean-ups, move window initialization back to main to avoid window re…
atavism Oct 3, 2024
5dc0166
clean-ups, move window initialization back to main to avoid window re…
atavism Oct 3, 2024
0e6c138
Add comments
atavism Oct 3, 2024
9b06298
Add comment and temporary fix for broken UI on windows
atavism Oct 3, 2024
063db2c
update comment
atavism Oct 3, 2024
bbc2bf0
update _initWindowManager
atavism Oct 3, 2024
51cf708
update _initWindowManager
atavism Oct 4, 2024
ea5cc97
immediately exit after cleanup
atavism Oct 4, 2024
c454e42
clean-ups
atavism Oct 4, 2024
e1542a3
call setState to trigger refresh on windows
atavism Oct 4, 2024
2a1c6bd
remove call to setResizable
atavism Oct 4, 2024
00e8be8
add call to setState
atavism Oct 4, 2024
befa2c8
try downgrading window_manager
atavism Oct 4, 2024
a7d9213
updates that work on windows
atavism Oct 4, 2024
337f8e3
set window resizable to false on other platforms
atavism Oct 4, 2024
81f4231
rename _initWindowManager
atavism Oct 4, 2024
3ff81f3
Merge remote-tracking branch 'origin/main' into atavism/update-onwind…
atavism Oct 4, 2024
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
58 changes: 45 additions & 13 deletions desktop/app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,12 @@ import (
"github.com/getlantern/lantern-client/desktop/datacap"
"github.com/getlantern/lantern-client/desktop/settings"
"github.com/getlantern/lantern-client/desktop/ws"
"github.com/getlantern/lantern-client/internalsdk/auth"
"github.com/getlantern/lantern-client/internalsdk/common"
"github.com/getlantern/lantern-client/internalsdk/pro"
proclient "github.com/getlantern/lantern-client/internalsdk/pro"
"github.com/getlantern/lantern-client/internalsdk/protos"
"github.com/getlantern/lantern-client/internalsdk/webclient"
)

var (
Expand Down Expand Up @@ -78,6 +81,7 @@ type App struct {
flashlight *flashlight.Flashlight

issueReporter *issueReporter
authClient auth.AuthClient
proClient proclient.ProClient

selectedTab Tab
Expand All @@ -94,18 +98,18 @@ type App struct {

onUserData []func(current *protos.User, new *protos.User)

mu sync.Mutex
mu sync.RWMutex
}

// NewApp creates a new desktop app that initializes the app and acts as a moderator between all desktop components.
func NewApp(flags flashlight.Flags, configDir string, proClient proclient.ProClient, ss *settings.Settings) *App {
func NewApp(flags flashlight.Flags, configDir string) *App {
ss := settings.LoadSettings(configDir)
analyticsSession := newAnalyticsSession(ss)
statsTracker := NewStatsTracker()
app := &App{
Flags: flags,
configDir: configDir,
exited: eventual.NewValue(),
proClient: proClient,
settings: ss,
analyticsSession: analyticsSession,
connectionStatusCallbacks: make([]func(isConnected bool), 0),
Expand Down Expand Up @@ -153,33 +157,47 @@ func newAnalyticsSession(settings *settings.Settings) analytics.Session {
// Run starts the app.
func (app *App) Run(ctx context.Context) {
golog.OnFatal(app.exitOnFatal)

go func() {
for <-geolookup.OnRefresh() {
app.settings.SetCountry(geolookup.GetCountry(0))
app.Settings().SetCountry(geolookup.GetCountry(0))
}
}()

// Run below in separate goroutine as config.Init() can potentially block when Lantern runs
// for the first time. User can still quit Lantern through systray menu when it happens.
go func() {
log.Debug(app.Flags)
userConfig := func() common.UserConfig {
return settings.UserConfig(app.Settings())
}
proClient := proclient.NewClient(fmt.Sprintf("https://%s", common.ProAPIHost), &webclient.Opts{
UserConfig: userConfig,
})
authClient := auth.NewClient(fmt.Sprintf("https://%s", common.DFBaseUrl), userConfig)

app.mu.Lock()
app.proClient = proClient
app.authClient = authClient
app.mu.Unlock()

settings := app.Settings()

if app.Flags.ProxyAll {
// If proxyall flag was supplied, force proxying of all
app.settings.SetProxyAll(true)
settings.SetProxyAll(true)
}

listenAddr := app.Flags.Addr
if listenAddr == "" {
listenAddr = app.settings.GetAddr()
listenAddr = settings.GetAddr()
}
if listenAddr == "" {
listenAddr = defaultHTTPProxyAddress
}

socksAddr := app.Flags.SocksAddr
if socksAddr == "" {
socksAddr = app.settings.GetSOCKSAddr()
socksAddr = settings.GetSOCKSAddr()
}
if socksAddr == "" {
socksAddr = defaultSOCKSProxyAddress
Expand All @@ -200,15 +218,15 @@ func (app *App) Run(ctx context.Context) {
common.RevisionDate,
app.configDir,
app.Flags.VPN,
func() bool { return app.settings.GetDisconnected() }, // check whether we're disconnected
app.settings.GetProxyAll,
func() bool { return settings.GetDisconnected() }, // check whether we're disconnected
settings.GetProxyAll,
func() bool { return false }, // on desktop, we do not allow private hosts
app.settings.IsAutoReport,
settings.IsAutoReport,
app.Flags.AsMap(),
app.settings,
settings,
app.statsTracker,
app.IsPro,
app.settings.GetLanguage,
settings.GetLanguage,
func(addr string) (string, error) { return addr, nil }, // no dnsgrab reverse lookups on desktop
app.analyticsSession.EventWithLabel,
flashlight.WithOnConfig(app.onConfigUpdate),
Expand Down Expand Up @@ -786,5 +804,19 @@ func (app *App) GetTranslations(filename string) ([]byte, error) {
}

func (app *App) Settings() *settings.Settings {
app.mu.RLock()
defer app.mu.RUnlock()
return app.settings
}

func (app *App) AuthClient() auth.AuthClient {
app.mu.RLock()
defer app.mu.RUnlock()
return app.authClient
}

func (app *App) ProClient() pro.ProClient {
app.mu.RLock()
defer app.mu.RUnlock()
return app.proClient
}
14 changes: 1 addition & 13 deletions desktop/app/integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ package app
import (
"context"
"crypto/tls"
"fmt"
"io/ioutil"
"net/http"
"net/url"
Expand All @@ -29,9 +28,6 @@ import (
"github.com/getlantern/flashlight/v7/logging"
"github.com/getlantern/lantern-client/desktop/doh"
"github.com/getlantern/lantern-client/desktop/settings"
uicommon "github.com/getlantern/lantern-client/internalsdk/common"
"github.com/getlantern/lantern-client/internalsdk/pro"
"github.com/getlantern/lantern-client/internalsdk/webclient"

"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
Expand Down Expand Up @@ -193,16 +189,8 @@ func startApp(t *testing.T, helper *integrationtest.Helper) (*App, error) {
UIAddr: "127.0.0.1:16823",
Timeout: time.Duration(0),
}

ss := settings.EmptySettings()
webclientOpts := &webclient.Opts{
UserConfig: func() uicommon.UserConfig {
return settings.UserConfig(ss)
},
}
proClient := pro.NewClient(fmt.Sprintf("https://%s", common.ProAPIHost), webclientOpts)

a := NewApp(flags, helper.ConfigDir, proClient, ss)
a := NewApp(flags, helper.ConfigDir)
id := ss.GetUserID()
if id == 0 {
ss.SetUserIDAndToken(1, "token")
Expand Down
18 changes: 9 additions & 9 deletions desktop/auth.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ func getUserSalt(email string) ([]byte, error) {
return salt, nil
}
log.Debugf("Salt not found calling api for %s", email)
saltResponse, err := authClient.GetSalt(context.Background(), lowerCaseEmail)
saltResponse, err := a.AuthClient().GetSalt(context.Background(), lowerCaseEmail)
if err != nil {
return nil, err
}
Expand All @@ -61,7 +61,7 @@ func getUserSalt(email string) ([]byte, error) {
func signup(email *C.char, password *C.char) *C.char {
lowerCaseEmail := strings.ToLower(C.GoString(email))

salt, err := authClient.SignUp(lowerCaseEmail, C.GoString(password))
salt, err := a.AuthClient().SignUp(lowerCaseEmail, C.GoString(password))
if err != nil {
return sendError(err)
}
Expand All @@ -77,7 +77,7 @@ func signup(email *C.char, password *C.char) *C.char {
//export login
func login(email *C.char, password *C.char) *C.char {
lowerCaseEmail := strings.ToLower(C.GoString(email))
user, salt, err := authClient.Login(lowerCaseEmail, C.GoString(password), getDeviceID())
user, salt, err := a.AuthClient().Login(lowerCaseEmail, C.GoString(password), getDeviceID())
if err != nil {
return sendError(err)
}
Expand Down Expand Up @@ -119,7 +119,7 @@ func logout() *C.char {
LegacyUserID: userId,
}
log.Debugf("Sign out request %+v", signoutData)
loggedOut, logoutErr := authClient.SignOut(ctx, signoutData)
loggedOut, logoutErr := a.AuthClient().SignOut(ctx, signoutData)
if logoutErr != nil {
return sendError(log.Errorf("Error while signing out %v", logoutErr))
}
Expand Down Expand Up @@ -167,7 +167,7 @@ func startRecoveryByEmail(email *C.char) *C.char {
prepareRequestBody := &protos.StartRecoveryByEmailRequest{
Email: lowerCaseEmail,
}
recovery, err := authClient.StartRecoveryByEmail(context.Background(), prepareRequestBody)
recovery, err := a.AuthClient().StartRecoveryByEmail(context.Background(), prepareRequestBody)
if err != nil {
return sendError(err)
}
Expand Down Expand Up @@ -199,7 +199,7 @@ func completeRecoveryByEmail(email *C.char, code *C.char, password *C.char) *C.c
}

log.Debugf("new Verifier %v and salt %v", verifierKey.Bytes(), newsalt)
recovery, err := authClient.CompleteRecoveryByEmail(context.Background(), prepareRequestBody)
recovery, err := a.AuthClient().CompleteRecoveryByEmail(context.Background(), prepareRequestBody)
if err != nil {
return sendError(err)
}
Expand All @@ -219,7 +219,7 @@ func validateRecoveryByEmail(email *C.char, code *C.char) *C.char {
Email: lowerCaseEmail,
Code: C.GoString(code),
}
recovery, err := authClient.ValidateEmailRecoveryCode(context.Background(), prepareRequestBody)
recovery, err := a.AuthClient().ValidateEmailRecoveryCode(context.Background(), prepareRequestBody)
if err != nil {
return sendError(err)
}
Expand Down Expand Up @@ -253,7 +253,7 @@ func deleteAccount(password *C.char) *C.char {
A: A.Bytes(),
}
log.Debugf("Delete Account request email %v A %v", lowerCaseEmail, A.Bytes())
srpB, err := authClient.LoginPrepare(context.Background(), prepareRequestBody)
srpB, err := a.AuthClient().LoginPrepare(context.Background(), prepareRequestBody)
if err != nil {
return sendError(err)
}
Expand Down Expand Up @@ -295,7 +295,7 @@ func deleteAccount(password *C.char) *C.char {
}

log.Debugf("Delete Account request email %v prooof %v deviceId %v", lowerCaseEmail, clientProof, deviceId)
isAccountDeleted, err := authClient.DeleteAccount(context.Background(), changeEmailRequestBody)
isAccountDeleted, err := a.AuthClient().DeleteAccount(context.Background(), changeEmailRequestBody)
if err != nil {
return sendError(err)
}
Expand Down
Loading
Loading