Skip to content

Commit

Permalink
paozhu update
Browse files Browse the repository at this point in the history
  • Loading branch information
hggq committed Jan 1, 2025
1 parent a36983e commit 57dfce0
Show file tree
Hide file tree
Showing 22 changed files with 5,796 additions and 39 deletions.
43 changes: 30 additions & 13 deletions frameworks/C++/paozhu/paozhu.dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -20,23 +20,40 @@ RUN git clone https://github.com/hggq/paozhu
# RUN unzip benchmark.zip
RUN rm -Rf ./paozhu/controller
RUN rm -Rf ./paozhu/libs
RUN mkdir ./paozhu/libs
RUN mkdir ./paozhu/libs/types
RUN rm -Rf ./paozhu/view
RUN rm -Rf ./paozhu/viewsrc
RUN rm -Rf ./paozhu/orm
RUN rm -Rf ./paozhu/models
RUN rm -Rf ./paozhu/common

RUN mkdir ./paozhu/controller
RUN mkdir ./paozhu/controller/include
RUN mkdir ./paozhu/controller/src

COPY ./paozhu_benchmark/controller/include/techempower.h ./paozhu/controller/include/
COPY ./paozhu_benchmark/controller/src/techempower.cpp ./paozhu/controller/src/
COPY ./paozhu_benchmark/controller ./paozhu/
COPY ./paozhu_benchmark/libs ./paozhu/
COPY ./paozhu_benchmark/view ./paozhu/
COPY ./paozhu_benchmark/viewsrc ./paozhu/

COPY ./paozhu_benchmark/libs/types/techempower_json.h ./paozhu/libs/types/
COPY ./paozhu_benchmark/libs/types/techempower_json_jsonreflect.cpp ./paozhu/libs/types/
COPY ./paozhu_benchmark/orm ./paozhu/
COPY ./paozhu_benchmark/models ./paozhu/
COPY ./paozhu_benchmark/common ./paozhu/

COPY ./paozhu_benchmark/common/autocontrolmethod.hpp ./paozhu/common/
COPY ./paozhu_benchmark/common/reghttpmethod_pre.hpp ./paozhu/common/
COPY ./paozhu_benchmark/common/reghttpmethod.hpp ./paozhu/common/
COPY ./paozhu_benchmark/common/json_reflect_headers.h ./paozhu/common/

# RUN mkdir ./paozhu/libs
# RUN mkdir ./paozhu/libs/types

# RUN mkdir ./paozhu/controller
# RUN mkdir ./paozhu/controller/include
# RUN mkdir ./paozhu/controller/src

# COPY ./paozhu_benchmark/controller/include/techempower.h ./paozhu/controller/include/
# COPY ./paozhu_benchmark/controller/src/techempower.cpp ./paozhu/controller/src/

# COPY ./paozhu_benchmark/libs/types/techempower_json.h ./paozhu/libs/types/
# COPY ./paozhu_benchmark/libs/types/techempower_json_jsonreflect.cpp ./paozhu/libs/types/

# COPY ./paozhu_benchmark/common/autocontrolmethod.hpp ./paozhu/common/
# COPY ./paozhu_benchmark/common/reghttpmethod_pre.hpp ./paozhu/common/
# COPY ./paozhu_benchmark/common/reghttpmethod.hpp ./paozhu/common/
# COPY ./paozhu_benchmark/common/json_reflect_headers.h ./paozhu/common/

COPY ./paozhu_benchmark/conf/server.conf ./paozhu/conf/server.conf
COPY ./paozhu_benchmark/conf/orm.conf ./paozhu/conf/orm.conf
Expand Down
145 changes: 121 additions & 24 deletions frameworks/C++/paozhu/paozhu_benchmark/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -117,13 +117,11 @@ include_directories(${CMAKE_CURRENT_SOURCE_DIR}/viewsrc/include)
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/websockets/include)
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/include)

