extras

package
v0.0.3 Latest Latest
Warning

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

Go to latest
Published: May 26, 2022 License: GPL-3.0 Imports: 16 Imported by: 0

Documentation

Overview

Package extras contains some utilities that are not part of the OpenVPN implementation, but that are useful for practical purposes together with the tunnel.

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

func RunMeasurement added in v0.0.3

func RunMeasurement(d vpn.TunDialer, ndt7Server string, mode string, direct bool)

RunMeasurement performs a download & upload measurement against a given ndt7 server. It expects a vpn Dialer and a server string (ip:port). If the direct parameter is set to true, the vpn Dialer will not be used and a direct connection will be used instead.

Types

type Pinger

type Pinger struct {
	Count    int
	Interval time.Duration
	ID       int
	// contains filtered or unexported fields
}

Pinger holds all the needed info to ping a target.

Example
package main

import (
	"os"

	"github.com/ainghazal/minivpn/vpn"
)

var (
	cfg    = "data/calyx/config"
	target = "8.8.8.8"
	count  = 3
)

func main() {
	opts, err := vpn.ParseConfigFile(cfg)
	if err != nil {
		os.Exit(1)
	}
	rawDialer := vpn.NewRawDialer(opts)
	pinger := NewPinger(rawDialer, target, count)
	pinger.Run()
}
Output:

func NewPinger

func NewPinger(rawDialer *vpn.RawDialer, host string, count int) *Pinger

NewPinger returns a pointer to a Pinger struct configured to handle data from a vpn.Client. It needs host and count as parameters, and also accepts a done channel in which termination of the measurement series will be notified.

func (*Pinger) Run

func (p *Pinger) Run() error

func (*Pinger) Stats

func (p *Pinger) Stats() []st

Starts return the measured stats.

func (*Pinger) Stop

func (p *Pinger) Stop()

Stop prints ping statistics before quitting.

Directories

Path Synopsis
ndt7
emitter
Package emitter contains the ndt7-client emitter.
Package emitter contains the ndt7-client emitter.

Jump to

Keyboard shortcuts

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