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
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
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
Julian Merlin
bitmask-vpn
Commits
ef0d5525
Unverified
Commit
ef0d5525
authored
4 years ago
by
Kali Kaneko
Browse files
Options
Downloads
Patches
Plain Diff
[refactor] grab appname from providers.json
parent
998b5cb5
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
gui/backend.go
+0
-5
0 additions, 5 deletions
gui/backend.go
gui/handlers.cpp
+0
-7
0 additions, 7 deletions
gui/handlers.cpp
gui/handlers.h
+0
-1
0 additions, 1 deletion
gui/handlers.h
gui/main.cpp
+32
-20
32 additions, 20 deletions
gui/main.cpp
pkg/backend/api.go
+0
-10
0 additions, 10 deletions
pkg/backend/api.go
with
32 additions
and
43 deletions
gui/backend.go
+
0
−
5
View file @
ef0d5525
...
@@ -17,11 +17,6 @@ func GetVersion() *C.char {
...
@@ -17,11 +17,6 @@ func GetVersion() *C.char {
return
(
*
C
.
char
)(
backend
.
GetVersion
())
return
(
*
C
.
char
)(
backend
.
GetVersion
())
}
}
//export GetAppName
func
GetAppName
()
*
C
.
char
{
return
(
*
C
.
char
)(
backend
.
GetAppName
())
}
//export Login
//export Login
func
Login
(
username
,
password
string
)
{
func
Login
(
username
,
password
string
)
{
backend
.
Login
(
username
,
password
)
backend
.
Login
(
username
,
password
)
...
...
This diff is collapsed.
Click to expand it.
gui/handlers.cpp
+
0
−
7
View file @
ef0d5525
...
@@ -8,8 +8,6 @@
...
@@ -8,8 +8,6 @@
GoString
toGoStr
(
QString
s
)
GoString
toGoStr
(
QString
s
)
{
{
// TODO verify that it's more correct
// char *c = s.toLocal8Bit().data();
const
char
*
c
=
s
.
toUtf8
().
constData
();
const
char
*
c
=
s
.
toUtf8
().
constData
();
return
(
GoString
){
c
,
(
long
int
)
strlen
(
c
)};
return
(
GoString
){
c
,
(
long
int
)
strlen
(
c
)};
}
}
...
@@ -19,11 +17,6 @@ Backend::Backend(QObject *parent) : QObject(parent)
...
@@ -19,11 +17,6 @@ Backend::Backend(QObject *parent) : QObject(parent)
{
{
}
}
QString
Backend
::
getAppName
()
{
return
QString
(
GetAppName
());
}
QString
Backend
::
getVersion
()
QString
Backend
::
getVersion
()
{
{
return
QString
(
GetVersion
());
return
QString
(
GetVersion
());
...
...
This diff is collapsed.
Click to expand it.
gui/handlers.h
+
0
−
1
View file @
ef0d5525
...
@@ -33,7 +33,6 @@ signals:
...
@@ -33,7 +33,6 @@ signals:
void
quitDone
();
void
quitDone
();
public
slots
:
public
slots
:
QString
getAppName
();
QString
getVersion
();
QString
getVersion
();
void
switchOn
();
void
switchOn
();
void
switchOff
();
void
switchOff
();
...
...
This diff is collapsed.
Click to expand it.
gui/main.cpp
+
32
−
20
View file @
ef0d5525
...
@@ -38,20 +38,40 @@ void signalHandler(int) {
...
@@ -38,20 +38,40 @@ void signalHandler(int) {
exit
(
0
);
exit
(
0
);
}
}
QString
getAppName
(
QJsonValue
info
,
QString
provider
)
{
for
(
auto
p
:
info
.
toArray
())
{
QJsonObject
item
=
p
.
toObject
();
if
(
item
[
"name"
]
==
provider
)
{
return
item
[
"applicationName"
].
toString
();
}
}
return
"BitmaskVPN"
;
}
int
main
(
int
argc
,
char
**
argv
)
{
int
main
(
int
argc
,
char
**
argv
)
{
signal
(
SIGINT
,
signalHandler
);
signal
(
SIGINT
,
signalHandler
);
Backend
backend
;
Backend
backend
;
QApplication
::
setAttribute
(
Qt
::
AA_EnableHighDpiScaling
);
QApplication
::
setAttribute
(
Qt
::
AA_EnableHighDpiScaling
);
QApplication
::
setApplicationName
(
backend
.
getAppName
());
QApplication
::
setApplicationVersion
(
backend
.
getVersion
());
QApplication
::
setApplicationVersion
(
backend
.
getVersion
());
QApplication
app
(
argc
,
argv
);
QApplication
app
(
argc
,
argv
);
app
.
setQuitOnLastWindowClosed
(
false
);
app
.
setQuitOnLastWindowClosed
(
false
);
/* load providers json */
QFile
providerJson
(
":/providers.json"
);
providerJson
.
open
(
QIODevice
::
ReadOnly
|
QIODevice
::
Text
);
QJsonModel
*
providers
=
new
QJsonModel
;
providers
->
loadJson
(
providerJson
.
readAll
());
QJsonValue
defaultProvider
=
providers
->
json
().
object
().
value
(
"default"
);
QJsonValue
providersInfo
=
providers
->
json
().
object
().
value
(
"providers"
);
QString
appName
=
getAppName
(
providersInfo
,
defaultProvider
.
toString
());
QApplication
::
setApplicationName
(
appName
);
QCommandLineParser
parser
;
QCommandLineParser
parser
;
parser
.
setApplicationDescription
(
parser
.
setApplicationDescription
(
backend
.
getA
ppName
()
+
a
ppName
+
QApplication
::
translate
(
QApplication
::
translate
(
"main"
,
": a fast and secure VPN. Powered by Bitmask."
));
"main"
,
": a fast and secure VPN. Powered by Bitmask."
));
parser
.
addHelpOption
();
parser
.
addHelpOption
();
...
@@ -80,30 +100,24 @@ int main(int argc, char **argv) {
...
@@ -80,30 +100,24 @@ int main(int argc, char **argv) {
{
"v"
,
"version"
},
{
"v"
,
"version"
},
QApplication
::
translate
(
QApplication
::
translate
(
"main"
,
"main"
,
"Version of the bitmask-vpn."
),
"Version of the bitmask-vpn."
),
},
},
{
{
{
"o"
,
"obfs4"
},
{
"o"
,
"obfs4"
},
QApplication
::
translate
(
QApplication
::
translate
(
"main"
,
"main"
,
"Use obfs4 to obfuscate the traffic i
s
available in the provider."
),
"Use obfs4 to obfuscate the traffic
,
i
f
available in the provider."
),
},
},
{
{
{
"a"
,
"disable-autostart"
},
{
"a"
,
"disable-autostart"
},
QApplication
::
translate
(
QApplication
::
translate
(
"main"
,
"main"
,
"Disable the autostart for the next run."
),
"Disable autostart for the next run."
),
},
{
{
"s"
,
"start-vpn"
},
QApplication
::
translate
(
"main"
,
"Start the vpn in turned 'on' or 'off'."
),
},
},
});
});
QCommandLineOption
webPortOption
(
"web-port"
,
QApplication
::
translate
(
"main"
,
"Web api port (default: 8080)"
),
"port"
,
"8080"
);
QCommandLineOption
webPortOption
(
"web-port"
,
QApplication
::
translate
(
"main"
,
"Web api port (default: 8080)"
),
"port"
,
"8080"
);
parser
.
addOption
(
webPortOption
);
parser
.
addOption
(
webPortOption
);
QCommandLineOption
startVPNOption
(
"start-vpn"
,
QApplication
::
translate
(
"main"
,
"Start the vpn
in turned
'on' or 'off'."
),
"status"
,
""
);
QCommandLineOption
startVPNOption
(
"start-vpn"
,
QApplication
::
translate
(
"main"
,
"Start the vpn
, either
'on' or 'off'."
),
"status"
,
""
);
parser
.
addOption
(
startVPNOption
);
parser
.
addOption
(
startVPNOption
);
parser
.
process
(
app
);
parser
.
process
(
app
);
...
@@ -121,6 +135,11 @@ int main(int argc, char **argv) {
...
@@ -121,6 +135,11 @@ int main(int argc, char **argv) {
exit
(
0
);
exit
(
0
);
}
}
if
(
startVPN
!=
""
&&
startVPN
!=
"on"
&&
startVPN
!=
"off"
)
{
qDebug
()
<<
"Error: --start-vpn must be either 'on' or 'off'"
;
exit
(
0
);
}
if
(
hideSystray
)
{
if
(
hideSystray
)
{
qDebug
()
<<
"Not showing systray icon because --no-systray option is set."
;
qDebug
()
<<
"Not showing systray icon because --no-systray option is set."
;
}
}
...
@@ -144,12 +163,6 @@ int main(int argc, char **argv) {
...
@@ -144,12 +163,6 @@ int main(int argc, char **argv) {
QJsonModel
*
model
=
new
QJsonModel
;
QJsonModel
*
model
=
new
QJsonModel
;
/* load providers json */
QFile
providerJson
(
":/providers.json"
);
providerJson
.
open
(
QIODevice
::
ReadOnly
|
QIODevice
::
Text
);
QJsonModel
*
providers
=
new
QJsonModel
;
providers
->
loadJson
(
providerJson
.
readAll
());
/* the backend handler has slots for calling back to Go when triggered by
/* the backend handler has slots for calling back to Go when triggered by
signals in Qml. */
signals in Qml. */
ctx
->
setContextProperty
(
"backend"
,
&
backend
);
ctx
->
setContextProperty
(
"backend"
,
&
backend
);
...
@@ -180,7 +193,6 @@ int main(int argc, char **argv) {
...
@@ -180,7 +193,6 @@ int main(int argc, char **argv) {
GoString
statusChangedEvt
=
{
stCh
,
(
long
int
)
strlen
(
stCh
)};
GoString
statusChangedEvt
=
{
stCh
,
(
long
int
)
strlen
(
stCh
)};
SubscribeToEvent
(
statusChangedEvt
,
(
void
*
)
onStatusChanged
);
SubscribeToEvent
(
statusChangedEvt
,
(
void
*
)
onStatusChanged
);
QJsonValue
defaultProvider
=
providers
->
json
().
object
().
value
(
"default"
);
/* we send json as bytes because it breaks as a simple string */
/* we send json as bytes because it breaks as a simple string */
QString
QProvidersJSON
(
providers
->
json
().
toJson
(
QJsonDocument
::
Compact
));
QString
QProvidersJSON
(
providers
->
json
().
toJson
(
QJsonDocument
::
Compact
));
...
@@ -188,7 +200,7 @@ int main(int argc, char **argv) {
...
@@ -188,7 +200,7 @@ int main(int argc, char **argv) {
InitializeBitmaskContext
(
InitializeBitmaskContext
(
toGoStr
(
defaultProvider
.
toString
()),
toGoStr
(
defaultProvider
.
toString
()),
(
char
*
)
QProvidersJSON
.
toUtf8
().
data
(),
strlen
(
QProvidersJSON
.
toUtf8
().
data
()),
(
char
*
)
QProvidersJSON
.
toUtf8
().
data
(),
strlen
(
QProvidersJSON
.
toUtf8
().
data
()),
obfs4
,
disAutostart
,
toGoStr
(
startVPN
));
obfs4
,
disAutostart
,
toGoStr
(
startVPN
));
/* if requested, enable web api for controlling the VPN */
/* if requested, enable web api for controlling the VPN */
if
(
webAPI
)
{
if
(
webAPI
)
{
...
...
This diff is collapsed.
Click to expand it.
pkg/backend/api.go
+
0
−
10
View file @
ef0d5525
...
@@ -145,16 +145,6 @@ func EnableWebAPI(port string) {
...
@@ -145,16 +145,6 @@ func EnableWebAPI(port string) {
go
enableWebAPI
(
intPort
)
go
enableWebAPI
(
intPort
)
}
}
/* these two are a bit redundant since we already add them to ctx. however, we
want to have them available before everything else, to be able to parse cli
arguments. In the long run, we probably want to move all vendoring to qt, so
this probably should not live in the backend, see #326*/
func
GetVersion
()
*
C
.
char
{
func
GetVersion
()
*
C
.
char
{
return
C
.
CString
(
version
.
VERSION
)
return
C
.
CString
(
version
.
VERSION
)
}
}
func
GetAppName
()
*
C
.
char
{
p
:=
bitmask
.
GetConfiguredProvider
()
return
C
.
CString
(
p
.
AppName
)
}
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