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

psiphon: store cache files in correct location #92

Merged
merged 1 commit into from
May 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 1 addition & 1 deletion app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ func runWarpWithPsiphon(ctx context.Context, l *slog.Logger, opts WarpOptions, e
}

// run psiphon
err = psiphon.RunPsiphon(ctx, l.With("subsystem", "psiphon"), warpBind.String(), opts.Bind.String(), opts.Psiphon.Country)
err = psiphon.RunPsiphon(ctx, l.With("subsystem", "psiphon"), warpBind.String(), opts.CacheDir, opts.Bind.String(), opts.Psiphon.Country)
if err != nil {
return fmt.Errorf("unable to run psiphon %w", err)
}
Expand Down
21 changes: 2 additions & 19 deletions psiphon/p.go
Original file line number Diff line number Diff line change
Expand Up @@ -103,8 +103,6 @@ func StartTunnel(
configJSON []byte,
embeddedServerEntryList string,
params Parameters,
paramsDelta ParametersDelta,
noticeReceiver func(NoticeEvent),
) (retTunnel *Tunnel, retErr error) {
config, err := psiphon.LoadConfig(configJSON)
if err != nil {
Expand Down Expand Up @@ -147,14 +145,6 @@ func StartTunnel(
return nil, errors.New("config.Commit failed")
}

// If supplied, apply the parameters delta
if len(paramsDelta) > 0 {
err = config.SetParameters("", false, paramsDelta)
if err != nil {
return nil, fmt.Errorf("set parameters failed for delta %v : %w", paramsDelta, err)
}
}

// Will receive a value when the tunnel has successfully connected.
connected := make(chan struct{}, 1)
// Will receive a value if an error occurs during the connection sequence.
Expand Down Expand Up @@ -199,12 +189,6 @@ func StartTunnel(
}
}
}

// Some users of this package may need to add special processing of notices.
// If the caller has requested it, we'll pass on the notices.
if noticeReceiver != nil {
noticeReceiver(event)
}
}))

err = psiphon.OpenDataStore(config)
Expand Down Expand Up @@ -316,7 +300,7 @@ func (tunnel *Tunnel) Stop() {
psiphon.CloseDataStore()
}

func RunPsiphon(ctx context.Context, l *slog.Logger, wgBind, localSocksPort, country string) error {
func RunPsiphon(ctx context.Context, l *slog.Logger, wgBind, dir, localSocksPort, country string) error {
// Embedded configuration
host, port, err := net.SplitHostPort(localSocksPort)
if err != nil {
Expand All @@ -342,7 +326,6 @@ func RunPsiphon(ctx context.Context, l *slog.Logger, wgBind, localSocksPort, cou
"AllowDefaultDNSResolverWithBindToDevice":true
}`

dir := "."
ClientPlatform := "Android_4.0.4_com.example.exampleClientLibraryApp"
network := "test"
timeout := 60
Expand Down Expand Up @@ -371,7 +354,7 @@ func RunPsiphon(ctx context.Context, l *slog.Logger, wgBind, localSocksPort, cou
}
return errors.New("psiphon handshake maximum time exceeded")
case <-t.C:
tunnel, err := StartTunnel(ctx, []byte(configJSON), "", p, nil, nil)
tunnel, err := StartTunnel(ctx, []byte(configJSON), "", p)
if err != nil {
l.Info("Unable to start psiphon", err, "reconnecting...")
continue
Expand Down