build: add custom ua option

This commit is contained in:
Zxilly 2023-05-22 19:39:07 +08:00
parent 547b4b1fac
commit 7a5f99d4d5
2 changed files with 35 additions and 0 deletions

View File

@ -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

View File

@ -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