37 Star 407 Fork 74

GVPrancher/rancher

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
tls_dialer.go 962 Bytes
一键复制 编辑 原始数据 按行查看 历史
Darren Shepherd 提交于 2018-02-20 12:54 . Add HA support and cluster import
package dialer
import (
"crypto/tls"
"errors"
"net"
"strings"
"github.com/rancher/rancher/pkg/nodeconfig"
"github.com/rancher/types/apis/management.cattle.io/v3"
"github.com/rancher/types/config/dialer"
)
func (f *Factory) tlsDialer(machine *v3.Node) (dialer.Dialer, error) {
config, err := nodeconfig.NewNodeConfig(f.store, machine)
if err != nil {
return nil, err
}
tlsConfig, err := config.TLSConfig()
if err != nil {
return nil, err
}
realTLSConfig, err := tlsConfig.ToConfig()
if err != nil {
return nil, err
}
d := &tlsDialer{
Config: realTLSConfig,
Address: tlsConfig.Address,
}
return d.Dial, nil
}
type tlsDialer struct {
Config *tls.Config
Address string
}
func (t *tlsDialer) Dial(network, address string) (net.Conn, error) {
if !strings.Contains(address, "docker.sock") {
return nil, errors.New("only docker.sock connections are supported for this node")
}
return tls.Dial("tcp", t.Address, t.Config)
}
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Go
1
https://gitee.com/rancher/rancher.git
git@gitee.com:rancher/rancher.git
rancher
rancher
rancher
v2.1.7-rc3

搜索帮助