github.com/pwn-term/docker@v0.0.0-20210616085119-6e977cce2565/libnetwork/portmapper/proxy_linux.go (about) 1 package portmapper 2 3 import ( 4 "net" 5 "os/exec" 6 "strconv" 7 "syscall" 8 ) 9 10 func newProxyCommand(proto string, hostIP net.IP, hostPort int, containerIP net.IP, containerPort int, proxyPath string) (userlandProxy, error) { 11 path := proxyPath 12 if proxyPath == "" { 13 cmd, err := exec.LookPath(userlandProxyCommandName) 14 if err != nil { 15 return nil, err 16 } 17 path = cmd 18 } 19 20 args := []string{ 21 path, 22 "-proto", proto, 23 "-host-ip", hostIP.String(), 24 "-host-port", strconv.Itoa(hostPort), 25 "-container-ip", containerIP.String(), 26 "-container-port", strconv.Itoa(containerPort), 27 } 28 29 return &proxyCommand{ 30 cmd: &exec.Cmd{ 31 Path: path, 32 Args: args, 33 SysProcAttr: &syscall.SysProcAttr{ 34 Pdeathsig: syscall.SIGTERM, // send a sigterm to the proxy if the daemon process dies 35 }, 36 }, 37 }, nil 38 }