forked from cwtch.im/cwtch
Fixing Tor/Server Integration
This commit is contained in:
parent
d5fb0a5793
commit
2d9050346b
|
@ -10,7 +10,6 @@ import (
|
|||
"encoding/json"
|
||||
"errors"
|
||||
"git.openprivacy.ca/openprivacy/log"
|
||||
"runtime/debug"
|
||||
"strconv"
|
||||
"strings"
|
||||
"sync"
|
||||
|
@ -299,12 +298,7 @@ func (cp *cwtchPeer) GetGroupState(groupid string) (connections.ConnectionState,
|
|||
func (cp *cwtchPeer) PeerWithOnion(onion string) {
|
||||
cp.mutex.Lock()
|
||||
defer cp.mutex.Unlock()
|
||||
if contact, 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
|
||||
}
|
||||
if _, exists := cp.Profile.GetContact(onion); !exists {
|
||||
cp.AddContact(onion, onion, model.AuthApproved)
|
||||
}
|
||||
cp.eventBus.Publish(event.NewEvent(event.PeerRequest, map[event.Field]string{event.RemotePeer: onion}))
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
package server
|
||||
|
||||
import (
|
||||
"crypto/rand"
|
||||
"cwtch.im/tapir/primitives"
|
||||
"encoding/json"
|
||||
"git.openprivacy.ca/openprivacy/log"
|
||||
|
@ -49,9 +48,20 @@ func (config *Config) Save(dir, filename string) {
|
|||
func LoadConfig(configDir, filename string) Config {
|
||||
log.Infof("Loading config from %s\n", path.Join(configDir, filename))
|
||||
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.ServerReporting.LogMetricsToFile = true
|
||||
config.ServerReporting = Reporting{
|
||||
LogMetricsToFile: true,
|
||||
ReportingGroupID: "",
|
||||
ReportingServerAddr: "",
|
||||
}
|
||||
|
||||
raw, err := ioutil.ReadFile(path.Join(configDir, filename))
|
||||
if err == nil {
|
||||
err = json.Unmarshal(raw, &config)
|
||||
|
@ -60,11 +70,6 @@ func LoadConfig(configDir, filename string) Config {
|
|||
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)
|
||||
config.Save(configDir, filename)
|
||||
return config
|
||||
|
|
|
@ -116,6 +116,9 @@ func TestCwtchPeerIntegration(t *testing.T) {
|
|||
log.ExcludeFromPattern("pipeBridge")
|
||||
log.ExcludeFromPattern("tapir")
|
||||
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"})
|
||||
if err != nil {
|
||||
t.Fatalf("Could not start Tor: %v", err)
|
||||
|
|
|
@ -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
|
Loading…
Reference in New Issue