diff --git a/iocore/aio/CMakeLists.txt b/iocore/aio/CMakeLists.txt index c6e7df6f7bf..df24884c6dc 100644 --- a/iocore/aio/CMakeLists.txt +++ b/iocore/aio/CMakeLists.txt @@ -17,5 +17,9 @@ add_library(aio STATIC) +add_library(ts::aio ALIAS aio) + target_sources(aio PRIVATE AIO.cc Inline.cc) target_include_directories(aio PRIVATE ${CMAKE_SOURCE_DIR}/iocore/eventsystem ${CMAKE_SOURCE_DIR}/iocore/io_uring) + +target_link_libraries(aio PUBLIC ts::tscore) diff --git a/iocore/cache/CMakeLists.txt b/iocore/cache/CMakeLists.txt index fd47f624aae..ed12d9ebccc 100644 --- a/iocore/cache/CMakeLists.txt +++ b/iocore/cache/CMakeLists.txt @@ -31,13 +31,12 @@ add_library(inkcache STATIC RamCacheLRU.cc Store.cc ) +add_library(ts::inkcache ALIAS inkcache) + if(BUILD_REGRESSION_TESTING) target_sources(inkcache PRIVATE CacheTest.cc) endif() -target_link_libraries(inkcache PRIVATE ZLIB::ZLIB) -if(HAVE_LZMA_H) - target_link_libraries(inkcache PRIVATE LibLZMA::LibLZMA) -endif() + target_include_directories(inkcache PRIVATE ${CMAKE_SOURCE_DIR}/iocore/eventsystem ${CMAKE_SOURCE_DIR}/iocore/io_uring @@ -52,3 +51,15 @@ target_include_directories(inkcache PRIVATE ${CMAKE_SOURCE_DIR}/proxy/hdrs ${CMAKE_SOURCE_DIR}/lib ) + +target_link_libraries(inkcache + PUBLIC + ts::tscore + PRIVATE + fastlz + ZLIB::ZLIB +) + +if(HAVE_LZMA_H) + target_link_libraries(inkcache PRIVATE LibLZMA::LibLZMA) +endif() diff --git a/iocore/dns/CMakeLists.txt b/iocore/dns/CMakeLists.txt index 44e3b6ec7aa..96b8793e9b4 100644 --- a/iocore/dns/CMakeLists.txt +++ b/iocore/dns/CMakeLists.txt @@ -22,6 +22,8 @@ add_library(inkdns STATIC Inline.cc SplitDNS.cc ) +add_library(ts::inkdns ALIAS inkdns) + target_include_directories(inkdns PRIVATE ${CMAKE_SOURCE_DIR}/iocore/eventsystem ${CMAKE_SOURCE_DIR}/iocore/dns @@ -34,3 +36,5 @@ target_include_directories(inkdns PRIVATE ${CMAKE_SOURCE_DIR}/proxy/http ${CMAKE_SOURCE_DIR}/proxy/hdrs ) + +target_link_libraries(inkdns PUBLIC ts::tscore) diff --git a/iocore/hostdb/CMakeLists.txt b/iocore/hostdb/CMakeLists.txt index 42378d68bdc..b0cb7ae2d59 100644 --- a/iocore/hostdb/CMakeLists.txt +++ b/iocore/hostdb/CMakeLists.txt @@ -23,6 +23,8 @@ add_library(inkhostdb STATIC HostFile.cc HostDBInfo.cc ) +add_library(ts::inkhostdb ALIAS inkhostdb) + target_include_directories(inkhostdb PRIVATE ${CMAKE_SOURCE_DIR}/iocore/eventsystem ${CMAKE_SOURCE_DIR}/iocore/io_uring @@ -35,3 +37,5 @@ target_include_directories(inkhostdb PRIVATE ${CMAKE_SOURCE_DIR}/proxy/http ${CMAKE_SOURCE_DIR}/proxy/hdrs ) + +target_link_libraries(inkhostdb PUBLIC ts::tscore) diff --git a/iocore/hostdb/test_HostFile.cc b/iocore/hostdb/test_HostFile.cc index a28cba83992..1f8cfe72156 100644 --- a/iocore/hostdb/test_HostFile.cc +++ b/iocore/hostdb/test_HostFile.cc @@ -175,4 +175,5 @@ HostDBRecord::alloc(swoc::TextView query_name, unsigned int rr_count, size_t srv void HostDBRecord::free() { + delete this; } diff --git a/iocore/io_uring/CMakeLists.txt b/iocore/io_uring/CMakeLists.txt index 223ed949a5b..d83801404a4 100644 --- a/iocore/io_uring/CMakeLists.txt +++ b/iocore/io_uring/CMakeLists.txt @@ -31,10 +31,11 @@ include_directories( add_executable(test_iouring unit_tests/test_diskIO.cc) target_link_libraries(test_iouring + PUBLIC + ts::tscore PRIVATE inkuring libswoc - ts::tscore tscpputil uring ) diff --git a/iocore/net/CMakeLists.txt b/iocore/net/CMakeLists.txt index a3fbb97168d..e6256cfe35b 100644 --- a/iocore/net/CMakeLists.txt +++ b/iocore/net/CMakeLists.txt @@ -30,6 +30,7 @@ add_library(inknet STATIC NetVCOptions.cc NetVConnection.cc PollCont.cc + PreWarmManager.cc ProxyProtocol.cc Socks.cc SSLCertLookup.cc @@ -97,7 +98,7 @@ if(BUILD_REGRESSION_TESTING) target_sources(inknet PRIVATE NetVCTest.cc) endif() -target_link_libraries(inknet PUBLIC inkevent records) + target_compile_options(inknet PUBLIC -Wno-deprecated-declarations) target_include_directories(inknet PUBLIC ${CMAKE_SOURCE_DIR}/iocore/eventsystem @@ -117,6 +118,13 @@ target_include_directories(inknet PUBLIC ${YAML_INCLUDE_DIRS} ) +target_link_libraries(inknet + PUBLIC + ts::inkevent + ts::records + ts::tscore +) + # Fails to link because of circular dep with proxy (ParentSelection) # add_executable(test_net unit_tests/test_ProxyProtocol.cc) # target_link_libraries(test_net records_p inknet inkevent tscore yaml-cpp libswoc) diff --git a/iocore/net/Makefile.am b/iocore/net/Makefile.am index edc95af8425..929dc79a864 100644 --- a/iocore/net/Makefile.am +++ b/iocore/net/Makefile.am @@ -195,6 +195,7 @@ libinknet_a_SOURCES = \ P_UnixUDPConnection.h \ PollCont.h \ PollCont.cc \ + PreWarmManager.cc \ ProxyProtocol.h \ ProxyProtocol.cc \ Socks.cc \ diff --git a/iocore/net/P_SNIActionPerformer.h b/iocore/net/P_SNIActionPerformer.h index dde481c3a31..a3abb8200ab 100644 --- a/iocore/net/P_SNIActionPerformer.h +++ b/iocore/net/P_SNIActionPerformer.h @@ -453,7 +453,12 @@ class OutboundSNIPolicy : public ActionItem class ServerMaxEarlyData : public ActionItem { public: - ServerMaxEarlyData(uint32_t value) : server_max_early_data(value) {} + ServerMaxEarlyData(uint32_t value) +#if TS_HAS_TLS_EARLY_DATA + : server_max_early_data(value) +#endif + { + } ~ServerMaxEarlyData() override {} int @@ -472,6 +477,8 @@ class ServerMaxEarlyData : public ActionItem return SSL_TLSEXT_ERR_OK; } +#if TS_HAS_TLS_EARLY_DATA private: uint32_t server_max_early_data = 0; +#endif }; diff --git a/proxy/http/PreWarmManager.cc b/iocore/net/PreWarmManager.cc similarity index 100% rename from proxy/http/PreWarmManager.cc rename to iocore/net/PreWarmManager.cc diff --git a/proxy/http/PreWarmManager.h b/iocore/net/PreWarmManager.h similarity index 100% rename from proxy/http/PreWarmManager.h rename to iocore/net/PreWarmManager.h diff --git a/iocore/net/TLSTunnelSupport.cc b/iocore/net/TLSTunnelSupport.cc index fd632ebc076..1ae0bd391bd 100644 --- a/iocore/net/TLSTunnelSupport.cc +++ b/iocore/net/TLSTunnelSupport.cc @@ -22,12 +22,16 @@ limitations under the License. */ +#include "SSLTypes.h" +#include "PreWarmManager.h" #include "TLSTunnelSupport.h" #include "tscore/ink_assert.h" #include "tscore/Diags.h" #include "swoc/IPEndpoint.h" +#include + int TLSTunnelSupport::_ex_data_index = -1; void @@ -77,3 +81,10 @@ TLSTunnelSupport::set_tunnel_destination(const std::string_view &destination, SN Warning("Invalid destination \"%.*s\" in SNI configuration.", int(destination.size()), destination.data()); } } + +PreWarm::SPtrConstDst +TLSTunnelSupport::create_dst(int pid) const +{ + return std::make_shared(get_tunnel_host(), get_tunnel_port(), + is_upstream_tls() ? SNIRoutingType::PARTIAL_BLIND : SNIRoutingType::FORWARD, pid); +} diff --git a/iocore/net/TLSTunnelSupport.h b/iocore/net/TLSTunnelSupport.h index d2807cdcf33..813334ba35b 100644 --- a/iocore/net/TLSTunnelSupport.h +++ b/iocore/net/TLSTunnelSupport.h @@ -25,6 +25,8 @@ #pragma once #include + +#include "PreWarmManager.h" #include "tscore/ink_memory.h" #include "tscore/ink_inet.h" #include "YamlSNIConfig.h" @@ -54,6 +56,8 @@ class TLSTunnelSupport YamlSNIConfig::TunnelPreWarm prewarm); YamlSNIConfig::TunnelPreWarm get_tunnel_prewarm_configuration() const; + PreWarm::SPtrConstDst create_dst(int pid) const; + protected: void _clear(); diff --git a/iocore/utils/CMakeLists.txt b/iocore/utils/CMakeLists.txt index 87840d4ed99..69c4f6e8738 100644 --- a/iocore/utils/CMakeLists.txt +++ b/iocore/utils/CMakeLists.txt @@ -31,3 +31,5 @@ target_include_directories(inkutils PRIVATE ${CMAKE_SOURCE_DIR}/proxy/http ${CMAKE_SOURCE_DIR}/proxy/hdrs ) + +target_link_libraries(inkutils PUBLIC ts::tscore) diff --git a/mgmt/config/CMakeLists.txt b/mgmt/config/CMakeLists.txt index ddc08687d66..26b2307179c 100644 --- a/mgmt/config/CMakeLists.txt +++ b/mgmt/config/CMakeLists.txt @@ -19,10 +19,14 @@ add_library(configmanager STATIC FileManager.cc AddConfigFilesHere.cc ) +add_library(ts::configmanager ALIAS configmanager) + include_directories( ${CMAKE_SOURCE_DIR}/mgmt ${CMAKE_SOURCE_DIR}/proxy ${CMAKE_SOURCE_DIR}/proxy/hdrs ${CMAKE_SOURCE_DIR}/proxy/http ${IOCORE_INCLUDE_DIRS} -) \ No newline at end of file +) + +target_link_libraries(configmanager PUBLIC ts::tscore) diff --git a/mgmt/rpc/CMakeLists.txt b/mgmt/rpc/CMakeLists.txt index 9e9aee25dec..e992a797966 100644 --- a/mgmt/rpc/CMakeLists.txt +++ b/mgmt/rpc/CMakeLists.txt @@ -31,6 +31,9 @@ add_library(jsonrpc_protocol STATIC jsonrpc/JsonRPCManager.cc jsonrpc/Context.cc ) +add_library(ts::jsonrpc_protocol ALIAS jsonrpc_protocol) + +target_link_libraries(jsonrpc_protocol PUBLIC ts::tscore) add_library(jsonrpc_server STATIC server/RPCServer.cc @@ -38,6 +41,9 @@ add_library(jsonrpc_server STATIC server/IPCSocketServer.cc config/JsonRPCConfig.cc ) +add_library(ts::jsonrpc_server ALIAS jsonrpc_server) + +target_link_libraries(jsonrpc_server PUBLIC ts::tscore) add_library(rpcpublichandlers STATIC handlers/common/RecordsUtils.cc @@ -47,3 +53,6 @@ add_library(rpcpublichandlers STATIC handlers/server/Server.cc handlers/plugins/Plugins.cc ) +add_library(ts::rpcpublichandlers ALIAS rpcpublichandlers) + +target_link_libraries(rpcpublichandlers PUBLIC ts::tscore) diff --git a/plugins/CMakeLists.txt b/plugins/CMakeLists.txt index d7f635bed45..4bdc856c442 100644 --- a/plugins/CMakeLists.txt +++ b/plugins/CMakeLists.txt @@ -22,7 +22,6 @@ function(add_atsplugin name) target_link_libraries(${name} PRIVATE traffic_server) set_target_properties(${name} PROPERTIES PREFIX "") set_target_properties(${name} PROPERTIES SUFFIX ".so") - set_target_properties(${name} PROPERTIES LINK_FLAGS "-Wl,-rpath,${CMAKE_INSTALL_PREFIX}/lib") install(TARGETS ${name} DESTINATION libexec/trafficserver) endfunction() diff --git a/plugins/experimental/slice/CMakeLists.txt b/plugins/experimental/slice/CMakeLists.txt index 26ec4be731b..60d1406d79c 100644 --- a/plugins/experimental/slice/CMakeLists.txt +++ b/plugins/experimental/slice/CMakeLists.txt @@ -32,7 +32,7 @@ add_atsplugin(slice util.cc ) -target_link_libraries(access_control PRIVATE PCRE::PCRE) +target_link_libraries(slice PRIVATE ts::tscore) if(BUILD_TESTING) add_subdirectory(unit-tests) diff --git a/plugins/header_rewrite/conditions.cc b/plugins/header_rewrite/conditions.cc index 91dbf228ff1..d44a2cee262 100644 --- a/plugins/header_rewrite/conditions.cc +++ b/plugins/header_rewrite/conditions.cc @@ -90,6 +90,8 @@ ConditionMethod::initialize(Parser &p) match->set(p.get_arg()); _matcher = match; + + require_resources(RSRC_CLIENT_REQUEST_HEADERS); } bool diff --git a/plugins/s3_auth/CMakeLists.txt b/plugins/s3_auth/CMakeLists.txt index e60d827c309..b0b797e7114 100644 --- a/plugins/s3_auth/CMakeLists.txt +++ b/plugins/s3_auth/CMakeLists.txt @@ -19,4 +19,6 @@ project(s3_auth) add_atsplugin(s3_auth s3_auth.cc aws_auth_v4.cc) +target_link_libraries(s3_auth PRIVATE ts::tscore) + add_subdirectory(unit_tests) diff --git a/proxy/CMakeLists.txt b/proxy/CMakeLists.txt index 6406c4e31fd..2b7f1ddecf0 100644 --- a/proxy/CMakeLists.txt +++ b/proxy/CMakeLists.txt @@ -58,6 +58,8 @@ target_include_directories(proxy PUBLIC ${CMAKE_SOURCE_DIR}/lib/yamlcpp/include ) +target_link_libraries(proxy PUBLIC ts::tscore) + add_subdirectory(hdrs) add_subdirectory(shared) add_subdirectory(http) diff --git a/proxy/http/CMakeLists.txt b/proxy/http/CMakeLists.txt index 5f919ceb23c..ec2a6d2121e 100644 --- a/proxy/http/CMakeLists.txt +++ b/proxy/http/CMakeLists.txt @@ -39,7 +39,6 @@ add_library(http STATIC ConnectingEntry.cc ForwardedConfig.cc PreWarmConfig.cc - PreWarmManager.cc ) add_library(ts::http ALIAS http) @@ -56,6 +55,8 @@ target_include_directories(http ${YAMLCPP_INCLUDE_DIR} ) +target_link_libraries(http PUBLIC ts::tscore) + if(TS_USE_QUIC) target_link_libraries(http PRIVATE ts::http3) endif() diff --git a/proxy/http/HttpSM.cc b/proxy/http/HttpSM.cc index 6abdcd98d90..879738f59d1 100644 --- a/proxy/http/HttpSM.cc +++ b/proxy/http/HttpSM.cc @@ -37,7 +37,6 @@ #include "P_Cache.h" #include "P_Net.h" #include "PreWarmConfig.h" -#include "PreWarmManager.h" #include "StatPages.h" #include "Log.h" #include "LogAccess.h" @@ -5185,6 +5184,54 @@ HttpSM::ip_allow_deny_request(const IpAllow::ACL &acl) call_transact_and_set_next_state(HttpTransact::Forbidden); } +bool +HttpSM::grab_pre_warmed_net_v_connection_if_possible(const TLSTunnelSupport &tts, int pid) +{ + bool result{false}; + + if (is_prewarm_enabled_or_sni_overridden(tts)) { + EThread *ethread = this_ethread(); + _prewarm_sm = ethread->prewarm_queue->dequeue(tts.create_dst(pid)); + + if (_prewarm_sm != nullptr) { + open_prewarmed_connection(); + result = true; + } else { + SMDebug("http_ss", "no pre-warmed tunnel"); + } + } + + return result; +} + +bool +HttpSM::is_prewarm_enabled_or_sni_overridden(const TLSTunnelSupport &tts) const +{ + PreWarmConfig::scoped_config prewarm_conf; + bool result = prewarm_conf->enabled; + + if (YamlSNIConfig::TunnelPreWarm sni_use_prewarm = tts.get_tunnel_prewarm_configuration(); + sni_use_prewarm != YamlSNIConfig::TunnelPreWarm::UNSET) { + result = static_cast(sni_use_prewarm); + } + + return result; +} + +void +HttpSM::open_prewarmed_connection() +{ + NetVConnection *netvc = _prewarm_sm->move_netvc(); + ink_release_assert(_prewarm_sm->handler == &PreWarmSM::state_closed); + + SMDebug("http_ss", "using pre-warmed tunnel netvc=%p", netvc); + + t_state.current.retry_attempts.clear(); + + ink_release_assert(default_handler == HttpSM::default_handler); + handleEvent(NET_EVENT_OPEN, netvc); +} + ////////////////////////////////////////////////////////////////////////// // // HttpSM::do_http_server_open() @@ -5466,40 +5513,8 @@ HttpSM::do_http_server_open(bool raw, bool only_direct) } } - // - // Grab pre-warmed NetVConnection if possible - // - PreWarmConfig::scoped_config prewarm_conf; - bool use_prewarm = prewarm_conf->enabled; - - // override "proxy.config.tunnel.prewarm" by "tunnel_prewarm" in sni.yaml - if (YamlSNIConfig::TunnelPreWarm sni_use_prewarm = tts->get_tunnel_prewarm_configuration(); - sni_use_prewarm != YamlSNIConfig::TunnelPreWarm::UNSET) { - use_prewarm = static_cast(sni_use_prewarm); - } - - if (use_prewarm) { - // TODO: avoid copy of string -> make map key std::variant - PreWarm::SPtrConstDst dst = - std::make_shared(tts->get_tunnel_host(), tts->get_tunnel_port(), - tls_upstream ? SNIRoutingType::PARTIAL_BLIND : SNIRoutingType::FORWARD, pid); - - EThread *ethread = this_ethread(); - _prewarm_sm = ethread->prewarm_queue->dequeue(dst); - - if (_prewarm_sm != nullptr) { - NetVConnection *netvc = _prewarm_sm->move_netvc(); - ink_release_assert(_prewarm_sm->handler == &PreWarmSM::state_closed); - - SMDebug("http_ss", "using pre-warmed tunnel netvc=%p", netvc); - - t_state.current.retry_attempts.clear(); - - ink_release_assert(default_handler == HttpSM::default_handler); - handleEvent(NET_EVENT_OPEN, netvc); - return; - } - SMDebug("http_ss", "no pre-warmed tunnel"); + if (grab_pre_warmed_net_v_connection_if_possible(*tts, pid)) { + return; } } opt.local_port = _ua.get_txn()->get_outbound_port(); diff --git a/proxy/http/HttpSM.h b/proxy/http/HttpSM.h index 63eaafc33ab..883a0ad300c 100644 --- a/proxy/http/HttpSM.h +++ b/proxy/http/HttpSM.h @@ -34,6 +34,7 @@ #include #include +#include "TLSTunnelSupport.h" #include "tscore/ink_platform.h" #include "I_EventSystem.h" #include "HttpCacheSM.h" @@ -390,6 +391,9 @@ class HttpSM : public Continuation, public PluginUserArgs bool apply_ip_allow_filter(); bool ip_allow_is_request_forbidden(const IpAllow::ACL &acl); void ip_allow_deny_request(const IpAllow::ACL &acl); + bool grab_pre_warmed_net_v_connection_if_possible(const TLSTunnelSupport &tts, int pid); + bool is_prewarm_enabled_or_sni_overridden(const TLSTunnelSupport &tts) const; + void open_prewarmed_connection(); void send_origin_throttled_response(); void do_setup_post_tunnel(HttpVC_t to_vc_type); void do_cache_prepare_write(); diff --git a/proxy/http/Makefile.am b/proxy/http/Makefile.am index 84d4d8e515e..ae6493d87fa 100644 --- a/proxy/http/Makefile.am +++ b/proxy/http/Makefile.am @@ -82,8 +82,7 @@ libhttp_a_SOURCES = \ HttpVCTable.cc \ HttpVCTable.h \ ForwardedConfig.cc \ - PreWarmConfig.cc \ - PreWarmManager.cc + PreWarmConfig.cc if BUILD_TESTS libhttp_a_SOURCES += RegressionHttpTransact.cc diff --git a/proxy/http/remap/CMakeLists.txt b/proxy/http/remap/CMakeLists.txt index 15b357f7d4c..0347de48b6e 100644 --- a/proxy/http/remap/CMakeLists.txt +++ b/proxy/http/remap/CMakeLists.txt @@ -34,9 +34,13 @@ add_library(http_remap STATIC UrlMappingPathIndex.cc UrlRewrite.cc ) +add_library(ts::http_remap ALIAS http_remap) + target_include_directories(http_remap PRIVATE ${IOCORE_INCLUDE_DIRS} ${PROXY_INCLUDE_DIRS} ${CMAKE_SOURCE_DIR}/src/records ${YAML_INCLUDE_DIRS} ) + +target_link_libraries(http_remap PUBLIC ts::tscore) diff --git a/proxy/http2/CMakeLists.txt b/proxy/http2/CMakeLists.txt index 464d7a50b31..c65f5fdc2f7 100644 --- a/proxy/http2/CMakeLists.txt +++ b/proxy/http2/CMakeLists.txt @@ -29,8 +29,12 @@ add_library(http2 STATIC Http2SessionAccept.cc Http2ServerSession.cc ) +add_library(ts::http2 ALIAS http2) + target_include_directories(http2 PRIVATE ${IOCORE_INCLUDE_DIRS} ${PROXY_INCLUDE_DIRS} ${YAMLCPP_INCLUDE_DIR} ) + +target_link_libraries(http2 PUBLIC ts::tscore) diff --git a/proxy/logging/CMakeLists.txt b/proxy/logging/CMakeLists.txt index cbe94e906fa..f5bee95318b 100644 --- a/proxy/logging/CMakeLists.txt +++ b/proxy/logging/CMakeLists.txt @@ -32,9 +32,13 @@ add_library(logging STATIC YamlLogConfig.cc YamlLogConfigDecoders.cc ) +add_library(ts::logging ALIAS logging) + target_include_directories(logging PRIVATE ${IOCORE_INCLUDE_DIRS} ${PROXY_INCLUDE_DIRS} ${YAML_INCLUDE_DIRS} ${SWOC_INCLUDE_DIR} ) + +target_link_libraries(logging PUBLIC ts::tscore) diff --git a/proxy/shared/CMakeLists.txt b/proxy/shared/CMakeLists.txt index 5e93f01a3f3..70b853e0d55 100644 --- a/proxy/shared/CMakeLists.txt +++ b/proxy/shared/CMakeLists.txt @@ -17,8 +17,12 @@ add_library(diagsconfig STATIC DiagsConfig.cc) +add_library(ts::diagsconfig ALIAS diagsconfig) + target_include_directories(diagsconfig PRIVATE ${IOCORE_INCLUDE_DIRS} ${PROXY_INCLUDE_DIRS} ${YAMLCPP_INCLUDE_DIR} ) + +target_link_libraries(diagsconfig PUBLIC ts::tscore) diff --git a/src/traffic_server/CMakeLists.txt b/src/traffic_server/CMakeLists.txt index 6152bfb4dce..390c8edefd3 100644 --- a/src/traffic_server/CMakeLists.txt +++ b/src/traffic_server/CMakeLists.txt @@ -34,30 +34,27 @@ target_include_directories(traffic_server PRIVATE ) target_link_libraries(traffic_server PRIVATE - tscore - http - http_remap - http2 - logging - hdrs - configmanager - diagsconfig - inkutils - inkdns - inkhostdb - inkcache - fastlz - aio - tscpputil - proxy - inknet - records - inkevent - yaml-cpp + ts::tscore + ts::http + ts::http_remap + ts::http2 + ts::logging + ts::hdrs + ts::configmanager + ts::diagsconfig + ts::inkutils + ts::inkdns + ts::inkhostdb + ts::inkcache + ts::aio + ts::proxy + ts::inknet + ts::records + ts::inkevent libswoc - jsonrpc_protocol - jsonrpc_server - rpcpublichandlers + ts::jsonrpc_protocol + ts::jsonrpc_server + ts::rpcpublichandlers ) if(TS_USE_QUIC) diff --git a/src/tscore/CMakeLists.txt b/src/tscore/CMakeLists.txt index 76aea94365b..a6219108dd5 100644 --- a/src/tscore/CMakeLists.txt +++ b/src/tscore/CMakeLists.txt @@ -115,11 +115,12 @@ else() target_sources(tscore PRIVATE HKDF_openssl.cc) endif() +target_link_libraries(tscore PUBLIC PCRE::PCRE) if(TS_USE_POSIX_CAP) target_link_libraries(tscore PUBLIC cap::cap) endif() -add_dependencies(tscore ParseRules tscpputil) +add_dependencies(tscore ParseRules) target_include_directories(tscore PRIVATE ${CMAKE_CURRENT_BINARY_DIR} ${YAML_INCLUDE_DIRS} @@ -167,7 +168,6 @@ target_link_libraries(test_tscore yaml-cpp::yaml-cpp libswoc ${OPENSSL_LIBRARIES} - PCRE::PCRE resolv tscpputil ) diff --git a/src/tscore/Regex.cc b/src/tscore/Regex.cc index e8195f0de28..22bb2e1c9ec 100644 --- a/src/tscore/Regex.cc +++ b/src/tscore/Regex.cc @@ -55,10 +55,10 @@ Regex::Regex(Regex &&that) noexcept : regex(that.regex), regex_extra(that.regex_ bool Regex::compile(const char *pattern, const unsigned flags) { - const char *error; - int erroffset; - int options = 0; - int study_opts = 0; + const char *error = nullptr; + int erroffset = 0; + int options = 0; + int study_opts = 0; if (regex) { return false; diff --git a/src/tscpp/api/CMakeLists.txt b/src/tscpp/api/CMakeLists.txt index c31a876bf50..9142712cdbe 100644 --- a/src/tscpp/api/CMakeLists.txt +++ b/src/tscpp/api/CMakeLists.txt @@ -45,5 +45,10 @@ add_library(ts::tscppapi ALIAS tscppapi) target_link_libraries(tscppapi PUBLIC libswoc - yaml-cpp::yaml-cpp) + yaml-cpp::yaml-cpp +) install(TARGETS tscppapi) + +if(APPLE) + target_link_options(tscppapi PRIVATE -undefined dynamic_lookup) +endif() diff --git a/src/tscpp/util/CMakeLists.txt b/src/tscpp/util/CMakeLists.txt index d752b48e7ca..26d66a095aa 100644 --- a/src/tscpp/util/CMakeLists.txt +++ b/src/tscpp/util/CMakeLists.txt @@ -25,7 +25,9 @@ add_library(ts::tscpputil ALIAS tscpputil) target_link_libraries(tscpputil PUBLIC libswoc - yaml-cpp::yaml-cpp) + yaml-cpp::yaml-cpp + ts::tscore +) install(TARGETS tscpputil) add_executable(test_tscpputil diff --git a/tests/gold_tests/pluginTest/header_rewrite/gold/header_rewrite_cond_method.gold b/tests/gold_tests/pluginTest/header_rewrite/gold/header_rewrite_cond_method.gold new file mode 100644 index 00000000000..3fb44fbfe33 --- /dev/null +++ b/tests/gold_tests/pluginTest/header_rewrite/gold/header_rewrite_cond_method.gold @@ -0,0 +1,8 @@ +`` +> `` http://www.example.com/ HTTP/1.1 +> Host: www.example.com +`` +< HTTP/1.1 200 OK +`` +< Via:`` +`` diff --git a/tests/gold_tests/pluginTest/header_rewrite/header_rewrite_cond_method.test.py b/tests/gold_tests/pluginTest/header_rewrite/header_rewrite_cond_method.test.py new file mode 100644 index 00000000000..2e6ae69f37e --- /dev/null +++ b/tests/gold_tests/pluginTest/header_rewrite/header_rewrite_cond_method.test.py @@ -0,0 +1,73 @@ +''' +''' +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +Test.Summary = ''' +Test header_rewrite with METHOD conditions and operators. +''' + +Test.ContinueOnFail = True +# Define default ATS +ts = Test.MakeATSProcess("ts") +server = Test.MakeOriginServer("server") + +Test.testName = "header_rewrite_method_condition" +request_get = {"headers": "GET / HTTP/1.1\r\nHost: www.example.com\r\n\r\n", "timestamp": "1469733493.993", "body": ""} +request_delete = {"headers": "DELETE / HTTP/1.1\r\nHost: www.example.com\r\n\r\n", "timestamp": "1469733493.993", "body": ""} +# expected response from the origin server +response = {"headers": "HTTP/1.1 200 OK\r\nConnection: close\r\n\r\n", "timestamp": "1469733493.993", "body": ""} + +# add response to the server dictionary +session_file = "sessionfile.log" +server.addResponse(session_file, request_get, response) +server.addResponse(session_file, request_delete, response) +ts.Disk.records_config.update({ + 'proxy.config.diags.debug.enabled': 1, + 'proxy.config.diags.debug.tags': 'header.*', + 'proxy.config.http.insert_response_via_str': 0, +}) +# The following rule inserts a via header if the request method is a GET or DELETE +conf_name = "rule_cond_method.conf" +ts.Setup.CopyAs('rules/{0}'.format(conf_name), Test.RunDirectory) +ts.Disk.plugin_config.AddLine( + 'header_rewrite.so {0}/{1}'.format(Test.RunDirectory, conf_name) +) +ts.Disk.remap_config.AddLine( + 'map http://www.example.com http://127.0.0.1:{0}'.format(server.Variables.Port) +) + +# Test method in READ_REQUEST_HDR_HOOK. +expected_output = "gold/header_rewrite_cond_method.gold" +expected_log = "gold/header_rewrite-tag.gold" +tr = Test.AddTestRun() +tr.Processes.Default.Command = 'curl --proxy 127.0.0.1:{0} "http://www.example.com" -H "Proxy-Connection: keep-alive" --verbose'.format( + ts.Variables.port) +tr.Processes.Default.ReturnCode = 0 +tr.Processes.Default.StartBefore(server, ready=When.PortOpen(server.Variables.Port)) +tr.Processes.Default.StartBefore(Test.Processes.ts) +tr.Processes.Default.Streams.stderr = expected_output +tr.StillRunningAfter = server +ts.Disk.traffic_out.Content = expected_log + +# Test method in SEND_REQUEST_HDR_HOOK. +tr = Test.AddTestRun() +tr.Processes.Default.Command = 'curl --request DELETE --proxy 127.0.0.1:{0} "http://www.example.com" -H "Proxy-Connection: keep-alive" --verbose'.format( + ts.Variables.port) +tr.Processes.Default.ReturnCode = 0 +tr.Processes.Default.Streams.stderr = expected_output +tr.StillRunningAfter = server +ts.Disk.traffic_out.Content = expected_log diff --git a/tests/gold_tests/pluginTest/header_rewrite/rules/rule_cond_method.conf b/tests/gold_tests/pluginTest/header_rewrite/rules/rule_cond_method.conf new file mode 100644 index 00000000000..deb77ab5399 --- /dev/null +++ b/tests/gold_tests/pluginTest/header_rewrite/rules/rule_cond_method.conf @@ -0,0 +1,24 @@ +# +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +cond %{READ_REQUEST_HDR_HOOK} +cond %{METHOD} =GET +set-config proxy.config.http.insert_response_via_str 1 [L] + +cond %{SEND_REQUEST_HDR_HOOK} +cond %{METHOD} =DELETE +set-config proxy.config.http.insert_response_via_str 1 [L]