mirror of https://github.com/portainer/portainer
fix(api): fix invalid platform build statements (#2064)
parent
f62b40dc3f
commit
b1227b17e1
|
@ -0,0 +1,11 @@
|
|||
// +build !windows
|
||||
|
||||
package websocket
|
||||
|
||||
import (
|
||||
"net"
|
||||
)
|
||||
|
||||
func createDial(scheme, host string) (net.Conn, error) {
|
||||
return net.Dial(scheme, host)
|
||||
}
|
|
@ -0,0 +1,16 @@
|
|||
// +build windows
|
||||
|
||||
package websocket
|
||||
|
||||
import (
|
||||
"net"
|
||||
|
||||
"github.com/Microsoft/go-winio"
|
||||
)
|
||||
|
||||
func createDial(scheme, host string) (net.Conn, error) {
|
||||
if scheme == "npipe" {
|
||||
return winio.DialPipe(host, nil)
|
||||
}
|
||||
return net.Dial(scheme, host)
|
||||
}
|
|
@ -127,7 +127,7 @@ func (handler *Handler) proxyWebsocketRequest(w http.ResponseWriter, r *http.Req
|
|||
}
|
||||
|
||||
func hijackExecStartOperation(websocketConn *websocket.Conn, endpoint *portainer.Endpoint, execID string) error {
|
||||
dial, err := createDial(endpoint)
|
||||
dial, err := initDial(endpoint)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
@ -158,7 +158,7 @@ func hijackExecStartOperation(websocketConn *websocket.Conn, endpoint *portainer
|
|||
return nil
|
||||
}
|
||||
|
||||
func createDial(endpoint *portainer.Endpoint) (net.Conn, error) {
|
||||
func initDial(endpoint *portainer.Endpoint) (net.Conn, error) {
|
||||
url, err := url.Parse(endpoint.URL)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
@ -170,26 +170,16 @@ func createDial(endpoint *portainer.Endpoint) (net.Conn, error) {
|
|||
host = url.Path
|
||||
}
|
||||
|
||||
var (
|
||||
dial net.Conn
|
||||
dialErr error
|
||||
)
|
||||
|
||||
if endpoint.TLSConfig.TLS {
|
||||
tlsConfig, err := crypto.CreateTLSConfigurationFromDisk(endpoint.TLSConfig.TLSCACertPath, endpoint.TLSConfig.TLSCertPath, endpoint.TLSConfig.TLSKeyPath, endpoint.TLSConfig.TLSSkipVerify)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
dial, dialErr = tls.Dial(url.Scheme, host, tlsConfig)
|
||||
} else {
|
||||
if url.Scheme == "npipe" {
|
||||
dial, dialErr = createWinDial(host)
|
||||
} else {
|
||||
dial, dialErr = net.Dial(url.Scheme, host)
|
||||
}
|
||||
|
||||
return tls.Dial(url.Scheme, host, tlsConfig)
|
||||
}
|
||||
|
||||
return dial, dialErr
|
||||
return createDial(url.Scheme, host)
|
||||
}
|
||||
|
||||
func createExecStartRequest(execID string) (*http.Request, error) {
|
||||
|
|
|
@ -1,11 +0,0 @@
|
|||
// +build linux
|
||||
|
||||
package websocket
|
||||
|
||||
import (
|
||||
"net"
|
||||
)
|
||||
|
||||
func createWinDial(host string) (net.Conn, error) {
|
||||
return nil, nil
|
||||
}
|
|
@ -1,13 +0,0 @@
|
|||
// +build windows
|
||||
|
||||
package websocket
|
||||
|
||||
import (
|
||||
"net"
|
||||
|
||||
"github.com/Microsoft/go-winio"
|
||||
)
|
||||
|
||||
func createWinDial(host string) (net.Conn, error) {
|
||||
return winio.DialPipe(host, nil)
|
||||
}
|
|
@ -1,4 +1,4 @@
|
|||
// +build linux
|
||||
// +build !windows
|
||||
|
||||
package proxy
|
||||
|
||||
|
|
Loading…
Reference in New Issue