aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTulir Asokan <tulir@maunium.net>2020-05-07 11:56:21 +0300
committerTulir Asokan <tulir@maunium.net>2020-05-07 11:56:21 +0300
commite1b38bb20268a755ce63efb3e8894f983eedc02e (patch)
tree53afb7354ac1417a8d79fd14d723131c52427c8a
parent2b07b80e64e0c1ebe1673a5a534398f1fb8ad086 (diff)
Add command to get e2ee fingerprint
-rw-r--r--go.mod2
-rw-r--r--go.sum2
-rw-r--r--interface/matrix.go13
-rw-r--r--matrix/matrix.go12
-rw-r--r--ui/command-processor.go2
-rw-r--r--ui/commands.go19
6 files changed, 35 insertions, 15 deletions
diff --git a/go.mod b/go.mod
index 38bfbf6..acf2930 100644
--- a/go.mod
+++ b/go.mod
@@ -21,7 +21,7 @@ require (
golang.org/x/net v0.0.0-20200505041828-1ed23360d12c
gopkg.in/toast.v1 v1.0.0-20180812000517-0a84660828b2
gopkg.in/yaml.v2 v2.2.8
- maunium.net/go/mautrix v0.3.2
+ maunium.net/go/mautrix v0.3.3
maunium.net/go/mauview v0.1.1
maunium.net/go/tcell v0.2.0
)
diff --git a/go.sum b/go.sum
index cd4d758..d94436a 100644
--- a/go.sum
+++ b/go.sum
@@ -95,6 +95,8 @@ maunium.net/go/mautrix v0.3.1 h1:zDhN4PYdWavbssA+9JVoCsUmu/u0LtdHeE647oh3W8c=
maunium.net/go/mautrix v0.3.1/go.mod h1:SkGZzch8CvU2qKtNpYxtzZ0sQxfVEJ3IsVVLSUBUx9Y=
maunium.net/go/mautrix v0.3.2 h1:YLTj8euBTxb118XOryghWpsE/aieFI4lG6jCpCmw5HA=
maunium.net/go/mautrix v0.3.2/go.mod h1:SkGZzch8CvU2qKtNpYxtzZ0sQxfVEJ3IsVVLSUBUx9Y=
+maunium.net/go/mautrix v0.3.3 h1:PV+5oSDaFj3cPTE062O44q/G83x7qfP6gm9kr+BZIgE=
+maunium.net/go/mautrix v0.3.3/go.mod h1:SkGZzch8CvU2qKtNpYxtzZ0sQxfVEJ3IsVVLSUBUx9Y=
maunium.net/go/mauview v0.1.0 h1:x2WdkKI2zdriJuPAB0CKlwmnHGE7W9xfM5z6RgG+IIg=
maunium.net/go/mauview v0.1.0/go.mod h1:og9WbzmWe9SNYNyOFlCv8qa9zMcOvG2nzRJ5vYyud9U=
maunium.net/go/mauview v0.1.1 h1:wfTXyPx3LGAGpTskh+UbBv/QItUWnEpaneHmywoYnfY=
diff --git a/interface/matrix.go b/interface/matrix.go
index f4f46ef..122757f 100644
--- a/interface/matrix.go
+++ b/interface/matrix.go
@@ -64,4 +64,17 @@ type MatrixContainer interface {
DownloadToDisk(uri id.ContentURI, file *attachment.EncryptedFile, target string) (string, error)
GetDownloadURL(uri id.ContentURI) string
GetCachePath(uri id.ContentURI) string
+
+ Crypto() Crypto
+}
+
+type Crypto interface {
+ Load() error
+ FlushStore() error
+ ProcessSyncResponse(resp *mautrix.RespSync, since string)
+ HandleMemberEvent(*event.Event)
+ DecryptMegolmEvent(*event.Event) (*event.Event, error)
+ EncryptMegolmEvent(id.RoomID, event.Type, event.Content) (*event.EncryptedEventContent, error)
+ ShareGroupSession(id.RoomID, []id.UserID) error
+ Fingerprint() string
}
diff --git a/matrix/matrix.go b/matrix/matrix.go
index 7918aeb..e9a4f79 100644
--- a/matrix/matrix.go
+++ b/matrix/matrix.go
@@ -55,7 +55,7 @@ import (
// It is used for all Matrix calls from the UI and Matrix event handlers.
type Container struct {
client *mautrix.Client
- crypto CryptoInterface
+ crypto ifc.Crypto
syncer *GomuksSyncer
gmx ifc.Gomuks
ui ifc.GomuksUI
@@ -89,14 +89,8 @@ func (log mxLogger) Debugfln(message string, args ...interface{}) {
debug.Printf("[Matrix] "+message, args...)
}
-type CryptoInterface interface {
- Load() error
- FlushStore() error
- ProcessSyncResponse(resp *mautrix.RespSync, since string)
- HandleMemberEvent(*event.Event)
- DecryptMegolmEvent(*event.Event) (*event.Event, error)
- EncryptMegolmEvent(id.RoomID, event.Type, event.Content) (*event.EncryptedEventContent, error)
- ShareGroupSession(id.RoomID, []id.UserID) error
+func (c *Container) Crypto() ifc.Crypto {
+ return c.crypto
}
// InitClient initializes the mautrix client and connects to the homeserver specified in the config.
diff --git a/ui/command-processor.go b/ui/command-processor.go
index 10478cc..7a67d77 100644
--- a/ui/command-processor.go
+++ b/ui/command-processor.go
@@ -134,6 +134,8 @@ func NewCommandProcessor(parent *MainView) *CommandProcessor {
"hprof": cmdHeapProfile,
"cprof": cmdCPUProfile,
"trace": cmdTrace,
+
+ "fingerprint": cmdFingerprint,
},
}
}
diff --git a/ui/commands.go b/ui/commands.go
index 02d2a3d..961be26 100644
--- a/ui/commands.go
+++ b/ui/commands.go
@@ -237,7 +237,7 @@ func cmdTag(cmd *Command) {
err = cmd.Matrix.Client().AddTag(cmd.Room.MxRoom().ID, cmd.Args[0], order)
}
if err != nil {
- cmd.Reply("Failed to add tag:", err)
+ cmd.Reply("Failed to add tag: %v", err)
}
}
@@ -248,7 +248,7 @@ func cmdUntag(cmd *Command) {
}
err := cmd.Matrix.Client().RemoveTag(cmd.Room.MxRoom().ID, cmd.Args[0])
if err != nil {
- cmd.Reply("Failed to remove tag:", err)
+ cmd.Reply("Failed to remove tag: %v", err)
}
}
@@ -258,7 +258,16 @@ func cmdRoomNick(cmd *Command) {
member.Displayname = strings.Join(cmd.Args, " ")
_, err := cmd.Matrix.Client().SendStateEvent(room.ID, event.StateMember, string(room.SessionUserID), member)
if err != nil {
- cmd.Reply("Failed to set room nick:", err)
+ cmd.Reply("Failed to set room nick: %v", err)
+ }
+}
+
+func cmdFingerprint(cmd *Command) {
+ c := cmd.Matrix.Crypto()
+ if c == nil {
+ cmd.Reply("Encryption support is not enabled")
+ } else {
+ cmd.Reply("Device ID: %s\nFingerprint: %s", cmd.Matrix.Client().DeviceID, c.Fingerprint())
}
}
@@ -440,7 +449,7 @@ func cmdCreateRoom(cmd *Command) {
}
room, err := cmd.Matrix.CreateRoom(req)
if err != nil {
- cmd.Reply("Failed to create room:", err)
+ cmd.Reply("Failed to create room: %v", err)
return
}
cmd.MainView.SwitchRoom("", room)
@@ -465,7 +474,7 @@ func cmdPrivateMessage(cmd *Command) {
}
room, err := cmd.Matrix.CreateRoom(req)
if err != nil {
- cmd.Reply("Failed to create room:", err)
+ cmd.Reply("Failed to create room: %v", err)
return
}
cmd.MainView.SwitchRoom("", room)