1
0
mirror of https://github.com/v2fly/v2ray-core.git synced 2024-11-18 02:16:10 -05:00
v2fly/transport/internet/domainsocket/config.go

30 lines
572 B
Go
Raw Normal View History

2018-04-09 11:09:24 -04:00
package domainsocket
2018-04-09 14:45:23 -04:00
import (
"v2ray.com/core/common"
"v2ray.com/core/common/net"
"v2ray.com/core/transport/internet"
)
2018-04-09 11:09:24 -04:00
2018-08-06 07:48:35 -04:00
const protocolName = "domainsocket"
2018-04-09 11:09:24 -04:00
func (c *Config) GetUnixAddr() (*net.UnixAddr, error) {
path := c.Path
if len(path) == 0 {
return nil, newError("empty domain socket path")
}
if c.Abstract && path[0] != '\x00' {
path = "\x00" + path
}
return &net.UnixAddr{
Name: path,
Net: "unix",
}, nil
}
2018-04-09 14:45:23 -04:00
func init() {
2018-08-06 07:48:35 -04:00
common.Must(internet.RegisterProtocolConfigCreatorByName(protocolName, func() interface{} {
2018-04-09 14:45:23 -04:00
return new(Config)
}))
}