Skip to content

Instantly share code, notes, and snippets.

@chobits
chobits / gen.py
Created November 28, 2024 03:07
Generate 100 routes associated with the Rate Limiting Advanced (RLA) plugin for Konnect.
import yaml
# Configuration
num_services = 100
backend_url = "http://mockbin.org/request"
# YAML Structure
kong_config = {
"_format_version": "3.0",
@chobits
chobits / nginx.gdb
Last active August 29, 2024 08:18
nginx.gdb
# vim: set ft=gdb
set print pretty on
set pagination off
set print repeats 16
handle SIGPIPE nostop
### nginx debug function ###
@chobits
chobits / perf.lua
Last active August 14, 2024 07:35
perfermance test for kong old and new dns client library
--[[
run it by this command:
$ resty --shdict "kong_dns_cache 10m" ./perf.lua
]]
setmetatable(_G, nil) -- disable the _G write guard alert log introduced in OpenResty 1.15.8.1
pcall(require, "luarocks.loader")
@chobits
chobits / bt.lua
Last active September 7, 2023 03:15
trace function call chains while reading the lua source
-- Trace request context exclusively within Lua projects
-- executed by the Lua-nginx-module
--
-- The timer context is not available within functions triggered by
-- ngx.timer.at(). However, you can easily make adjustments to this file to
-- enable it.
--
-- In your lua source file:
-- require("bt").init_hook()
mail message modified:
Xiaochen Wang <[email protected]>
11:07 AM (2 hours ago)
to web-07
hi mike,
We still have an issue, always crashed on first instruction of tracing generated machine code.
@chobits
chobits / test_log_alibaba_tengine_pull_1105.md
Last active December 20, 2018 11:23
test case for updating nginx-1.15.1 modules

Test Case:

  • Case failure:
    • sub_filter_slice.t: current tengine has its slice module, so this case is not run for nginx module.
    • limit_conn_complex.t: limit_req module is not updated.
    • index2.t: current tengine does not merge http://hg.nginx.org/nginx/rev/d91a8c4ac6bb.
    • userid.t: tengine refactor 404 page. It outputs URI in response, the URI has "expires" string, which makes case failed.
@chobits
chobits / ffi.md
Created September 29, 2015 09:40
luajit source notes
1.
luaopen_ffi()
 -> lj_ctype_init(L)
   -> setmref(G(L)->ctype_state, cts)
 -> lj_clib_default(L) # init ffi.C (default libc.so loader)
   -> cl = clib_new()
      cl->handle = RTLD_DEFAULT   

ctype_cts(L)
$ cd /home/xiaochen.wxc/work/github-xiaochen/tengine-xiaochen
$ cat test_nginx.sh
TEST_NGINX="/home/xiaochen.wxc/work/github-xiaochen/tengine-xiaochen/tests/test-nginx/test-nginx"
export PATH=/home/xiaochen.wxc/work/github-xiaochen/tengine-xiaochen/objs:$PATH
prove -v -I $TEST_NGINX/inc -I $TEST_NGINX/lib \
tests/test-nginx/cases/footer.t \
tests/test-nginx/cases/proxy_no_buffering_chunked.t \
tests/test-nginx/cases/proxy_no_buffering.t \
@chobits
chobits / spdy_zlib.py
Last active December 28, 2015 11:49
zlib wrapper for spdy v2/v3
# Used for python 3.3+
# API: decompress, compress
# zlib dictionary support for python: http://bugs.python.org/issue14684
#
# For test:
# $ python3 spdy_zlib.py
import zlib
spdy_v2_dict = b'''\
@chobits
chobits / nginx_kqueue_event.txt
Last active December 22, 2015 02:19
nginx source notes
The available and post_available field of structure ngx_event_t is only used by KQUEUE.
Other event modules (epoll, poll and etc) donest care about it.
For read event, available means size of data ready to read.
For read event(listening event), available means size of listen backlog.
post_avalibale is only used for multi-thread & KQUEUE.
multi_accept directive doesn't matter for kqueue. (see http://forum.nginx.org/read.php?2,3638,3661)