Skip to content

Sniffer

Sniffing configuration for router. Empty means no sniffing. Supports TCP and UDP sniffing. The sniffing result can be obtained by router script and exposed as ctx.sniffer.domain and ctx.sniffer.type and ctx.sniffer.version.

Example configuration:

router:
  sniffer:
    tcp:
      - ports: [80]
        protocols: [http]
      - ports: [443]
        protocols: [tls]
    udp:
      - ports: [] # empty ports sniffing any ports
        protocols: [quic]
  src: |
    return function(ctx)
      if ctx.sniffer and ctx.sniffer.domain then
        -- Override the destination with the sniffed domain
          ctx.dst_domain = ctx.sniffer.domain
        end

        local ok, cn = pcall(find_domain, "geosite-db", "cn", ctx.sniffer.domain)
        if ok and cn then return "direct" end
      end
      return "select"
    end

Fields

tcp

  • Type: list of SnifferRule
  • Required: no
  • Default: (type default)

TCP sniffer rules. Empty means no sniffing. Supports HTTP and TLS.

udp

  • Type: list of SnifferRule
  • Required: no
  • Default: (type default)

UDP sniffer rules. Empty means no sniffing. Supports QUIC.

timeout

  • Type: u64
  • Required: no
  • Default: 100

Absolute inspection deadline in milliseconds.

max-bytes

  • Type: usize
  • Required: no
  • Default: 32768

max-concurrent

  • Type: usize
  • Required: no
  • Default: 256

max-buffered-bytes

  • Type: usize
  • Required: no
  • Default: 8 * 1024 * 1024