SpoofDPI is a simple and fast anti-censorship tool written in Go that bypasses Deep Packet Inspection (DPI) by splitting HTTPS requests into chunks and sending the first byte separately.
Created attachment 252479 [details] net/spoofdpi
Created attachment 252480 [details] poudriere testport log
Created attachment 252481 [details] portlint log
Maybe create rc.d start script? I can help with this.
I never created a rc.d script before, so I would like to get help. I tried writing a rc.d script now and it starts the program but i don't want to see program's output transferred into terminal. Also I't doesn't run in background mode. Here is my uncompleted script. I looked to moused's rc.d script for help. #!/bin/sh . /etc/rc.subr name="spoofdpi" desc="SpoofDPI daemon" rcvar="${name}_enable" command="/usr/local/bin/spoof-dpi" start_cmd="${name}_start" stop_cmd=":" load_rc_config $name spoofdpi_start() { local myflags myflags="$spoofdpi_flags" startmsg -n "Starting ${name}" ${command} ${myflags} startmsg '.' } run_rc_command "$1" & The program can take some arguments like: -addr string listen address (default "127.0.0.1") -debug enable debug output -dns-addr string dns address (default "8.8.8.8") -dns-port int port number for dns (default 53) -enable-doh enable 'dns over https' -no-banner disable banner -pattern string bypass DPI only on packets matching this regex pattern -port int port (default 8080) -timeout int timeout in milliseconds. no timeout when not given -url value Bypass DPI only on this url, can be passed multiple times -v print spoof-dpi's version. this may contain some other relevant information -window-size int chunk size, in number of bytes, for fragmented client hello, try lower values if the default value doesn't bypass the DPI; when not given, the client hello packet will be sent in two parts: fragmentation for the first data packet and the rest
Lets rename binary file to spoofdpi: GO_BUILDFLAGS= -ldflags="-s -w" -o ./build/spoofdpi PLIST_FILES= bin/spoofdpi Try this net/spoofdpi/files/spoofdpi.in (we can add other options like addr, port, dns and etc - what you want): #!/bin/sh # PROVIDE: spoofdpi # REQUIRE: LOGIN # KEYWORD: shutdown # # Add the following lines to /etc/rc.conf or /etc/rc.conf.local to # enable spoofdpi: # spoofdpi_args (str): Custom additional arguments to be passed # spoofdpi (default empty). # spoofdpi_user (str): User to run spoofdpi as. Default # to "%%USER%%" created by the port. # spoofdpi_log (path): Console log file (default /dev/null). . /etc/rc.subr case $0 in /etc/rc*) # during boot (shutdown) $0 is /etc/rc (/etc/rc.shutdown), # so get the name of the script from $_file name=$_file ;; *) name=$0 ;; esac name=${name##*/} rcvar="${name}_enable" load_rc_config "${name}" eval "${rcvar}=\${${rcvar}:-'NO'}" eval "_args=\${${name}_args:-''}" eval "_user=\${${name}_user:-'%%USER%%'}" eval "_log=\${${name}_log:-/dev/null}" pidfile="/var/run/${name}.pid" command="/usr/sbin/daemon" command_args="-P ${pidfile} -u ${_user} -f -H -o ${_log} -m 3 %%PREFIX%%/bin/spoofdpi -no-banner ${_args}" run_rc_command "$1" Also add to Makefile: USE_RC_SUBR= ${PORTNAME} SUB_LIST= USER=${USERS} USERS= spoofdpi GROUPS= spoofdpi UIDs: spoofdpi:*:380:380:SpoofDPI Daemon:0:0: :/nonexistent:/usr/sbin/nologin GIDs: spoofdpi:*:380:
Not tested yet.
I tested rc.d script and it seems to work. I just fixed the UID, i guess there was a syntax error and it was causing error when system trying to create the group. Very thanks. I appreciate it. I hope you don't mind me attaching a second patch instead of full patch again.
Created attachment 252497 [details] [second patch] net/spoofdpi: Create rc.d script, user and group and replace binary name with spoofdpi
> I just fixed the UID, i guess there was a syntax error > and it was causing error when system trying to create the group. Sorry, it wasn't group error, it was user error.
I guess rc.d script doesn't work without specifying args in /etc/rc.conf. I'll test it more...
Do you use IRC or Discord?
I don't use Discord but I just created an IRC account. My nickname is nxjoseph
PORTNAME= spoofdpi DISTVERSIONPREFIX= v DISTVERSION= 0.10.4 CATEGORIES= net MAINTAINER= nxjoseph@protonmail.com COMMENT= Simple and fast anti-censorship tool WWW= https://github.com/xvzc/SpoofDPI LICENSE= APACHE20 USES= go:modules USE_GITHUB= yes GH_ACCOUNT= xvzc GH_PROJECT= SpoofDPI GH_TUPLE= atomicgo:cursor:v0.2.0:atomicgo_cursor/vendor/atomicgo.dev/cursor \ atomicgo:keyboard:v0.2.9:atomicgo_keyboard/vendor/atomicgo.dev/keyboard \ atomicgo:schedule:v0.1.0:atomicgo_schedule/vendor/atomicgo.dev/schedule \ containerd:console:v1.0.3:containerd_console/vendor/github.com/containerd/console \ golang:mod:v0.18.0:golang_mod/vendor/golang.org/x/mod \ golang:net:v0.27.0:golang_net/vendor/golang.org/x/net \ golang:sync:v0.7.0:golang_sync/vendor/golang.org/x/sync \ golang:sys:v0.22.0:golang_sys/vendor/golang.org/x/sys \ golang:term:v0.22.0:golang_term/vendor/golang.org/x/term \ golang:text:v0.16.0:golang_text/vendor/golang.org/x/text \ golang:tools:v0.22.0:golang_tools/vendor/golang.org/x/tools \ gookit:color:v1.5.4:gookit_color/vendor/github.com/gookit/color \ likexian:doh:v0.7.1:likexian_doh/vendor/github.com/likexian/doh \ likexian:gokit:v0.25.15:likexian_gokit/vendor/github.com/likexian/gokit \ lithammer:fuzzysearch:v1.1.8:lithammer_fuzzysearch/vendor/github.com/lithammer/fuzzysearch \ mattn:go-runewidth:v0.0.15:mattn_go_runewidth/vendor/github.com/mattn/go-runewidth \ miekg:dns:v1.1.61:miekg_dns/vendor/github.com/miekg/dns \ pterm:pterm:v0.12.79:pterm_pterm/vendor/github.com/pterm/pterm \ rivo:uniseg:v0.4.4:rivo_uniseg/vendor/github.com/rivo/uniseg \ sirupsen:logrus:v1.9.3:sirupsen_logrus/vendor/github.com/sirupsen/logrus \ xo:terminfo:abceb7e1c41e:xo_terminfo/vendor/github.com/xo/terminfo USE_RC_SUBR= ${PORTNAME} GO_TARGET= ./cmd/spoof-dpi:${PORTNAME} GO_BUILDFLAGS= -ldflags="-s -w" SUB_LIST= USER=${USERS} USERS= ${PORTNAME} GROUPS= ${PORTNAME} PLIST_FILES= bin/${PORTNAME} .include <bsd.port.mk>
#!/bin/sh # PROVIDE: spoofdpi # REQUIRE: LOGIN # KEYWORD: shutdown # # Add the following lines to /etc/rc.conf or /etc/rc.conf.local to # enable spoofdpi: # spoofdpi_args (str): Custom additional arguments to be passed # spoofdpi (default empty). # spoofdpi_user (str): User to run spoofdpi as. Default # to "%%USER%%" created by the port. # spoofdpi_log (path): Console log file (default /dev/null). . /etc/rc.subr case $0 in /etc/rc*) # during boot (shutdown) $0 is /etc/rc (/etc/rc.shutdown), # so get the name of the script from $_file name=$_file ;; *) name=$0 ;; esac name=${name##*/} rcvar="${name}_enable" load_rc_config "${name}" eval "${rcvar}=\${${rcvar}:-'NO'}" eval "_args=\${${name}_args:-''}" eval "_user=\${${name}_user:-'%%USER%%'}" eval "_log=\${${name}_log:-/dev/null}" pidfile="/var/run/${name}.pid" command="/usr/sbin/daemon" command_args="-P ${pidfile} -u ${_user} -f -H -o ${_log} -m 3 %%PREFIX%%/bin/spoofdpi -no-banner ${_args}" run_rc_command "$1"
Created attachment 252529 [details] net/spoofdpi Attaching new complete patch and marking second patch obsolete.
Created attachment 252530 [details] poudriere testport log
Created attachment 252531 [details] portlint log
Created attachment 252533 [details] net/spoofdpi use substitutions like %%USER%% and %%PREFIX%% in service file.
Created attachment 252534 [details] poudriere testport log
Created attachment 252535 [details] portlint log
A commit in branch main references this bug: URL: https://cgit.FreeBSD.org/ports/commit/?id=3ad03358f6959b68ea10c2d395274dda595afec9 commit 3ad03358f6959b68ea10c2d395274dda595afec9 Author: Yusuf Yaman <nxjoseph@protonmail.com> AuthorDate: 2024-08-05 23:01:57 +0000 Commit: Vladimir Druzenko <vvd@FreeBSD.org> CommitDate: 2024-08-05 23:01:57 +0000 net/spoofdpi: New port: Simple and fast anti-censorship tool SpoofDPI is a simple and fast anti-censorship tool written in Go that bypasses Deep Packet Inspection (DPI) by splitting HTTPS requests into chunks and sending the first byte separately. It can be run as daemon via rc.d script spoofdpi. https://github.com/xvzc/SpoofDPI PR: 280591 GIDs | 2 +- UIDs | 2 +- net/Makefile | 1 + net/spoofdpi/Makefile (new) | 47 ++++++++++++++++++++++++++++++++++++ net/spoofdpi/distinfo (new) | 45 ++++++++++++++++++++++++++++++++++ net/spoofdpi/files/spoofdpi.in (new) | 43 +++++++++++++++++++++++++++++++++ net/spoofdpi/pkg-descr (new) | 3 +++ 7 files changed, 141 insertions(+), 2 deletions(-)
Thanks!
A commit in branch main references this bug: URL: https://cgit.FreeBSD.org/ports/commit/?id=46b3743b84691248050b1e8e810355d17f5bb084 commit 46b3743b84691248050b1e8e810355d17f5bb084 Author: Vladimir Druzenko <vvd@FreeBSD.org> AuthorDate: 2024-08-06 00:52:18 +0000 Commit: Vladimir Druzenko <vvd@FreeBSD.org> CommitDate: 2024-08-06 00:52:18 +0000 UIDs: fix typo in username for net/spoofdpi PR: 280591 Fixes: 3ad03358f695 (New port: Simple and fast anti-censorship tool) UIDs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)