|
|
@@ -2,7 +2,9 @@ package conf
|
|
|
|
|
|
import (
|
|
|
"encoding/json"
|
|
|
+ "runtime"
|
|
|
"strconv"
|
|
|
+ "syscall"
|
|
|
|
|
|
"github.com/golang/protobuf/proto" // nolint: staticcheck
|
|
|
|
|
|
@@ -147,6 +149,11 @@ func (c *TrojanServerConfig) Build() (proto.Message, error) {
|
|
|
switch fb.Dest[0] {
|
|
|
case '@', '/':
|
|
|
fb.Type = "unix"
|
|
|
+ if fb.Dest[0] == '@' && len(fb.Dest) > 1 && fb.Dest[1] == '@' && runtime.GOOS == "linux" {
|
|
|
+ fullAddr := make([]byte, len(syscall.RawSockaddrUnix{}.Path)) // may need padding to work in front of haproxy
|
|
|
+ copy(fullAddr, fb.Dest[1:])
|
|
|
+ fb.Dest = string(fullAddr)
|
|
|
+ }
|
|
|
default:
|
|
|
if _, err := strconv.Atoi(fb.Dest); err == nil {
|
|
|
fb.Dest = "127.0.0.1:" + fb.Dest
|