OpenGFW is a flexible, easy-to-use, open source implementation of GFW on Linux OpenGFW 是 GFW 在 Linux 上的灵活、易于使用的开源实现
Go to file
2024-01-27 13:58:35 -08:00
.github/workflows ci: add release workflow action 2024-01-20 10:42:14 -08:00
analyzer refactor: merge sock4 and socks5 into one 2024-01-27 20:45:11 +08:00
cmd refactor: merge sock4 and socks5 into one 2024-01-27 20:45:11 +08:00
docs chore: minor doc fix 2024-01-27 13:40:29 -08:00
engine fix: incorrect prop update logic 2024-01-21 12:26:23 -08:00
io fix: remove "reject with tcp reset" for now as it doesn't work properly 2024-01-27 13:27:27 -08:00
modifier first 2024-01-19 16:45:01 -08:00
ruleset first 2024-01-19 16:45:01 -08:00
.gitignore first 2024-01-19 16:45:01 -08:00
go.mod first 2024-01-19 16:45:01 -08:00
go.sum first 2024-01-19 16:45:01 -08:00
LICENSE first 2024-01-19 16:45:01 -08:00
main.go first 2024-01-19 16:45:01 -08:00
README.ja.md docs: add socks4 2024-01-27 13:58:35 -08:00
README.md docs: add socks4 2024-01-27 13:58:35 -08:00
README.zh.md docs: add socks4 2024-01-27 13:58:35 -08:00

OpenGFW

License

中文文档 日本語ドキュメント

OpenGFW is a flexible, easy-to-use, open source implementation of GFW on Linux that's in many ways more powerful than the real thing. It's cyber sovereignty you can have on a home router.

Caution

This project is still in very early stages of development. Use at your own risk.

Note

We are looking for contributors to help us with this project, especially implementing analyzers for more protocols!!!

Features

  • Full IP/TCP reassembly, various protocol analyzers
  • Full IPv4 and IPv6 support
  • Flow-based multicore load balancing
  • Connection offloading
  • Powerful rule engine based on expr
  • Flexible analyzer & modifier framework
  • Extensible IO implementation (only NFQueue for now)
  • [WIP] Web UI

Use cases

  • Ad blocking
  • Parental control
  • Malware protection
  • Abuse prevention for VPN/proxy services
  • Traffic analysis (log only mode)

Usage

Build

go build

Run

export OPENGFW_LOG_LEVEL=debug
./OpenGFW -c config.yaml rules.yaml

Example config

io:
  queueSize: 1024
  local: true # set to false if you want to run OpenGFW on FORWARD chain

workers:
  count: 4
  queueSize: 16
  tcpMaxBufferedPagesTotal: 4096
  tcpMaxBufferedPagesPerConn: 64
  udpMaxStreams: 4096

Example rules

Analyzer properties

For syntax of the expression language, please refer to Expr Language Definition.

- name: block v2ex http
  action: block
  expr: string(http?.req?.headers?.host) endsWith "v2ex.com"

- name: block v2ex https
  action: block
  expr: string(tls?.req?.sni) endsWith "v2ex.com"

- name: block shadowsocks
  action: block
  expr: fet != nil && fet.yes

- name: block trojan
  action: block
  expr: trojan != nil && trojan.yes

- name: v2ex dns poisoning
  action: modify
  modifier:
    name: dns
    args:
      a: "0.0.0.0"
      aaaa: "::"
  expr: dns != nil && dns.qr && any(dns.questions, {.name endsWith "v2ex.com"})

- name: block google socks
  action: block
  expr: string(socks?.req?.addr) endsWith "google.com" && socks?.req?.port == 80

Supported actions

  • allow: Allow the connection, no further processing.
  • block: Block the connection, no further processing.
  • drop: For UDP, drop the packet that triggered the rule, continue processing future packets in the same flow. For TCP, same as block.
  • modify: For UDP, modify the packet that triggered the rule using the given modifier, continue processing future packets in the same flow. For TCP, same as allow.