Files
gluetun/internal/openvpn/command.go

29 lines
796 B
Go
Raw Normal View History

package openvpn
import (
2020-04-19 18:13:48 +00:00
"context"
"fmt"
"strings"
2020-07-26 12:07:06 +00:00
"github.com/qdm12/gluetun/internal/constants"
)
2021-01-26 04:17:22 +00:00
func (c *configurator) Start(ctx context.Context) (stdoutLines, stderrLines chan string, waitError chan error, err error) {
2020-04-12 19:07:19 +00:00
c.logger.Info("starting openvpn")
2021-01-26 04:17:22 +00:00
return c.commander.Start(ctx, "openvpn", "--config", string(constants.OpenVPNConf))
}
2020-04-19 18:13:48 +00:00
func (c *configurator) Version(ctx context.Context) (string, error) {
output, err := c.commander.Run(ctx, "openvpn", "--version")
if err != nil && err.Error() != "exit status 1" {
return "", err
}
firstLine := strings.Split(output, "\n")[0]
words := strings.Fields(firstLine)
2020-10-20 02:45:28 +00:00
const minWords = 2
if len(words) < minWords {
return "", fmt.Errorf("openvpn --version: first line is too short: %q", firstLine)
}
return words[1], nil
}