if (EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/bin/paozhu_empty)
file(REMOVE_RECURSE ${CMAKE_CURRENT_SOURCE_DIR}/bin/paozhu_empty)
endif ()
#EXECUTE_PROCESS(COMMAND rm ${CMAKE_CURRENT_SOURCE_DIR}/bin/paozhu_empty)
if (EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/bin/paozhu_pre)
file(REMOVE_RECURSE ${CMAKE_CURRENT_SOURCE_DIR}/bin/paozhu_pre)
endif()
set(PAOZHU_PRE paozhu_pre)
add_executable(${PAOZHU_PRE} ${CMAKE_CURRENT_SOURCE_DIR}/vendor/httpcli/autopickmethod.cpp ${CMAKE_CURRENT_SOURCE_DIR}/vendor/httpserver/src/md5.cpp)
add_executable(paozhu_empty ${CMAKE_CURRENT_SOURCE_DIR}/vendor/httpcli/autoemptymethod.cpp)



Expand All @@ -138,6 +136,22 @@ file(GLOB_RECURSE src_list ${CMAKE_CURRENT_SOURCE_DIR}/src/*.cpp)

foreach(cppfile IN LISTS controller_list)
string(REGEX REPLACE "${CMAKE_CURRENT_SOURCE_DIR}/controller/src/" "" cppfilename ${cppfile})
string(FIND ${cppfilename} "/" strpos)
if(${strpos} GREATER_EQUAL "0" )
string(REGEX MATCHALL "([A-Za-z0-9._-]+)/" npaths ${cppfilename} )
set(fullpaths "")
string(APPEND fullpaths "${CMAKE_CURRENT_SOURCE_DIR}/controller/include/")
foreach(onepathname ${npaths})
string(REPLACE "/" "" toucpath ${onepathname})
string(APPEND fullpaths ${toucpath})
if (IS_DIRECTORY "${fullpaths}")
else()
message("mkdir ${fullpaths}")
file(MAKE_DIRECTORY "${fullpaths}")
endif()
string(APPEND fullpaths "/")
endforeach()
endif()
string(REGEX REPLACE ".cpp" "" cppbasename ${cppfilename})
# message(${cppbasename})
if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/controller/include/${cppbasename}.h")
Expand Down Expand Up @@ -175,21 +189,18 @@ set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/bin)


if(${mode} AND (CMAKE_BUILD_TYPE STREQUAL "Release"))
add_executable(paozhu ${CMAKE_CURRENT_SOURCE_DIR}/test/testbenchmark.cpp ${common_list} ${viewsrc_list} ${FRAMEWORK_CPP_PATH} ${orm_list} ${reflect_list} ${src_list} ${source_list} ${controller_list})
add_executable(paozhu ${CMAKE_CURRENT_SOURCE_DIR}/test/testdaemon.cpp ${common_list} ${viewsrc_list} ${FRAMEWORK_CPP_PATH} ${orm_list} ${reflect_list} ${src_list} ${source_list} ${controller_list})
else()
add_executable(paozhu ${CMAKE_CURRENT_SOURCE_DIR}/test/test.cpp ${common_list} ${viewsrc_list} ${FRAMEWORK_CPP_PATH} ${orm_list} ${reflect_list} ${src_list} ${source_list} ${controller_list})
endif()

if (ENABLE_WIN_VCPKG STREQUAL "ON")
else ()
else()
add_custom_command(
TARGET paozhu_empty paozhu
DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/bin/paozhu_pre
PRE_BUILD
TARGET paozhu_pre POST_BUILD
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/
COMMAND echo "-- controls method --"
COMMAND ${PAOZHU_PRE} ${CMAKE_CURRENT_SOURCE_DIR}/
COMMAND ${CMAKE_COMMAND} -E remove ${CMAKE_CURRENT_SOURCE_DIR}/bin/paozhu_empty
)
endif()

Expand Down Expand Up @@ -265,7 +276,7 @@ else ()

if(USE_STANDALONE_ASIO)
if(CMAKE_SYSTEM_NAME MATCHES "Darwin")
set(ASIO_PATH "/usr/local/opt/asio/include" "/usr/local/include")
set(ASIO_PATH "/usr/local/opt/asio/include" "/usr/local/include" "/opt/homebrew/opt/asio" ${CMAKE_CURRENT_SOURCE_DIR}/asio)
else()
set(ASIO_PATH ${CMAKE_CURRENT_SOURCE_DIR}/asio "/usr/include")
endif()
Expand Down Expand Up @@ -324,19 +335,54 @@ if(ZLIB_FOUND)
target_link_libraries(paozhu z)
endif()

find_path(MYSQL_ROOT_DIR mysql)

if(CMAKE_SYSTEM_NAME MATCHES "Darwin")
if (IS_DIRECTORY "/usr/local/mysql/include")
MESSAGE( STATUS "/usr/local/mysql")
set(MYSQL_INCLUDE_DIR "/usr/local/mysql/include")
include_sub_directories_recursively(/usr/local/mysql/include)
endif()

if (IS_DIRECTORY "/usr/local/opt/mysql-client")
MESSAGE( STATUS "/usr/local/opt/mysql-client")
set(MYSQL_INCLUDE_DIR "/usr/local/opt/mysql-client/include")
include_sub_directories_recursively(/usr/local/opt/mysql-client/include)
endif()

if (IS_DIRECTORY "/opt/homebrew/opt/mysql")
MESSAGE( STATUS "/opt/homebrew/opt/mysql")
set(MYSQL_INCLUDE_DIR "/opt/homebrew/opt/mysql/include")
include_sub_directories_recursively(/opt/homebrew/opt/mysql/include)
endif()


if (IS_DIRECTORY "/opt/homebrew/opt/mysql-client")
MESSAGE( STATUS "/opt/homebrew/opt/mysql-client")
set(MYSQL_INCLUDE_DIR "/opt/homebrew/opt/mysql-client/include")
include_sub_directories_recursively(/opt/homebrew/opt/mysql-client/include)
endif()
MESSAGE( STATUS "MYSQL_ROOT_DIR = ${MYSQL_ROOT_DIR} ")
else()
find_path(MYSQL_ROOT_DIR mysql)
endif()


FIND_PATH(MYSQL_INCLUDE_DIR NAMES mysql.h
PATHS /usr/local/include/mysql /usr/include/mysql /opt/homebrew/opt/mysql/include /usr/local/opt/mysql-client/include /opt/homebrew/opt/mysql-client/include
)

MESSAGE( STATUS "MYSQL_ROOT_DIR = ${MYSQL_ROOT_DIR} ")
find_package_handle_standard_args(mysql REQUIRED_VARS MYSQL_ROOT_DIR)

FIND_PATH(MYSQL_INCLUDE_DIR mysql.h
/usr/local/include/mysql
/usr/include/mysql
/usr/local/mysql/include
)

if(NOT MYSQL_INCLUDE_DIR)
message(STATUS "Could not find \"mysql.h\" from searching ")
endif()

SET(MYSQL_NAMES mysqlclient)
FIND_LIBRARY(MYSQL_LIBRARY
NAMES ${MYSQL_NAMES}
PATHS /usr/lib /usr/local/lib /usr/local/mysql/lib
PATHS /usr/lib /usr/local/lib /usr/local/mysql/lib /usr/local/opt/mysql/lib /opt/homebrew/opt/mysql/lib /opt/homebrew/opt/mysql-client/lib
PATH_SUFFIXES mysql
)

Expand Down Expand Up @@ -371,7 +417,17 @@ if(ENABLE_GD STREQUAL "ON")
message("---ENABLE_GD-----")

if(CMAKE_SYSTEM_NAME MATCHES "Darwin")
set(GD_ROOT_DIR "/usr/local/opt/gd/lib")

if (IS_DIRECTORY "/usr/local/opt/gd/lib")
MESSAGE( STATUS "/usr/local/opt/gd/lib")
set(GD_ROOT_DIR "/usr/local/opt/gd/lib")
include_sub_directories_recursively(/usr/local/opt/gd/include)
endif()
if (IS_DIRECTORY "/opt/homebrew/opt/gd/lib")
MESSAGE( STATUS "/opt/homebrew/opt/gd/lib")
set(GD_ROOT_DIR "/opt/homebrew/opt/gd/lib")
include_sub_directories_recursively(/opt/homebrew/opt/gd/include)
endif()
else()
set(GD_ROOT_DIR "${sys_so_path}")
endif()
Expand All @@ -393,7 +449,18 @@ endif()
message(STATUS "GD Graphics Library at: ${GD_LIB_DIR}")

if(CMAKE_SYSTEM_NAME MATCHES "Darwin")
set(QR_ROOT_DIR "/usr/local/opt/qrencode/lib")

if (IS_DIRECTORY "/usr/local/opt/qrencode/lib")
MESSAGE( STATUS "/usr/local/opt/qrencode/lib")
set(QR_ROOT_DIR "/usr/local/opt/qrencode/lib")
include_sub_directories_recursively(/usr/local/opt/qrencode/include)
endif()
if (IS_DIRECTORY "/opt/homebrew/opt/qrencode/lib")
MESSAGE( STATUS "/opt/homebrew/opt/qrencode/lib")
set(QR_ROOT_DIR "/opt/homebrew/opt/qrencode/lib")
include_sub_directories_recursively(/opt/homebrew/opt/qrencode/include)
endif()

else()
set(QR_ROOT_DIR "${sys_so_path}")
endif()
Expand Down Expand Up @@ -422,7 +489,18 @@ target_link_libraries(paozhu ${GD_LIB_DIR})
target_link_libraries(paozhu ${QR_LIB_DIR})

if(CMAKE_SYSTEM_NAME MATCHES "Darwin")
set(PNG_ROOT_DIR "/usr/local/opt/libpng/lib")

if (IS_DIRECTORY "/usr/local/opt/libpng/lib")
MESSAGE( STATUS "/usr/local/opt/libpng/lib")
set(PNG_ROOT_DIR "/usr/local/opt/libpng/lib")
include_sub_directories_recursively(/usr/local/opt/libpng/include)
endif()
if (IS_DIRECTORY "/opt/homebrew/opt/libpng/lib")
MESSAGE( STATUS "/opt/homebrew/opt/libpng/lib")
set(PNG_ROOT_DIR "/opt/homebrew/opt/libpng/lib")
include_sub_directories_recursively(/opt/homebrew/opt/libpng/include)
endif()

else()
set(PNG_ROOT_DIR "${sys_so_path}")
endif()
Expand All @@ -435,7 +513,18 @@ find_library(PNG_LIB_DIR
target_link_libraries(paozhu ${PNG_LIB_DIR})

if(CMAKE_SYSTEM_NAME MATCHES "Darwin")
set(FREETYPE_ROOT_DIR "/usr/local/opt/freetype/lib")

if (IS_DIRECTORY "/usr/local/opt/freetype/lib")
MESSAGE( STATUS "/usr/local/opt/freetype/lib")
set(FREETYPE_ROOT_DIR "/usr/local/opt/freetype/lib")
include_sub_directories_recursively(/usr/local/opt/freetype/include)
endif()
if (IS_DIRECTORY "/opt/homebrew/opt/freetype/lib")
MESSAGE( STATUS "/opt/homebrew/opt/freetype/lib")
set(FREETYPE_ROOT_DIR "/opt/homebrew/opt/freetype/lib")
include_sub_directories_recursively(/opt/homebrew/opt/freetype/include)
endif()

else()
set(FREETYPE_ROOT_DIR "${sys_so_path}")
endif()
Expand All @@ -450,7 +539,15 @@ target_link_libraries(paozhu ${FREETYPE_LIB_DIR})
endif()

if(CMAKE_SYSTEM_NAME MATCHES "Darwin")
set(BROTLI_ROOT_DIR "/usr/local/opt/brotli/lib")
if (IS_DIRECTORY "/usr/local/opt/brotli/lib")
set(BROTLI_ROOT_DIR "/usr/local/opt/brotli/lib")
INCLUDE_DIRECTORIES("/usr/local/opt/brotli/include")
endif()
# set(BROTLI_ROOT_DIR "/usr/local/opt/brotli/lib")
if (IS_DIRECTORY "/opt/homebrew/opt/brotli/lib")
set(BROTLI_ROOT_DIR "/opt/homebrew/opt/brotli/lib")
INCLUDE_DIRECTORIES("/opt/homebrew/opt/brotli/include")
endif()
else()
set(BROTLI_ROOT_DIR "${sys_so_path}")
endif()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,16 @@ namespace http


}

void _initauto_domain_httpmethodregto(std::map<std::string, std::map<std::string, regmethold_t>> &domain_methodcallback)
{
struct regmethold_t temp;
std::map<std::string, regmethold_t> methodcallback;
std::map<std::string, std::map<std::string, regmethold_t>>::iterator domain_iterator;


}

}

#endif
Expand Down
40 changes: 40 additions & 0 deletions frameworks/C++/paozhu/paozhu_benchmark/common/autorestfulpaths.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@

#ifndef __HTTP_AUTO_REG_CONTROL_HTTPRESTFUL_HPP
#define __HTTP_AUTO_REG_CONTROL_HTTPRESTFUL_HPP

#if defined(_MSC_VER) && (_MSC_VER >= 1200)
#pragma once
#endif // defined(_MSC_VER) && (_MSC_VER >= 1200)

#include "httppeer.h"



namespace http
{
void _initauto_control_httprestful_paths(std::map<std::string, std::vector<std::string>> &restfulmethod)
{


if(restfulmethod.size())
{}


}

void _initauto_domain_httprestful_paths(std::map<std::string,std::map<std::string, std::vector<std::string>>> &restfulmethod)
{
std::map<std::string, std::vector<std::string>> temp_path;
std::map<std::string,std::map<std::string, std::vector<std::string>>>::iterator domain_iterator;

domain_iterator=restfulmethod.begin();
temp_path.clear();


}

}

#endif


9 changes: 9 additions & 0 deletions frameworks/C++/paozhu/paozhu_benchmark/common/cost_define.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#pragma once
#ifndef _CONST_DEFINE_FUNC_H
#define _CONST_DEFINE_FUNC_H

#define CONST_MONEY_PART 1000000
#define CONST_HTTP_HEADER_BODY_SIZE 16384
#define CONST_PHP_BODY_POST_SIZE 16777216

#endif
39 changes: 39 additions & 0 deletions frameworks/C++/paozhu/paozhu_benchmark/common/httphook.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
#include <iostream>
#include <list>
#include <map>
#include <mutex>
#include <queue>
#include <string>
#include <thread>
#include <memory>
#include <string_view>
#include "httppeer.h"
namespace http
{
std::map<std::string, bool> _block_ip_tables;
std::map<std::string, bool> _block_host_tables;
bool check_blockip(const std::string &client_ip)
{
if (client_ip.size() > 0)
{
return false;
}
return false;
}
bool hook_host_http1(std::shared_ptr<httppeer> peer)
{
if (peer->host.size() > 0)
{
return false;
}
return false;
}
bool hook_host_http2(std::shared_ptr<httppeer> peer)
{
if (peer->host.size() > 0)
{
return false;
}
return false;
}
}// namespace http
Empty file.
Loading

0 comments on commit 57dfce0

Please sign in to comment.