mirror of
https://github.com/v2fly/v2ray-core.git
synced 2024-10-19 02:03:38 -04:00
23 lines
462 B
Go
23 lines
462 B
Go
//go:build unix
|
|
// +build unix
|
|
|
|
package internet
|
|
|
|
import (
|
|
"os"
|
|
"strconv"
|
|
"syscall"
|
|
|
|
"github.com/v2fly/v2ray-core/v5/common/net"
|
|
)
|
|
|
|
func activate_socket(address string) (net.Listener, error) {
|
|
fd, err := strconv.Atoi(address[8:])
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
// Ignore the fail of SetNonblock: it's merely an optimization so that Go can poll this fd.
|
|
_ = syscall.SetNonblock(fd, true)
|
|
return net.FileListener(os.NewFile(uintptr(fd), address))
|
|
}
|