This commit is contained in:
midoks
2022-10-21 01:25:57 +08:00
parent 3d366ee774
commit 24fe8b6f5f
7 changed files with 23 additions and 21 deletions
+1 -1
View File
@@ -294,7 +294,7 @@ def autoMakeLuaConf():
def initDreplace():
path = getServerDir()
if not os.path.exists(path + '/waf'):
if not os.path.exists(path + '/waf/lua'):
sdir = getPluginDir() + '/waf'
cmd = 'cp -rf ' + sdir + ' ' + path
mw.execShell(cmd)
+5 -2
View File
@@ -77,15 +77,18 @@ Install_of(){
# copy to code path
DEFAULT_DIR=$serverPath/op_waf/luarocks/lib/lua/5.1
if [ -f ${DEFAULT_DIR}/lsqlite3.so ];then
mkdir -p $serverPath/webstats/lua
mkdir -p $serverPath/op_waf/waf/conf
cp -rf ${DEFAULT_DIR}/lsqlite3.so $serverPath/op_waf/waf/conf/lsqlite3.so
fi
echo "${version}" > $serverPath/op_waf/version.pl
echo 'install ok' > $install_tmp
cd ${rootPath} && python3 ${rootPath}/plugins/op_waf/index.py start
# cd ${rootPath} && python3 ${rootPath}/plugins/op_waf/index.py restart
}
Uninstall_of(){
+2 -2
View File
@@ -221,6 +221,6 @@ def test_start():
if __name__ == "__main__":
# os.system('cd /Users/midoks/Desktop/mwdev/server/mdserver-web/plugins/op_waf && sh install.sh uninstall 0.2.2 && sh install.sh install 0.2.2')
# os.system('cd /Users/midoks/Desktop/mwdev/server/mdserver-web/ && python3 plugins/openresty/index.py stop && python3 plugins/openresty/index.py start')
os.system('cd /Users/midoks/Desktop/mwdev/server/mdserver-web/plugins/op_waf && sh install.sh uninstall 0.2.2 && sh install.sh install 0.2.2')
os.system('cd /Users/midoks/Desktop/mwdev/server/mdserver-web/ && python3 plugins/openresty/index.py stop && python3 plugins/openresty/index.py start')
test_start()
+11 -11
View File
@@ -4,6 +4,7 @@ local _M = { _VERSION = '0.02' }
local mt = { __index = _M }
local json = require "cjson"
local sqlite3 = require "lsqlite3"
local ngx_match = ngx.re.find
local debug_mode = false
@@ -64,25 +65,25 @@ end
function _M.log(self, args, rule_name, reason)
local local_db = self:initDB()
local stmt2 = local_db:prepare[[INSERT INTO logs(time, ip, domain, server_name, method, status_code, uri, rule_name,reason)
local stmt2 = local_db:prepare[[INSERT INTO logs(time, ip, domain, server_name, method, status_code, uri, rule_name, reason)
VALUES(:time, :ip, :domain, :server_name, :method, :status_code, :uri, :rule_name, :reason)]]
local_db:exec([[BEGIN TRANSACTION]])
stmt2:bind_names{
time=args['time'],
ip=args['ip'],
domain=args['server_name'],
server_name=args['server_name'],
method=args['method'],
status_code=args['status_code'],
uri=args['request_uri'],
time=args["time"],
ip=args["ip"],
domain=args["server_name"],
server_name=args["server_name"],
method=args["method"],
status_code=args["status_code"],
uri=args["request_uri"],
rule_name=rule_name,
reason=reason
}
local res, err = stmt2:step()
self:D("LOG[1]:"..tostring(res)..":"..tostring(err))
-- self:D("LOG[1]:"..tostring(res)..":"..tostring(err))
if tostring(res) == "5" then
self.D("waf the step database connection is busy, so it will be stored later.")
return false
@@ -90,8 +91,7 @@ function _M.log(self, args, rule_name, reason)
stmt2:reset()
local res, err = local_db:execute([[COMMIT]])
self:D("LOG[2]:"..tostring(res)..":"..tostring(err))
-- self:D("LOG[2]:"..tostring(res)..":"..tostring(err))
if local_db and local_db:isopen() then
local_db:close()
end
+1
View File
@@ -2,6 +2,7 @@ local json = require "cjson"
local ngx_match = ngx.re.find
local __C = require "common"
local C = __C:getInstance()
local config = require "waf_config"
+2 -1
View File
@@ -242,7 +242,8 @@ def start():
def stop():
path = luaConf()
os.remove(path)
if os.path.exists(path):
os.remove(path)
import tool_task
tool_task.removeBgTask()
+1 -4
View File
@@ -108,10 +108,7 @@ Install_App()
Uninstall_App()
{
if [ "$sys_os" != "Darwin" ];then
cd $rootPath && python3 ${rootPath}/plugins/webstats/index.py stop
fi
cd $rootPath && python3 ${rootPath}/plugins/webstats/index.py stop
rm -rf $serverPath/webstats
echo "卸载完成" > $install_tmp
}