summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorkali kaneko (leap communications) <kali@leap.se>2021-11-29 01:47:10 +0100
committerkali kaneko (leap communications) <kali@leap.se>2021-11-29 18:14:17 +0100
commit74970372b6586b336364ac1affac9dd7d22baef1 (patch)
tree5e801e7ba16198c165f6d8450490cd82e6426521
parent18f52af5be3a9a0c73811706108f790d65ee9c67 (diff)
[gui] motd
-rw-r--r--Makefile3
-rw-r--r--branding/motd-cli/main.go3
-rw-r--r--pkg/motd/fetch.go19
-rw-r--r--pkg/motd/motd.go10
4 files changed, 24 insertions, 11 deletions
diff --git a/Makefile b/Makefile
index cafdb13..3f42739 100644
--- a/Makefile
+++ b/Makefile
@@ -301,7 +301,8 @@ clean:
#########################################################################
qmllint:
- @qmllint gui/qml/*.qml
+ @qmllint gui/*.qml
+ @qmllint gui/components/*.qml
qmlfmt:
# needs https://github.com/jesperhh/qmlfmt in your path
diff --git a/branding/motd-cli/main.go b/branding/motd-cli/main.go
index cea5910..e1842bf 100644
--- a/branding/motd-cli/main.go
+++ b/branding/motd-cli/main.go
@@ -47,6 +47,9 @@ func main() {
fmt.Printf("Platform: %s %v\n", msg.Platform, mark(msg.IsValidPlatform()))
fmt.Printf("Urgency: %s %v\n", msg.Urgency, mark(msg.IsValidUrgency()))
fmt.Printf("Languages: %d %v\n", len(msg.Text), mark(msg.HasLocalizedText()))
+ for _, t := range msg.Text {
+ fmt.Printf(t.Str)
+ }
if !msg.IsValid() {
os.Exit(1)
}
diff --git a/pkg/motd/fetch.go b/pkg/motd/fetch.go
index 4f22388..fd76d7c 100644
--- a/pkg/motd/fetch.go
+++ b/pkg/motd/fetch.go
@@ -9,17 +9,26 @@ import (
"0xacab.org/leap/bitmask-vpn/pkg/config"
)
+const riseupMOTD = "https://static.riseup.net/vpn/motd.json"
+
func FetchLatest() []Message {
empty := []Message{}
if os.Getenv("SKIP_MOTD") == "1" {
return empty
}
url := ""
- switch config.Provider {
- case "riseup.net":
- url = "https://downloads.leap.se/motd/riseup/motd.json"
- default:
- return empty
+ if os.Getenv("DEBUG") == "1" {
+ url = os.Getenv("MOTD_URL")
+ if url == "" {
+ url = riseupMOTD
+ }
+ } else {
+ switch config.Provider {
+ case "riseup.net":
+ url = riseupMOTD
+ default:
+ return empty
+ }
}
log.Println("Fetching MOTD for", config.Provider)
b, err := fetchURL(url)
diff --git a/pkg/motd/motd.go b/pkg/motd/motd.go
index db21025..4dead55 100644
--- a/pkg/motd/motd.go
+++ b/pkg/motd/motd.go
@@ -47,6 +47,11 @@ type Message struct {
Text []LocalizedText `json:"text"`
}
+type LocalizedText struct {
+ Lang string `json:"lang"`
+ Str string `json:"str"`
+}
+
func (m *Message) IsValid() bool {
valid := (m.IsValidBegin() && m.IsValidEnd() &&
m.IsValidType() && m.IsValidPlatform() && m.IsValidUrgency() &&
@@ -111,8 +116,3 @@ func (m *Message) IsValidUrgency() bool {
func (m *Message) HasLocalizedText() bool {
return len(m.Text) > 0
}
-
-type LocalizedText struct {
- Lang string `json:"lang"`
- Str string `json:"str"`
-}