mirror of
https://github.com/linuxkit/linuxkit.git
synced 2025-07-26 04:03:11 +00:00
proxy: listen on vsock before requesting a connection
The 9P operations tell the host to connect to the vsock port in the UDP case, so always listen before sending the 9P request. Signed-off-by: David Scott <dave.scott@docker.com>
This commit is contained in:
parent
caeb0d53cc
commit
e940e12abc
@ -14,17 +14,17 @@ import (
|
|||||||
func main() {
|
func main() {
|
||||||
host, port, container := parseHostContainerAddrs()
|
host, port, container := parseHostContainerAddrs()
|
||||||
|
|
||||||
|
p, err := libproxy.NewProxy(&vsock.VsockAddr{Port: uint(port)}, container)
|
||||||
|
if err != nil {
|
||||||
|
sendError(err)
|
||||||
|
}
|
||||||
ctl, err := exposePort(host, port)
|
ctl, err := exposePort(host, port)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
sendError(err)
|
sendError(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
p, err := libproxy.NewProxy(&vsock.VsockAddr{Port: uint(port)}, container)
|
|
||||||
if err != nil {
|
|
||||||
sendError(err)
|
|
||||||
}
|
|
||||||
|
|
||||||
go handleStopSignals(p)
|
go handleStopSignals(p)
|
||||||
|
// TODO: avoid this line if we are running in a TTY
|
||||||
sendOK()
|
sendOK()
|
||||||
p.Run()
|
p.Run()
|
||||||
ctl.Close() // ensure ctl remains alive and un-GCed until here
|
ctl.Close() // ensure ctl remains alive and un-GCed until here
|
||||||
@ -32,7 +32,7 @@ func main() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func exposePort(host net.Addr, port int) (*os.File, error) {
|
func exposePort(host net.Addr, port int) (*os.File, error) {
|
||||||
name := host.String()
|
name := host.Network() + ":" + host.String()
|
||||||
log.Printf("exposePort %s\n", name)
|
log.Printf("exposePort %s\n", name)
|
||||||
err := os.Mkdir("/port/"+name, 0)
|
err := os.Mkdir("/port/"+name, 0)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
Loading…
Reference in New Issue
Block a user