summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--branding/config/vendor.conf2
-rw-r--r--gui/backend.go9
-rw-r--r--gui/handlers.cpp21
-rw-r--r--gui/handlers.h4
-rw-r--r--gui/main.cpp4
-rw-r--r--gui/qml/LoginOKDialog.qml3
-rw-r--r--pkg/backend/api.go7
-rw-r--r--pkg/backend/init.go8
-rw-r--r--pkg/config/config.go59
9 files changed, 59 insertions, 58 deletions
diff --git a/branding/config/vendor.conf b/branding/config/vendor.conf
index 4b3d4a9..687caad 100644
--- a/branding/config/vendor.conf
+++ b/branding/config/vendor.conf
@@ -1,6 +1,6 @@
[default]
-provider = riseup
+provider = demolib
[riseup]
diff --git a/gui/backend.go b/gui/backend.go
index a5cb3ab..c953d18 100644
--- a/gui/backend.go
+++ b/gui/backend.go
@@ -23,8 +23,8 @@ func GetAppName() *C.char {
}
//export Login
-func Login(username, password *C.char) {
- backend.Login(C.GoString(username), C.GoString(password))
+func Login(username, password string) {
+ backend.Login(username, password)
}
//export SwitchOn
@@ -76,6 +76,11 @@ func RefreshContext() *C.char {
return (*C.char)(backend.RefreshContext())
}
+//export ResetError
+func ResetError(errname string) {
+ backend.ResetError(errname)
+}
+
//export InstallHelpers
func InstallHelpers() {
backend.InstallHelpers()
diff --git a/gui/handlers.cpp b/gui/handlers.cpp
index 3959964..f34133e 100644
--- a/gui/handlers.cpp
+++ b/gui/handlers.cpp
@@ -6,6 +6,13 @@
#include "handlers.h"
#include "lib/libgoshim.h"
+GoString toGoStr(QString s)
+{
+ char *c = s.toLocal8Bit().data();
+ return (GoString){c, (long int)strlen(c)};
+}
+
+
Backend::Backend(QObject *parent) : QObject(parent)
{
}
@@ -37,14 +44,12 @@ void Backend::donateAccepted()
void Backend::login(QString username, QString password)
{
- // TODO: there has to be a cleaner way to do the conversion
- char * u = new char [username.length()+1];
- char * p = new char [password.length()+1];
- strcpy(u, username.toStdString().c_str());
- strcpy(p, password.toStdString().c_str());
- Login(u, p);
- delete [] u;
- delete [] p;
+ Login(toGoStr(username), toGoStr(password));
+}
+
+void Backend::resetError(QString errlabel)
+{
+ ResetError(toGoStr(errlabel));
}
void Backend::quit()
diff --git a/gui/handlers.h b/gui/handlers.h
index 656a451..9299827 100644
--- a/gui/handlers.h
+++ b/gui/handlers.h
@@ -4,6 +4,9 @@
#include <QDebug>
#include <QObject>
#include "qjsonmodel.h"
+#include "lib/libgoshim.h"
+
+GoString toGoStr(QString s);
class QJsonWatch : public QObject {
@@ -36,6 +39,7 @@ public slots:
void switchOff();
void donateAccepted();
void login(QString username, QString password);
+ void resetError(QString errlabel);
void quit();
};
diff --git a/gui/main.cpp b/gui/main.cpp
index 2a300e2..e3b8530 100644
--- a/gui/main.cpp
+++ b/gui/main.cpp
@@ -144,9 +144,7 @@ int main(int argc, char **argv) {
/* if requested, enable web api for controlling the VPN */
if (webAPI) {
- char* wp = webPort.toLocal8Bit().data();
- GoString p = {wp, (long int)strlen(wp)};
- EnableWebAPI(p);
+ EnableWebAPI(toGoStr(webPort));
};
/* kick off your shoes, put your feet up */
diff --git a/gui/qml/LoginOKDialog.qml b/gui/qml/LoginOKDialog.qml
index 52b3770..be023dd 100644
--- a/gui/qml/LoginOKDialog.qml
+++ b/gui/qml/LoginOKDialog.qml
@@ -12,9 +12,8 @@ Dialog {
}
}
- // TODO implement cleanNotifications on backend
function _loginOk() {
- loginDone = true;
+ backend.resetError("bad_auth")
}
visible: false
diff --git a/pkg/backend/api.go b/pkg/backend/api.go
index 7c049fc..7aa5527 100644
--- a/pkg/backend/api.go
+++ b/pkg/backend/api.go
@@ -85,6 +85,11 @@ func RefreshContext() *C.char {
return C.CString(string(c))
}
+func ResetError(errname string) {
+ log.Println("DEBUG: resetting error", errname)
+ resetErrors(errname)
+}
+
func InstallHelpers() {
pickle.InstallHelpers()
}
@@ -105,7 +110,7 @@ func EnableWebAPI(port string) {
/* 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. */
+ this probably should not live in the backend, see #326*/
func GetVersion() *C.char {
return C.CString(version.VERSION)
diff --git a/pkg/backend/init.go b/pkg/backend/init.go
index bae9b9b..af43bab 100644
--- a/pkg/backend/init.go
+++ b/pkg/backend/init.go
@@ -34,11 +34,19 @@ func initializeContext(opts *InitOpts) {
func checkErrors(errCh chan string) {
for {
err := <-errCh
+ // TODO consider a queue instead
ctx.Errors = err
go trigger(OnStatusChanged)
}
}
+func resetErrors(errname string) {
+ if ctx.Errors == errname {
+ ctx.Errors = ""
+ log.Println("DEBUG: reset error", errname)
+ }
+}
+
func initializeBitmask(errCh chan string, opts *InitOpts) {
if ctx == nil {
log.Println("bug: cannot initialize bitmask, ctx is nil!")
diff --git a/pkg/config/config.go b/pkg/config/config.go
index e799176..908409a 100644
--- a/pkg/config/config.go
+++ b/pkg/config/config.go
@@ -1,22 +1,22 @@
// Code generated by go generate; DO NOT EDIT.
// This file was generated by vendorize.py
-// At 2020-08-19 17:38:43
+// At 2020-08-20 13:39:50
package config
/* All these constants are defined in the vendor.conf file
*/
const (
- Provider = "riseup.net"
- ApplicationName = "RiseupVPN"
- BinaryName = "riseup-vpn"
- Auth = "anon"
- DonateURL = "https://riseup.net/vpn/donate"
- AskForDonations = "true"
- HelpURL = "https://riseup.net/support"
- TosURL = "https://riseup.net/tos"
- APIURL = "https://api.black.riseup.net/"
- GeolocationAPI = "https://api.black.riseup.net:9001/json"
+ Provider = "vpnlib.bitmask.net"
+ ApplicationName = "DemoLib"
+ BinaryName = "demo-lib"
+ Auth = "sip"
+ DonateURL = ""
+ AskForDonations = "false"
+ HelpURL = "https://libraryvpn.org/"
+ TosURL = "https://libraryvpn.org/"
+ APIURL = "https://api.vpnlib.bitmask.net:4430/"
+ GeolocationAPI = "https://getmyip.vpnlib.bitmask.net/json"
)
var Version string
@@ -29,34 +29,11 @@ CaCert : a string containing a representation of the provider CA, used to
*/
var CaCert = []byte(`-----BEGIN CERTIFICATE-----
-MIIFj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