tails #42
|
@ -15,14 +15,14 @@ steps:
|
|||
- chmod a+x tmp/tor
|
||||
- go mod download
|
||||
- name: quality
|
||||
image: golang:1.17.5
|
||||
image: golang:1.19.1
|
||||
volumes:
|
||||
- name: deps
|
||||
path: /go
|
||||
commands:
|
||||
- staticcheck ./...
|
||||
- name: units-tests
|
||||
image: golang:1.17.5
|
||||
image: golang:1.19.1
|
||||
volumes:
|
||||
- name: deps
|
||||
path: /go
|
||||
|
@ -33,7 +33,7 @@ steps:
|
|||
- sh testing/tests.sh
|
||||
- pkill -9 tor
|
||||
- name: integration-tests
|
||||
image: golang:1.17.5
|
||||
image: golang:1.19.1
|
||||
volumes:
|
||||
- name: deps
|
||||
path: /go
|
||||
|
|
|
@ -3,7 +3,6 @@ package testing
|
|||
import (
|
||||
"git.openprivacy.ca/openprivacy/connectivity/tor"
|
||||
"git.openprivacy.ca/openprivacy/log"
|
||||
"io/ioutil"
|
||||
"math/rand"
|
||||
"os"
|
||||
path "path/filepath"
|
||||
|
@ -30,7 +29,7 @@ func TestLaunchTor(t *testing.T) {
|
|||
}
|
||||
|
||||
dataDir := ""
|
||||
if dataDir, err = ioutil.TempDir(path.Join("..", "testing"), "data-dir-"); err != nil {
|
||||
if dataDir, err = os.MkdirTemp(path.Join("..", "testing"), "data-dir-"); err != nil {
|
||||
t.Fatalf("could not create data dir")
|
||||
}
|
||||
|
||||
|
|
|
@ -486,10 +486,10 @@ func startTor(appDirectory string, bundledTorPath string, dataDir string, contro
|
|||
if err == nil {
|
||||
log.Debugf("creating tor handler from system tor")
|
||||
tp.t = createFromExisting(controlport, dataDir)
|
||||
}
|
||||
tp.dialer, err = tp.t.Dialer(context.TODO(), &tor.DialConf{Authenticator: tp.authenticator})
|
||||
return tp, err
|
||||
}
|
||||
}
|
||||
|
||||
// check if the torrc file is present where expected
|
||||
if _, err := os.Stat(path.Join(torDir, "torrc")); os.IsNotExist(err) {
|
||||
|
@ -527,6 +527,7 @@ func startTor(appDirectory string, bundledTorPath string, dataDir string, contro
|
|||
tp.t.DeleteDataDirOnClose = false // caller is responsible for dealing with cached information...
|
||||
tp.dialer, err = tp.t.Dialer(context.TODO(), &tor.DialConf{Authenticator: tp.authenticator})
|
||||
tp.version = version
|
||||
tp.t.Control.TakeOwnership()
|
||||
return tp, err
|
||||
}
|
||||
return nil, fmt.Errorf("could not connect to running tor: %v", err)
|
||||
|
|
|
@ -3,7 +3,6 @@ package tor
|
|||
import (
|
||||
"fmt"
|
||||
"git.openprivacy.ca/openprivacy/log"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
path "path/filepath"
|
||||
"runtime"
|
||||
|
@ -41,7 +40,7 @@ func TestTorProvider(t *testing.T) {
|
|||
|
||||
dataDir := ""
|
||||
var err error
|
||||
if dataDir, err = ioutil.TempDir(path.Join("..", "testing"), "data-dir-"); err != nil {
|
||||
if dataDir, err = os.MkdirTemp(path.Join("..", "testing"), "data-dir-"); err != nil {
|
||||
t.Fatalf("could not create data dir")
|
||||
}
|
||||
|
||||
|
|
|
@ -6,7 +6,7 @@ import (
|
|||
"encoding/hex"
|
||||
"fmt"
|
||||
"io"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"strings"
|
||||
)
|
||||
|
||||
|
@ -42,15 +42,28 @@ func (tb *TorrcBuilder) WithControlPort(port int) *TorrcBuilder {
|
|||
return tb
|
||||
}
|
||||
|
||||
// WithLog sets the Log to file directive to the specified with with the specified log level
|
||||
// WithLog sets the Log to file directive to the specified file with the specified log level
|
||||
func (tb *TorrcBuilder) WithLog(logfile string, level TorLogLevel) *TorrcBuilder {
|
||||
tb.lines = append(tb.lines, fmt.Sprintf("Log %v file %v", level, logfile))
|
||||
return tb
|
||||
}
|
||||
|
||||
// WithCustom clobbers the torrc builder and allows the client to set any option they want, while benefiting
|
||||
// WithSocksTimeout adjusts how long before a timeout error is generated trying to connect to the SOCKS port
|
||||
func (tb *TorrcBuilder) WithSocksTimeout(timeOutSecs int) *TorrcBuilder {
|
||||
tb.lines = append(tb.lines, fmt.Sprintf("SocksTimeout %v", timeOutSecs))
|
||||
return tb
|
||||
}
|
||||
|
||||
// WithCustom appends to the torrc builder and allows the client to set any option they want, while benefiting
|
||||
// from other configuration options.
|
||||
func (tb *TorrcBuilder) WithCustom(lines []string) *TorrcBuilder {
|
||||
tb.lines = append(tb.lines, lines...)
|
||||
return tb
|
||||
}
|
||||
|
||||
// UseCustom clobbers the torrc builder and allows the client to set any option they want, while benefiting
|
||||
// from other configuration options.
|
||||
func (tb *TorrcBuilder) UseCustom(lines []string) *TorrcBuilder {
|
||||
tb.lines = lines
|
||||
return tb
|
||||
}
|
||||
|
@ -66,6 +79,12 @@ func (tb *TorrcBuilder) WithOnionTrafficOnly() *TorrcBuilder {
|
|||
return tb
|
||||
}
|
||||
|
||||
// WithOwningPid adds a __OwningControllerProcess line to the config that will attempt to have tor monitor parent PID health and die when parent dies
|
||||
func (tb *TorrcBuilder) WithOwningPid(pid int) *TorrcBuilder {
|
||||
tb.lines = append(tb.lines, fmt.Sprintf("__OwningControllerProcess %v", pid))
|
||||
return tb
|
||||
}
|
||||
|
||||
// WithHashedPassword sets a password for the control port.
|
||||
func (tb *TorrcBuilder) WithHashedPassword(password string) *TorrcBuilder {
|
||||
var salt [8]byte
|
||||
|
@ -79,7 +98,7 @@ func (tb *TorrcBuilder) WithHashedPassword(password string) *TorrcBuilder {
|
|||
|
||||
// Build finalizes the torrc contents and write a file
|
||||
func (tb *TorrcBuilder) Build(path string) error {
|
||||
return ioutil.WriteFile(path, []byte(strings.Join(tb.lines, "\n")), 0600)
|
||||
return os.WriteFile(path, []byte(strings.Join(tb.lines, "\n")), 0600)
|
||||
}
|
||||
|
||||
// Preview provides a string representation of the torrc file without writing it to a file location.
|
||||
|
|
Loading…
Reference in New Issue