文件 設定 入站

入站

listeners 欄位可以在一份設定裡同時開多個入站埠,甚至讓 mihomo 本身充當 Shadowsocks/VMess/TUIC 伺服器,功能上等價於分別寫 port/socks-port/mixed-port,但更靈活。

區域網路入站

用於監聽區域網路流量,適用於無加密傳輸的場景:

config.yaml YAML
listeners:
  - name: socks5-in-1
    type: socks
    port: 10808
    # listen: 0.0.0.0        # 預設監聽 0.0.0.0
    # rule: sub-rule-name1   # 預設使用 rules,找不到該 sub-rule 則回退 rules
    # proxy: proxy           # 不為空則該入站流量直接交由指定 proxy 處理
    # udp: false             # 預設 true

  - name: http-in-1
    type: http
    port: 10809
    listen: 0.0.0.0

  - name: mixed-in-1
    type: mixed # HTTP(S) 和 SOCKS 代理混合
    port: 10810
    listen: 0.0.0.0

  - name: redir-in-1
    type: redir
    port: 10811
    listen: 0.0.0.0

  - name: tproxy-in-1
    type: tproxy
    port: 10812
    listen: 0.0.0.0

  - name: tunnel-in-1
    type: tunnel
    port: 10816
    listen: 0.0.0.0
    network: [tcp, udp]
    target: target.com

  - name: tun-in-1
    type: tun
    stack: system # gvisor / lwip
    dns-hijack:
      - 0.0.0.0:53
    inet4-address: # 必須手動設定 IPv4 位址段
      - 198.19.0.1/30
    inet6-address: # 必須手動設定 IPv6 位址段
      - "fdfe:dcba:9877::1/126"

每一項通用支援 rule(指定這個入站預設使用哪個 子規則,找不到則回退主規則)和 proxy(不為空時該入站流量直接交給指定的出站代理/策略組處理,跳過路由規則)。

網際網路入站

讓 mihomo 本身充當加密協議伺服器,別的裝置可以把這台機器當成 Shadowsocks / VMess / TUIC 節點來連:

config.yaml YAML
listeners:
  - name: shadowsocks-in-1
    type: shadowsocks
    port: 10813
    listen: 0.0.0.0
    password: vlmpIPSyHH6f4S8WVPdRIHIlzmB+GIRfoH3aNJ/t9Gg=
    cipher: 2022-blake3-aes-256-gcm

  - name: vmess-in-1
    type: vmess
    port: 10814
    listen: 0.0.0.0
    users:
      - username: 1
        uuid: 9d0cb9d0-964f-4ef6-897d-6c6b3ccf9e68
        alterId: 1

  - name: tuic-in-1
    type: tuic
    port: 10815
    listen: 0.0.0.0
    certificate: ./server.crt
    private-key: ./server.key

協議特有欄位(比如 mixed 的 users/TLS 憑證、TUIC 的 token/users 二選一)請參照對應協議頁面。想在這一層直接接受訂閱連結格式的入站,還可以用 ss-config: ss://... / vmess-config: vmess://... 這種一行式寫法。