diff options
| author | Paul Bütow <pbuetow@mimecast.com> | 2020-01-20 18:41:05 +0000 |
|---|---|---|
| committer | Paul Bütow <pbuetow@mimecast.com> | 2020-01-21 14:35:23 +0000 |
| commit | c128865c4c7411c29a59fca9a3a2f95537686d7b (patch) | |
| tree | 193bccc70d942c8b70cc93fae2670263701e43aa /clients/grepclient.go | |
| parent | 3755a9911ecb05886577095f2b8cc8b9e4066a3a (diff) | |
Move commands to cmd/ and move internal dependencies to internal/
Diffstat (limited to 'clients/grepclient.go')
| -rw-r--r-- | clients/grepclient.go | 49 |
1 files changed, 0 insertions, 49 deletions
diff --git a/clients/grepclient.go b/clients/grepclient.go deleted file mode 100644 index dbae96c..0000000 --- a/clients/grepclient.go +++ /dev/null @@ -1,49 +0,0 @@ -package clients - -import ( - "dtail/clients/handlers" - "dtail/clients/remote" - "dtail/ssh/client" - "errors" - "fmt" - "strings" - - gossh "golang.org/x/crypto/ssh" -) - -// GrepClient searches a remote file for all lines matching a regular expression. Only the matching lines are displayed. -type GrepClient struct { - baseClient -} - -// NewGrepClient creates a new grep client. -func NewGrepClient(args Args) (*GrepClient, error) { - if args.Regex == "" { - return nil, errors.New("No regex specified, use '-regex' flag") - } - - c := GrepClient{ - baseClient: baseClient{ - Args: args, - stop: make(chan struct{}), - stopped: make(chan struct{}), - throttleCh: make(chan struct{}, args.MaxInitConnections), - retry: false, - }, - } - - c.init(c) - - return &c, nil -} - -func (c GrepClient) makeConnection(server string, sshAuthMethods []gossh.AuthMethod, hostKeyCallback *client.HostKeyCallback) *remote.Connection { - conn := remote.NewConnection(server, c.UserName, sshAuthMethods, hostKeyCallback) - conn.Handler = handlers.NewClientHandler(server, c.PingTimeout) - - for _, file := range strings.Split(c.Files, ",") { - conn.Commands = append(conn.Commands, fmt.Sprintf("%s %s regex %s", c.Mode.String(), file, c.Regex)) - } - - return conn -} |
