diff options
l--------- | branding/assets/demolib | 1 | ||||
-rw-r--r-- | branding/config/demolib-ca.crt | 10 | ||||
-rw-r--r-- | branding/config/vendor.conf | 22 | ||||
-rw-r--r-- | gui/backend.go | 5 | ||||
-rw-r--r-- | gui/handlers.cpp | 12 | ||||
-rw-r--r-- | gui/handlers.h | 1 | ||||
-rw-r--r-- | gui/qml/LoginDialog.qml | 5 | ||||
-rw-r--r-- | gui/qml/main.qml | 4 | ||||
-rw-r--r-- | pkg/backend/api.go | 18 | ||||
-rw-r--r-- | pkg/backend/status.go | 1 | ||||
-rw-r--r-- | pkg/config/config.go | 59 |
11 files changed, 93 insertions, 45 deletions
diff --git a/branding/assets/demolib b/branding/assets/demolib new file mode 120000 index 0000000..efd261b --- /dev/null +++ b/branding/assets/demolib @@ -0,0 +1 @@ +demo
\ No newline at end of file diff --git a/branding/config/demolib-ca.crt b/branding/config/demolib-ca.crt new file mode 100644 index 0000000..ae726f4 --- /dev/null +++ b/branding/config/demolib-ca.crt @@ -0,0 +1,10 @@ +-----BEGIN CERTIFICATE----- +MIIBQzCB6aADAgECAgEBMAoGCCqGSM49BAMCMBcxFTATBgNVBAMTDExFQVAgUm9v +dCBDQTAeFw0yMDA4MDYxOTA3NDRaFw0yNTA4MDYxOTEyNDRaMBcxFTATBgNVBAMT +DExFQVAgUm9vdCBDQTBZMBMGByqGSM49AgEGCCqGSM49AwEHA0IABIG5POr4cAdK +kTavKpSJr8nW1V7HLpr27qKaShpk1TUy5ipaAlusmavGLxKsPE+i3AMlvf/f6ch3 +1MjAtIf5rYujJjAkMA4GA1UdDwEB/wQEAwICpDASBgNVHRMBAf8ECDAGAQH/AgEB +MAoGCCqGSM49BAMCA0kAMEYCIQDXj280LNZbSbi0Y2WvtQrJBUw4wdm8qAeOeuH7 +6XiLEwIhAPBRsmst/ujcChsG2t6LpG+p8s4rfIfh8YLo/4qrcc5p +-----END CERTIFICATE----- + diff --git a/branding/config/vendor.conf b/branding/config/vendor.conf index a1aca33..ac0f4b1 100644 --- a/branding/config/vendor.conf +++ b/branding/config/vendor.conf @@ -1,6 +1,6 @@ [default] -provider = riseup +provider = demolib [riseup] @@ -63,3 +63,23 @@ geolocationAPI = askForDonations = false donateURL = + +[demolib] + +name = demolib +applicationName = DemoLib +binaryName = demo-lib +auth = sip + +providerURL = vpnlib.bitmask.net +apiURL = https://api.vpnlib.bitmask.net/ +caURL = https://api.vpnlib.bitmask.net/ca.crt + +infoURL = https://libraryvpn.org/ +tosURL = https://libraryvpn.org/ +helpURL = https://libraryvpn.org/ + +geolocationAPI = https://getmyip.vpnlib.bitmask.net/ + +askForDonations = false +donateURL = diff --git a/gui/backend.go b/gui/backend.go index 536ade3..a5cb3ab 100644 --- a/gui/backend.go +++ b/gui/backend.go @@ -22,6 +22,11 @@ func GetAppName() *C.char { return (*C.char)(backend.GetAppName()) } +//export Login +func Login(username, password *C.char) { + backend.Login(C.GoString(username), C.GoString(password)) +} + //export SwitchOn func SwitchOn() { backend.SwitchOn() diff --git a/gui/handlers.cpp b/gui/handlers.cpp index ab64afb..3959964 100644 --- a/gui/handlers.cpp +++ b/gui/handlers.cpp @@ -35,6 +35,18 @@ void Backend::donateAccepted() 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; +} + void Backend::quit() { Quit(); diff --git a/gui/handlers.h b/gui/handlers.h index 62a733d..656a451 100644 --- a/gui/handlers.h +++ b/gui/handlers.h @@ -35,6 +35,7 @@ public slots: void switchOn(); void switchOff(); void donateAccepted(); + void login(QString username, QString password); void quit(); }; diff --git a/gui/qml/LoginDialog.qml b/gui/qml/LoginDialog.qml index 0c0f18e..1724769 100644 --- a/gui/qml/LoginDialog.qml +++ b/gui/qml/LoginDialog.qml @@ -22,7 +22,6 @@ Dialog { } visible: false - //visible: ctx.showLogin == true - //onAccepted: backend.login(username.text, password.text) - onRejected: backend.quit() // TODO: it doesn't close + onAccepted: backend.login(username.text, password.text) + onRejected: backend.quit() } diff --git a/gui/qml/main.qml b/gui/qml/main.qml index 09bbab5..0242493 100644 --- a/gui/qml/main.qml +++ b/gui/qml/main.qml @@ -19,6 +19,10 @@ ApplicationWindow { console.debug(jsonModel.getJson()) donate.visible = true } + if (ctx.loginDialog == 'true') { + console.debug(jsonModel.getJson()) + login.visible = true + } if (ctx.errors ) { if ( ctx.errors == "nohelpers" ) { showInitFailure(qsTr("Could not find helpers. Check your installation")) diff --git a/pkg/backend/api.go b/pkg/backend/api.go index ff8c1bb..7b48906 100644 --- a/pkg/backend/api.go +++ b/pkg/backend/api.go @@ -13,6 +13,21 @@ import ( "0xacab.org/leap/bitmask-vpn/pkg/pickle" ) +func Login(username, password string) { + success, err := ctx.bm.DoLogin(username, password) + if err != nil { + // TODO + log.Printf("Error login: %v", err) + } else if success { + // TODO: Notify success + log.Printf("Logged in as %s", username) + } else { + // TODO: display login again with an err + log.Printf("Failed to login as %s", username) + ctx.LoginDialog = true + } +} + func SwitchOn() { go setStatus(starting) go startVPN() @@ -57,6 +72,9 @@ func InitializeBitmaskContext(opts *InitOpts) { initOnce.Do(func() { initializeContext(opts) }) runDonationReminder() if ctx.bm != nil { + if ctx.bm.NeedsCredentials() { + ctx.LoginDialog = true + } go ctx.updateStatus() } } diff --git a/pkg/backend/status.go b/pkg/backend/status.go index 2bfb52d..5e9a0f8 100644 --- a/pkg/backend/status.go +++ b/pkg/backend/status.go @@ -37,6 +37,7 @@ type connectionCtx struct { AskForDonations bool `json:"askForDonations"` DonateDialog bool `json:"donateDialog"` DonateURL string `json:"donateURL"` + LoginDialog bool `json:"loginDialog"` Version string `json:"version"` Errors string `json:"errors"` Status status `json:"status"` diff --git a/pkg/config/config.go b/pkg/config/config.go index 80f5df4..e9866d2 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-06-16 21:44:41 +// At 2020-08-13 22:38:42 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/" + GeolocationAPI = "https://getmyip.vpnlib.bitmask.net/" ) var Version string @@ -29,34 +29,11 @@ CaCert : a string containing a representation of the provider CA, used to */ var CaCert = []byte(`-----BEGIN CERTIFICATE----- -MIIFjTCCA3WgAwIBAgIBATANBgkqhkiG9w0BAQ0FADBZMRgwFgYDVQQKDA9SaXNl -dXAgTmV0d29ya3MxGzAZBgNVBAsMEmh0dHBzOi8vcmlzZXVwLm5ldDEgMB4GA1UE -AwwXUmlzZXVwIE5ldHdvcmtzIFJvb3QgQ0EwHhcNMTQwNDI4MDAwMDAwWhcNMjQw -NDI4MDAwMDAwWjBZMRgwFgYDVQQKDA9SaXNldXAgTmV0d29ya3MxGzAZBgNVBAsM -Emh0dHBzOi8vcmlzZXVwLm5ldDEgMB4GA1UEAwwXUmlzZXVwIE5ldHdvcmtzIFJv -b3QgQ0EwggIiMA0GCSqGSIb3DQEBAQUAA4ICDwAwggIKAoICAQC76J4ciMJ8Sg0m -TP7DF2DT9zNe0Csk4myoMFC57rfJeqsAlJCv1XMzBmXrw8wq/9z7XHv6n/0sWU7a -7cF2hLR33ktjwODlx7vorU39/lXLndo492ZBhXQtG1INMShyv+nlmzO6GT7ESfNE -LliFitEzwIegpMqxC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