vpn

package
v0.0.0-...-b7dec55 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 20, 2025 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type IProviderVPN

type IProviderVPN interface {
	ConnectVPN() error
	ListVPN() map[string][]string
	SetLocationVPN(countryCode string) ([]string, error)
	SetCustomDNSResolver(ip string) error
	SetDefaultDNSResolver() error
	CheckVPNStatus(expectedCountryCode string) ([]string, error)
	ExtractIPAddresses(status string) (ipv4, ipv6 string)
}

type Mullvad

type Mullvad struct{}

func (Mullvad) CheckVPNStatus

func (m Mullvad) CheckVPNStatus(expectedCountryCode string) ([]string, error)

func (Mullvad) ConnectVPN

func (m Mullvad) ConnectVPN() error
func (m Mullvad) ListVPN() map[string][]string {
	cmd := exec.Command("mullvad", "relay", "list")
	var out bytes.Buffer
	cmd.Stdout = &out
	err := cmd.Run()
	if err != nil {
		log.Printf("Error executing command: %v\n", err)
		return nil
	}

	relays := parseOutput(out.String())

	// Print the parsed relays
	//for countryCode, names := range relays {
	//	for _, name := range names {
	//		fmt.Printf("Country Code: %s, Name: %s\n", countryCode, name)
	//	}
	//}

	return relays
}

func (Mullvad) ExtractIPAddresses

func (m Mullvad) ExtractIPAddresses(status string) (ipv4, ipv6 string)

func (Mullvad) ListVPN

func (m Mullvad) ListVPN() map[string][]string

func (Mullvad) SetCustomDNSResolver

func (m Mullvad) SetCustomDNSResolver(ip string) error

func (Mullvad) SetDefaultDNSResolver

func (m Mullvad) SetDefaultDNSResolver() error

func (Mullvad) SetLocationVPN

func (m Mullvad) SetLocationVPN(countryCode string) ([]string, error)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL