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:
@@ -45,8 +45,9 @@ type Probe struct {
|
||||
db sqlbuilder.Database
|
||||
isBatch bool
|
||||
|
||||
home string
|
||||
tempDir string
|
||||
home string
|
||||
tempDir string
|
||||
tunnelDir string
|
||||
|
||||
dbPath string
|
||||
configPath string
|
||||
@@ -207,12 +208,16 @@ func (p *Probe) NewSession() (*engine.Session, error) {
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "creating engine's kvstore")
|
||||
}
|
||||
if err := os.MkdirAll(utils.TunnelDir(p.home), 0700); err != nil {
|
||||
return nil, errors.Wrap(err, "creating tunnel dir")
|
||||
}
|
||||
return engine.NewSession(engine.SessionConfig{
|
||||
KVStore: kvstore,
|
||||
Logger: enginex.Logger,
|
||||
SoftwareName: p.softwareName,
|
||||
SoftwareVersion: p.softwareVersion,
|
||||
TempDir: p.tempDir,
|
||||
TunnelDir: p.tunnelDir,
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user