Squashed 'fakehttp/' changes from 9bb5ff9..08f829e
08f829e optimize the init script 92c1e67 add init scripts git-subtree-dir: fakehttp git-subtree-split: 08f829e96534891b8ab9aef4141256a47c2e69c2
This commit is contained in:
parent
cddfadca48
commit
ee5048aa89
18
Makefile
18
Makefile
|
@ -9,7 +9,7 @@ PKG_UPSTREAM_NAME:=FakeHTTP
|
||||||
PKG_UPSTREAM_VERSION:=0.9.18
|
PKG_UPSTREAM_VERSION:=0.9.18
|
||||||
PKG_UPSTREAM_GITHASH:=
|
PKG_UPSTREAM_GITHASH:=
|
||||||
PKG_VERSION:=$(PKG_UPSTREAM_VERSION)$(if $(PKG_UPSTREAM_GITHASH),~$(call version_abbrev,$(PKG_UPSTREAM_GITHASH)))
|
PKG_VERSION:=$(PKG_UPSTREAM_VERSION)$(if $(PKG_UPSTREAM_GITHASH),~$(call version_abbrev,$(PKG_UPSTREAM_GITHASH)))
|
||||||
PKG_RELEASE:=1
|
PKG_RELEASE:=2
|
||||||
|
|
||||||
PKG_SOURCE_SUBDIR:=$(PKG_UPSTREAM_NAME)-$(PKG_UPSTREAM_VERSION)
|
PKG_SOURCE_SUBDIR:=$(PKG_UPSTREAM_NAME)-$(PKG_UPSTREAM_VERSION)
|
||||||
PKG_BUILD_DIR:=$(BUILD_DIR)/$(PKG_SOURCE_SUBDIR)
|
PKG_BUILD_DIR:=$(BUILD_DIR)/$(PKG_SOURCE_SUBDIR)
|
||||||
|
@ -36,17 +36,27 @@ PKG_BUILD_PARALLEL:=1
|
||||||
|
|
||||||
include $(INCLUDE_DIR)/package.mk
|
include $(INCLUDE_DIR)/package.mk
|
||||||
|
|
||||||
define Package/fakehttp
|
define Package/$(PKG_NAME)
|
||||||
SECTION:=net
|
SECTION:=net
|
||||||
CATEGORY:=Network
|
CATEGORY:=Network
|
||||||
TITLE:=Obfuscate all your TCP connections into HTTP protocol
|
TITLE:=Obfuscate all your TCP connections into HTTP protocol.
|
||||||
URL:=https://github.com/MikeWang000000/FakeHTTP
|
URL:=https://github.com/MikeWang000000/FakeHTTP
|
||||||
DEPENDS:=+libmnl +libnfnetlink +libnetfilter-queue +kmod-nft-queue +nftables
|
DEPENDS:=+libmnl +libnfnetlink +libnetfilter-queue +kmod-nft-queue +nftables
|
||||||
endef
|
endef
|
||||||
|
|
||||||
define Package/fakehttp/install
|
define Package/$(PKG_NAME)/conffiles
|
||||||
|
/etc/config/fakehttp
|
||||||
|
endef
|
||||||
|
|
||||||
|
define Package/$(PKG_NAME)/install
|
||||||
$(INSTALL_DIR) $(1)/usr/sbin
|
$(INSTALL_DIR) $(1)/usr/sbin
|
||||||
$(INSTALL_BIN) $(PKG_BUILD_DIR)/build/fakehttp $(1)/usr/sbin/fakehttp
|
$(INSTALL_BIN) $(PKG_BUILD_DIR)/build/fakehttp $(1)/usr/sbin/fakehttp
|
||||||
|
|
||||||
|
$(INSTALL_DIR) $(1)/etc/init.d/
|
||||||
|
$(INSTALL_BIN) $(CURDIR)/files/fakehttp.init $(1)/etc/init.d/fakehttp
|
||||||
|
|
||||||
|
$(INSTALL_DIR) $(1)/etc/config/
|
||||||
|
$(INSTALL_CONF) $(CURDIR)/files/fakehttp.config $(1)/etc/config/fakehttp
|
||||||
endef
|
endef
|
||||||
|
|
||||||
$(eval $(call BuildPackage,$(PKG_NAME)))
|
$(eval $(call BuildPackage,$(PKG_NAME)))
|
36
files/fakehttp.config
Normal file
36
files/fakehttp.config
Normal file
|
@ -0,0 +1,36 @@
|
||||||
|
config globals 'globals'
|
||||||
|
option enabled '0'
|
||||||
|
list interface 'eth0'
|
||||||
|
option silent '0'
|
||||||
|
|
||||||
|
config payload
|
||||||
|
option type 'h'
|
||||||
|
option hostname 'node-36-250-1-90.speedtest.cn'
|
||||||
|
|
||||||
|
#config payload
|
||||||
|
# option type 'e'
|
||||||
|
# option hostname 'node-36-250-1-90.speedtest.cn'
|
||||||
|
#
|
||||||
|
#config payload
|
||||||
|
# option type 'b'
|
||||||
|
# option file '/tmp/fakehttp_payload'
|
||||||
|
|
||||||
|
config advanced 'advanced'
|
||||||
|
# -f skip firewall rules
|
||||||
|
option skip '0'
|
||||||
|
# -g disable hop count estimation
|
||||||
|
option disable_estimation '0'
|
||||||
|
# -y <pct> raise TTL dynamically to <pct>% of estimated hops
|
||||||
|
option pct '-1'
|
||||||
|
# -m <mark> fwmark for bypassing the queue
|
||||||
|
option fwmark_bypassing '-1'
|
||||||
|
# -x <mask> set the mask for fwmark
|
||||||
|
option fwmark_handle '-1'
|
||||||
|
# -n <number> netfilter queue number
|
||||||
|
option queue_number '-1'
|
||||||
|
# -r <repeat> duplicate generated packets for <repeat> times
|
||||||
|
option repeat '-1'
|
||||||
|
# -t <ttl> TTL for generated packets
|
||||||
|
option ttl '-1'
|
||||||
|
# -z use iptables commands instead of nft
|
||||||
|
option use_iptables '0'
|
106
files/fakehttp.init
Normal file
106
files/fakehttp.init
Normal file
|
@ -0,0 +1,106 @@
|
||||||
|
#!/bin/sh /etc/rc.common
|
||||||
|
|
||||||
|
USE_PROCD=1
|
||||||
|
START=99
|
||||||
|
STOP=01
|
||||||
|
|
||||||
|
PROG="/usr/sbin/fakehttp"
|
||||||
|
NAME="fakehttp"
|
||||||
|
|
||||||
|
service_triggers() {
|
||||||
|
procd_add_reload_trigger "${NAME}"
|
||||||
|
}
|
||||||
|
|
||||||
|
add_interface() {
|
||||||
|
local ifname="$1"
|
||||||
|
|
||||||
|
procd_append_param command "-i" "${ifname}"
|
||||||
|
procd_append_param netdev "${ifname}"
|
||||||
|
}
|
||||||
|
|
||||||
|
add_payload() {
|
||||||
|
local section="$1"
|
||||||
|
|
||||||
|
local type
|
||||||
|
config_get type "${section}" "type" ""
|
||||||
|
|
||||||
|
case "${type}" in
|
||||||
|
"h")
|
||||||
|
local hostname
|
||||||
|
config_get hostname "${section}" "hostname" ""
|
||||||
|
procd_append_param command "-h" "${hostname}"
|
||||||
|
;;
|
||||||
|
"e")
|
||||||
|
local hostname
|
||||||
|
config_get hostname "${section}" "hostname" ""
|
||||||
|
procd_append_param command "-e" "${hostname}"
|
||||||
|
;;
|
||||||
|
"b")
|
||||||
|
local file
|
||||||
|
config_get file "${section}" "file" ""
|
||||||
|
procd_append_param command "-b" "${file}"
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
}
|
||||||
|
|
||||||
|
test_bool_then_append() {
|
||||||
|
local section="$1"
|
||||||
|
local config_option="$2"
|
||||||
|
local command_option="$3"
|
||||||
|
|
||||||
|
local tmp
|
||||||
|
config_get_bool tmp "${section}" "${config_option}" "0"
|
||||||
|
[ "${tmp}" -eq "1" ] && procd_append_param command "${command_option}"
|
||||||
|
}
|
||||||
|
|
||||||
|
test_number_then_append() {
|
||||||
|
local section="$1"
|
||||||
|
local config_option="$2"
|
||||||
|
local command_option="$3"
|
||||||
|
|
||||||
|
local tmp
|
||||||
|
config_get tmp "${section}" "${config_option}" "-1"
|
||||||
|
[ "${tmp}" -gt "0" ] && procd_append_param command "${command_option}" "${tmp}"
|
||||||
|
}
|
||||||
|
|
||||||
|
add_advanced() {
|
||||||
|
test_bool_then_append "advanced" "skip" "-f"
|
||||||
|
test_bool_then_append "advanced" "disable_estimation" "-g"
|
||||||
|
test_number_then_append "advanced" "pct" "-y"
|
||||||
|
test_number_then_append "advanced" "fwmark_bypassing" "-m"
|
||||||
|
test_number_then_append "advanced" "fwmark_handle" "-x"
|
||||||
|
test_number_then_append "advanced" "queue_number" "-n"
|
||||||
|
test_number_then_append "advanced" "repeat" "-r"
|
||||||
|
test_number_then_append "advanced" "ttl" "-t"
|
||||||
|
test_bool_then_append "advanced" "use_iptables" "-z"
|
||||||
|
}
|
||||||
|
|
||||||
|
fakehttp_instance() {
|
||||||
|
config_load "${NAME}"
|
||||||
|
|
||||||
|
local enabled
|
||||||
|
config_get_bool enabled "globals" "enabled" "0"
|
||||||
|
[ "${enabled}" -eq "1" ] || return 0
|
||||||
|
|
||||||
|
procd_open_instance
|
||||||
|
procd_set_param command "${PROG}"
|
||||||
|
config_list_foreach "globals" "interface" add_interface
|
||||||
|
test_bool_then_append "globals" "silent" "-s"
|
||||||
|
config_foreach add_payload "payload"
|
||||||
|
add_advanced
|
||||||
|
|
||||||
|
procd_set_param stdout 1
|
||||||
|
procd_set_param stderr 1
|
||||||
|
procd_set_param respawn
|
||||||
|
|
||||||
|
procd_close_instance
|
||||||
|
}
|
||||||
|
|
||||||
|
start_service() {
|
||||||
|
fakehttp_instance
|
||||||
|
}
|
||||||
|
|
||||||
|
reload_service() {
|
||||||
|
stop
|
||||||
|
start
|
||||||
|
}
|
Loading…
Reference in a new issue