mirror of
https://github.com/XTLS/Xray-core.git
synced 2025-05-07 20:58:40 +00:00
v1.0.0
This commit is contained in:
parent
47d23e9972
commit
c7f7c08ead
711 changed files with 82154 additions and 2 deletions
38
transport/internet/domainsocket/config.go
Normal file
38
transport/internet/domainsocket/config.go
Normal file
|
@ -0,0 +1,38 @@
|
|||
// +build !confonly
|
||||
|
||||
package domainsocket
|
||||
|
||||
import (
|
||||
"github.com/xtls/xray-core/v1/common"
|
||||
"github.com/xtls/xray-core/v1/common/net"
|
||||
"github.com/xtls/xray-core/v1/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)
|
||||
copy(addr, raw)
|
||||
path = string(addr)
|
||||
}
|
||||
return &net.UnixAddr{
|
||||
Name: path,
|
||||
Net: "unix",
|
||||
}, nil
|
||||
}
|
||||
|
||||
func init() {
|
||||
common.Must(internet.RegisterProtocolConfigCreator(protocolName, func() interface{} {
|
||||
return new(Config)
|
||||
}))
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue