-
-
Notifications
You must be signed in to change notification settings - Fork 11.1k
prevent PacketTunnel from wedging during cold startup #8946
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
Open
atavism
wants to merge
8
commits into
main
Choose a base branch
from
atavism/issue-3747
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
f9c9cff
Fix macOS VPN startup reentry
atavism cf5a3eb
Merge remote-tracking branch 'origin/main' into atavism/issue-3747
atavism ff31932
code review updates
atavism 11e957d
code review updates
atavism b0c443e
code review updates
atavism c1c79eb
Merge branch 'main' into atavism/issue-3747
atavism 9c63d1f
code review updates
atavism 8aa897d
Merge remote-tracking branch 'origin/main' into atavism/issue-3747
atavism File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,86 +1,58 @@ | ||
| package mobile | ||
|
|
||
| // // todo implement a mock for all test cases | ||
| // func radianceOptions() radiance.Options { | ||
| // return radiance.Options{ | ||
| // DataDir: os.TempDir(), | ||
| // LogDir: os.TempDir(), | ||
| // DeviceID: "test-123", | ||
| // Locale: "en-us", | ||
| // } | ||
| // } | ||
|
|
||
| // func TestSetupRadiance(t *testing.T) { | ||
| // rr, err := radiance.NewRadiance(radianceOptions()) | ||
| // assert.Nil(t, err) | ||
| // assert.NotNil(t, rr) | ||
|
|
||
| // } | ||
|
|
||
| // // // skip this test for now | ||
| // // func TestStartVPN(t *testing.T) { | ||
| // // data := radianceOptions().DataDir | ||
| // // log := radianceOptions().LogDir | ||
| // // rr, err := client.NewVPNClient(data, log, nil, false) | ||
| // // assert.Nil(t, err) | ||
| // // assert.NotNil(t, rr) | ||
| // // err1 := rr.StartVPN() | ||
| // // assert.Nil(t, err1) | ||
| // // } | ||
|
|
||
| // func TestCreateUser(t *testing.T) { | ||
| // rr, err := radiance.NewRadiance(radianceOptions()) | ||
| // api := rr.APIHandler() | ||
| // assert.Nil(t, err) | ||
| // assert.NotNil(t, rr) | ||
| // user, err := api.NewUser(context.Background()) | ||
| // assert.Nil(t, err) | ||
| // assert.NotNil(t, user) | ||
| // } | ||
|
|
||
| // func TestSubscriptionRedirect(t *testing.T) { | ||
| // rr, err := radiance.NewRadiance(radianceOptions()) | ||
| // apiClient := rr.APIHandler() | ||
| // assert.Nil(t, err) | ||
| // assert.NotNil(t, rr) | ||
| // data := api.PaymentRedirectData{ | ||
| // Provider: "stripe", | ||
| // Plan: "monthly", | ||
| // DeviceName: "test-123", | ||
| // Email: "test@getlantern.org", | ||
| // BillingType: api.SubscriptionTypeSubscription, | ||
| // } | ||
| // user, err := apiClient.SubscriptionPaymentRedirectURL(context.Background(), data) | ||
| // assert.Nil(t, err) | ||
| // assert.NotNil(t, user) | ||
| // } | ||
|
|
||
| // func TestUserData(t *testing.T) { | ||
| // rr, err := radiance.NewRadiance(radianceOptions()) | ||
| // api := rr.APIHandler() | ||
| // assert.Nil(t, err) | ||
| // assert.NotNil(t, rr) | ||
| // user, err := api.UserData(context.Background()) | ||
| // assert.Nil(t, err) | ||
| // assert.NotNil(t, user) | ||
| // } | ||
|
|
||
| // func TestPlans(t *testing.T) { | ||
| // rr, err := radiance.NewRadiance(radianceOptions()) | ||
| // api := rr.APIHandler() | ||
| // assert.Nil(t, err) | ||
| // assert.NotNil(t, rr) | ||
| // plans, err := api.SubscriptionPlans(context.Background(), "non-store") | ||
| // assert.Nil(t, err) | ||
| // assert.NotNil(t, plans) | ||
| // } | ||
|
|
||
| // func TestOAuthLoginUrl(t *testing.T) { | ||
| // rr, err := radiance.NewRadiance(radianceOptions()) | ||
| // api := rr.APIHandler() | ||
| // assert.Nil(t, err) | ||
| // assert.NotNil(t, rr) | ||
| // user, err := api.OAuthLoginUrl(context.Background(), "google") | ||
| // assert.Nil(t, err) | ||
| // assert.NotNil(t, user) | ||
| // } | ||
| import ( | ||
| "errors" | ||
| "testing" | ||
| "time" | ||
|
|
||
| "github.com/getlantern/radiance/ipc" | ||
| ) | ||
|
|
||
| func TestGetClientDoesNotWaitForIPCLifecycleLock(t *testing.T) { | ||
| want := &ipc.Client{} | ||
| previousClient := ipcClient.Swap(want) | ||
| t.Cleanup(func() { | ||
| ipcClient.Store(previousClient) | ||
| }) | ||
|
|
||
| ipcMu.Lock() | ||
| defer ipcMu.Unlock() | ||
|
|
||
| result := make(chan *ipc.Client, 1) | ||
| go func() { | ||
| client, _ := getClient() | ||
| result <- client | ||
| }() | ||
|
|
||
| select { | ||
| case got := <-result: | ||
| if got != want { | ||
| t.Fatalf("getClient() = %p, want %p", got, want) | ||
| } | ||
| case <-time.After(time.Second): | ||
| t.Fatal("getClient blocked on the IPC lifecycle lock") | ||
| } | ||
| } | ||
|
|
||
| func TestStartIPCServerReportsLifecycleBusy(t *testing.T) { | ||
| ipcMu.Lock() | ||
| previousServer := ipcServer | ||
| previousStarting := ipcStarting | ||
| previousClosing := ipcClosing | ||
| ipcServer = nil | ||
| ipcStarting = true | ||
| ipcClosing = false | ||
| ipcMu.Unlock() | ||
| t.Cleanup(func() { | ||
| ipcMu.Lock() | ||
| ipcServer = previousServer | ||
| ipcStarting = previousStarting | ||
| ipcClosing = previousClosing | ||
| ipcMu.Unlock() | ||
| }) | ||
|
|
||
| err := StartIPCServer(nil, nil) | ||
| if !errors.Is(err, errIPCLifecycleBusy) { | ||
| t.Fatalf("StartIPCServer() error = %v, want %v", err, errIPCLifecycleBusy) | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.