2020-02-06 20:42:46 -05:00
|
|
|
package tinyproxy
|
|
|
|
|
|
|
|
|
|
import (
|
2020-04-19 18:13:48 +00:00
|
|
|
"context"
|
2020-02-06 20:42:46 -05:00
|
|
|
"fmt"
|
|
|
|
|
"io"
|
|
|
|
|
"strings"
|
|
|
|
|
)
|
|
|
|
|
|
2020-04-19 18:13:48 +00:00
|
|
|
func (c *configurator) Start(ctx context.Context) (stdout io.ReadCloser, waitFn func() error, err error) {
|
2020-04-12 19:07:19 +00:00
|
|
|
c.logger.Info("starting tinyproxy server")
|
2020-04-19 18:13:48 +00:00
|
|
|
stdout, _, waitFn, err = c.commander.Start(ctx, "tinyproxy", "-d")
|
2020-02-13 13:23:22 +00:00
|
|
|
return stdout, waitFn, err
|
2020-02-06 20:42:46 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Version obtains the version of the installed Tinyproxy server
|
2020-04-19 18:13:48 +00:00
|
|
|
func (c *configurator) Version(ctx context.Context) (string, error) {
|
|
|
|
|
output, err := c.commander.Run(ctx, "tinyproxy", "-v")
|
2020-02-06 20:42:46 -05:00
|
|
|
if err != nil {
|
|
|
|
|
return "", err
|
|
|
|
|
}
|
|
|
|
|
words := strings.Fields(output)
|
|
|
|
|
if len(words) < 2 {
|
|
|
|
|
return "", fmt.Errorf("tinyproxy -v: output is too short: %q", output)
|
|
|
|
|
}
|
|
|
|
|
return words[1], nil
|
|
|
|
|
}
|