feat(tunnel): introduce persistent tunnel state dir (#294)
* feat(tunnel): introduce persistent tunnel state dir This diff introduces a persistent state directory for tunnels, so that we can bootstrap them more quickly after the first time. Part of https://github.com/ooni/probe/issues/985 * fix: make tunnel dir optional We have many tests where it does not make sense to explicitly provide a tunnel dir because we're not using tunnels. This should simplify setting up a session. * fix(tunnel): repair tests * final changes * more cleanups
This commit is contained in:
@@ -80,6 +80,7 @@ func (r *Runner) newsession(logger *ChanLogger) (*engine.Session, error) {
|
||||
SoftwareName: r.settings.Options.SoftwareName,
|
||||
SoftwareVersion: r.settings.Options.SoftwareVersion,
|
||||
TempDir: r.settings.TempDir,
|
||||
TunnelDir: r.settings.TunnelDir,
|
||||
}
|
||||
if r.settings.Options.ProbeServicesBaseURL != "" {
|
||||
config.AvailableProbeServices = []model.Service{{
|
||||
|
||||
@@ -44,6 +44,11 @@ type Settings struct {
|
||||
// for iOS and does not work for Android.
|
||||
TempDir string `json:"temp_dir"`
|
||||
|
||||
// TunnelDir is the directory where to store persistent state
|
||||
// related to circumvention tunnels. This directory is required
|
||||
// only if you want to use the tunnels. Added since 3.10.0.
|
||||
TunnelDir string `json:"tunnel_dir"`
|
||||
|
||||
// Version indicates the version of this structure.
|
||||
Version int64 `json:"version"`
|
||||
}
|
||||
|
||||
@@ -87,6 +87,11 @@ type SessionConfig struct {
|
||||
// remove any temporary file created within this Session.
|
||||
TempDir string
|
||||
|
||||
// TunnelDir is the directory where the Session shall store
|
||||
// persistent data regarding circumvention tunnels. This directory
|
||||
// is mandatory if you want to use tunnels.
|
||||
TunnelDir string
|
||||
|
||||
// Verbose is optional. If there is a non-null Logger and this
|
||||
// field is true, then the Logger will also receive Debug messages,
|
||||
// otherwise it will not receive such messages.
|
||||
@@ -143,6 +148,7 @@ func NewSession(config *SessionConfig) (*Session, error) {
|
||||
SoftwareName: config.SoftwareName,
|
||||
SoftwareVersion: config.SoftwareVersion,
|
||||
TempDir: config.TempDir,
|
||||
TunnelDir: config.TunnelDir,
|
||||
}
|
||||
sessp, err := engine.NewSession(engineConfig)
|
||||
if err != nil {
|
||||
|
||||
Reference in New Issue
Block a user