From e27ec3fe477ea8dfd059c6e71851fa53fb3e8256 Mon Sep 17 00:00:00 2001 From: "Ycarus (Yannick Chabanois)" Date: Thu, 7 Sep 2023 17:22:15 +0200 Subject: [PATCH 1/2] Update netifd --- netifd/Makefile | 15 ++++++--------- netifd/files/etc/init.d/packet_steering | 18 ++++++++++++++++++ netifd/files/lib/netifd/dhcp.script | 1 + netifd/files/lib/netifd/proto/dhcp.sh | 4 ++-- .../libexec/network/packet-steering.sh} | 7 +++++-- 5 files changed, 32 insertions(+), 13 deletions(-) create mode 100755 netifd/files/etc/init.d/packet_steering rename netifd/files/{etc/hotplug.d/net/20-smp-packet-steering => usr/libexec/network/packet-steering.sh} (92%) mode change 100644 => 100755 diff --git a/netifd/Makefile b/netifd/Makefile index 4b5f110da..808432756 100644 --- a/netifd/Makefile +++ b/netifd/Makefile @@ -1,19 +1,19 @@ include $(TOPDIR)/rules.mk PKG_NAME:=netifd -PKG_RELEASE:=1 +PKG_RELEASE:=3 PKG_SOURCE_PROTO:=git PKG_SOURCE_URL=$(PROJECT_GIT)/project/netifd.git -PKG_SOURCE_DATE:=2021-07-26 -PKG_SOURCE_VERSION:=440eb0647708274cc8d7d9e7c2bb0cfdfba90023 -PKG_MIRROR_HASH:=eed957036ab608fdc49bdf801fc5b4405fcd2a3a5e5d3343ec39898e156c10e9 +PKG_SOURCE_DATE:=2023-08-31 +PKG_SOURCE_VERSION:=1a07f1dff32b3af49e39533e33e8964b59535662 +PKG_MIRROR_HASH:=dc621dd04c3c9631002f929cf10a4620f57af8b0baf614c590bda17957fa6201 PKG_MAINTAINER:=Felix Fietkau PKG_LICENSE:=GPL-2.0 PKG_LICENSE_FILES:= -PKG_BUILD_PARALLEL:=1 +PKG_BUILD_FLAGS:=lto include $(INCLUDE_DIR)/package.mk include $(INCLUDE_DIR)/cmake.mk @@ -32,10 +32,7 @@ endef TARGET_CFLAGS += \ -I$(STAGING_DIR)/usr/include/libnl-tiny \ - -I$(STAGING_DIR)/usr/include \ - -flto - -TARGET_LDFLAGS += -flto -fuse-linker-plugin + -I$(STAGING_DIR)/usr/include CMAKE_OPTIONS += \ -DLIBNL_LIBS=-lnl-tiny \ diff --git a/netifd/files/etc/init.d/packet_steering b/netifd/files/etc/init.d/packet_steering new file mode 100755 index 000000000..9d8f791e2 --- /dev/null +++ b/netifd/files/etc/init.d/packet_steering @@ -0,0 +1,18 @@ +#!/bin/sh /etc/rc.common + +START=25 +USE_PROCD=1 + +start_service() { + reload_service +} + +service_triggers() { + procd_add_reload_trigger "network" + procd_add_reload_trigger "firewall" + procd_add_raw_trigger "interface.*" 1000 /etc/init.d/packet_steering reload +} + +reload_service() { + /usr/libexec/network/packet-steering.sh +} diff --git a/netifd/files/lib/netifd/dhcp.script b/netifd/files/lib/netifd/dhcp.script index c857c9fc0..02a95dd76 100755 --- a/netifd/files/lib/netifd/dhcp.script +++ b/netifd/files/lib/netifd/dhcp.script @@ -61,6 +61,7 @@ setup_interface() { [ -n "$message" ] && json_add_string message "$message" [ -n "$timezone" ] && json_add_int timezone "$timezone" [ -n "$lease" ] && json_add_int leasetime "$lease" + [ -n "$serverid" ] && json_add_string dhcpserver "$serverid" proto_close_data proto_send_update "$INTERFACE" diff --git a/netifd/files/lib/netifd/proto/dhcp.sh b/netifd/files/lib/netifd/proto/dhcp.sh index 8db848260..0771d8a05 100755 --- a/netifd/files/lib/netifd/proto/dhcp.sh +++ b/netifd/files/lib/netifd/proto/dhcp.sh @@ -1,6 +1,6 @@ #!/bin/sh -[ -L /sbin/udhcpc ] || exit 0 +[ -x /sbin/udhcpc ] || exit 0 . /lib/functions.sh . ../netifd-proto.sh @@ -68,7 +68,7 @@ proto_dhcp_setup() { -p /var/run/udhcpc-$iface.pid \ -s /lib/netifd/dhcp.script \ -f -t 0 -i "$iface" \ - ${ipaddr:+-r $ipaddr} \ + ${ipaddr:+-r ${ipaddr/\/*/}} \ ${hostname:+-x "hostname:$hostname"} \ ${vendorid:+-V "$vendorid"} \ $clientid $defaultreqopts $broadcast $norelease $dhcpopts diff --git a/netifd/files/etc/hotplug.d/net/20-smp-packet-steering b/netifd/files/usr/libexec/network/packet-steering.sh old mode 100644 new mode 100755 similarity index 92% rename from netifd/files/etc/hotplug.d/net/20-smp-packet-steering rename to netifd/files/usr/libexec/network/packet-steering.sh index 8a86bf75f..799c08080 --- a/netifd/files/etc/hotplug.d/net/20-smp-packet-steering +++ b/netifd/files/usr/libexec/network/packet-steering.sh @@ -1,6 +1,4 @@ #!/bin/sh -[ "$ACTION" = add ] || exit - NPROCS="$(grep -c "^processor.*:" /proc/cpuinfo)" [ "$NPROCS" -gt 1 ] || exit @@ -40,6 +38,11 @@ packet_steering="$(uci get "network.@globals[0].packet_steering")" exec 512>/var/lock/smp_tune.lock flock 512 || exit 1 +[ -e "/usr/libexec/platform/packet-steering.sh" ] && { + /usr/libexec/platform/packet-steering.sh + exit 0 +} + for dev in /sys/class/net/*; do [ -d "$dev" ] || continue From 59074daba96e40c84fa630c487ec2350db619680 Mon Sep 17 00:00:00 2001 From: "Ycarus (Yannick Chabanois)" Date: Tue, 12 Sep 2023 11:20:33 +0200 Subject: [PATCH 2/2] V2Ray Trojan protocol can do UDP over TCP, disable UDP proxy using V2Ray by default --- .../luasrc/view/openmptcprouter/wizard.htm | 2 +- v2ray-core/files/etc/init.d/v2ray | 4 ++-- v2ray-core/files/etc/uci-defaults/3010-omr-v2ray | 5 ++--- v2ray-core/patches/add-mptcp-support.patch | 2 +- 4 files changed, 6 insertions(+), 7 deletions(-) diff --git a/luci-app-openmptcprouter/luasrc/view/openmptcprouter/wizard.htm b/luci-app-openmptcprouter/luasrc/view/openmptcprouter/wizard.htm index b616b2191..03d88add2 100644 --- a/luci-app-openmptcprouter/luasrc/view/openmptcprouter/wizard.htm +++ b/luci-app-openmptcprouter/luasrc/view/openmptcprouter/wizard.htm @@ -241,7 +241,7 @@
- <%:Set the default Proxy used for TCP when ShadowSocks is enabled, for TCP and UDP when V2Ray VLESS or VMESS is enabled.%> + <%:Set the default Proxy used for TCP when ShadowSocks is enabled, for TCP and UDP when V2Ray VLESS, VMESS or Trojan is enabled.%> <%:Only ShadowSocks is supported with server multiple IPs for now.%>
diff --git a/v2ray-core/files/etc/init.d/v2ray b/v2ray-core/files/etc/init.d/v2ray index 1c122c897..7adbfa052 100755 --- a/v2ray-core/files/etc/init.d/v2ray +++ b/v2ray-core/files/etc/init.d/v2ray @@ -448,7 +448,7 @@ add_v2ray_redirect_rules() { v2ray-rules -f #logger -t "v2ray" "v2ray-rules -l ${port} -L ${port} -s $OUTBOUND_SERVERS_V4 --rule-name def --src-default forward --dst-default forward --local-default forward" commandline="-l ${port} -s $OUTBOUND_SERVERS_V4 --rule-name def --src-default forward --dst-default forward --local-default forward" - [ "$(uci -q get v2ray.main_transparent_proxy.redirect_udp)" = "1" ] && ([ "$(uci -q get v2ray.omrout.protocol)" = "vless" ] || [ "$(uci -q get v2ray.omrout.protocol)" = "vmess" ]) && commandline="$commandline -L ${port}" + [ "$(uci -q get v2ray.main_transparent_proxy.redirect_udp)" = "1" ] && [ "$(uci -q get v2ray.omrout.protocol)" != "socks" ] && commandline="$commandline -L ${port}" v2ray-rules $commandline [ "$(uci -q get v2ray.main.inbounds | grep omr6)" != "" ] && [ -n "$OUTBOUND_SERVERS_V6" ] && { v2ray-rules6 -f @@ -1885,7 +1885,7 @@ init_transparent_proxy() { TRANSPARENT_PROXY_PORT="$redirect_port" TRANSPARENT_PROXY_USE_TPROXY="$use_tproxy" - if [ "x$redirect_udp" = "x1" ] && [ "$(uci -q get v2ray.omrout.protocol)" != "trojan" ] && [ "$(uci -q get v2ray.omrout.protocol)" != "socks" ]; then + if [ "x$redirect_udp" = "x1" ] && [ "$(uci -q get v2ray.omrout.protocol)" != "socks" ]; then TRANSPARENT_PROXY_ADDITION="udp" elif [ "x$redirect_dns" = "x1" ] ; then TRANSPARENT_PROXY_ADDITION="dns" diff --git a/v2ray-core/files/etc/uci-defaults/3010-omr-v2ray b/v2ray-core/files/etc/uci-defaults/3010-omr-v2ray index e72351856..df545a5b6 100644 --- a/v2ray-core/files/etc/uci-defaults/3010-omr-v2ray +++ b/v2ray-core/files/etc/uci-defaults/3010-omr-v2ray @@ -6,7 +6,7 @@ if [ -z "$(uci -q get v2ray.main)" ]; then set v2ray.main=v2ray set v2ray.main.v2ray_file='/usr/bin/v2ray' set v2ray.main.mem_percentage='0' - set v2ray.main.loglevel='debug' + set v2ray.main.loglevel='error' set v2ray.main.access_log='/dev/null' set v2ray.main.error_log='/dev/null' set v2ray.main.enabled='0' @@ -30,7 +30,7 @@ if [ -z "$(uci -q get v2ray.main)" ]; then set v2ray.main_transparent_proxy.proxy_mode='default' set v2ray.main_transparent_proxy.apnic_delegated_mirror='apnic' set v2ray.main_transparent_proxy.gfwlist_mirror='github' - set v2ray.main_transparent_proxy.redirect_udp='1' + set v2ray.main_transparent_proxy.redirect_udp='0' set v2ray.main_transparent_proxy.redirect_port='1897' set v2ray.omrout=outbound set v2ray.omrout.tag='omrout_tunnel' @@ -197,5 +197,4 @@ if [ "$(uci -q get v2ray.omrout.s_socks_port)" = "" ]; then EOF fi -fi exit 0 \ No newline at end of file diff --git a/v2ray-core/patches/add-mptcp-support.patch b/v2ray-core/patches/add-mptcp-support.patch index 4878679da..85ba7a316 100644 --- a/v2ray-core/patches/add-mptcp-support.patch +++ b/v2ray-core/patches/add-mptcp-support.patch @@ -2444,7 +2444,7 @@ index 729899015..41f70be7b 100644 + if x != nil { + return x.Mptcp + } -+ return false ++ return true +} + var File_transport_internet_config_proto protoreflect.FileDescriptor