🌴 Sync 2026-03-05 23:51:42

This commit is contained in:
github-actions[bot] committed 2026-03-05 23:51:42 +08:00
1 parent 97c049ed0a
commit 0acff03804
14253 files changed
+3893239

No files matched your search

+71
View File
@@ -0,0 +1,71 @@
#
# Copyright (C) 2018-2019 wongsyrone
#
# This is free software, licensed under the GNU General Public License v3.
# See /LICENSE for more information.
#
include $(TOPDIR)/rules.mk
PKG_NAME:=trojan-plus
PKG_VERSION:=10.0.3
PKG_RELEASE:=1
PKG_SOURCE_PROTO:=git
PKG_SOURCE_URL:=https://github.com/peter-tank/trojan-plus.git
PKG_SOURCE_DATE:=2020-09-06
PKG_SOURCE_VERSION:=a6394cdd718669b0c7491493a78e61f6f0f899b3
PKG_MIRROR_HASH:=skip
PKG_BUILD_PARALLEL:=1
PKG_BUILD_DEPENDS:=openssl
PKG_LICENSE:=GPL-3.0
PKG_LICENSE_FILE:=LICENSE
PKG_MAINTAINER:=Trojan-Plus-Group
include $(INCLUDE_DIR)/package.mk
include $(INCLUDE_DIR)/cmake.mk
include ./boost-version.mk
TARGET_CXXFLAGS += -Wall -Wextra
TARGET_CXXFLAGS += $(FPIC)
# LTO
TARGET_CXXFLAGS += -flto
TARGET_LDFLAGS += -flto
# CXX standard
TARGET_CXXFLAGS += -std=c++11
TARGET_CXXFLAGS := $(filter-out -O%,$(TARGET_CXXFLAGS)) -O3
TARGET_CXXFLAGS += -ffunction-sections -fdata-sections
TARGET_LDFLAGS += -Wl,--gc-sections
CMAKE_OPTIONS += \
-DENABLE_MYSQL=OFF \
-DENABLE_NAT=ON \
-DENABLE_REUSE_PORT=ON \
-DENABLE_SSL_KEYLOG=ON \
-DENABLE_TLS13_CIPHERSUITES=ON \
-DFORCE_TCP_FASTOPEN=OFF \
-DSYSTEMD_SERVICE=OFF \
-DOPENSSL_USE_STATIC_LIBS=FALSE \
-DBoost_DEBUG=ON \
-DBoost_NO_BOOST_CMAKE=ON
define Package/trojan-plus
SECTION:=net
CATEGORY:=Network
TITLE:=An unidentifiable mechanism that helps you bypass GFW. It's compatible with original trojan with experimental features.
URL:=https://github.com/Trojan-Plus-Group/trojan-plus
DEPENDS:= \
+libpthread +libstdcpp +libopenssl \
+boost +boost-program_options \
$(if $(filter y,$(NEED_BOOST_SYSTEM)),,+boost-system)
endef
define Package/trojan-plus/install
$(INSTALL_DIR) $(1)/usr/sbin
$(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/bin/trojan $(1)/usr/sbin/trojan-plus
endef
$(eval $(call BuildPackage,trojan-plus))
+12
View File
@@ -0,0 +1,12 @@
# boost-version.mk
BOOST_MAKEFILE := $(firstword $(shell find -L $(TOPDIR) -type f -path "*/boost/Makefile"))
BOOST_PKG_VERSION := $(shell grep '^PKG_VERSION:=' $(BOOST_MAKEFILE) | head -n1 | cut -d= -f2)
BOOST_VER_MAJOR := $(word 1,$(subst ., ,$(BOOST_PKG_VERSION)))
BOOST_VER_MINOR := $(word 2,$(subst ., ,$(BOOST_PKG_VERSION)))
BOOST_VER_PATCH := $(word 3,$(subst ., ,$(BOOST_PKG_VERSION)))
BOOST_VERSION_CODE := $(shell echo $$(($(BOOST_VER_MAJOR)*100000 + $(BOOST_VER_MINOR)*100 + $(BOOST_VER_PATCH))))
NEED_BOOST_SYSTEM := $(if $(shell [ $(BOOST_VERSION_CODE) -ge 108900 ] && echo y),y,n)
@@ -0,0 +1,84 @@
--- a/src/core/service.cpp
+++ b/src/core/service.cpp
@@ -546,8 +546,15 @@ void Service::udp_async_read() {
int read_length = (int)length;
int ttl = -1;
+#if BOOST_VERSION >= 108700
+ auto buffer = udp_read_buf.prepare(config.get_udp_recv_buf());
+ char* data = static_cast<char*>(buffer.data());
+
+ targetdst = recv_tproxy_udp_msg((int)udp_socket.native_handle(), udp_recv_endpoint, data, read_length, ttl);
+#else
targetdst = recv_tproxy_udp_msg((int)udp_socket.native_handle(), udp_recv_endpoint,
boost::asio::buffer_cast<char*>(udp_read_buf.prepare(config.get_udp_recv_buf())), read_length, ttl);
+#endif
length = read_length < 0 ? 0 : read_length;
udp_read_buf.commit(length);
--- a/src/session/session.cpp
+++ b/src/session/session.cpp
@@ -68,7 +68,11 @@ void Session::udp_timer_async_wait(int t
}
boost::system::error_code ec;
+#if BOOST_VERSION >= 108700
+ udp_gc_timer.cancel();
+#else
udp_gc_timer.cancel(ec);
+#endif
if (ec) {
output_debug_info_ec(ec);
destroy();
@@ -104,7 +108,11 @@ void Session::udp_timer_cancel() {
}
boost::system::error_code ec;
+#if BOOST_VERSION >= 108700
+ udp_gc_timer.cancel();
+#else
udp_gc_timer.cancel(ec);
+#endif
if (ec) {
output_debug_info_ec(ec);
}
--- a/src/core/utils.cpp
+++ b/src/core/utils.cpp
@@ -59,8 +59,13 @@ size_t streambuf_append(
return 0;
}
+#if BOOST_VERSION >= 108700
+ auto* dest = static_cast<uint8_t*>(target.prepare(n).data());
+ const auto* src = static_cast<const uint8_t*>(append_buf.data().data()) + start;
+#else
auto* dest = boost::asio::buffer_cast<uint8_t*>(target.prepare(n));
const auto* src = boost::asio::buffer_cast<const uint8_t*>(append_buf.data()) + start;
+#endif
memcpy(dest, src, n);
target.commit(n);
return n;
@@ -102,7 +107,11 @@ size_t streambuf_append(boost::asio::str
size_t streambuf_append(boost::asio::streambuf& target, char append_char) {
_guard;
const size_t char_length = sizeof(char);
+#if BOOST_VERSION >= 108700
+ auto cp = gsl::span<char>(static_cast<char*>(target.prepare(char_length).data()), char_length);
+#else
auto cp = gsl::span<char>(boost::asio::buffer_cast<char*>(target.prepare(char_length)), char_length);
+#endif
cp[0] = append_char;
target.commit(char_length);
return char_length;
@@ -137,7 +146,11 @@ size_t streambuf_append(boost::asio::str
std::string_view streambuf_to_string_view(const boost::asio::streambuf& target) {
_guard;
+#if BOOST_VERSION >= 108700
+ return std::string_view(static_cast<const char*>(target.data().data()), target.size());
+#else
return std::string_view(boost::asio::buffer_cast<const char*>(target.data()), target.size());
+#endif
_unguard;
}
@@ -0,0 +1,52 @@
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -184,26 +184,45 @@ endif()
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
if (ANDROID)
- set(ANDROID_MY_LIBS ${PROJECT_SOURCE_DIR}/trojan-plus-android-libs)
+ set(ANDROID_MY_LIBS ${PROJECT_SOURCE_DIR}/trojan-plus-android-libs)
+
+ find_path(BOOST_INCLUDE_DIR
+ NAMES boost/version.hpp
+ HINTS ${ANDROID_MY_LIBS}/include
+ )
+
set(ANDROID_MY_LIBS_LIBRARIES
${ANDROID_MY_LIBS}/lib/${ANDROID_ABI}/libssl.a
${ANDROID_MY_LIBS}/lib/${ANDROID_ABI}/libcrypto.a
- ${ANDROID_MY_LIBS}/lib/${ANDROID_ABI}/libboost_system.a
${ANDROID_MY_LIBS}/lib/${ANDROID_ABI}/libboost_program_options.a)
+ if(BOOST_INCLUDE_DIR)
+ file(STRINGS "${BOOST_INCLUDE_DIR}/boost/version.hpp" BOOST_VERSION_LINE REGEX "^#define BOOST_VERSION ")
+ string(REGEX REPLACE "^#define BOOST_VERSION ([0-9]+)" "\\1" BOOST_VERSION ${BOOST_VERSION_LINE})
+
+ if(${BOOST_VERSION} VERSION_LESS 108900)
+ list(APPEND ANDROID_MY_LIBS_LIBRARIES ${ANDROID_MY_LIBS}/lib/${ANDROID_ABI}/libboost_system.a)
+ endif()
+ endif()
+
set(OPENSSL_VERSION 1.1.1)
include_directories(${ANDROID_MY_LIBS}/include)
target_link_libraries(trojan ${ANDROID_MY_LIBS_LIBRARIES})
else()
- find_package(Boost 1.66.0 REQUIRED COMPONENTS system program_options)
+ find_package(Boost 1.66.0 REQUIRED)
+ if (Boost_MAJOR_VERSION LESS_EQUAL 1 AND Boost_MINOR_VERSION LESS 89)
+ find_package(Boost 1.66.0 REQUIRED COMPONENTS system program_options)
+ else()
+ find_package(Boost 1.66.0 REQUIRED COMPONENTS program_options)
+ endif()
include_directories(${Boost_INCLUDE_DIR})
target_link_libraries(trojan ${Boost_LIBRARIES})
if(MSVC)
add_definitions(-DBOOST_DATE_TIME_NO_LIB)
endif()
- find_package(OpenSSL 1.1.0 REQUIRED)
+ find_package(OpenSSL 1.1.1 REQUIRED)
include_directories(${OPENSSL_INCLUDE_DIR})
target_link_libraries(trojan ${OPENSSL_LIBRARIES})
endif()