You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
v2ray-core/transport/internet/domainsocket/config.go

41 lines
763 B

// +build !confonly
package domainsocket
import (
"v2ray.com/core/common"
"v2ray.com/core/common/net"
"v2ray.com/core/transport/internet"
)
const protocolName = "domainsocket"
const sizeofSunPath = 108
func (c *Config) GetUnixAddr() (*net.UnixAddr, error) {
path := c.Path
if path == "" {
return nil, newError("empty domain socket path")
}
if c.Abstract && path[0] != '@' {
path = "@" + path
}
if c.Abstract && c.Padding {
raw := []byte(path)
addr := make([]byte, sizeofSunPath)
for i, c := range raw {
addr[i] = c
}
path = string(addr)
}
return &net.UnixAddr{
Name: path,
Net: "unix",
}, nil
}
func init() {
common.Must(internet.RegisterProtocolConfigCreator(protocolName, func() interface{} {
return new(Config)
}))
}