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:
41
internal/openvpn/run.go
Normal file
41
internal/openvpn/run.go
Normal 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
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user