Files
gluetun/internal/openvpn/openvpn.go

38 lines
942 B
Go
Raw Normal View History

2021-02-06 16:26:23 +00:00
// Package openvpn defines interfaces to interact with openvpn
// and run it in a stateful loop.
package openvpn
import (
2020-04-19 18:13:48 +00:00
"context"
"github.com/qdm12/gluetun/internal/unix"
"github.com/qdm12/golibs/command"
"github.com/qdm12/golibs/logging"
2021-01-02 01:57:00 +00:00
"github.com/qdm12/golibs/os"
)
type Configurator interface {
2020-04-19 18:13:48 +00:00
Version(ctx context.Context) (string, error)
2020-12-29 16:44:35 +00:00
WriteAuthFile(user, password string, puid, pgid int) error
CheckTUN() error
CreateTUN() error
2021-01-26 04:17:22 +00:00
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.NewChild(logging.SetPrefix("openvpn configurator: ")),
commander: command.NewCommander(),
os: os,
unix: unix,
}
}