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 {
|
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
|
2020-02-06 20:42:46 -05:00
|
|
|
CheckTUN() error
|
2020-02-08 15:30:28 +00:00
|
|
|
CreateTUN() error
|
2021-01-26 04:17:22 +00:00
|
|
|
Start(ctx context.Context) (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{
|
2020-12-29 00:55:31 +00:00
|
|
|
logger: logger.WithPrefix("openvpn configurator: "),
|
|
|
|
|
commander: command.NewCommander(),
|
|
|
|
|
os: os,
|
2020-12-29 01:02:47 +00:00
|
|
|
unix: unix,
|
2020-02-06 20:42:46 -05:00
|
|
|
}
|
|
|
|
|
}
|