2021-02-06 16:26:23 +00:00
|
|
|
// Package openvpn defines interfaces to interact with openvpn
|
|
|
|
|
// and run it in a stateful loop.
|
2020-02-06 20:42:46 -05:00
|
|
|
package openvpn
|
|
|
|
|
|
|
|
|
|
import (
|
2020-04-19 18:13:48 +00:00
|
|
|
"context"
|
2020-02-06 20:42:46 -05:00
|
|
|
|
2020-12-29 01:02:47 +00:00
|
|
|
"github.com/qdm12/gluetun/internal/unix"
|
2020-02-06 20:42:46 -05:00
|
|
|
"github.com/qdm12/golibs/command"
|
|
|
|
|
"github.com/qdm12/golibs/logging"
|
2021-01-02 01:57:00 +00:00
|
|
|
"github.com/qdm12/golibs/os"
|
2020-02-06 20:42:46 -05:00
|
|
|
)
|
|
|
|
|
|
|
|
|
|
type Configurator interface {
|
2021-05-31 18:54:36 +00:00
|
|
|
Version24(ctx context.Context) (version string, err error)
|
|
|
|
|
Version25(ctx context.Context) (version string, err error)
|
2020-12-29 16:44:35 +00:00
|
|
|
WriteAuthFile(user, password string, puid, pgid int) error
|
2020-02-06 20:42:46 -05:00
|
|
|
CheckTUN() error
|
2020-02-08 15:30:28 +00:00
|
|
|
CreateTUN() error
|
2021-07-19 15:10:53 +00:00
|
|
|
Start(ctx context.Context, version string, flags []string) (
|
2021-05-31 18:54:36 +00:00
|
|
|
stdoutLines, stderrLines chan string, waitError chan error, err error)
|
2020-02-06 20:42:46 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
type configurator struct {
|
2020-12-29 00:55:31 +00:00
|
|
|
logger logging.Logger
|
|
|
|
|
commander command.Commander
|
|
|
|
|
os os.OS
|
2020-12-29 01:02:47 +00:00
|
|
|
unix unix.Unix
|
2020-02-06 20:42:46 -05:00
|
|
|
}
|
|
|
|
|
|
2020-12-29 01:02:47 +00:00
|
|
|
func NewConfigurator(logger logging.Logger, os os.OS, unix unix.Unix) Configurator {
|
2020-02-06 20:42:46 -05:00
|
|
|
return &configurator{
|
2021-05-12 22:57:15 +00:00
|
|
|
logger: logger,
|
2020-12-29 00:55:31 +00:00
|
|
|
commander: command.NewCommander(),
|
|
|
|
|
os: os,
|
2020-12-29 01:02:47 +00:00
|
|
|
unix: unix,
|
2020-02-06 20:42:46 -05:00
|
|
|
}
|
|
|
|
|
}
|