mirror of
https://github.com/k3s-io/k3s.git
synced 2024-06-07 19:41:36 +00:00
29 lines
648 B
Go
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)
|
|
}
|
|
}
|