diff options
Diffstat (limited to 'pkg/vpn/openvpn.go')
-rw-r--r-- | pkg/vpn/openvpn.go | 16 |
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 |