Compare commits
14 Commits
v0.2.1
...
wip-noenob
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
234ee32687 | ||
|
|
1852a2594d | ||
|
|
bc8d15ef37 | ||
|
|
5d2d874089 | ||
|
|
797dce3dc2 | ||
|
|
420286a46c | ||
|
|
531a7b0ceb | ||
|
|
20e0637756 | ||
|
|
74dcc92fc6 | ||
|
|
b780ff65a4 | ||
|
|
8bd34d7798 | ||
|
|
bed34f94be | ||
|
|
bc2e21e35d | ||
|
|
a0b994ce22 |
8
.github/workflows/release.yaml
vendored
8
.github/workflows/release.yaml
vendored
@@ -1,6 +1,6 @@
|
|||||||
on:
|
on:
|
||||||
release:
|
release:
|
||||||
types: [ created ]
|
types: [published]
|
||||||
|
|
||||||
permissions:
|
permissions:
|
||||||
contents: write
|
contents: write
|
||||||
@@ -12,8 +12,8 @@ jobs:
|
|||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
strategy:
|
strategy:
|
||||||
matrix:
|
matrix:
|
||||||
goos: [ linux ]
|
goos: [linux]
|
||||||
goarch: [ "386", amd64, arm64 ]
|
goarch: ["386", amd64, arm64]
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v4
|
||||||
- uses: wangyoucao577/go-release-action@v1
|
- uses: wangyoucao577/go-release-action@v1
|
||||||
@@ -21,6 +21,6 @@ jobs:
|
|||||||
github_token: ${{ secrets.GITHUB_TOKEN }}
|
github_token: ${{ secrets.GITHUB_TOKEN }}
|
||||||
goos: ${{ matrix.goos }}
|
goos: ${{ matrix.goos }}
|
||||||
goarch: ${{ matrix.goarch }}
|
goarch: ${{ matrix.goarch }}
|
||||||
goversion: "https://go.dev/dl/go1.21.6.linux-amd64.tar.gz"
|
goversion: "https://go.dev/dl/go1.22.0.linux-amd64.tar.gz"
|
||||||
binary_name: "OpenGFW"
|
binary_name: "OpenGFW"
|
||||||
extra_files: LICENSE README.md README.zh.md
|
extra_files: LICENSE README.md README.zh.md
|
||||||
@@ -19,7 +19,7 @@ Telegram グループ: https://t.me/OpGFW
|
|||||||
|
|
||||||
- フル IP/TCP 再アセンブル、各種プロトコルアナライザー
|
- フル IP/TCP 再アセンブル、各種プロトコルアナライザー
|
||||||
- HTTP、TLS、QUIC、DNS、SSH、SOCKS4/5、WireGuard、その他多数
|
- HTTP、TLS、QUIC、DNS、SSH、SOCKS4/5、WireGuard、その他多数
|
||||||
- Shadowsocks の「完全に暗号化されたトラフィック」の検出など (https://gfw.report/publications/usenixsecurity23/data/paper/paper.pdf)
|
- Shadowsocks の「完全に暗号化されたトラフィック」の検出など (https://gfw.report/publications/usenixsecurity23/en/)
|
||||||
- トロイの木馬キラー (https://github.com/XTLS/Trojan-killer) に基づくトロイの木馬 (プロキシプロトコル) 検出
|
- トロイの木馬キラー (https://github.com/XTLS/Trojan-killer) に基づくトロイの木馬 (プロキシプロトコル) 検出
|
||||||
- [WIP] 機械学習に基づくトラフィック分類
|
- [WIP] 機械学習に基づくトラフィック分類
|
||||||
- IPv4 と IPv6 をフルサポート
|
- IPv4 と IPv6 をフルサポート
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ Telegram group: https://t.me/OpGFW
|
|||||||
- Full IP/TCP reassembly, various protocol analyzers
|
- Full IP/TCP reassembly, various protocol analyzers
|
||||||
- HTTP, TLS, QUIC, DNS, SSH, SOCKS4/5, WireGuard, and many more to come
|
- HTTP, TLS, QUIC, DNS, SSH, SOCKS4/5, WireGuard, and many more to come
|
||||||
- "Fully encrypted traffic" detection for Shadowsocks,
|
- "Fully encrypted traffic" detection for Shadowsocks,
|
||||||
etc. (https://gfw.report/publications/usenixsecurity23/data/paper/paper.pdf)
|
etc. (https://gfw.report/publications/usenixsecurity23/en/)
|
||||||
- Trojan (proxy protocol) detection based on Trojan-killer (https://github.com/XTLS/Trojan-killer)
|
- Trojan (proxy protocol) detection based on Trojan-killer (https://github.com/XTLS/Trojan-killer)
|
||||||
- [WIP] Machine learning based traffic classification
|
- [WIP] Machine learning based traffic classification
|
||||||
- Full IPv4 and IPv6 support
|
- Full IPv4 and IPv6 support
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ Telegram 群组: https://t.me/OpGFW
|
|||||||
|
|
||||||
- 完整的 IP/TCP 重组,各种协议解析器
|
- 完整的 IP/TCP 重组,各种协议解析器
|
||||||
- HTTP, TLS, QUIC, DNS, SSH, SOCKS4/5, WireGuard, 更多协议正在开发中
|
- HTTP, TLS, QUIC, DNS, SSH, SOCKS4/5, WireGuard, 更多协议正在开发中
|
||||||
- Shadowsocks 等 "全加密流量" 检测 (https://gfw.report/publications/usenixsecurity23/data/paper/paper.pdf)
|
- Shadowsocks 等 "全加密流量" 检测 (https://gfw.report/publications/usenixsecurity23/zh/)
|
||||||
- 基于 Trojan-killer 的 Trojan 检测 (https://github.com/XTLS/Trojan-killer)
|
- 基于 Trojan-killer 的 Trojan 检测 (https://github.com/XTLS/Trojan-killer)
|
||||||
- [开发中] 基于机器学习的流量分类
|
- [开发中] 基于机器学习的流量分类
|
||||||
- 同等支持 IPv4 和 IPv6
|
- 同等支持 IPv4 和 IPv6
|
||||||
|
|||||||
@@ -143,8 +143,11 @@ func isTLSorHTTP(bytes []byte) bool {
|
|||||||
if len(bytes) < 3 {
|
if len(bytes) < 3 {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
if bytes[0] == 0x16 && bytes[1] == 0x03 && bytes[2] <= 0x03 {
|
// "We observe that the GFW exempts any connection whose first
|
||||||
// TLS handshake for TLS 1.0-1.3
|
// three bytes match the following regular expression:
|
||||||
|
// [\x16-\x17]\x03[\x00-\x09]" - from the paper in Section 4.3
|
||||||
|
if bytes[0] >= 0x16 && bytes[0] <= 0x17 &&
|
||||||
|
bytes[1] == 0x03 && bytes[2] <= 0x09 {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
// HTTP request
|
// HTTP request
|
||||||
|
|||||||
@@ -127,6 +127,10 @@ func NewNFQueuePacketIO(config NFQueuePacketIOConfig) (PacketIO, error) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
err = n.Con.SetOption(netlink.NoENOBUFS, true)
|
||||||
|
if err != nil {
|
||||||
|
return nil, fmt.Errorf("failed to set NoENOBUFS option: %w", err)
|
||||||
|
}
|
||||||
return &nfqueuePacketIO{
|
return &nfqueuePacketIO{
|
||||||
n: n,
|
n: n,
|
||||||
local: config.Local,
|
local: config.Local,
|
||||||
@@ -138,9 +142,10 @@ func NewNFQueuePacketIO(config NFQueuePacketIOConfig) (PacketIO, error) {
|
|||||||
func (n *nfqueuePacketIO) Register(ctx context.Context, cb PacketCallback) error {
|
func (n *nfqueuePacketIO) Register(ctx context.Context, cb PacketCallback) error {
|
||||||
err := n.n.RegisterWithErrorFunc(ctx,
|
err := n.n.RegisterWithErrorFunc(ctx,
|
||||||
func(a nfqueue.Attribute) int {
|
func(a nfqueue.Attribute) int {
|
||||||
if a.PacketID == nil || a.Ct == nil || a.Payload == nil || len(*a.Payload) < 20 {
|
if ok, verdict := n.packetAttributeSanityCheck(a); !ok {
|
||||||
// Invalid packet, ignore
|
if a.PacketID != nil {
|
||||||
// 20 is the minimum possible size of an IP packet
|
_ = n.n.SetVerdict(*a.PacketID, verdict)
|
||||||
|
}
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
p := &nfqueuePacket{
|
p := &nfqueuePacket{
|
||||||
@@ -170,6 +175,25 @@ func (n *nfqueuePacketIO) Register(ctx context.Context, cb PacketCallback) error
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (n *nfqueuePacketIO) packetAttributeSanityCheck(a nfqueue.Attribute) (ok bool, verdict int) {
|
||||||
|
if a.PacketID == nil {
|
||||||
|
// Re-inject to NFQUEUE is actually not possible in this condition
|
||||||
|
return false, -1
|
||||||
|
}
|
||||||
|
if a.Payload == nil || len(*a.Payload) < 20 {
|
||||||
|
// 20 is the minimum possible size of an IP packet
|
||||||
|
return false, nfqueue.NfDrop
|
||||||
|
}
|
||||||
|
if a.Ct == nil {
|
||||||
|
// Multicast packets may not have a conntrack, but only appear in local mode
|
||||||
|
if n.local {
|
||||||
|
return false, nfqueue.NfAccept
|
||||||
|
}
|
||||||
|
return false, nfqueue.NfDrop
|
||||||
|
}
|
||||||
|
return true, -1
|
||||||
|
}
|
||||||
|
|
||||||
func (n *nfqueuePacketIO) SetVerdict(p Packet, v Verdict, newPacket []byte) error {
|
func (n *nfqueuePacketIO) SetVerdict(p Packet, v Verdict, newPacket []byte) error {
|
||||||
nP, ok := p.(*nfqueuePacket)
|
nP, ok := p.(*nfqueuePacket)
|
||||||
if !ok {
|
if !ok {
|
||||||
|
|||||||
Reference in New Issue
Block a user