1
0
mirror of https://github.com/rancher/norman.git synced 2025-08-31 06:35:09 +00:00
Files
norman/pkg/remotedialer/dialer.go
2018-10-23 22:46:45 -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)
}
}