diff --git a/plugins/op_waf/index.py b/plugins/op_waf/index.py index c0b25df1e..a93240b16 100755 --- a/plugins/op_waf/index.py +++ b/plugins/op_waf/index.py @@ -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) diff --git a/plugins/op_waf/install.sh b/plugins/op_waf/install.sh index 9d3ffbf28..938e8612f 100755 --- a/plugins/op_waf/install.sh +++ b/plugins/op_waf/install.sh @@ -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(){ diff --git a/plugins/op_waf/t/index.py b/plugins/op_waf/t/index.py index 59f21996c..f474e9f62 100644 --- a/plugins/op_waf/t/index.py +++ b/plugins/op_waf/t/index.py @@ -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() diff --git a/plugins/op_waf/waf/lua/common.lua b/plugins/op_waf/waf/lua/common.lua index c7d8a07c8..0e0da3d5c 100644 --- a/plugins/op_waf/waf/lua/common.lua +++ b/plugins/op_waf/waf/lua/common.lua @@ -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 diff --git a/plugins/op_waf/waf/lua/init.lua b/plugins/op_waf/waf/lua/init.lua index 0e2408256..e622c476d 100644 --- a/plugins/op_waf/waf/lua/init.lua +++ b/plugins/op_waf/waf/lua/init.lua @@ -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" diff --git a/plugins/webstats/index.py b/plugins/webstats/index.py index 39bdd0a61..9ba0926f7 100755 --- a/plugins/webstats/index.py +++ b/plugins/webstats/index.py @@ -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() diff --git a/plugins/webstats/install.sh b/plugins/webstats/install.sh index 8d1df01ad..14c31e490 100755 --- a/plugins/webstats/install.sh +++ b/plugins/webstats/install.sh @@ -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 }