Browse Source

Blocking now kills listening connections too

full_block
Sarah Jamie Lewis 1 year ago
parent
commit
ebe8db6c31

+ 1
- 1
app/app.go View File

@@ -67,7 +67,7 @@ func (app *application) CreatePeer(name string, password string) (peer.CwtchPeer
profileStore, err := storage.NewProfileStore(app.eventBus, path.Join(app.directory, "profiles", randomFileName), password)
profileStore.Init(name)
p := peer.NewCwtchPeer(name)
app.eventBus.Publish(event.NewEvent(event.SetProfileName, map[string]string{"Name": name}))
app.eventBus.Publish(event.NewEvent(event.SetProfileName, map[event.Field]string{event.ProfileName: name}))
if err != nil {
return nil, err
}

+ 2
- 0
event/common.go View File

@@ -45,6 +45,8 @@ const (
GroupServer = Field("GroupServer")
GroupInvite = Field("GroupInvite")

ProfileName = Field("ProfileName")

Data = Field("Data")

Error = Field("Error")

+ 1
- 3
go.mod View File

@@ -1,10 +1,8 @@
module cwtch.im/cwtch

require (
git.openprivacy.ca/openprivacy/libricochet-go v0.0.0-20190111200107-540e68b8ef5a
github.com/agl/ed25519 v0.0.0-20170116200512-5312a6153412 // indirect
git.openprivacy.ca/openprivacy/libricochet-go v0.0.0-20190121203021-e068de0ef857
github.com/c-bata/go-prompt v0.2.3
github.com/cretz/bine v0.0.0-20181205142746-62912bff1c53 // indirect
github.com/golang/protobuf v1.2.0
github.com/mattn/go-colorable v0.0.9 // indirect
github.com/mattn/go-isatty v0.0.4 // indirect

+ 11
- 2
go.sum View File

@@ -1,11 +1,13 @@
git.openprivacy.ca/openprivacy/libricochet-go v0.0.0-20190111200107-540e68b8ef5a h1:DS4HfF/QtiBBJ46WlVQaU9dweVSqe7JQZLm/gt73iE0=
git.openprivacy.ca/openprivacy/libricochet-go v0.0.0-20190111200107-540e68b8ef5a/go.mod h1:sWushFF6OU1utq/jNKiCz03FJg9TyVSW/LbDduFduPs=
git.openprivacy.ca/openprivacy/libricochet-go v0.0.0-20190121203021-e068de0ef857 h1:Nigo3CR96RG8+I2Prl5JD0M1lVUAafIF1aqKhWd8wWU=
git.openprivacy.ca/openprivacy/libricochet-go v0.0.0-20190121203021-e068de0ef857/go.mod h1:ym2A8NFOWi63Vn+IdYWtZrGhOr9zqGCIxA7i4ZsjQL8=
github.com/agl/ed25519 v0.0.0-20170116200512-5312a6153412 h1:w1UutsfOrms1J05zt7ISrnJIXKzwaspym5BTKGx93EI=
github.com/agl/ed25519 v0.0.0-20170116200512-5312a6153412/go.mod h1:WPjqKcmVOxf0XSf3YxCJs6N6AOSrOx3obionmG7T0y0=
github.com/c-bata/go-prompt v0.2.3 h1:jjCS+QhG/sULBhAaBdjb2PlMRVaKXQgn+4yzaauvs2s=
github.com/c-bata/go-prompt v0.2.3/go.mod h1:VzqtzE2ksDBcdln8G7mk2RX9QyGjH+OVqOCSiVIqS34=
github.com/cretz/bine v0.0.0-20181205142746-62912bff1c53 h1:4QCes8f+MR6nfZOVXg64Y7OHKCDB4dOTbPjJnVpuW5s=
github.com/cretz/bine v0.0.0-20181205142746-62912bff1c53/go.mod h1:6PF6fWAvYtwjRGkAuDEJeWNOv3a2hUouSP/yRYXmvHw=
github.com/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8=
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/golang/protobuf v1.2.0 h1:P3YflyNX/ehuJFLhxviNdFxQPkGK5cDcApsge1SqnvM=
github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
github.com/mattn/go-colorable v0.0.9 h1:UVL0vNpWh04HeJXV0KLcaT7r06gOH2l4OW6ddYRUIY4=
@@ -18,11 +20,18 @@ github.com/mattn/go-tty v0.0.0-20181127064339-e4f871175a2f h1:4P7Ul+TAnk92vTeVkX
github.com/mattn/go-tty v0.0.0-20181127064339-e4f871175a2f/go.mod h1:XPvLUNfbS4fJH25nqRHfWLMa1ONC8Amw+mIA639KxkE=
github.com/pkg/term v0.0.0-20190109203006-aa71e9d9e942 h1:A7GG7zcGjl3jqAqGPmcNjd/D9hzL95SuoOQAaFNdLU0=
github.com/pkg/term v0.0.0-20190109203006-aa71e9d9e942/go.mod h1:eCbImbZ95eXtAUIbLAuAVnBnwf83mjf6QIVH8SHYwqQ=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/testify v1.3.0 h1:TivCn/peBQ7UY8ooIcPgZFpTNSz0Q2U6UrFlUfqbe0Q=
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
github.com/struCoder/pidusage v0.1.2 h1:fFPTThlcWFQyizv3xKs5Lyq1lpG5lZ36arEGNhWz2Vs=
github.com/struCoder/pidusage v0.1.2/go.mod h1:pWBlW3YuSwRl6h7R5KbvA4N8oOqe9LjaKW5CwT1SPjI=
golang.org/x/crypto v0.0.0-20190103213133-ff983b9c42bc h1:F5tKCVGp+MUAHhKp5MZtGqAlGX3+oCsiL1Q629FL90M=
golang.org/x/crypto v0.0.0-20190103213133-ff983b9c42bc/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4=
golang.org/x/net v0.0.0-20190110200230-915654e7eabc h1:Yx9JGxI1SBhVLFjpAkWMaO1TF+xyqtHLjZpvQboJGiM=
golang.org/x/net v0.0.0-20190110200230-915654e7eabc/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4 h1:YUO/7uOKsKeq9UokNS62b8FYywz3ker1l1vDZRCRefw=
golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sys v0.0.0-20190109145017-48ac38b7c8cb h1:1w588/yEchbPNpa9sEvOcMZYbWHedwJjg4VOAdDHWHk=
golang.org/x/sys v0.0.0-20190109145017-48ac38b7c8cb/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=

+ 5
- 0
protocol/connections/engine.go View File

@@ -91,6 +91,11 @@ func (e *Engine) eventHandler() {
}
case event.BlockPeer:
e.blocked.Store(ev.Data[event.RemotePeer], true)
ppc := e.connectionsManager.GetPeerPeerConnectionForOnion(ev.Data[event.RemotePeer])
if ppc != nil {
ppc.Close()
}
e.app.Close(ev.Data[event.RemotePeer])
case event.ProtocolEngineStartListen:
go e.listenFn()
default:

+ 1
- 1
protocol/connections/peerpeerconnection.go View File

@@ -107,6 +107,6 @@ func (ppc *PeerPeerConnection) Run() error {
func (ppc *PeerPeerConnection) Close() {
ppc.state = KILLED
if ppc.connection != nil {
ppc.connection.Conn.Close()
ppc.connection.Close()
}
}

+ 1
- 1
protocol/connections/peerserverconnection.go View File

@@ -129,7 +129,7 @@ func (psc *PeerServerConnection) SendGroupMessage(gm *protocol.GroupMessage) err
func (psc *PeerServerConnection) Close() {
psc.state = KILLED
if psc.connection != nil {
psc.connection.Conn.Close()
psc.connection.Close()
}
}


Loading…
Cancel
Save