IrineSistiana / mosdns

一个 DNS 转发器
GNU General Public License v3.0
3.01k stars 340 forks source link

[Bug] HTTP服务器监听abstract unix domain socket时不能工作 #830

Open TargetLocked opened 3 months ago

TargetLocked commented 3 months ago

在提交之前,请确认

mosdns 版本

v5.3.1-0-ga281fdb

操作系统

ubuntu 20.04

Bug 描述和复现步骤

复现:

curl -H 'accept: application/dns-message' --abstract-unix-socket 'some_uds' 'http://localhost/dns-query?dns=q80BAAABAAAAAAAAA3d3dwdleGFtcGxlA2NvbQAAAQAB' -vvvs > /dev/null
*   Trying :0...
* Connected to localhost () port 80 (#0)
> GET /dns-query?dns=q80BAAABAAAAAAAAA3d3dwdleGFtcGxlA2NvbQAAAQAB HTTP/1.1
> Host: localhost
> User-Agent: curl/7.68.0
> accept: application/dns-message
> 
* Mark bundle as not supporting multiuse
< HTTP/1.1 500 Internal Server Error
< Date: Thu, 15 Aug 2024 13:22:00 GMT
< Content-Length: 0
< 
* Connection #0 to host localhost left intact

使用的配置文件

log:
    level: info
plugins:
    - args:
        upstreams:
            - addr: 114.114.114.114
      tag: forward
      type: forward
    - args:
        entries:
          - path: /dns-query
            exec: forward
        listen: "@some_uds"
      tag: http_server
      type: http_server

mosdns 的 log 记录

2024-08-15T21:18:35.135+0800    INFO    main config loaded      {"file": "test.yml"}
2024-08-15T21:18:35.135+0800    INFO    loading plugin  {"tag": "forward", "type": "forward"}
2024-08-15T21:18:35.135+0800    INFO    loading plugin  {"tag": "http_server", "type": "http_server"}
2024-08-15T21:18:35.136+0800    INFO    http_server     http server started     {"addr": "@some_uds"}
2024-08-15T21:18:35.136+0800    INFO    all plugins are loaded
2024-08-15T21:21:46.619+0800    ERROR   http_server     failed to parse request remote addr     {"addr": "@", "error": "not an ip:port"}
2024-08-15T21:21:57.276+0800    ERROR   http_server     failed to parse request remote addr     {"addr": "@", "error": "not an ip:port"}
2024-08-15T21:22:00.970+0800    ERROR   http_server     failed to parse request remote addr     {"addr": "@", "error": "not an ip:port"}
2024-08-15T21:23:34.284+0800  WARN    signal received {"signal": "interrupt"}
2024-08-15T21:23:34.284+0800    INFO    starting shutdown sequences
2024-08-15T21:23:34.284+0800    INFO    closing plugin  {"tag": "forward"}
2024-08-15T21:23:34.284+0800    INFO    closing plugin  {"tag": "http_server"}
2024-08-15T21:23:34.284+0800    INFO    all plugins were closed