Merge pull request 'add build date and version info; add server sync state data' (#75) from state into trunk
continuous-integration/drone/push Build is passing
Details
continuous-integration/drone/push Build is passing
Details
Reviewed-on: #75 Reviewed-by: Sarah Jamie Lewis <sarah@openprivacy.ca>
This commit is contained in:
commit
4b881b9a12
8
Makefile
8
Makefile
|
@ -16,19 +16,19 @@ windows: libCwtch.dll
|
||||||
|
|
||||||
libCwtch.so: lib.go
|
libCwtch.so: lib.go
|
||||||
./switch-ffi.sh
|
./switch-ffi.sh
|
||||||
go build -buildmode c-shared -o libCwtch.so
|
go build -ldflags "-X main.buildVer=$(shell git describe --tags) -X main.buildDate=$(shell date +%G-%m-%d-%H-%M)" -buildmode c-shared -o libCwtch.so
|
||||||
|
|
||||||
libCwtch.dylib: lib.go
|
libCwtch.dylib: lib.go
|
||||||
./switch-ffi.sh
|
./switch-ffi.sh
|
||||||
go build -buildmode c-shared -o libCwtch.dylib
|
go build -ldflags "-X main.buildVer=$(shell git describe --tags) -X main.buildDate=$(shell date +%G-%m-%d-%H-%M)" -buildmode c-shared -o libCwtch.dylib
|
||||||
|
|
||||||
cwtch.aar: lib.go
|
cwtch.aar: lib.go
|
||||||
./switch-gomobile.sh
|
./switch-gomobile.sh
|
||||||
gomobile bind -target android
|
gomobile bind -target android -ldflags="-X cwtch.buildVer=$(shell git describe --tags) -X cwtch.buildDate=$(shell date +%G-%m-%d-%H-%M)"
|
||||||
|
|
||||||
libCwtch.dll: lib.go
|
libCwtch.dll: lib.go
|
||||||
./switch-ffi.sh
|
./switch-ffi.sh
|
||||||
GOOS=windows GOARCH=amd64 CGO_ENABLED=1 CC=x86_64-w64-mingw32-gcc-win32 go build -buildmode c-shared -o libCwtch.dll
|
GOOS=windows GOARCH=amd64 CGO_ENABLED=1 CC=x86_64-w64-mingw32-gcc-win32 go build -ldflags "-X main.buildVer=$(shell git describe --tags) -X main.buildDate=$(shell date +%G-%m-%d-%H-%M)" -buildmode c-shared -o libCwtch.dll
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
rm -f cwtch.aar cwtch_go.apk libCwtch.h libCwtch.so cwtch-sources.jar libCwtch.dll libCwtch.dylib
|
rm -f cwtch.aar cwtch_go.apk libCwtch.h libCwtch.so cwtch-sources.jar libCwtch.dll libCwtch.dylib
|
||||||
|
|
|
@ -4,6 +4,7 @@ import (
|
||||||
"cwtch.im/cwtch/event"
|
"cwtch.im/cwtch/event"
|
||||||
"cwtch.im/cwtch/model"
|
"cwtch.im/cwtch/model"
|
||||||
"cwtch.im/cwtch/model/attr"
|
"cwtch.im/cwtch/model/attr"
|
||||||
|
constants2 "cwtch.im/cwtch/model/constants"
|
||||||
"cwtch.im/cwtch/peer"
|
"cwtch.im/cwtch/peer"
|
||||||
"cwtch.im/cwtch/protocol/connections"
|
"cwtch.im/cwtch/protocol/connections"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
@ -57,5 +58,9 @@ func (gf *GroupFunctionality) GetServerInfo(serverOnion string, profile peer.Cwt
|
||||||
}
|
}
|
||||||
|
|
||||||
description, _ := serverInfo.GetAttribute(attr.LocalScope, attr.ServerZone, constants.Description)
|
description, _ := serverInfo.GetAttribute(attr.LocalScope, attr.ServerZone, constants.Description)
|
||||||
return Server{Onion: serverOnion, Identifier: serverInfo.ID, Status: connections.ConnectionStateName[profile.GetPeerState(serverInfo.Handle)], Keys: serverKeys, Description: description}
|
startTimeStr := serverInfo.Attributes[attr.LocalScope.ConstructScopedZonedPath(attr.LegacyGroupZone.ConstructZonedPath(constants2.SyncPreLastMessageTime)).ToString()]
|
||||||
|
recentTimeStr := serverInfo.Attributes[attr.LocalScope.ConstructScopedZonedPath(attr.LegacyGroupZone.ConstructZonedPath(constants2.SyncMostRecentMessageTime)).ToString()]
|
||||||
|
syncStatus := SyncStatus{startTimeStr, recentTimeStr}
|
||||||
|
|
||||||
|
return Server{Onion: serverOnion, Identifier: serverInfo.ID, Status: connections.ConnectionStateName[profile.GetPeerState(serverInfo.Handle)], Keys: serverKeys, Description: description, SyncProgress: syncStatus}
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,10 +5,16 @@ type ServerKey struct {
|
||||||
Key string `json:"key"`
|
Key string `json:"key"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type SyncStatus struct {
|
||||||
|
StartTime string `json:"startTime"`
|
||||||
|
LastMessageTime string `json:"lastMessageTime"`
|
||||||
|
}
|
||||||
|
|
||||||
type Server struct {
|
type Server struct {
|
||||||
Onion string `json:"onion"`
|
Onion string `json:"onion"`
|
||||||
Identifier int `json:"identifier"`
|
Identifier int `json:"identifier"`
|
||||||
Status string `json:"status"`
|
Status string `json:"status"`
|
||||||
Description string `json:"description"`
|
Description string `json:"description"`
|
||||||
Keys []ServerKey `json:"keys"`
|
Keys []ServerKey `json:"keys"`
|
||||||
|
SyncProgress SyncStatus `json:"syncProgress"`
|
||||||
}
|
}
|
||||||
|
|
2
go.mod
2
go.mod
|
@ -3,7 +3,7 @@ module git.openprivacy.ca/cwtch.im/libcwtch-go
|
||||||
go 1.15
|
go 1.15
|
||||||
|
|
||||||
require (
|
require (
|
||||||
cwtch.im/cwtch v0.15.1
|
cwtch.im/cwtch v0.15.2
|
||||||
git.openprivacy.ca/cwtch.im/server v1.4.2
|
git.openprivacy.ca/cwtch.im/server v1.4.2
|
||||||
git.openprivacy.ca/openprivacy/connectivity v1.8.1
|
git.openprivacy.ca/openprivacy/connectivity v1.8.1
|
||||||
git.openprivacy.ca/openprivacy/log v1.0.3
|
git.openprivacy.ca/openprivacy/log v1.0.3
|
||||||
|
|
4
go.sum
4
go.sum
|
@ -11,8 +11,8 @@ cloud.google.com/go/firestore v1.1.0/go.mod h1:ulACoGHTpvq5r8rxGJ4ddJZBZqakUQqCl
|
||||||
cloud.google.com/go/pubsub v1.0.1/go.mod h1:R0Gpsv3s54REJCy4fxDixWD93lHJMoZTyQ2kNxGRt3I=
|
cloud.google.com/go/pubsub v1.0.1/go.mod h1:R0Gpsv3s54REJCy4fxDixWD93lHJMoZTyQ2kNxGRt3I=
|
||||||
cloud.google.com/go/storage v1.0.0/go.mod h1:IhtSnM/ZTZV8YYJWCY8RULGVqBDmpoyjwiyrjsg+URw=
|
cloud.google.com/go/storage v1.0.0/go.mod h1:IhtSnM/ZTZV8YYJWCY8RULGVqBDmpoyjwiyrjsg+URw=
|
||||||
cwtch.im/cwtch v0.14.9/go.mod h1:/fLuoYLY/7JHw6RojFojpd245CiOcU24QpWqzh9FRDI=
|
cwtch.im/cwtch v0.14.9/go.mod h1:/fLuoYLY/7JHw6RojFojpd245CiOcU24QpWqzh9FRDI=
|
||||||
cwtch.im/cwtch v0.15.1 h1:y+c8KNnX3BVEa+THqX9drsI6CUZxHlFhZ+BtwGiVYT8=
|
cwtch.im/cwtch v0.15.2 h1:hGeLP3K2olqYevIGYYPY/x5TguQFwWb7X4pd6SHYON4=
|
||||||
cwtch.im/cwtch v0.15.1/go.mod h1:lG9e5RUib+SbX2XsjWtHKJWz9geoIglSAq55LrCm8Io=
|
cwtch.im/cwtch v0.15.2/go.mod h1:lG9e5RUib+SbX2XsjWtHKJWz9geoIglSAq55LrCm8Io=
|
||||||
dmitri.shuralyov.com/gpu/mtl v0.0.0-20190408044501-666a987793e9/go.mod h1:H6x//7gZCb22OMCxBHrMx7a5I7Hp++hsVxbQ4BYO7hU=
|
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 h1:m0VOOB23frXZvAOK44usCgLWvtsxIoMCTBGJZlpmGfU=
|
||||||
filippo.io/edwards25519 v1.0.0-rc.1/go.mod h1:N1IkdkCkiLB6tki+MYJoSx2JTY9NUlxZE7eHn5EwJns=
|
filippo.io/edwards25519 v1.0.0-rc.1/go.mod h1:N1IkdkCkiLB6tki+MYJoSx2JTY9NUlxZE7eHn5EwJns=
|
||||||
|
|
28
lib.go
28
lib.go
|
@ -32,7 +32,6 @@ import (
|
||||||
"cwtch.im/cwtch/functionality/filesharing"
|
"cwtch.im/cwtch/functionality/filesharing"
|
||||||
"cwtch.im/cwtch/model"
|
"cwtch.im/cwtch/model"
|
||||||
"cwtch.im/cwtch/model/attr"
|
"cwtch.im/cwtch/model/attr"
|
||||||
"cwtch.im/cwtch/peer"
|
|
||||||
"git.openprivacy.ca/cwtch.im/libcwtch-go/constants"
|
"git.openprivacy.ca/cwtch.im/libcwtch-go/constants"
|
||||||
"git.openprivacy.ca/cwtch.im/libcwtch-go/features/groups"
|
"git.openprivacy.ca/cwtch.im/libcwtch-go/features/groups"
|
||||||
"git.openprivacy.ca/cwtch.im/libcwtch-go/features/servers"
|
"git.openprivacy.ca/cwtch.im/libcwtch-go/features/servers"
|
||||||
|
@ -56,6 +55,12 @@ const (
|
||||||
ProfileOnion = event.Field("ProfileOnion")
|
ProfileOnion = event.Field("ProfileOnion")
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// supplied by make
|
||||||
|
var (
|
||||||
|
buildVer string
|
||||||
|
buildDate string
|
||||||
|
)
|
||||||
|
|
||||||
var application app.Application
|
var application app.Application
|
||||||
var globalAppDir string
|
var globalAppDir string
|
||||||
var globalTorPath string
|
var globalTorPath string
|
||||||
|
@ -105,6 +110,8 @@ func StartCwtch(appDir string, torPath string) int {
|
||||||
log.SetLevel(log.LevelDebug)
|
log.SetLevel(log.LevelDebug)
|
||||||
}
|
}
|
||||||
log.Infof("StartCwtch(...)")
|
log.Infof("StartCwtch(...)")
|
||||||
|
log.Debugf("builddate: %v buildver: %v", buildDate, buildVer)
|
||||||
|
|
||||||
// Quick hack check that we're being called with the correct params
|
// Quick hack check that we're being called with the correct params
|
||||||
// On android a stale worker could be calling us with "last apps" directory. Best to abort fast so the app can make a new worker
|
// On android a stale worker could be calling us with "last apps" directory. Best to abort fast so the app can make a new worker
|
||||||
if runtime.GOOS == "android" {
|
if runtime.GOOS == "android" {
|
||||||
|
@ -179,24 +186,6 @@ func _startCwtch(appDir string, torPath string) {
|
||||||
|
|
||||||
eventHandler.HandleApp(application)
|
eventHandler.HandleApp(application)
|
||||||
|
|
||||||
peer.DefaultEventsToHandle = []event.Type{
|
|
||||||
event.EncryptedGroupMessage,
|
|
||||||
event.NewMessageFromPeerEngine,
|
|
||||||
event.PeerAcknowledgement,
|
|
||||||
event.PeerError,
|
|
||||||
event.SendMessageToPeerError,
|
|
||||||
event.SendMessageToGroupError,
|
|
||||||
event.NewGetValMessageFromPeer,
|
|
||||||
event.PeerStateChange,
|
|
||||||
event.NewRetValMessageFromPeer,
|
|
||||||
event.NewGroupInvite,
|
|
||||||
event.ServerStateChange,
|
|
||||||
event.ProtocolEngineStopped,
|
|
||||||
event.RetryServerRequest,
|
|
||||||
event.ManifestReceived,
|
|
||||||
event.FileDownloaded,
|
|
||||||
}
|
|
||||||
|
|
||||||
// Settings may have changed...
|
// Settings may have changed...
|
||||||
settings = utils.ReadGlobalSettings()
|
settings = utils.ReadGlobalSettings()
|
||||||
settingsJson, _ := json.Marshal(settings)
|
settingsJson, _ := json.Marshal(settings)
|
||||||
|
@ -1019,7 +1008,6 @@ func ShutdownCwtch() {
|
||||||
if application != nil {
|
if application != nil {
|
||||||
// Kill the isolate
|
// Kill the isolate
|
||||||
eventHandler.Push(event.NewEvent(event.Shutdown, map[event.Field]string{}))
|
eventHandler.Push(event.NewEvent(event.Shutdown, map[event.Field]string{}))
|
||||||
|
|
||||||
servers.Shutdown()
|
servers.Shutdown()
|
||||||
// Allow for the shutdown events to go through and then purge everything else...
|
// Allow for the shutdown events to go through and then purge everything else...
|
||||||
log.Infof("Shutting Down Application...")
|
log.Infof("Shutting Down Application...")
|
||||||
|
|
|
@ -341,7 +341,7 @@ func (eh *EventHandler) handleProfileEvent(ev *EventProfileEnvelope) string {
|
||||||
if ci != nil && ci.Accepted {
|
if ci != nil && ci.Accepted {
|
||||||
handleImagePreviews(profile, &ev.Event, conversationID, ci.ID)
|
handleImagePreviews(profile, &ev.Event, conversationID, ci.ID)
|
||||||
}
|
}
|
||||||
gci, err := profile.GetConversationInfo(conversationID)
|
gci, _ := profile.GetConversationInfo(conversationID)
|
||||||
ev.Event.Data["notification"] = string(determineNotification(gci))
|
ev.Event.Data["notification"] = string(determineNotification(gci))
|
||||||
case event.PeerAcknowledgement:
|
case event.PeerAcknowledgement:
|
||||||
ci, err := profile.FetchConversationInfo(ev.Event.Data["RemotePeer"])
|
ci, err := profile.FetchConversationInfo(ev.Event.Data["RemotePeer"])
|
||||||
|
|
Reference in New Issue