Files
gluetun/internal/openvpn/openvpn.go
2021-02-06 16:26:23 +00:00

38 lines
925 B
Go

// Package openvpn defines interfaces to interact with openvpn
// and run it in a stateful loop.
package openvpn
import (
"context"
"github.com/qdm12/gluetun/internal/unix"
"github.com/qdm12/golibs/command"
"github.com/qdm12/golibs/logging"
"github.com/qdm12/golibs/os"
)
type Configurator interface {
Version(ctx context.Context) (string, error)
WriteAuthFile(user, password string, puid, pgid int) error
CheckTUN() error
CreateTUN() error
Start(ctx context.Context) (stdoutLines, stderrLines chan string,
waitError chan error, err error)
}
type configurator struct {
logger logging.Logger
commander command.Commander
os os.OS
unix unix.Unix
}
func NewConfigurator(logger logging.Logger, os os.OS, unix unix.Unix) Configurator {
return &configurator{
logger: logger.WithPrefix("openvpn configurator: "),
commander: command.NewCommander(),
os: os,
unix: unix,
}
}