1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
| package domainsocket
|
| import (
| "github.com/v2fly/v2ray-core/v5/common"
| "github.com/v2fly/v2ray-core/v5/common/net"
| "github.com/v2fly/v2ray-core/v5/transport/internet"
| )
|
| const (
| protocolName = "domainsocket"
| 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)
| }))
| }
|
|