Fixing Tor/Server Integration
the build was successful Details

This commit is contained in:
Sarah Jamie Lewis 2020-09-21 15:39:15 -07:00
parent d5fb0a5793
commit 2d9050346b
4 changed files with 46 additions and 15 deletions

View File

@ -10,7 +10,6 @@ import (
"encoding/json" "encoding/json"
"errors" "errors"
"git.openprivacy.ca/openprivacy/log" "git.openprivacy.ca/openprivacy/log"
"runtime/debug"
"strconv" "strconv"
"strings" "strings"
"sync" "sync"
@ -299,12 +298,7 @@ func (cp *cwtchPeer) GetGroupState(groupid string) (connections.ConnectionState,
func (cp *cwtchPeer) PeerWithOnion(onion string) { func (cp *cwtchPeer) PeerWithOnion(onion string) {
cp.mutex.Lock() cp.mutex.Lock()
defer cp.mutex.Unlock() defer cp.mutex.Unlock()
if contact, exists := cp.Profile.GetContact(onion); !exists { if _, exists := cp.Profile.GetContact(onion); !exists {
if contact.IsServer() {
log.Debugf("Tried to peer with a server...should never happen so logging it to try and trace the path:")
debug.PrintStack()
return // ABORT
}
cp.AddContact(onion, onion, model.AuthApproved) cp.AddContact(onion, onion, model.AuthApproved)
} }
cp.eventBus.Publish(event.NewEvent(event.PeerRequest, map[event.Field]string{event.RemotePeer: onion})) cp.eventBus.Publish(event.NewEvent(event.PeerRequest, map[event.Field]string{event.RemotePeer: onion}))

View File

@ -1,7 +1,6 @@
package server package server
import ( import (
"crypto/rand"
"cwtch.im/tapir/primitives" "cwtch.im/tapir/primitives"
"encoding/json" "encoding/json"
"git.openprivacy.ca/openprivacy/log" "git.openprivacy.ca/openprivacy/log"
@ -49,9 +48,20 @@ func (config *Config) Save(dir, filename string) {
func LoadConfig(configDir, filename string) Config { func LoadConfig(configDir, filename string) Config {
log.Infof("Loading config from %s\n", path.Join(configDir, filename)) log.Infof("Loading config from %s\n", path.Join(configDir, filename))
config := Config{} config := Config{}
config.ConfigDir = configDir
id, pk := primitives.InitializeEphemeralIdentity()
tid, tpk := primitives.InitializeEphemeralIdentity()
config.PrivateKey = pk
config.PublicKey = id.PublicKey()
config.TokenServerPrivateKey = tpk
config.TokenServerPublicKey = tid.PublicKey()
config.MaxBufferLines = 100000 config.MaxBufferLines = 100000
config.ServerReporting.LogMetricsToFile = true config.ServerReporting = Reporting{
LogMetricsToFile: true,
ReportingGroupID: "",
ReportingServerAddr: "",
}
raw, err := ioutil.ReadFile(path.Join(configDir, filename)) raw, err := ioutil.ReadFile(path.Join(configDir, filename))
if err == nil { if err == nil {
err = json.Unmarshal(raw, &config) err = json.Unmarshal(raw, &config)
@ -60,11 +70,6 @@ func LoadConfig(configDir, filename string) Config {
log.Errorf("reading config: %v", err) log.Errorf("reading config: %v", err)
} }
} }
if config.PrivateKey == nil {
config.PublicKey, config.PrivateKey, _ = ed25519.GenerateKey(rand.Reader)
}
// Always save (first time generation, new version with new variables populated) // Always save (first time generation, new version with new variables populated)
config.Save(configDir, filename) config.Save(configDir, filename)
return config return config

View File

@ -116,6 +116,9 @@ func TestCwtchPeerIntegration(t *testing.T) {
log.ExcludeFromPattern("pipeBridge") log.ExcludeFromPattern("pipeBridge")
log.ExcludeFromPattern("tapir") log.ExcludeFromPattern("tapir")
os.RemoveAll("tor") os.RemoveAll("tor")
dataDir := path.Join(".", "tor")
os.MkdirAll(dataDir, 0700)
tor.GenerateTorrc("examplehashedpassword", "./tor/torrc")
acn, err := tor.NewTorACNWithAuth(".", "", 9051, tor.HashedPasswordAuthenticator{Password: "examplehashedpassword"}) acn, err := tor.NewTorACNWithAuth(".", "", 9051, tor.HashedPasswordAuthenticator{Password: "examplehashedpassword"})
if err != nil { if err != nil {
t.Fatalf("Could not start Tor: %v", err) t.Fatalf("Could not start Tor: %v", err)

View File

@ -0,0 +1,29 @@
Uptime: 3m0.015645854s
messages:
Minutes: 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
Hours: 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
Days: 0 0 0 0 0 0 0
Weeks: 0 0 0 0
Months: 0 0 0 0 0 0 0 0 0 0 0 0
Client Connections:
Minutes: 2 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
Hours: 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
Days: 0 0 0 0 0 0 0
Weeks: 0 0 0 0
Months: 0 0 0 0 0 0 0 0 0 0 0 0
CPU:
Minutes: 0.00 100.00 1.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00
Hours: 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00
Days: 0.00 0.00 0.00 0.00 0.00 0.00 0.00
Weeks: 0.00 0.00 0.00 0.00
Months: 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00
Memory:
Minutes: 14MBs 14MBs 14MBs 0MBs 0MBs 0MBs 0MBs 0MBs 0MBs 0MBs 0MBs 0MBs 0MBs 0MBs 0MBs 0MBs 0MBs 0MBs 0MBs 0MBs 0MBs 0MBs 0MBs 0MBs 0MBs 0MBs 0MBs 0MBs 0MBs 0MBs 0MBs 0MBs 0MBs 0MBs 0MBs 0MBs 0MBs 0MBs 0MBs 0MBs 0MBs 0MBs 0MBs 0MBs 0MBs 0MBs 0MBs 0MBs 0MBs 0MBs 0MBs 0MBs 0MBs 0MBs 0MBs 0MBs 0MBs 0MBs 0MBs 0MBs
Hours: 0MBs 0MBs 0MBs 0MBs 0MBs 0MBs 0MBs 0MBs 0MBs 0MBs 0MBs 0MBs 0MBs 0MBs 0MBs 0MBs 0MBs 0MBs 0MBs 0MBs 0MBs 0MBs 0MBs 0MBs
Days: 0MBs 0MBs 0MBs 0MBs 0MBs 0MBs 0MBs
Weeks: 0MBs 0MBs 0MBs 0MBs
Months: 0MBs 0MBs 0MBs 0MBs 0MBs 0MBs 0MBs 0MBs 0MBs 0MBs 0MBs 0MBs