Use Connectivity + Fix Server Update Bug
the build was successful
Details
the build was successful
Details
This commit is contained in:
parent
325c959b69
commit
c4d5d889b6
2
go.mod
2
go.mod
|
@ -4,7 +4,7 @@ go 1.12
|
||||||
|
|
||||||
require (
|
require (
|
||||||
cwtch.im/cwtch v0.4.1
|
cwtch.im/cwtch v0.4.1
|
||||||
git.openprivacy.ca/openprivacy/connectivity v1.2.1
|
git.openprivacy.ca/openprivacy/connectivity v1.2.2
|
||||||
git.openprivacy.ca/openprivacy/log v1.0.1
|
git.openprivacy.ca/openprivacy/log v1.0.1
|
||||||
github.com/gopherjs/gopherjs v0.0.0-20200209183636-89e6cbcd0b6d // indirect
|
github.com/gopherjs/gopherjs v0.0.0-20200209183636-89e6cbcd0b6d // indirect
|
||||||
github.com/therecipe/qt v0.0.0-20200126204426-5074eb6d8c41
|
github.com/therecipe/qt v0.0.0-20200126204426-5074eb6d8c41
|
||||||
|
|
2
go.sum
2
go.sum
|
@ -33,6 +33,8 @@ git.openprivacy.ca/openprivacy/connectivity v1.2.0 h1:dbZ5CRl11vg3BNHdzRKSlDP8OU
|
||||||
git.openprivacy.ca/openprivacy/connectivity v1.2.0/go.mod h1:B7vzuVmChJtSKoh0ezph5vu6DQ0gIk0zHUNG6IgXCcA=
|
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 h1:oRL56TR9ZQnKkGkTIQ9wYbJ2IkOOsi/zLYExYiAS+sE=
|
||||||
git.openprivacy.ca/openprivacy/connectivity v1.2.1/go.mod h1:B7vzuVmChJtSKoh0ezph5vu6DQ0gIk0zHUNG6IgXCcA=
|
git.openprivacy.ca/openprivacy/connectivity v1.2.1/go.mod h1:B7vzuVmChJtSKoh0ezph5vu6DQ0gIk0zHUNG6IgXCcA=
|
||||||
|
git.openprivacy.ca/openprivacy/connectivity v1.2.2 h1:CeuZB469xHMHxygxZD559CkRUAGR7ct4oeSlsAHQmKo=
|
||||||
|
git.openprivacy.ca/openprivacy/connectivity v1.2.2/go.mod h1:B7vzuVmChJtSKoh0ezph5vu6DQ0gIk0zHUNG6IgXCcA=
|
||||||
git.openprivacy.ca/openprivacy/libricochet-go v1.0.11 h1:C7QFFzG0p5XKu0zcOIdLGwEpA9uU0BceBM7CfVK5D40=
|
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.11/go.mod h1:yTMps/ZpYS+BNBBvANsNAft28FXrBvFHQauMYNWPrwE=
|
||||||
git.openprivacy.ca/openprivacy/libricochet-go v1.0.13 h1:Z86uL9K47onznY1wP1P/wWfWMbbyvk6xnCp94R180os=
|
git.openprivacy.ca/openprivacy/libricochet-go v1.0.13 h1:Z86uL9K47onznY1wP1P/wWfWMbbyvk6xnCp94R180os=
|
||||||
|
|
|
@ -127,6 +127,7 @@ func PeerHandler(onion string, uiManager ui.Manager, subscribed chan bool) {
|
||||||
if state == connections.AUTHENTICATED {
|
if state == connections.AUTHENTICATED {
|
||||||
loading = true
|
loading = true
|
||||||
}
|
}
|
||||||
|
uiManager.UpdateContactStatus(groupID, int(state), loading)
|
||||||
uiManager.UpdateContactStatus(serverOnion, int(state), loading)
|
uiManager.UpdateContactStatus(serverOnion, int(state), loading)
|
||||||
} else {
|
} else {
|
||||||
log.Errorf("found group that is nil :/")
|
log.Errorf("found group that is nil :/")
|
||||||
|
|
31
main.go
31
main.go
|
@ -1,14 +1,15 @@
|
||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"crypto/rand"
|
||||||
libapp "cwtch.im/cwtch/app"
|
libapp "cwtch.im/cwtch/app"
|
||||||
"cwtch.im/cwtch/event/bridge"
|
"cwtch.im/cwtch/event/bridge"
|
||||||
"cwtch.im/ui/go/handlers"
|
"cwtch.im/ui/go/handlers"
|
||||||
"cwtch.im/ui/go/the"
|
"cwtch.im/ui/go/the"
|
||||||
"cwtch.im/ui/go/ui"
|
"cwtch.im/ui/go/ui"
|
||||||
"cwtch.im/ui/go/ui/android"
|
"cwtch.im/ui/go/ui/android"
|
||||||
|
"encoding/base64"
|
||||||
"flag"
|
"flag"
|
||||||
"fmt"
|
|
||||||
"git.openprivacy.ca/openprivacy/connectivity/tor"
|
"git.openprivacy.ca/openprivacy/connectivity/tor"
|
||||||
"git.openprivacy.ca/openprivacy/log"
|
"git.openprivacy.ca/openprivacy/log"
|
||||||
"github.com/therecipe/qt/androidextras"
|
"github.com/therecipe/qt/androidextras"
|
||||||
|
@ -17,13 +18,13 @@ import (
|
||||||
"github.com/therecipe/qt/network"
|
"github.com/therecipe/qt/network"
|
||||||
"github.com/therecipe/qt/qml"
|
"github.com/therecipe/qt/qml"
|
||||||
"github.com/therecipe/qt/quickcontrols2"
|
"github.com/therecipe/qt/quickcontrols2"
|
||||||
"io/ioutil"
|
mrand "math/rand"
|
||||||
"math/rand"
|
|
||||||
"os"
|
"os"
|
||||||
"os/user"
|
"os/user"
|
||||||
"path"
|
"path"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"runtime"
|
"runtime"
|
||||||
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
const androidBaseDir = "/data/data/ca.openprivacy.cwtch.ui/"
|
const androidBaseDir = "/data/data/ca.openprivacy.cwtch.ui/"
|
||||||
|
@ -234,23 +235,29 @@ func loadACN() {
|
||||||
torpath = path.Join(dir, "tor")
|
torpath = path.Join(dir, "tor")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
var err error
|
|
||||||
the.ACN, err = tor.NewTorACN(the.CwtchDir, torpath)
|
|
||||||
|
|
||||||
if _, ok := err.(*tor.NoTorrcError); ok {
|
// generate a random socks and control port (not real random...these are port numbers...)
|
||||||
// Stopgap: just dump a basic torrc for now
|
mrand.Seed(int64(time.Now().Nanosecond()))
|
||||||
port := rand.Intn(1000) + 9600
|
port := mrand.Intn(1000) + 9600
|
||||||
controlPort := port + 1
|
controlPort := port + 1
|
||||||
ioutil.WriteFile(path.Join(the.CwtchDir, "tor", "torrc"), []byte(fmt.Sprintf(`SOCKSPort %v \n ControlPort %v`, port, controlPort)), 0600)
|
|
||||||
the.ACN, err = tor.NewTorACNWithAuth(the.CwtchDir, torpath, controlPort, tor.NullAuthenticator{})
|
// generate a random password (actually random, stored in memory, for the control port)
|
||||||
|
key := make([]byte, 64)
|
||||||
|
_, err := rand.Read(key)
|
||||||
|
if err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
// generate torrc on the fly
|
||||||
|
// TODO if we have been configured for it, use system tor (like orbot) - we need a way to config this in the UI first
|
||||||
|
tor.NewTorrc().WithSocksPort(port).WithOnionTrafficOnly().WithControlPort(controlPort).WithHashedPassword(base64.StdEncoding.EncodeToString(key)).Build(path.Join(the.CwtchDir, "tor", "torrc"))
|
||||||
|
the.ACN, err = tor.NewTorACNWithAuth(the.CwtchDir, torpath, controlPort, tor.HashedPasswordAuthenticator{base64.StdEncoding.EncodeToString(key)})
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
// TODO: turn into UI error: status panel?
|
// TODO: turn into UI error: status panel?
|
||||||
log.Errorf("Could not start Tor: %v", err)
|
log.Errorf("Could not start Tor: %v", err)
|
||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func loadNetworkingAndFiles(gcd *ui.GrandCentralDispatcher, service bool, clientUI bool) {
|
func loadNetworkingAndFiles(gcd *ui.GrandCentralDispatcher, service bool, clientUI bool) {
|
||||||
|
|
Reference in New Issue