func nsProxySocketConnect(fd uintptr, proto ProtoType, rAddr string) (net.Conn, error) { origNs, _ := ns.OpenProcess(os.Getpid(), ns.CLONE_NEWNET) defer ns.Close(origNs) defer ns.Set(origNs, ns.CLONE_NEWNET) err := ns.Set(uintptr(fd), ns.CLONE_NEWNET) if err != nil { return nil, err } return net.Dial(string(proto), rAddr) }
func nsSocketListener(fd uintptr, proto ProtoType, lAddr string) (net.Listener, error) { origNs, _ := ns.OpenProcess(os.Getpid(), ns.CLONE_NEWNET) defer ns.Close(origNs) defer ns.Set(origNs, ns.CLONE_NEWNET) err := ns.Set(uintptr(fd), ns.CLONE_NEWNET) if err != nil { return nil, err } return net.Listen(string(proto), lAddr) }