k3s/vendor/github.com/rancher/remotedialer/dialer.go
Darren Shepherd 16f7aaab66 Update vendor
2019-05-25 23:44:33 -07:00

29 lines
648 B
Go

package remotedialer
import (
"net"
"time"
)
type Dialer func(network, address string) (net.Conn, error)
func (s *Server) HasSession(clientKey string) bool {
_, err := s.sessions.getDialer(clientKey, 0)
return err == nil
}
func (s *Server) Dial(clientKey string, deadline time.Duration, proto, address string) (net.Conn, error) {
d, err := s.sessions.getDialer(clientKey, deadline)
if err != nil {
return nil, err
}
return d(proto, address)
}
func (s *Server) Dialer(clientKey string, deadline time.Duration) Dialer {
return func(proto, address string) (net.Conn, error) {
return s.Dial(clientKey, deadline, proto, address)
}
}