diff --git a/CMakeLists.txt b/CMakeLists.txt index 865149d..210e320 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -16,6 +16,13 @@ set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,-gc-sections") add_compile_options(-std=gnu17) +if(UA2F_CUSTOM_USER_AGENT) + if(NOT UA2F_USER_AGENT_STRING) + message(FATAL_ERROR "UA2F_USER_AGENT_STRING is not set") + endif() + add_compile_definitions(UA2F_CUSTOM_UA="${UA2F_USER_AGENT_STRING}") +endif() + add_executable(ua2f src/ua2f.c src/statistics.c diff --git a/openwrt/Makefile b/openwrt/Makefile index 2147f47..b741032 100644 --- a/openwrt/Makefile +++ b/openwrt/Makefile @@ -19,6 +19,7 @@ define Package/ua2f SUBMENU:=Routing and Redirection TITLE:=Change User-Agent to Fwords on the fly. URL:=https://github.com/Zxilly/UA2F + MENU:=1 DEPENDS:= \ +libnetfilter-conntrack \ +libnetfilter-queue \ @@ -30,6 +31,33 @@ define Package/ua2f +PACKAGE_firewall:iptables-mod-nfqueue endef +define Package/ua2f/config + menu "Configuration" + depends on PACKAGE_ua2f + + config UA2F_CUSTOM_USER_AGENT + bool "Enable custom User-Agent" + default n + help + Enable this option to use a custom User-Agent string. + + config UA2F_USER_AGENT_STRING + string "Custom User-Agent string" + depends on UA2F_CUSTOM_USER_AGENT + default "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/112.0.0.0 Safari/537.36 Edg/112.0.1722.68" + help + Specify the custom User-Agent string to use when UA2F_CUSTOM_USER_AGENT is enabled. + + endmenu +endef + +define Build/Configure + $(call Build/Configure/Default, \ + -DUA2F_CUSTOM_USER_AGENT=$(if $(CONFIG_UA2F_CUSTOM_USER_AGENT),ON,OFF), \ + -DUA2F_USER_AGENT_STRING="$(CONFIG_UA2F_USER_AGENT_STRING)" \ + ) +endef + define Package/ua2f/description Change User-agent to Fwords to prevent being checked by Dr.Com. endef