Skip to content

Handle UNIX network connections in Process method#5693

Open
smaznet wants to merge 3 commits intoXTLS:mainfrom
smaznet:patch-1
Open

Handle UNIX network connections in Process method#5693
smaznet wants to merge 3 commits intoXTLS:mainfrom
smaznet:patch-1

Conversation

@smaznet
Copy link

@smaznet smaznet commented Feb 14, 2026

Forward connections from UNIX to TCP network type.

Added support listening on unix socket for dokodemo and forwarding to TCP endpoint

  {
      "listen": "@test.socket",
      "port": 10085,
      "protocol": "dokodemo-door",
      "settings": {
        "address": "127.0.0.1",
        "network": "unix",
        "port": 8000
      },
      "tag": "test"
    }

creates a unix listener and forwards incoming request to that unix to tcp addr

   $ curl --abstract-unix-socket test.socket 127.0.0.1
<!DOCTYPE HTML>
<html lang="en">

Forward connections from UNIX to TCP network type.
@Fangliding
Copy link
Member

?

@Fangliding Fangliding closed this Feb 14, 2026
@smaznet
Copy link
Author

smaznet commented Feb 14, 2026

Why?

@Fangliding
Copy link
Member

Fangliding commented Feb 14, 2026

Sorry, I remembered sth incorrectly

@Fangliding Fangliding reopened this Feb 14, 2026
@RPRX
Copy link
Member

RPRX commented Feb 21, 2026

"network": "unix",

配置示例里这个?

@smaznet
Copy link
Author

smaznet commented Feb 21, 2026

yes

@smaznet
Copy link
Author

smaznet commented Feb 21, 2026

actually it listens on unix on client but sends to that tcp address better to rename it unix-tcp but this works for now

@RPRX
Copy link
Member

RPRX commented Feb 21, 2026

哦哦 address 和 port 是 target,然而这个 network 是 listen 的 network,感觉需要一些 rename 不然有点混乱

另外这个 network 应该放外面然后改成 "udp": "enabled"/"only" 才对,而不是根据 settings/streamSettings 来自动判断?

@Fangliding
Copy link
Member

Fangliding commented Feb 21, 2026

这一改现有配置又要大炸特炸了 这个需求很小众我觉得这个PR这么改几行就行了
还是core里一些部分把uds封装进TCP逻辑了一部分没有的锅

@smaznet
Copy link
Author

smaznet commented Feb 21, 2026

in previous versions we also can have unix as network and nothing changed i just changed logic to forward to tcp instead of unix as target

append unix as dokodemo network
@smaznet
Copy link
Author

smaznet commented Feb 21, 2026

now this works no need to configure network as unix

    {
      "listen": "@test.socket",
      "port": 10085,
      "protocol": "dokodemo-door",
      "settings": {
        "address": "127.0.0.1",
        "network": "tcp",
        "port": 8000
      },
      "tag": "test"
    }

logs:

app/proxyman/inbound: creating unix domain socket worker on @test.socket

if we change listen to 0.0.0.0 it listens on port

 {
      "listen": "0.0.0.0",
      "port": 10085,
      "protocol": "dokodemo-door",
      "settings": {
        "address": "127.0.0.1",
        "network": "tcp",
        "port": 8000
      },
      "tag": "test"
    }

logs:

app/proxyman/inbound: creating stream worker on 0.0.0.0:10085

@smaznet
Copy link
Author

smaznet commented Feb 21, 2026

in other word if we have network tcp we can set listen as unix address like vless , trojan, vmess

@smaznet
Copy link
Author

smaznet commented Feb 21, 2026

now unix socket works with udp too

{
      "listen": "@test.socket",
      "port": 10085,
      "protocol": "dokodemo-door",
      "settings": {
        "address": "127.0.0.1",
        "network": "udp",
        "port": 8000
      },
      "tag": "test"
    }

@smaznet
Copy link
Author

smaznet commented Feb 21, 2026

Example config for test

{
  "log": {
    "loglevel": "debug"
  },
  "inbounds": [

    {
      "listen": "@test-tcp.socket",
      "port": 10085,
      "protocol": "dokodemo-door",
      "settings": {
        "address": "127.0.0.1",
        "network": "tcp",
        "port": 8000 // forward to block-in for test
      },
      "tag": "test-tcp"
    },
    {
      "listen": "@test.socket",
      "port": 10085,
      "protocol": "dokodemo-door",
      "settings": {
        "address": "127.0.0.1",
        "network": "udp",
        "port": 8000 // forward to block-in for test
      },
      "tag": "test"
    },
    {
      "listen": "127.0.0.1",
      "port": 8000, // simple tcp,udp server on port 8000
      "tag": "block-in", 
      "protocol": "dokodemo-door",
      "settings": {
        "network": "tcp,udp"
      }
    }

  ],
  "outbounds": [
    {
      "tag": "free",
      "protocol": "freedom"
    },
    {
      "tag": "block",
      "protocol": "blackhole",
      "settings": {
        "response": {
          "type": "http"
        }
      }
    }
  ],
  "routing": {
    "rules": [
      {
        "inboundTag": [
          "block-in"
        ],
        "outboundTag": "block",
        "type": "field"
      }
    ],
    "domainStrategy": "AsIs"
  }
}

udp test

$ nc -U @test.socket
GET /

Responses:
HTTP/1.1 403 Forbidden
Connection: close
Cache-Control: max-age=3600, public
Content-Length: 0

tcp test

$ nc -U @test-tcp.socket
HTTP/1.1 403 Forbidden
Connection: close
Cache-Control: max-age=3600, public
Content-Length: 0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants