forked from cwtch.im/cwtch
Merge branch 'update-libricochet' of cwtch.im/cwtch into master
This commit is contained in:
commit
2db7385ce0
2
go.mod
2
go.mod
|
@ -1,7 +1,7 @@
|
||||||
module cwtch.im/cwtch
|
module cwtch.im/cwtch
|
||||||
|
|
||||||
require (
|
require (
|
||||||
git.openprivacy.ca/openprivacy/libricochet-go v0.0.0-20190121203021-e068de0ef857
|
git.openprivacy.ca/openprivacy/libricochet-go v0.0.0-20190123194730-b2f6b314fc5c
|
||||||
github.com/c-bata/go-prompt v0.2.3
|
github.com/c-bata/go-prompt v0.2.3
|
||||||
github.com/golang/protobuf v1.2.0
|
github.com/golang/protobuf v1.2.0
|
||||||
github.com/mattn/go-colorable v0.0.9 // indirect
|
github.com/mattn/go-colorable v0.0.9 // indirect
|
||||||
|
|
4
go.sum
4
go.sum
|
@ -1,5 +1,5 @@
|
||||||
git.openprivacy.ca/openprivacy/libricochet-go v0.0.0-20190121203021-e068de0ef857 h1:Nigo3CR96RG8+I2Prl5JD0M1lVUAafIF1aqKhWd8wWU=
|
git.openprivacy.ca/openprivacy/libricochet-go v0.0.0-20190123194730-b2f6b314fc5c h1:kzgZrgoURJ07ARliL+W91jjI0x03UkE6cZG1gb5aPjY=
|
||||||
git.openprivacy.ca/openprivacy/libricochet-go v0.0.0-20190121203021-e068de0ef857/go.mod h1:ym2A8NFOWi63Vn+IdYWtZrGhOr9zqGCIxA7i4ZsjQL8=
|
git.openprivacy.ca/openprivacy/libricochet-go v0.0.0-20190123194730-b2f6b314fc5c/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 h1:w1UutsfOrms1J05zt7ISrnJIXKzwaspym5BTKGx93EI=
|
||||||
github.com/agl/ed25519 v0.0.0-20170116200512-5312a6153412/go.mod h1:WPjqKcmVOxf0XSf3YxCJs6N6AOSrOx3obionmG7T0y0=
|
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 h1:jjCS+QhG/sULBhAaBdjb2PlMRVaKXQgn+4yzaauvs2s=
|
||||||
|
|
|
@ -119,9 +119,9 @@ func (e *Engine) listenFn() {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
af := application.ApplicationInstanceFactory{}
|
af := application.InstanceFactory{}
|
||||||
af.Init()
|
af.Init()
|
||||||
af.AddHandler("im.cwtch.peer", func(rai *application.ApplicationInstance) func() channels.Handler {
|
af.AddHandler("im.cwtch.peer", func(rai *application.Instance) func() channels.Handler {
|
||||||
cpi := new(CwtchPeerInstance)
|
cpi := new(CwtchPeerInstance)
|
||||||
cpi.Init(rai, ra)
|
cpi.Init(rai, ra)
|
||||||
return func() channels.Handler {
|
return func() channels.Handler {
|
||||||
|
@ -131,7 +131,7 @@ func (e *Engine) listenFn() {
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
af.AddHandler("im.cwtch.peer.data", func(rai *application.ApplicationInstance) func() channels.Handler {
|
af.AddHandler("im.cwtch.peer.data", func(rai *application.Instance) func() channels.Handler {
|
||||||
cpi := new(CwtchPeerInstance)
|
cpi := new(CwtchPeerInstance)
|
||||||
cpi.Init(rai, ra)
|
cpi.Init(rai, ra)
|
||||||
return func() channels.Handler {
|
return func() channels.Handler {
|
||||||
|
@ -237,12 +237,12 @@ func (e *Engine) GetServers() map[string]ConnectionState {
|
||||||
|
|
||||||
// CwtchPeerInstance encapsulates incoming peer connections
|
// CwtchPeerInstance encapsulates incoming peer connections
|
||||||
type CwtchPeerInstance struct {
|
type CwtchPeerInstance struct {
|
||||||
rai *application.ApplicationInstance
|
rai *application.Instance
|
||||||
ra *application.RicochetApplication
|
ra *application.RicochetApplication
|
||||||
}
|
}
|
||||||
|
|
||||||
// Init sets up a CwtchPeerInstance
|
// Init sets up a CwtchPeerInstance
|
||||||
func (cpi *CwtchPeerInstance) Init(rai *application.ApplicationInstance, ra *application.RicochetApplication) {
|
func (cpi *CwtchPeerInstance) Init(rai *application.Instance, ra *application.RicochetApplication) {
|
||||||
cpi.rai = rai
|
cpi.rai = rai
|
||||||
cpi.ra = ra
|
cpi.ra = ra
|
||||||
}
|
}
|
||||||
|
|
|
@ -33,7 +33,7 @@ func (s *Server) Run(acn connectivity.ACN, serverConfig Config) {
|
||||||
cwtchserver := new(application.RicochetApplication)
|
cwtchserver := new(application.RicochetApplication)
|
||||||
s.metricsPack.Start(cwtchserver, serverConfig.ConfigDir, s.config.ServerReporting.LogMetricsToFile)
|
s.metricsPack.Start(cwtchserver, serverConfig.ConfigDir, s.config.ServerReporting.LogMetricsToFile)
|
||||||
|
|
||||||
af := application.ApplicationInstanceFactory{}
|
af := application.InstanceFactory{}
|
||||||
af.Init()
|
af.Init()
|
||||||
ms := new(storage.MessageStore)
|
ms := new(storage.MessageStore)
|
||||||
err := ms.Init(serverConfig.ConfigDir, s.config.MaxBufferLines, s.metricsPack.MessageCounter)
|
err := ms.Init(serverConfig.ConfigDir, s.config.MaxBufferLines, s.metricsPack.MessageCounter)
|
||||||
|
@ -42,14 +42,14 @@ func (s *Server) Run(acn connectivity.ACN, serverConfig Config) {
|
||||||
acn.Close()
|
acn.Close()
|
||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
}
|
}
|
||||||
af.AddHandler("im.cwtch.server.listen", func(rai *application.ApplicationInstance) func() channels.Handler {
|
af.AddHandler("im.cwtch.server.listen", func(rai *application.Instance) func() channels.Handler {
|
||||||
return func() channels.Handler {
|
return func() channels.Handler {
|
||||||
cslc := new(listen.CwtchServerListenChannel)
|
cslc := new(listen.CwtchServerListenChannel)
|
||||||
return cslc
|
return cslc
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
af.AddHandler("im.cwtch.server.fetch", func(rai *application.ApplicationInstance) func() channels.Handler {
|
af.AddHandler("im.cwtch.server.fetch", func(rai *application.Instance) func() channels.Handler {
|
||||||
si := new(Instance)
|
si := new(Instance)
|
||||||
si.Init(rai, cwtchserver, ms)
|
si.Init(rai, cwtchserver, ms)
|
||||||
return func() channels.Handler {
|
return func() channels.Handler {
|
||||||
|
@ -59,7 +59,7 @@ func (s *Server) Run(acn connectivity.ACN, serverConfig Config) {
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
af.AddHandler("im.cwtch.server.send", func(rai *application.ApplicationInstance) func() channels.Handler {
|
af.AddHandler("im.cwtch.server.send", func(rai *application.Instance) func() channels.Handler {
|
||||||
si := new(Instance)
|
si := new(Instance)
|
||||||
si.Init(rai, cwtchserver, ms)
|
si.Init(rai, cwtchserver, ms)
|
||||||
return func() channels.Handler {
|
return func() channels.Handler {
|
||||||
|
|
|
@ -10,13 +10,13 @@ import (
|
||||||
|
|
||||||
// Instance encapsulates the Ricochet application.
|
// Instance encapsulates the Ricochet application.
|
||||||
type Instance struct {
|
type Instance struct {
|
||||||
rai *application.ApplicationInstance
|
rai *application.Instance
|
||||||
ra *application.RicochetApplication
|
ra *application.RicochetApplication
|
||||||
msi storage.MessageStoreInterface
|
msi storage.MessageStoreInterface
|
||||||
}
|
}
|
||||||
|
|
||||||
// Init sets up a Server Instance
|
// Init sets up a Server Instance
|
||||||
func (si *Instance) Init(rai *application.ApplicationInstance, ra *application.RicochetApplication, msi storage.MessageStoreInterface) {
|
func (si *Instance) Init(rai *application.Instance, ra *application.RicochetApplication, msi storage.MessageStoreInterface) {
|
||||||
si.rai = rai
|
si.rai = rai
|
||||||
si.ra = ra
|
si.ra = ra
|
||||||
si.msi = msi
|
si.msi = msi
|
||||||
|
@ -30,7 +30,7 @@ func (si *Instance) HandleFetchRequest() []*protocol.GroupMessage {
|
||||||
// HandleGroupMessage takes in a group message and distributes it to all listening peers
|
// HandleGroupMessage takes in a group message and distributes it to all listening peers
|
||||||
func (si *Instance) HandleGroupMessage(gm *protocol.GroupMessage) {
|
func (si *Instance) HandleGroupMessage(gm *protocol.GroupMessage) {
|
||||||
si.msi.AddMessage(*gm)
|
si.msi.AddMessage(*gm)
|
||||||
go si.ra.Broadcast(func(rai *application.ApplicationInstance) {
|
go si.ra.Broadcast(func(rai *application.Instance) {
|
||||||
rai.Connection.Do(func() error {
|
rai.Connection.Do(func() error {
|
||||||
channel := rai.Connection.Channel("im.cwtch.server.listen", channels.Inbound)
|
channel := rai.Connection.Channel("im.cwtch.server.listen", channels.Inbound)
|
||||||
if channel != nil {
|
if channel != nil {
|
||||||
|
|
|
@ -12,7 +12,7 @@ import (
|
||||||
|
|
||||||
func TestServerInstance(t *testing.T) {
|
func TestServerInstance(t *testing.T) {
|
||||||
si := new(Instance)
|
si := new(Instance)
|
||||||
ai := new(application.ApplicationInstance)
|
ai := new(application.Instance)
|
||||||
ra := new(application.RicochetApplication)
|
ra := new(application.RicochetApplication)
|
||||||
msi := new(storage.MessageStore)
|
msi := new(storage.MessageStore)
|
||||||
os.RemoveAll("messages")
|
os.RemoveAll("messages")
|
||||||
|
|
Loading…
Reference in New Issue