mirror of
https://github.com/v2fly/v2ray-core.git
synced 2024-12-22 18:17:52 -05:00
30 lines
566 B
Go
30 lines
566 B
Go
package domainsocket
|
|
|
|
import (
|
|
"v2ray.com/core/common"
|
|
"v2ray.com/core/common/net"
|
|
"v2ray.com/core/transport/internet"
|
|
)
|
|
|
|
const protocolName = "domainsocket"
|
|
|
|
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
|
|
}
|
|
|
|
func init() {
|
|
common.Must(internet.RegisterProtocolConfigCreator(protocolName, func() interface{} {
|
|
return new(Config)
|
|
}))
|
|
}
|