diff --git a/Makefile b/Makefile index a35d548..75275b2 100644 --- a/Makefile +++ b/Makefile @@ -9,7 +9,7 @@ PKG_UPSTREAM_NAME:=FakeHTTP PKG_UPSTREAM_VERSION:=0.9.18 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_BUILD_DIR:=$(BUILD_DIR)/$(PKG_SOURCE_SUBDIR) @@ -36,17 +36,27 @@ PKG_BUILD_PARALLEL:=1 include $(INCLUDE_DIR)/package.mk -define Package/fakehttp +define Package/$(PKG_NAME) SECTION:=net 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 DEPENDS:=+libmnl +libnfnetlink +libnetfilter-queue +kmod-nft-queue +nftables 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_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 $(eval $(call BuildPackage,$(PKG_NAME))) \ No newline at end of file diff --git a/files/fakehttp.config b/files/fakehttp.config new file mode 100644 index 0000000..c9a8354 --- /dev/null +++ b/files/fakehttp.config @@ -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 raise TTL dynamically to % of estimated hops + option pct '-1' + # -m fwmark for bypassing the queue + option fwmark_bypassing '-1' + # -x set the mask for fwmark + option fwmark_handle '-1' + # -n netfilter queue number + option queue_number '-1' + # -r duplicate generated packets for times + option repeat '-1' + # -t TTL for generated packets + option ttl '-1' + # -z use iptables commands instead of nft + option use_iptables '0' \ No newline at end of file diff --git a/files/fakehttp.init b/files/fakehttp.init new file mode 100644 index 0000000..07fa0ad --- /dev/null +++ b/files/fakehttp.init @@ -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 +} \ No newline at end of file