summaryrefslogtreecommitdiff
path: root/bitmask_go/vpn.go
diff options
context:
space:
mode:
authorRuben Pollan <meskio@sindominio.net>2018-06-25 18:39:49 +0200
committerRuben Pollan <meskio@sindominio.net>2018-06-25 18:47:08 +0200
commite24355110a908af9fc95ac0fd4c2754562a125ec (patch)
tree287fc23470378d75d7fd7c374e57d8e28a97666e /bitmask_go/vpn.go
parent3a27fa8dd3da90897b6bc7f8a035f1325313e4ac (diff)
[feat] rename bitmask_go to standalone
Diffstat (limited to 'bitmask_go/vpn.go')
-rw-r--r--bitmask_go/vpn.go121
1 files changed, 0 insertions, 121 deletions
diff --git a/bitmask_go/vpn.go b/bitmask_go/vpn.go
deleted file mode 100644
index 44fa768..0000000
--- a/bitmask_go/vpn.go
+++ /dev/null
@@ -1,121 +0,0 @@
-// Copyright (C) 2018 LEAP
-//
-// This program is free software: you can redistribute it and/or modify
-// it under the terms of the GNU General Public License as published by
-// the Free Software Foundation, either version 3 of the License, or
-// (at your option) any later version.
-//
-// This program is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-// GNU General Public License for more details.
-//
-// You should have received a copy of the GNU General Public License
-// along with this program. If not, see <http://www.gnu.org/licenses/>.
-
-package bitmask
-
-import (
- "path"
- "runtime"
-)
-
-const (
- openvpnManagementAddr = "127.0.0.1"
- openvpnManagementPort = "6061"
-)
-
-// StartVPN for provider
-func (b *Bitmask) StartVPN(provider string) error {
- gateways, err := b.bonafide.getGateways()
- if err != nil {
- return err
- }
- err = b.launch.firewallStart(gateways)
- if err != nil {
- return err
- }
-
- arg, err := b.bonafide.getOpenvpnArgs()
- if err != nil {
- return err
- }
- for _, gw := range gateways {
- arg = append(arg, "--remote", gw.IPAddress, "443", "tcp4")
- }
- certPemPath := b.getCertPemPath()
- arg = append(arg,
- "--nobind",
- "--verb", "1",
- "--dev", "tun",
- "--client",
- "--tls-client",
- "--remote-cert-tls", "server",
- "--script-security", "1",
- "--management-client",
- "--management", openvpnManagementAddr, openvpnManagementPort,
- "--ca", b.getCaCertPath(),
- "--cert", certPemPath,
- "--key", certPemPath)
- if runtime.GOOS == "windows" {
- arg = append(arg, "--log", `C:\bitmask\openvp.log`)
- }
- return b.launch.openvpnStart(arg...)
-}
-
-// StopVPN or cancel
-func (b *Bitmask) StopVPN() error {
- err := b.launch.firewallStop()
- if err != nil {
- return err
- }
- return b.launch.openvpnStop()
-}
-
-// GetStatus returns the VPN status
-func (b *Bitmask) GetStatus() (string, error) {
- status, err := b.getOpenvpnState()
- if err != nil {
- status = Off
- }
- return status, nil
-}
-
-// InstallHelpers into the system
-func (b *Bitmask) InstallHelpers() error {
- // TODO
- return nil
-}
-
-// VPNCheck returns if the helpers are installed and up to date and if polkit is running
-func (b *Bitmask) VPNCheck() (helpers bool, priviledge bool, err error) {
- // TODO
- return true, true, nil
-}
-
-// ListGateways return the names of the gateways
-func (b *Bitmask) ListGateways(provider string) ([]string, error) {
- gateways, err := b.bonafide.getGateways()
- if err != nil {
- return nil, err
- }
- gatewayNames := make([]string, len(gateways))
- for i, gw := range gateways {
- gatewayNames[i] = gw.Location
- }
- return gatewayNames, nil
-}
-
-// UseGateway selects name as the default gateway
-func (b *Bitmask) UseGateway(name string) error {
- b.bonafide.setDefaultGateway(name)
- return nil
-}
-
-func (b *Bitmask) getCertPemPath() string {
- return path.Join(b.tempdir, "openvpn.pem")
-}
-
-func (b *Bitmask) getCaCertPath() string {
- return path.Join(b.tempdir, "cacert.pem")
-}