Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
bitmask-vpn
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
leap
bitmask-vpn
Commits
74970372
Unverified
Commit
74970372
authored
3 years ago
by
Kali Kaneko
Browse files
Options
Downloads
Patches
Plain Diff
[gui] motd
parent
18f52af5
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
Makefile
+2
-1
2 additions, 1 deletion
Makefile
branding/motd-cli/main.go
+3
-0
3 additions, 0 deletions
branding/motd-cli/main.go
pkg/motd/fetch.go
+14
-5
14 additions, 5 deletions
pkg/motd/fetch.go
pkg/motd/motd.go
+5
-5
5 additions, 5 deletions
pkg/motd/motd.go
with
24 additions
and
11 deletions
Makefile
+
2
−
1
View file @
74970372
...
...
@@ -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
...
...
This diff is collapsed.
Click to expand it.
branding/motd-cli/main.go
+
3
−
0
View file @
74970372
...
...
@@ -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
)
}
...
...
This diff is collapsed.
Click to expand it.
pkg/motd/fetch.go
+
14
−
5
View file @
74970372
...
...
@@ -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
)
...
...
This diff is collapsed.
Click to expand it.
pkg/motd/motd.go
+
5
−
5
View file @
74970372
...
...
@@ -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"`
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment