SagerNet / SagerNet/sing-box

为 `direct` 提供 `tls` 支持

Open
#2,618 2 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

enhancement
Dominant language
Go
Stars
38.2k
Forks
4.6k
Avg merge
19d 15h
Merged PRs (30d)
1

Description

操作系统

Windows

系统版本

24H2

安装类型

sing-box 原始命令行程序

如果您使用图形客户端程序,请提供该程序版本。

No response

版本

描述

在一些场景下使用基于 tlsdns 服务时这些 dns 请求无法被解密与劫持。如果考虑支持对 direct 提供 tls 并且提供 hijack-dns 增强的话可以提供基于内部 dns 模块的加密 dns 服务。

此外配合适当规则的情况下,此变更可以实现基于 mitm 的广告过滤(规则的精度取决于对 http 探测的支持程度)等需求。

如果可以的话,是否考虑添加更多的 issue 模板以适用于不同类型的反馈。

重现方式
{
  "inbounds": [
    {
      "tag": "inbound",
      "type": "direct",
      "network": "tcp",
      "tls": {}
      // ...
    }
  ],
  "route": {
    "rules": [
      { "action": "sniff" },
      { "action": "hijack-dns", "protocol": ["http", "dns"], "inbound": "inbound" },
      { "action": "reject", "inbound": "inbound" }
      // ...
    ],
  }
  // ...
}
{
  "inbounds": [
    {
      "type": "tun",
      "tag": "tun"
      // ...
    },
    {
      "tag": "inbound",
      "type": "direct",
      "network": "tcp",
      "listen": "127.0.0.1",
      "listen_port": 8443,
      "override_port": 443,
      "tls": {}
      // ...
    }
  ],
  "outbounds": [
    {
      "tag": "outbound",
      "tls": {}
      // ...
    },
    {
      "tag": "direct",
      "type": "direct"
      // ...
    }
  ],
  "route": {
    "rules": [
      { "action": "sniff" },
      { "outbound": "direct", "protocol": "tls", "port": 443, "override_address": "127.0.0.1", "override_port": 8443 },
      { "action": "reject", "protocol": "http", "inbound": "inbound", "domain": "ad.io", "http-path": "/ad.png" },
      { "action": "resolve", "protocol": "http", "inbound": "inbound" },
      { "action": "reject", "inbound": "inbound", "ip_cidr": "127.0.0.1/32", "port": 443 },
      { "outbound": "outbound", "protocol": "http", "inbound": "inbound" }
      // ...
    ],
  }
}
日志

支持我们
完整性要求
  • 我保证阅读了文档,了解所有我编写的配置文件项的含义,而不是大量堆砌看似有用的选项或默认值。
  • 我保证提供了可以在本地重现该问题的服务器、客户端配置文件与流程,而不是一个脱敏的复杂客户端配置文件。
  • 我保证提供了可用于重现我报告的错误的最简配置,而不是依赖远程服务器、TUN、图形界面客户端或者其他闭源软件。
  • 我保证提供了完整的配置文件与日志,而不是出于对自身智力的自信而仅提供了部分认为有用的部分。

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by tracing the direct inbound configuration and route actions shown in the reproduction, especially sniff, hijack-dns, and TLS handling. Define the required configuration and behavior for TLS-enabled direct traffic and DNS interception, then verify both example scenarios end to end.

Written by the indexing model from the issue text.

Assessment

Tech stack
go
Domain
networking
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.