提交 046cca9a 编写于 作者: M Matt Rickard 提交者: GitHub

Merge pull request #829 from dlorenc/timeout

Add a cert generator with a larger timeout.
......@@ -17,18 +17,50 @@ limitations under the License.
package machine
import (
"crypto/tls"
"os"
"time"
"net"
"github.com/docker/machine/drivers/hyperv"
"github.com/docker/machine/drivers/virtualbox"
"github.com/docker/machine/drivers/vmwarefusion"
"github.com/docker/machine/libmachine/auth"
"github.com/docker/machine/libmachine/cert"
"github.com/docker/machine/libmachine/drivers/plugin"
"github.com/docker/machine/libmachine/drivers/plugin/localbinary"
"github.com/golang/glog"
)
// CertGenerator is used to override the default machine CertGenerator with a longer timeout.
type CertGenerator struct {
cert.X509CertGenerator
}
// ValidateCertificate is a reimplementation of the default generator with a longer timeout.
func (cg *CertGenerator) ValidateCertificate(addr string, authOptions *auth.Options) (bool, error) {
tlsConfig, err := cg.ReadTLSConfig(addr, authOptions)
if err != nil {
return false, err
}
dialer := &net.Dialer{
Timeout: time.Second * 40,
}
_, err = tls.DialWithDialer(dialer, "tcp", addr, tlsConfig)
if err != nil {
return false, err
}
return true, nil
}
// StartDriver starts the desired machine driver if necessary.
func StartDriver() {
cert.SetCertGenerator(&CertGenerator{})
if os.Getenv(localbinary.PluginEnvKey) == localbinary.PluginEnvVal {
driverName := os.Getenv(localbinary.PluginEnvDriverName)
switch driverName {
......@@ -43,5 +75,6 @@ func StartDriver() {
}
return
}
localbinary.CurrentBinaryIsDockerMachine = true
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册