forked from cloudfoundry/bosh-cli
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ssh_tunnel_factory.go
50 lines (41 loc) · 969 Bytes
/
ssh_tunnel_factory.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
package sshtunnel
import (
"time"
boshlog "github.com/cloudfoundry/bosh-utils/logger"
"github.com/pivotal-golang/clock"
)
type Options struct {
Host string
Port int
User string
PrivateKey string
Password string
LocalForwardPort int
RemoteForwardPort int
}
func (o Options) IsEmpty() bool {
return o == Options{}
}
type Factory interface {
NewSSHTunnel(Options) SSHTunnel
}
type factory struct {
logger boshlog.Logger
}
func NewFactory(logger boshlog.Logger) Factory {
return &factory{
logger: logger,
}
}
func (s *factory) NewSSHTunnel(options Options) SSHTunnel {
timeService := clock.NewClock()
return &sshTunnel{
connectionRefusedTimeout: 5 * time.Minute,
authFailureTimeout: 2 * time.Minute,
startDialDelay: 500 * time.Millisecond,
timeService: timeService,
options: options,
logger: s.logger,
logTag: "sshTunnel",
}
}