Skip to content

Commit 3520d5f

Browse files
committed
xtables-wgobfs: add WireGuard obfuscation kmod
Port from https://github.com/infinet/xt_wgobfs, this kernel module obfuscates WireGuard. It can work as server, client, or relay. Performance =========== Test in two Alpine linux VMs on same host. Each VM has 1 CPU and 256M RAM. Iperf3 over wg reports 1.1Gbits/sec without obfuscation, 950Mbits/sec with obfuscation. How it works ============ The sender and receiver share a secret key, which is used by `chacha6` to hash the same input into identical pseudo-random numbers. These pseudo-random numbers are used in obfuscation. The input to hash function is from 16th to 31st bytes of a WG message. The first byte of input is incremented when need to generate a different PRN. - The first 16 bytes of WG message is obfuscated. - The mac2 field is also obfuscated, if it is all zeros. - Padding WG message with random bytes of random length. - Drop keepalive message with 80% probability. - Change the Diffserv field to zero. `Chacha6` is chosen for its speed, as the goal is not encryption. See https://github.com/infinet/xt_wgobfs/blob/main/README.md for usage. Signed-off-by: Wei Chen <weichen302@gmail.com>
1 parent 3f52746 commit 3520d5f

File tree

1 file changed

+76
-0
lines changed

1 file changed

+76
-0
lines changed

net/xtables-wgobfs/Makefile

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
#
2+
# Copyright (C) 2022-2025 Wei Chen <weichen302@gmail.com>
3+
#
4+
# SPDX-License-Identifier: GPL-2.0-only
5+
#
6+
7+
include $(TOPDIR)/rules.mk
8+
9+
PKG_NAME:=xtables-wgobfs
10+
PKG_VERSION:=0.6.2
11+
PKG_RELEASE:=1
12+
13+
PKG_BUILD_DIR:=$(BUILD_DIR)/xt_wgobfs-$(PKG_VERSION)
14+
PKG_SOURCE:=xt_wgobfs-$(PKG_VERSION).tar.xz
15+
PKG_SOURCE_URL:= https://github.com/infinet/xt_wgobfs/releases/download/v$(PKG_VERSION)/
16+
PKG_HASH:=ba4c410c9dc304360d944249d5314ef4987515de381b1274873f8597928cb67f
17+
18+
PKG_LICENSE:=GPL-2.0-only
19+
PKG_LICENSE_FILES:=LICENSE
20+
21+
PKG_BUILD_DEPENDS:=iptables
22+
PKG_BUILD_PARALLEL:=1
23+
PKG_INSTALL:=1
24+
PKG_MAINTAINER:=Wei Chen <weichen302@gmail.com>
25+
26+
include $(INCLUDE_DIR)/kernel.mk
27+
include $(INCLUDE_DIR)/package.mk
28+
29+
define Package/xtables-wgobfs/description
30+
An iptables extension for WireGuard obfuscation
31+
endef
32+
33+
XTLIB_DIR:=/usr/lib/iptables
34+
35+
# uses GNU configure
36+
CONFIGURE_ARGS+= \
37+
--with-kbuild="$(LINUX_DIR)" \
38+
--with-xtlibdir="$(XTLIB_DIR)"
39+
40+
MAKE_FLAGS = \
41+
ARCH="$(LINUX_KARCH)" \
42+
CROSS_COMPILE="$(TARGET_CROSS)" \
43+
DESTDIR="$(PKG_INSTALL_DIR)" \
44+
DEPMOD="/bin/true"
45+
46+
define Build/Install
47+
mkdir -p $(PKG_INSTALL_DIR)/$(XTLIB_DIR)
48+
$(call Build/Install/Default)
49+
endef
50+
51+
define Package/iptables-mod-wgobfs
52+
SECTION:=net
53+
CATEGORY:=Network
54+
SUBMENU:=Firewall
55+
TITLE:=iptables WireGuard obfuscation extension
56+
URL:=https://github.com/infinet/xt_wgobfs
57+
DEPENDS:= +iptables +libxtables +kmod-ipt-wgobfs
58+
endef
59+
60+
define Package/iptables-mod-wgobfs/install
61+
$(INSTALL_DIR) $(1)/$(XTLIB_DIR)
62+
$(CP) \
63+
$(PKG_INSTALL_DIR)/$(XTLIB_DIR)/libxt_WGOBFS.so \
64+
$(1)/$(XTLIB_DIR)
65+
endef
66+
67+
define KernelPackage/ipt-wgobfs
68+
SUBMENU:=Netfilter Extensions
69+
TITLE:=WireGuard obfuscation netfilter module
70+
DEPENDS:=+kmod-ipt-core
71+
FILES:=$(PKG_BUILD_DIR)/src/xt_WGOBFS.$(LINUX_KMOD_SUFFIX)
72+
AUTOLOAD:=$(call AutoProbe,xt_WGOBFS)
73+
endef
74+
75+
$(eval $(call BuildPackage,iptables-mod-wgobfs))
76+
$(eval $(call KernelPackage,ipt-wgobfs))

0 commit comments

Comments
 (0)