From 4c48fd603d01bf43faeba9e72adb135879b7113c Mon Sep 17 00:00:00 2001 From: Dan Ballard Date: Fri, 17 Dec 2021 15:38:26 -0500 Subject: [PATCH 1/2] cwtch upgrade dropping unused events; android build notes --- README.md | 9 +++++++++ go.mod | 4 ++-- go.sum | 3 +++ utils/eventHandler.go | 9 +-------- 4 files changed, 15 insertions(+), 10 deletions(-) diff --git a/README.md b/README.md index f2f4c80..8cbd741 100644 --- a/README.md +++ b/README.md @@ -7,6 +7,15 @@ C-bindings for the Go Cwtch Library. make android make windows +## Android Build Notes + +Our build infrastructure is using Go 1.15.10, NDK 21.0.6113669, +and gomobile commit bdb1ca9a1e083af5929a8214e8a056d638ebbf2d (2021 07 16) + +Go 1.17.4, NDK 22.1.7171670, and gomobile 4e6c2922fdeed32d3596616518aaee7b0d79ce55 (2021 12 07) appear to compile as well. + +Other version combinations untested and some definitely do not work. + ## Experimental iOS support make ios diff --git a/go.mod b/go.mod index 313bb29..d4052a4 100644 --- a/go.mod +++ b/go.mod @@ -3,10 +3,10 @@ module git.openprivacy.ca/cwtch.im/libcwtch-go go 1.15 require ( - cwtch.im/cwtch v0.14.3 + cwtch.im/cwtch v0.14.4 git.openprivacy.ca/cwtch.im/server v1.4.1 git.openprivacy.ca/openprivacy/connectivity v1.5.0 git.openprivacy.ca/openprivacy/log v1.0.3 github.com/mutecomm/go-sqlcipher/v4 v4.4.2 golang.org/x/sys v0.0.0-20210823070655-63515b42dcdf // indirect -) +) \ No newline at end of file diff --git a/go.sum b/go.sum index 0984f1b..87a169d 100644 --- a/go.sum +++ b/go.sum @@ -15,6 +15,8 @@ cwtch.im/cwtch v0.14.2 h1:Q9rUainxUcHB2+F46lxhIS5kwZLy9BhPoQI1WnKcOD4= cwtch.im/cwtch v0.14.2/go.mod h1:/fLuoYLY/7JHw6RojFojpd245CiOcU24QpWqzh9FRDI= cwtch.im/cwtch v0.14.3 h1:CKNBYGfKErtLDY3fUOyadTVNbI2JjOe+Ud/srydVAko= cwtch.im/cwtch v0.14.3/go.mod h1:/fLuoYLY/7JHw6RojFojpd245CiOcU24QpWqzh9FRDI= +cwtch.im/cwtch v0.14.4 h1:QbQVzrAqczAG5tGazQvRVfN7MyQPWVN5Fwv7MzCXZs4= +cwtch.im/cwtch v0.14.4/go.mod h1:/fLuoYLY/7JHw6RojFojpd245CiOcU24QpWqzh9FRDI= dmitri.shuralyov.com/gpu/mtl v0.0.0-20190408044501-666a987793e9/go.mod h1:H6x//7gZCb22OMCxBHrMx7a5I7Hp++hsVxbQ4BYO7hU= filippo.io/edwards25519 v1.0.0-rc.1 h1:m0VOOB23frXZvAOK44usCgLWvtsxIoMCTBGJZlpmGfU= filippo.io/edwards25519 v1.0.0-rc.1/go.mod h1:N1IkdkCkiLB6tki+MYJoSx2JTY9NUlxZE7eHn5EwJns= @@ -274,6 +276,7 @@ golang.org/x/lint v0.0.0-20190409202823-959b441ac422/go.mod h1:6SW0HCj/g11FgYtHl golang.org/x/lint v0.0.0-20190909230951-414d861bb4ac/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= golang.org/x/lint v0.0.0-20190930215403-16217165b5de/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= golang.org/x/mobile v0.0.0-20190312151609-d3739f865fa6/go.mod h1:z+o9i4GpDbdi3rU15maQ/Ox0txvL9dWGYEHz965HBQE= +golang.org/x/mobile v0.0.0-20190719004257-d2bd2a29d028 h1:4+4C/Iv2U4fMZBiMCc98MG1In4gJY5YRhtpDNeDeHWs= golang.org/x/mobile v0.0.0-20190719004257-d2bd2a29d028/go.mod h1:E/iHnbuqvinMTCcRqshq8CkpyQDoeVncDDYHnLhea+o= golang.org/x/mod v0.0.0-20190513183733-4bf6d317e70e/go.mod h1:mXi4GBBbnImb6dmsKGUJ2LatrhH/nqhxcFungHvyanc= golang.org/x/mod v0.1.0/go.mod h1:0QHyrYULN0/3qlju5TqG8bIK38QM8yzMo5ekMj3DlcY= diff --git a/utils/eventHandler.go b/utils/eventHandler.go index 4cc5784..2255668 100644 --- a/utils/eventHandler.go +++ b/utils/eventHandler.go @@ -41,7 +41,6 @@ func (eh *EventHandler) HandleApp(application app.Application) { application.GetPrimaryBus().Subscribe(event.Shutdown, eh.appBusQueue) application.GetPrimaryBus().Subscribe(event.AppError, eh.appBusQueue) application.GetPrimaryBus().Subscribe(event.ACNStatus, eh.appBusQueue) - application.GetPrimaryBus().Subscribe(event.ReloadDone, eh.appBusQueue) application.GetPrimaryBus().Subscribe(event.ACNVersion, eh.appBusQueue) application.GetPrimaryBus().Subscribe(UpdateGlobalSettings, eh.appBusQueue) application.GetPrimaryBus().Subscribe(CwtchStarted, eh.appBusQueue) @@ -95,7 +94,7 @@ func (eh *EventHandler) handleAppBusEvent(e *event.Event) string { if e.Data[event.Created] == event.True { profile.SetScopedZonedAttribute(attr.PublicScope, attr.ProfileZone, constants2.Picture, ImageToString(NewImage(RandomProfileImage(onion), TypeImageDistro))) } - if e.Data[event.Status] != event.StorageRunning || e.Data[event.Created] == event.True { + if e.Data[event.Created] == event.True { profile.SetScopedZonedAttribute(attr.LocalScope, attr.ProfileZone, constants2.PeerOnline, event.False) eh.app.AddPeerPlugin(onion, plugins.CONNECTIONRETRY) eh.app.AddPeerPlugin(onion, plugins.NETWORKCHECK) @@ -405,18 +404,12 @@ func (eh *EventHandler) startHandlingPeer(onion string) { eventBus.Subscribe(event.MessageCounterResync, q) eventBus.Subscribe(event.GroupCreated, q) eventBus.Subscribe(event.NewGroup, q) - eventBus.Subscribe(event.AcceptGroupInvite, q) - eventBus.Subscribe(event.SetPeerAttribute, q) - eventBus.Subscribe(event.SetGroupAttribute, q) eventBus.Subscribe(event.DeleteGroup, q) eventBus.Subscribe(event.SendMessageToGroupError, q) eventBus.Subscribe(event.SendMessageToPeerError, q) eventBus.Subscribe(event.ServerStateChange, q) eventBus.Subscribe(event.PeerStateChange, q) - eventBus.Subscribe(event.ChangePasswordSuccess, q) - eventBus.Subscribe(event.ChangePasswordError, q) eventBus.Subscribe(event.NewRetValMessageFromPeer, q) - eventBus.Subscribe(event.SetAttribute, q) eventBus.Subscribe(event.ShareManifest, q) eventBus.Subscribe(event.ManifestSizeReceived, q) eventBus.Subscribe(event.ManifestError, q) From 4903e9376bebab18ed5bbbea3b3a340df226fc7e Mon Sep 17 00:00:00 2001 From: Dan Ballard Date: Fri, 17 Dec 2021 20:20:17 -0500 Subject: [PATCH 2/2] fix logic error on loading peer --- go.mod | 4 ++-- go.sum | 2 ++ utils/eventHandler.go | 37 +++++++++++++++++++------------------ 3 files changed, 23 insertions(+), 20 deletions(-) diff --git a/go.mod b/go.mod index d4052a4..b5e5651 100644 --- a/go.mod +++ b/go.mod @@ -3,10 +3,10 @@ module git.openprivacy.ca/cwtch.im/libcwtch-go go 1.15 require ( - cwtch.im/cwtch v0.14.4 + cwtch.im/cwtch v0.14.5 git.openprivacy.ca/cwtch.im/server v1.4.1 git.openprivacy.ca/openprivacy/connectivity v1.5.0 git.openprivacy.ca/openprivacy/log v1.0.3 github.com/mutecomm/go-sqlcipher/v4 v4.4.2 golang.org/x/sys v0.0.0-20210823070655-63515b42dcdf // indirect -) \ No newline at end of file +) diff --git a/go.sum b/go.sum index 87a169d..02918ee 100644 --- a/go.sum +++ b/go.sum @@ -17,6 +17,8 @@ cwtch.im/cwtch v0.14.3 h1:CKNBYGfKErtLDY3fUOyadTVNbI2JjOe+Ud/srydVAko= cwtch.im/cwtch v0.14.3/go.mod h1:/fLuoYLY/7JHw6RojFojpd245CiOcU24QpWqzh9FRDI= cwtch.im/cwtch v0.14.4 h1:QbQVzrAqczAG5tGazQvRVfN7MyQPWVN5Fwv7MzCXZs4= cwtch.im/cwtch v0.14.4/go.mod h1:/fLuoYLY/7JHw6RojFojpd245CiOcU24QpWqzh9FRDI= +cwtch.im/cwtch v0.14.5 h1:GY86C8UgqmuGh7ATR4C14hndc+c7PwPI8WH3l2iwnaQ= +cwtch.im/cwtch v0.14.5/go.mod h1:/fLuoYLY/7JHw6RojFojpd245CiOcU24QpWqzh9FRDI= dmitri.shuralyov.com/gpu/mtl v0.0.0-20190408044501-666a987793e9/go.mod h1:H6x//7gZCb22OMCxBHrMx7a5I7Hp++hsVxbQ4BYO7hU= filippo.io/edwards25519 v1.0.0-rc.1 h1:m0VOOB23frXZvAOK44usCgLWvtsxIoMCTBGJZlpmGfU= filippo.io/edwards25519 v1.0.0-rc.1/go.mod h1:N1IkdkCkiLB6tki+MYJoSx2JTY9NUlxZE7eHn5EwJns= diff --git a/utils/eventHandler.go b/utils/eventHandler.go index 2255668..c4a6cc2 100644 --- a/utils/eventHandler.go +++ b/utils/eventHandler.go @@ -94,26 +94,25 @@ func (eh *EventHandler) handleAppBusEvent(e *event.Event) string { if e.Data[event.Created] == event.True { profile.SetScopedZonedAttribute(attr.PublicScope, attr.ProfileZone, constants2.Picture, ImageToString(NewImage(RandomProfileImage(onion), TypeImageDistro))) } - if e.Data[event.Created] == event.True { - profile.SetScopedZonedAttribute(attr.LocalScope, attr.ProfileZone, constants2.PeerOnline, event.False) - eh.app.AddPeerPlugin(onion, plugins.CONNECTIONRETRY) - eh.app.AddPeerPlugin(onion, plugins.NETWORKCHECK) - // If the user has chosen to block unknown profiles - // then explicitly configure the protocol engine to do so.. - if ReadGlobalSettings().BlockUnknownConnections { - profile.BlockUnknownConnections() - } else { - // For completeness - profile.AllowUnknownConnections() - } + profile.SetScopedZonedAttribute(attr.LocalScope, attr.ProfileZone, constants2.PeerOnline, event.False) + eh.app.AddPeerPlugin(onion, plugins.CONNECTIONRETRY) + eh.app.AddPeerPlugin(onion, plugins.NETWORKCHECK) - // Start up the Profile - profile.Listen() - profile.StartPeersConnections() - if _, err := groups.ExperimentGate(ReadGlobalSettings().Experiments); err == nil { - profile.StartServerConnections() - } + // If the user has chosen to block unknown profiles + // then explicitly configure the protocol engine to do so.. + if ReadGlobalSettings().BlockUnknownConnections { + profile.BlockUnknownConnections() + } else { + // For completeness + profile.AllowUnknownConnections() + } + + // Start up the Profile + profile.Listen() + profile.StartPeersConnections() + if _, err := groups.ExperimentGate(ReadGlobalSettings().Experiments); err == nil { + profile.StartServerConnections() } online, _ := profile.GetScopedZonedAttribute(attr.LocalScope, attr.ProfileZone, constants2.PeerOnline) @@ -409,6 +408,8 @@ func (eh *EventHandler) startHandlingPeer(onion string) { eventBus.Subscribe(event.SendMessageToPeerError, q) eventBus.Subscribe(event.ServerStateChange, q) eventBus.Subscribe(event.PeerStateChange, q) + eventBus.Subscribe(event.ChangePasswordSuccess, q) + eventBus.Subscribe(event.ChangePasswordError, q) eventBus.Subscribe(event.NewRetValMessageFromPeer, q) eventBus.Subscribe(event.ShareManifest, q) eventBus.Subscribe(event.ManifestSizeReceived, q)