From 2dd5338bc4de07ff80eb3f69cd6a9c0e7fdb2899 Mon Sep 17 00:00:00 2001 From: hero1s Date: Sat, 25 May 2024 17:36:34 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E4=BB=A3=E7=A0=81=E5=88=A0?= =?UTF-8?q?=E9=99=A4=E6=9C=AA=E5=BC=95=E7=94=A8=E6=96=87=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- core/luabus/src/socket_stream.cpp | 2 +- core/plugins/lplugins.vcxproj | 1 - core/plugins/lplugins.vcxproj.filters | 3 -- core/plugins/src/lbson/bson.h | 71 ++++++++++++++------------ core/plugins/src/lcodec/url.h | 49 ------------------ extend/luaxlsx/test/test.lua | 30 ----------- extend/luaxlsx/test/test.xlsx | Bin 9644 -> 0 bytes script/agent/proxy_agent.lua | 7 ++- script/network/http_server.lua | 1 + server/qtest/jps_test.lua | 29 ----------- 10 files changed, 44 insertions(+), 149 deletions(-) delete mode 100644 core/plugins/src/lcodec/url.h delete mode 100644 extend/luaxlsx/test/test.lua delete mode 100644 extend/luaxlsx/test/test.xlsx delete mode 100644 server/qtest/jps_test.lua diff --git a/core/luabus/src/socket_stream.cpp b/core/luabus/src/socket_stream.cpp index bc3f0712..f519449b 100644 --- a/core/luabus/src/socket_stream.cpp +++ b/core/luabus/src/socket_stream.cpp @@ -567,7 +567,7 @@ void socket_stream::dispatch_package(bool reset) { } // 数据包解析失败 if (m_codec->failed()) { - on_error(m_codec->err()); + on_error(fmt::format("codec decode failed:{}", m_codec->err()).c_str()); return; } size_t read_size = m_codec->get_packet_len(); diff --git a/core/plugins/lplugins.vcxproj b/core/plugins/lplugins.vcxproj index 55304621..06097bcf 100644 --- a/core/plugins/lplugins.vcxproj +++ b/core/plugins/lplugins.vcxproj @@ -19,7 +19,6 @@ - diff --git a/core/plugins/lplugins.vcxproj.filters b/core/plugins/lplugins.vcxproj.filters index 89fa0efd..de161c06 100644 --- a/core/plugins/lplugins.vcxproj.filters +++ b/core/plugins/lplugins.vcxproj.filters @@ -37,9 +37,6 @@ lcodec - - lcodec - lcodec diff --git a/core/plugins/src/lbson/bson.h b/core/plugins/src/lbson/bson.h index 4e0ca7bf..d627cd02 100644 --- a/core/plugins/src/lbson/bson.h +++ b/core/plugins/src/lbson/bson.h @@ -113,11 +113,11 @@ namespace lbson { } int date(lua_State* L, int64_t value) { - return make_bson_value(L, bson_type::BSON_DATE, (const char *)&value, sizeof(value)); + return make_bson_value(L, bson_type::BSON_DATE, (uint8_t*)&value, sizeof(value)); } int int64(lua_State* L, int64_t value) { - return make_bson_value(L, bson_type::BSON_INT64, (const char *)&value, sizeof(value)); + return make_bson_value(L, bson_type::BSON_INT64, (uint8_t*)&value, sizeof(value)); } int objectid(lua_State* L) { @@ -126,52 +126,54 @@ namespace lbson { if (data_len != 24) return luaL_error(L, "Invalid object id"); char buffer[16] = { 0 }; write_objectid(L, buffer, value); - return make_bson_value(L, bson_type::BSON_OBJECTID, buffer, 12); + return make_bson_value(L, bson_type::BSON_OBJECTID, (uint8_t*)buffer, 12); } int pairs(lua_State* L) { m_buffer.clean(); size_t data_len = 0; - char* data = (char*)encode_pairs(L, &data_len); - return make_bson_value(L, bson_type::BSON_DOCUMENT, data, data_len); + m_buffer.write(0); + m_buffer.write((uint8_t)bson_type::BSON_DOCUMENT); + uint8_t* data = encode_pairs(L, &data_len); + lua_pushlstring(L, (const char*)data, data_len); + return 1; } int binary(lua_State* L) { + m_buffer.clean(); size_t data_len = 0; - const char* value = lua_tolstring(L, 1, &data_len); - luaL_Buffer b; - luaL_buffinit(L, &b); - luaL_addchar(&b, 0); - luaL_addchar(&b, (uint8_t)bson_type::BSON_BINARY); - luaL_addchar(&b, 0); - luaL_addlstring(&b, value, data_len); - luaL_pushresult(&b); + uint8_t* value = (uint8_t*)lua_tolstring(L, 1, &data_len); + m_buffer.write(0); + m_buffer.write((uint8_t)bson_type::BSON_BINARY); + m_buffer.write(0); //subtype + m_buffer.write(data_len); + m_buffer.push_data(value, data_len); + lua_pushlstring(L, (const char*)m_buffer.head(), m_buffer.size()); return 1; } int regex(lua_State* L) { - luaL_Buffer b; - luaL_buffinit(L, &b); - luaL_addchar(&b, 0); - luaL_addchar(&b, (uint8_t)bson_type::BSON_REGEX); - lua_pushvalue(L,1); - luaL_addvalue(&b); - luaL_addchar(&b, 0); - lua_pushvalue(L,2); - luaL_addvalue(&b); - luaL_addchar(&b, 0); - luaL_pushresult(&b); + m_buffer.clean(); + size_t data_len = 0; + m_buffer.write(0); + m_buffer.write((uint8_t)bson_type::BSON_REGEX); + uint8_t* val1 = (uint8_t*)lua_tolstring(L, 1, &data_len); + m_buffer.push_data(val1, data_len); + m_buffer.write(0); + uint8_t* val2 = (uint8_t*)lua_tolstring(L, 2, &data_len); + m_buffer.push_data(val2, data_len); + m_buffer.write(0); + lua_pushlstring(L, (const char*)m_buffer.head(), m_buffer.size()); return 1; } protected: - int make_bson_value(lua_State *L, bson_type type, const char* ptr, size_t len) { - luaL_Buffer b; - luaL_buffinit(L, &b); - luaL_addchar(&b, 0); - luaL_addchar(&b, (uint8_t)type); - luaL_addlstring(&b, ptr, len); - luaL_pushresult(&b); + int make_bson_value(lua_State *L, bson_type type, uint8_t* value, size_t len) { + m_buffer.clean(); + m_buffer.write(0); + m_buffer.write((uint8_t)type); + m_buffer.push_data(value, len); + lua_pushlstring(L, (const char*)m_buffer.head(), m_buffer.size()); return 1; } @@ -545,12 +547,13 @@ namespace lbson { break; case bson_type::BSON_BINARY: { lua_createtable(L, 0, 4); + int32_t len = read_val(L, slice); lua_pushinteger(L, (uint32_t)bt); lua_setfield(L, -2, "__type"); lua_pushinteger(L, read_val(L, slice)); lua_setfield(L, -2, "subtype"); - const char* s = read_bytes(L, slice, sz); - lua_pushlstring(L, s, sz); + const char* s = read_bytes(L, slice, len); + lua_pushlstring(L, s, len); lua_setfield(L, -2, "binray"); } break; @@ -639,7 +642,7 @@ namespace lbson { m_bson->unpack_dict(L, m_slice, false); } catch (const exception& e){ lua_settop(L, otop); - throw e; + throw lua_exception(e.what()); } return lua_gettop(L) - otop; } diff --git a/core/plugins/src/lcodec/url.h b/core/plugins/src/lcodec/url.h deleted file mode 100644 index 16cef3c9..00000000 --- a/core/plugins/src/lcodec/url.h +++ /dev/null @@ -1,49 +0,0 @@ -#pragma once -#include - -namespace lcodec { - - inline unsigned char tohex(unsigned char x) { - return x > 9 ? x + 55 : x + 48; - } - - inline unsigned char fromhex(unsigned char x) { - if (x >= 'A' && x <= 'Z') return x - 'A' + 10; - else if (x >= 'a' && x <= 'z') return x - 'a' + 10; - else if (x >= '0' && x <= '9') return x - '0'; - else return x; - } - - static std::string url_encode(std::string str) { - std::string temp = ""; - size_t length = str.length(); - for (size_t i = 0; i < length; i++) { - if (isalnum((unsigned char)str[i]) || (str[i] == '-') || (str[i] == '_') || (str[i] == '.') || (str[i] == '~')) - temp += str[i]; - else if (str[i] == ' ') - temp += "+"; - else { - temp += '%'; - temp += tohex((unsigned char)str[i] >> 4); - temp += tohex((unsigned char)str[i] % 16); - } - } - return temp; - } - - static std::string url_decode(std::string str) { - std::string temp = ""; - size_t length = str.length(); - for (size_t i = 0; i < length; i++) - { - if (str[i] == '+') temp += ' '; - else if (str[i] == '%'){ - unsigned char high = fromhex((unsigned char)str[++i]); - unsigned char low = fromhex((unsigned char)str[++i]); - temp += high * 16 + low; - } - else temp += str[i]; - } - return temp; - } -} diff --git a/extend/luaxlsx/test/test.lua b/extend/luaxlsx/test/test.lua deleted file mode 100644 index db2b6f14..00000000 --- a/extend/luaxlsx/test/test.lua +++ /dev/null @@ -1,30 +0,0 @@ -local lxlsx = require "luaxlsx" - -local x = lxlsx.open('test.xlsx') - -local sheets = x.sheets() - -print(type(sheets), #sheets) - -for i, sheet1 in ipairs(sheets) do - - local f = io.open(sheet1.name .. '.txt', 'w') - print(sheet1.name()) - - for r = sheet1.first_row, sheet1.last_row do - local row_table = {} - for c = sheet1.first_col, sheet1.lastC_cl do - local cell = sheet1.get_cell(r, c) - local str = "." - if cell then - print(cell.type, cell.value, cell.fmt_id, cell.fmt_code) - str = cell.value - end - - table.insert(row_table, string.format("%30s", str)) - end - f:write(table.concat(row_table, '|') .. '\n') - end - - f:close() -end diff --git a/extend/luaxlsx/test/test.xlsx b/extend/luaxlsx/test/test.xlsx deleted file mode 100644 index c9710dfe53137af03ac798975dda65907d3fea50..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 9644 zcmeHtbyO8y`}U#h(A|ynIl!SirIGHIZVu872kAznQ<3hFkS>u_NdYAlq>)tkj=t~v z`8+)SzV-e8duOdZvu4fQ*Ua8?U;DoIb*nfZ&8JSO&TJfrdXp%RggX?HQmSOP#`C)gna$}og@+C;=$xkI zNB7vOQyQ19Ii1l+#-J-1Refh6Iq=T<@$J zD6ZF{?7y%+)DVe25E(hUJlAUi>&G*?u=h}QEQgy}bL#@cne&U+wh)7@&1ZT`#4#oq z%kGEno6aXWYEuWGhD)L1^!xA3(2@!Jw-eH!5I`25OBZ~6;_@Uh818Aew@82of1_)& zE|~Ef{E8}^jaYEHntR$fLqXg>_y48o|6*?brR(vjlj{9o;Lw3$r|ib{j;kVi(X$R! z#SVHMnjWTo+UA53CaLqYNThIO>!sHDj@8`ti-x#3iuUyHj8+h84I-?gub$6Rz?!cu?Wfbo zU)X#|-xQDPrg^|6_P*B<9W4N@LgGs7vY{2C=H?693bM*nkC)0P6dm*4l(oewpImy8 zEiJX&Q9MKs4LB!Dq(`0 z@Vv3T7Cv30W_+~5#@axI+`gDI(Tr(!uAzTU7v0R)evU&NuUJ>j4HB4~cT(4Q*dfJG zE~I6V)gO_rV@w6HktkHj92%B}Qdo0D)Zn(u8*W|Z#dq@;W;?{@Y2x{8Q49nFM=#x6 zRw1SdNw0z_r;f<6Mq{wj3KO{+!X3Vwkr*PP_~jRwq@SxIXDpPrhto@zu zjTLXJQ(y9X{Bf*d9SMN+W7j*GNixeZD@x}7C&wUyv z+Lv3KM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vUzS{au zJx0K;&%R4dv~m94RwVUhHN=fhwD-w!grpu=&-P`8RfPXP7iZt)i$+| zkJ0Fa)17f#5E(C7OITGiV?Z=KE~{<`(WLS}dwVn{b`F-?wPa z5&5H7GTr7xpX{N3S>G zm63ltGy)6mu` z?+Ssx0c+s-$ln2f%Yt`N?y5__Q3~*Xq1@G)?gHFR=6?ftz~#w5yvDE8{w~VhWa&4G zK3w*Kqx>Uvx{L7lT;sPr0ANG~0Q@8KxNCklX8Z=2rup>(|34ArF6iF_z;8$Zz>xMY b@AU6*@IVCx?#VyvT-X3-I2qU(exCgwPAfoN diff --git a/script/agent/proxy_agent.lua b/script/agent/proxy_agent.lua index 611d36bc..0ffa6561 100644 --- a/script/agent/proxy_agent.lua +++ b/script/agent/proxy_agent.lua @@ -7,9 +7,12 @@ local ProxyAgent = singleton(thread) local prop = property(ProxyAgent) prop:reader("ignore_statistics", {}) prop:reader("statis_status", false) +prop:reader("cur_path", "") function ProxyAgent:__init() - self.service = "proxy" + self.service = "proxy" + self.cur_path = stdfs.current_path() + --开启调度器 if scheduler then self:startup("worker.proxy") --开启统计 @@ -33,7 +36,7 @@ end --日志分发 function ProxyAgent:dispatch_log(content, lvl_name) - local title = sformat("[%s][%s]", hive.name, lvl_name) + local title = sformat("[%s][%s][%s]", hive.name, lvl_name, self.cur_path) return self:send("rpc_fire_webhook", title, content) end diff --git a/script/network/http_server.lua b/script/network/http_server.lua index 4f2cbe55..8c428a07 100644 --- a/script/network/http_server.lua +++ b/script/network/http_server.lua @@ -174,6 +174,7 @@ function HttpServer:response(socket, status, response, headers) local html = response:find("{},{} result:{}", sx, sy, ex, ey, result)