Skip to content

Releases: txthinking/tun2brook

v20240607

10 May 10:03
ad0f90f
Compare
Choose a tag to compare

v20240606

24 Mar 13:18
ad0f90f
Compare
Choose a tag to compare

v20240404

06 Mar 06:31
ad0f90f
Compare
Choose a tag to compare

support fragment

v20240214

01 Feb 08:07
1956298
Compare
Choose a tag to compare

bugfix

v20240102

29 Dec 06:02
1956298
Compare
Choose a tag to compare
  • 修复: 未自动 bypass bypassDNS IP
  • New: auto bypass brooklinks IP from script

v20240101

16 Dec 08:45
1956298
Compare
Choose a tag to compare

tun2brook v20240101: see which application is creating TCP and UDP network connections

Release Note

  • Optimization: When exiting tun2brook, automatically restore the system DNS to its original state.
  • New: See which program is creating TCP and UDP network connections.
  • New: It also means that it is possible to use scripts to perform network control for specific applications.
  • Tip: macOS, in Brook GUI and Shiliew App mode, appid is application bundle id

Install via nami

nami install tun2brook

FUCK Windows Defender

Usage

run tun2brook

sudo tun2brook -l 'brook://...' --log /tmp/a.log

Windows open terminal as admin, and remove sudo

follow log

tail -f /tmp/a.log

create TCP connection

curl --http2 https://http3.ooo -v
curl --http2 -4 https://http3.ooo -v
curl --http2 -6 https://http3.ooo -v

create UDP connection

curl --http3-only https://http3.ooo -v
curl --http3-only -4 https://http3.ooo -v
curl --http3-only -6 https://http3.ooo -v

If your curl does not support HTTP3, see here

Linux, macOS log:

{"action":"PROXY","appid":"/Users/fuck/.nami/bin/curl","brooklink":"default","content":"137.184.237.95:443","iface":"","kind":"TCP","time":"2023-12-15T16:24:31+08:00"}
{"action":"PROXY","appid":"/Users/fuck/.nami/bin/curl","brooklink":"default","content":"[2604:a880:4:1d0::4cf:b000]:443","iface":"","kind":"TCP","time":"2023-12-15T16:25:29+08:00"}

{"action":"PROXY","appid":"/Users/fuck/.nami/bin/curl","brooklink":"default","content":"137.184.237.95:443","iface":"","kind":"UDP","time":"2023-12-15T16:21:41+08:00"}
{"action":"PROXY","appid":"/Users/fuck/.nami/bin/curl","brooklink":"default","content":"[2604:a880:4:1d0::4cf:b000]:443","iface":"","kind":"UDP","time":"2023-12-15T16:22:43+08:00"}

You can see /Users/fuck/.nami/bin/curl who is creating TCP and UDP connection

Windows log:

{"action":"PROXY","appid":"C:\\Users\\cloud\\.nami\\bin\\curl.exe","brooklink":"default","content":"137.184.237.95:443","iface":"","kind":"TCP","time":"2023-12-15T16:24:31+08:00"}
{"action":"PROXY","appid":"C:\\Users\\cloud\\.nami\\bin\\curl.exe","brooklink":"default","content":"[2604:a880:4:1d0::4cf:b000]:443","iface":"","kind":"TCP","time":"2023-12-15T16:25:29+08:00"}

{"action":"PROXY","appid":"C:\\Users\\cloud\\.nami\\bin\\curl.exe","brooklink":"default","content":"137.184.237.95:443","iface":"","kind":"UDP","time":"2023-12-15T16:21:41+08:00"}
{"action":"PROXY","appid":"C:\\Users\\cloud\\.nami\\bin\\curl.exe","brooklink":"default","content":"[2604:a880:4:1d0::4cf:b000]:443","iface":"","kind":"UDP","time":"2023-12-15T16:22:43+08:00"}

You can see C:\\Users\\cloud\\.nami\\bin\\curl.exe who is creating TCP and UDP connection

With FakeDNS

run tun2brook

sudo tun2brook -l 'brook://...' --log /tmp/a.log --fakeDNS --script ./a.tengo

Windows open terminal as admin, and remove sudo

a.tengo(click to show)
    text := import("text")
    
    dnsquery_handler := func(m){
      if m.domain == "dns.google" {
          return {block: true}
      }
    }
    
    address_handler := func(m) {
      if m.ipaddress {
          if m.ipaddress == "8.8.8.8:853" || m.ipaddress == "8.8.8.8:443" || m.ipaddress == "8.8.4.4:853" || m.ipaddress == "8.8.4.4:443" || m.ipaddress == "[2001:4860:4860::8888]:853" || m.ipaddress == "[2001:4860:4860::8888]:443" || m.ipaddress == "[2001:4860:4860::8844]:853" || m.ipaddress == "[2001:4860:4860::8844]:443" {
              return { block: true }
          }
      }
      if m.domainaddress {
          if text.has_prefix(m.domainaddress, "dns.google:") {
              return { block: true }
          }
      }
    }
    
    handler := func(){
      if in_dnsquery {
          return dnsquery_handler(in_dnsquery)
      }
      if in_address {
          return address_handler(in_address)
      }
    }
    
    out := handler()

create TCP connection

curl --http2 https://http3.ooo -v

create UDP connection

curl --http3-only https://http3.ooo -v

Linux, macOS log:

{"action":"PROXY","appid":"/Users/fuck/.nami/bin/curl","brooklink":"default","content":"http3.ooo:443","iface":"","kind":"TCP","time":"2023-12-15T16:33:58+08:00"}

{"action":"PROXY","appid":"/Users/fuck/.nami/bin/curl","brooklink":"default","content":"http3.ooo:443","iface":"","kind":"UDP","time":"2023-12-15T16:34:39+08:00"}

Compared to before, you can see TCP and UDP domain address http3.ooo:443

Windows log:

{"action":"PROXY","appid":"C:\\Users\\cloud\\.nami\\bin\\curl.exe","brooklink":"default","content":"http3.ooo:443","iface":"","kind":"TCP","time":"2023-12-15T16:33:58+08:00"}

{"action":"PROXY","appid":"C:\\Users\\cloud\\.nami\\bin\\curl.exe","brooklink":"default","content":"http3.ooo:443","iface":"","kind":"UDP","time":"2023-12-15T16:34:39+08:00"}

Compared to before, you can see TCP and UDP domain address http3.ooo:443


Discuss

v20230805

05 Aug 03:48
1956298
Compare
Choose a tag to compare

Pragrammable

  • in_dnsquery.appid works on Linux
  • in_address.appid works on Linux

Bugfix

v20230607

07 Jun 04:50
1956298
Compare
Choose a tag to compare
  • --defaultInterface4 value Windows Only. Choose your default ipv4 interface, your can get it from $ netsh interface ipv4 show interfaces
  • --defaultInterface6 value Windows Only. Choose your default ipv6 interface, your can get it from $ netsh interface ipv6 show interfaces

v20230606

25 May 03:59
fc212e6
Compare
Choose a tag to compare

多个 server,编程控制选择哪一个

Multiple servers, programmatically control which one to choose

f := func() {
    if in_brooklinks {
        return {a: "brook://...", b: "brook://..."}
    }
    if in_address {
        if in_address.domainaddress {
            if in_address.domainaddress == "example.com:443" {
                return { "brooklinkkey": "a" }
            }
            if in_address.domainaddress == "example2.com:443" {
                return { "brooklinkkey": "b" }
            }
        }
        return
    }
}
out := f()