mirror of
https://github.com/XTLS/Xray-core.git
synced 2026-05-08 14:13:22 +00:00
Tunnel inbound: Compatible with listening UNIX domain socket (#5693)
https://github.com/XTLS/Xray-core/pull/5693#issuecomment-4229947428 --------- Co-authored-by: 风扇滑翔翼 <Fangliding.fshxy@outlook.com>
This commit is contained in:
@@ -2,6 +2,7 @@ package dokodemo
|
||||
|
||||
import (
|
||||
"context"
|
||||
"slices"
|
||||
"strconv"
|
||||
"strings"
|
||||
|
||||
@@ -56,6 +57,9 @@ func (d *DokodemoDoor) Init(config *Config, pm policy.Manager, sockopt *session.
|
||||
|
||||
// Network implements proxy.Inbound.
|
||||
func (d *DokodemoDoor) Network() []net.Network {
|
||||
if slices.Contains(d.config.Networks, net.Network_TCP) {
|
||||
return append(d.config.Networks, net.Network_UNIX)
|
||||
}
|
||||
return d.config.Networks
|
||||
}
|
||||
|
||||
@@ -68,6 +72,10 @@ func (d *DokodemoDoor) policy() policy.Session {
|
||||
// Process implements proxy.Inbound.
|
||||
func (d *DokodemoDoor) Process(ctx context.Context, network net.Network, conn stat.Connection, dispatcher routing.Dispatcher) error {
|
||||
errors.LogDebug(ctx, "processing connection from: ", conn.RemoteAddr())
|
||||
// forward to TCP if from UNIX
|
||||
if network == net.Network_UNIX {
|
||||
network = net.Network_TCP
|
||||
}
|
||||
dest := net.Destination{
|
||||
Network: network,
|
||||
Address: d.address,
|
||||
|
||||
Reference in New Issue
Block a user