Maint: move Openvpn package files

- Move internal/openvpn/config/*.go to internal/openvpn/
- Move internal/openvpn/setup.go to internal/vpn/openvpn.go
This commit is contained in:
Quentin McGaw (desktop)
2021-08-19 13:31:12 +00:00
parent d4ca5cf257
commit 105d81c018
13 changed files with 20 additions and 21 deletions

41
internal/openvpn/run.go Normal file
View File

@@ -0,0 +1,41 @@
package openvpn
import (
"context"
"github.com/qdm12/gluetun/internal/configuration"
"github.com/qdm12/golibs/logging"
)
type Runner interface {
Run(ctx context.Context, errCh chan<- error, ready chan<- struct{},
logger logging.Logger, settings configuration.OpenVPN)
}
func (c *Configurator) Run(ctx context.Context, errCh chan<- error,
ready chan<- struct{}, logger logging.Logger, settings configuration.OpenVPN) {
stdoutLines, stderrLines, waitError, err := c.start(ctx, settings.Version, settings.Flags)
if err != nil {
errCh <- err
return
}
streamCtx, streamCancel := context.WithCancel(context.Background())
streamDone := make(chan struct{})
go streamLines(streamCtx, streamDone, logger,
stdoutLines, stderrLines, ready)
select {
case <-ctx.Done():
<-waitError
close(waitError)
streamCancel()
<-streamDone
errCh <- ctx.Err()
case err := <-waitError:
close(waitError)
streamCancel()
<-streamDone
errCh <- err
}
}