Using connectivity NoTorrcErr typed error and stubbing torrc #326
5
go.mod
5
go.mod
|
@ -4,7 +4,7 @@ go 1.12
|
|||
|
||||
require (
|
||||
cwtch.im/cwtch v0.3.16
|
||||
git.openprivacy.ca/openprivacy/connectivity v1.2.0
|
||||
git.openprivacy.ca/openprivacy/connectivity v1.2.1
|
||||
git.openprivacy.ca/openprivacy/log v1.0.1
|
||||
github.com/gopherjs/gopherjs v0.0.0-20200209183636-89e6cbcd0b6d // indirect
|
||||
github.com/therecipe/qt v0.0.0-20200126204426-5074eb6d8c41
|
||||
|
@ -13,4 +13,5 @@ require (
|
|||
golang.org/x/crypto v0.0.0-20200420104511-884d27f42877 // indirect
|
||||
)
|
||||
|
||||
replace cwtch.im/cwtch => /home/sarah/workspace/src/cwtch.im/cwtch
|
||||
|
||||
replace cwtch.im/cwtch => /home/dan/src/go/src/cwtch.im/cwtch
|
||||
|
|
2
go.sum
2
go.sum
|
@ -27,6 +27,8 @@ git.openprivacy.ca/openprivacy/connectivity v1.1.4 h1:/I9epvNNjM8rR/q5y9Y63D9/aP
|
|||
git.openprivacy.ca/openprivacy/connectivity v1.1.4/go.mod h1:4P8mirZZslKbo2zBrXXVjgEdqGwHo/6qoFBwFQW6d6E=
|
||||
git.openprivacy.ca/openprivacy/connectivity v1.2.0 h1:dbZ5CRl11vg3BNHdzRKSlDP8OUtDB+mf6FkxMVf73qw=
|
||||
git.openprivacy.ca/openprivacy/connectivity v1.2.0/go.mod h1:B7vzuVmChJtSKoh0ezph5vu6DQ0gIk0zHUNG6IgXCcA=
|
||||
git.openprivacy.ca/openprivacy/connectivity v1.2.1 h1:oRL56TR9ZQnKkGkTIQ9wYbJ2IkOOsi/zLYExYiAS+sE=
|
||||
git.openprivacy.ca/openprivacy/connectivity v1.2.1/go.mod h1:B7vzuVmChJtSKoh0ezph5vu6DQ0gIk0zHUNG6IgXCcA=
|
||||
git.openprivacy.ca/openprivacy/libricochet-go v1.0.11 h1:C7QFFzG0p5XKu0zcOIdLGwEpA9uU0BceBM7CfVK5D40=
|
||||
git.openprivacy.ca/openprivacy/libricochet-go v1.0.11/go.mod h1:yTMps/ZpYS+BNBBvANsNAft28FXrBvFHQauMYNWPrwE=
|
||||
git.openprivacy.ca/openprivacy/libricochet-go v1.0.13 h1:Z86uL9K47onznY1wP1P/wWfWMbbyvk6xnCp94R180os=
|
||||
|
|
13
main.go
13
main.go
|
@ -8,6 +8,7 @@ import (
|
|||
"cwtch.im/ui/go/ui"
|
||||
"cwtch.im/ui/go/ui/android"
|
||||
"flag"
|
||||
"fmt"
|
||||
"git.openprivacy.ca/openprivacy/connectivity/tor"
|
||||
"git.openprivacy.ca/openprivacy/log"
|
||||
"github.com/therecipe/qt/androidextras"
|
||||
|
@ -16,6 +17,8 @@ import (
|
|||
"github.com/therecipe/qt/network"
|
||||
"github.com/therecipe/qt/qml"
|
||||
"github.com/therecipe/qt/quickcontrols2"
|
||||
"io/ioutil"
|
||||
"math/rand"
|
||||
"os"
|
||||
"os/user"
|
||||
"path"
|
||||
|
@ -233,6 +236,16 @@ func loadACN() {
|
|||
}
|
||||
var err error
|
||||
the.ACN, err = tor.NewTorACN(the.CwtchDir, torpath)
|
||||
if _, ok := err.(*tor.NoTorrcError); ok {
|
||||
// Stopgap: just dump a basic torrc for now
|
||||
port := rand.Intn(1000) + 9600
|
||||
controlPort := port + 1
|
||||
|
||||
ioutil.WriteFile(path.Join(the.CwtchDir, "tor", "torrc"), []byte(fmt.Sprintf(`SOCKSPort %v \
|
||||
ControlPort %v`, port, controlPort)), 0600)
|
||||
|
||||
the.ACN, err = tor.NewTorACNWithAuth(the.CwtchDir, torpath, controlPort, tor.NullAuthenticator{})
|
||||
}
|
||||
if err != nil {
|
||||
// TODO: turn into UI error: status panel?
|
||||
log.Errorf("Could not start Tor: %v", err)
|
||||
|
|
Reference in New Issue