mirror of
https://github.com/portainer/portainer.git
synced 2025-07-24 15:59:41 +02:00
feat(api): Add npipe support (#2018)
This commit is contained in:
parent
0368c4e937
commit
4129550d44
17 changed files with 133 additions and 43 deletions
|
@ -164,22 +164,32 @@ func createDial(endpoint *portainer.Endpoint) (net.Conn, error) {
|
|||
return nil, err
|
||||
}
|
||||
|
||||
var host string
|
||||
if url.Scheme == "tcp" {
|
||||
host = url.Host
|
||||
} else if url.Scheme == "unix" {
|
||||
host := url.Host
|
||||
|
||||
if url.Scheme == "unix" || url.Scheme == "npipe" {
|
||||
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
|
||||
}
|
||||
return tls.Dial(url.Scheme, host, tlsConfig)
|
||||
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 net.Dial(url.Scheme, host)
|
||||
return dial, dialErr
|
||||
}
|
||||
|
||||
func createExecStartRequest(execID string) (*http.Request, error) {
|
||||
|
|
11
api/http/handler/websocket/websocket_exec_linux.go
Normal file
11
api/http/handler/websocket/websocket_exec_linux.go
Normal file
|
@ -0,0 +1,11 @@
|
|||
// +build linux
|
||||
|
||||
package websocket
|
||||
|
||||
import (
|
||||
"net"
|
||||
)
|
||||
|
||||
func createWinDial(host string) (net.Conn, error) {
|
||||
return nil, nil
|
||||
}
|
13
api/http/handler/websocket/websocket_exec_windows.go
Normal file
13
api/http/handler/websocket/websocket_exec_windows.go
Normal file
|
@ -0,0 +1,13 @@
|
|||
// +build windows
|
||||
|
||||
package websocket
|
||||
|
||||
import (
|
||||
"net"
|
||||
|
||||
"github.com/Microsoft/go-winio"
|
||||
)
|
||||
|
||||
func createWinDial(host string) (net.Conn, error) {
|
||||
return winio.DialPipe(host, nil)
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue