1
0
mirror of https://github.com/v2fly/v2ray-core.git synced 2024-06-28 02:05:23 +00:00
v2fly/transport/internet/domainsocket/config.go

32 lines
587 B
Go
Raw Normal View History

2019-02-01 19:08:21 +00:00
// +build !confonly
2018-04-09 15:09:24 +00:00
package domainsocket
2018-04-09 18:45:23 +00:00
import (
"v2ray.com/core/common"
"v2ray.com/core/common/net"
"v2ray.com/core/transport/internet"
)
2018-04-09 15:09:24 +00:00
2018-08-06 11:48:35 +00:00
const protocolName = "domainsocket"
2018-04-09 15:09:24 +00: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 18:45:23 +00:00
func init() {
2019-01-06 19:33:58 +00:00
common.Must(internet.RegisterProtocolConfigCreator(protocolName, func() interface{} {
2018-04-09 18:45:23 +00:00
return new(Config)
}))
}