Skip to content

Build & Run

Build

export CGO_ENABLED=0
go build

Run

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

Where config.yaml is the config file and rules.yaml is the rules file.

pcap file replay mode

./OpenGFW -p your.pcap -c config.yaml rules.yaml

In pcap mode, none of the actions in the rules have any effect. This mode is mainly for debugging.

OpenWrt

OpenGFW has been tested to work on OpenWrt 23.05 (other versions should also work, just not verified).

Install the dependencies:

opkg install nftables kmod-nft-queue kmod-nf-conntrack-netlink

Config example

io:
  queueSize: 1024
  queueNum: 100 
  table: opengfw 
  connMarkAccept: 1001 
  connMarkDrop: 1002 
  rcvBuf: 4194304
  sndBuf: 4194304
  local: true 
  rst: false 

workers:
  count: 4 
  queueSize: 64
  tcpMaxBufferedPagesTotal: 65536
  tcpMaxBufferedPagesPerConn: 16
  tcpTimeout: 10m 
  udpMaxStreams: 4096

# The path to load specific local geoip/geosite db files.
# If not set, they will be automatically downloaded from https://github.com/Loyalsoldier/v2ray-rules-dat
# ruleset:
#   geoip: geoip.dat
#   geosite: geosite.dat

replay:
  realtime: false