summaryrefslogtreecommitdiff
path: root/pkg/vpn/openvpn.go
diff options
context:
space:
mode:
authorkali kaneko (leap communications) <kali@leap.se>2020-08-17 19:42:15 +0200
committerkali kaneko (leap communications) <kali@leap.se>2020-08-20 20:27:45 +0200
commita10c5ecd2b4bba6814fd66f0ec1997938d95bf92 (patch)
tree5002b8d9e6709d3c277682039bac3411ffc8f643 /pkg/vpn/openvpn.go
parent60a35bdde41e8648594dc6a501a11000081ff878 (diff)
[feat] login feedback
- Resolves: #334
Diffstat (limited to 'pkg/vpn/openvpn.go')
-rw-r--r--pkg/vpn/openvpn.go16
1 files changed, 16 insertions, 0 deletions
diff --git a/pkg/vpn/openvpn.go b/pkg/vpn/openvpn.go
index 31f8738..11bba69 100644
--- a/pkg/vpn/openvpn.go
+++ b/pkg/vpn/openvpn.go
@@ -16,6 +16,7 @@
package vpn
import (
+ "errors"
"fmt"
"io/ioutil"
"log"
@@ -43,9 +44,23 @@ func (b *Bitmask) StartVPN(provider string) error {
}
}
+ if !b.CanStartVPN() {
+ return errors.New("BUG: cannot start vpn")
+ }
return b.startOpenVPN(proxy)
}
+func (b *Bitmask) CanStartVPN() bool {
+ if !b.bonafide.NeedsCredentials() {
+ return true
+ }
+ _, err := b.getCert()
+ if err != nil {
+ return false
+ }
+ return true
+}
+
func (b *Bitmask) startTransport() (proxy string, err error) {
proxy = "127.0.0.1:4430"
if b.shapes != nil {
@@ -150,6 +165,7 @@ func (b *Bitmask) getCert() (certPath string, err error) {
certPath = b.getCertPemPath()
if _, err := os.Stat(certPath); os.IsNotExist(err) {
+ log.Println("Cert does not exist in ", certPath, "...fetching")
cert, err := b.bonafide.GetPemCertificate()
if err != nil {
return "", err