[apisix] branch master updated (f2f5ab9 -> 37a0792)

2020-10-30 Thread membphis
This is an automated email from the ASF dual-hosted git repository.

membphis pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/apisix.git.


from f2f5ab9  feat: support `json` encoding escape for access logs (#2269)
 add 37a0792  bugfix: fix zipkin plugin error when used with limit count 
plugin (#2499)

No new revisions were added by this update.

Summary of changes:
 apisix/plugins/zipkin.lua | 15 +++
 t/admin/plugins.t |  2 +-
 t/debug/debug-mode.t  |  2 +-
 t/plugin/zipkin.t | 45 +
 4 files changed, 58 insertions(+), 6 deletions(-)



[apisix] branch master updated (f2f5ab9 -> 37a0792)

2020-10-30 Thread membphis
This is an automated email from the ASF dual-hosted git repository.

membphis pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/apisix.git.


from f2f5ab9  feat: support `json` encoding escape for access logs (#2269)
 add 37a0792  bugfix: fix zipkin plugin error when used with limit count 
plugin (#2499)

No new revisions were added by this update.

Summary of changes:
 apisix/plugins/zipkin.lua | 15 +++
 t/admin/plugins.t |  2 +-
 t/debug/debug-mode.t  |  2 +-
 t/plugin/zipkin.t | 45 +
 4 files changed, 58 insertions(+), 6 deletions(-)



[apisix] branch master updated: feat: support `json` encoding escape for access logs (#2269)

2020-10-30 Thread membphis
This is an automated email from the ASF dual-hosted git repository.

membphis pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/apisix.git


The following commit(s) were added to refs/heads/master by this push:
 new f2f5ab9  feat: support `json` encoding escape for access logs (#2269)
f2f5ab9 is described below

commit f2f5ab97663805509baf3355c37336ffa557b68c
Author: YuanSheng Wang 
AuthorDate: Fri Oct 30 16:07:24 2020 +0800

feat: support `json` encoding escape for access logs (#2269)

fix #2266 .
---
 .travis/apisix_cli_test.sh | 31 +++
 bin/apisix |  2 +-
 conf/config-default.yaml   |  1 +
 3 files changed, 33 insertions(+), 1 deletion(-)

diff --git a/.travis/apisix_cli_test.sh b/.travis/apisix_cli_test.sh
index 091ff92..5f88ecd 100755
--- a/.travis/apisix_cli_test.sh
+++ b/.travis/apisix_cli_test.sh
@@ -441,3 +441,34 @@ if [ $count -ne 1 ]; then
 fi
 
 echo "passed: using env to set worker processes"
+
+# access log with JSON format
+
+echo '
+nginx_config:
+  http:
+access_log_format: |-
+  {"@timestamp": "$time_iso8601", "client_ip": "$remote_addr", "status": 
"$status"}
+access_log_format_escape: json
+' > conf/config.yaml
+
+make init
+make run
+sleep 0.1
+curl http://127.0.0.1:9080/hello2
+sleep 4
+tail -n 1 logs/access.log > output.log
+
+if [ `grep -c '"client_ip": "127.0.0.1"' output.log` -eq '0' ]; then
+echo "failed: invalid JSON log in access log"
+exit 1
+fi
+
+if [ `grep -c 'main escape=json' conf/nginx.conf` -eq '0' ]; then
+echo "failed: not found \"escape=json\" in conf/nginx.conf"
+exit 1
+fi
+
+make stop
+
+echo "passed: access log with JSON format"
diff --git a/bin/apisix b/bin/apisix
index 2e72a31..d600d2b 100755
--- a/bin/apisix
+++ b/bin/apisix
@@ -239,7 +239,7 @@ http {
 lua_regex_match_limit 10;
 lua_regex_cache_max_entries 8192;
 
-log_format main '{* http.access_log_format *}';
+log_format main escape={* http.access_log_format_escape *} '{* 
http.access_log_format *}';
 
 access_log {* http.access_log *} main buffer=16384 flush=3;
 open_file_cache  max=1000 inactive=60;
diff --git a/conf/config-default.yaml b/conf/config-default.yaml
index ef9331f..f94bda9 100644
--- a/conf/config-default.yaml
+++ b/conf/config-default.yaml
@@ -126,6 +126,7 @@ nginx_config: # config for render the 
template to genarate n
   http:
 access_log: "logs/access.log"
 access_log_format: "$remote_addr - $remote_user [$time_local] $http_host 
\"$request\" $status $body_bytes_sent $request_time \"$http_referer\" 
\"$http_user_agent\" $upstream_addr $upstream_status $upstream_response_time"
+access_log_format_escape: default   # allows setting json or default 
characters escaping in variables
 keepalive_timeout: 60s # timeout during which a keep-alive client 
connection will stay open on the server side.
 client_header_timeout: 60s # timeout for reading client request 
header, then 408 (Request Time-out) error is returned to the client
 client_body_timeout: 60s   # timeout for reading client request body, 
then 408 (Request Time-out) error is returned to the client



[apisix] branch master updated: chore: update CODE_STYLE to catch up with the reality (#2570)

2020-10-30 Thread membphis
This is an automated email from the ASF dual-hosted git repository.

membphis pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/apisix.git


The following commit(s) were added to refs/heads/master by this push:
 new e67dee1  chore: update CODE_STYLE to catch up with the reality (#2570)
e67dee1 is described below

commit e67dee137a3db78c877fad9dca99048d027a5ddd
Author: 罗泽轩 
AuthorDate: Fri Oct 30 16:06:21 2020 +0800

chore: update CODE_STYLE to catch up with the reality (#2570)

Currently we already have the line length style check in lj-releng. The
length we chose is 100.

Close #2569.
---
 CODE_STYLE.md | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/CODE_STYLE.md b/CODE_STYLE.md
index 71c2134..079c3e4 100644
--- a/CODE_STYLE.md
+++ b/CODE_STYLE.md
@@ -135,7 +135,7 @@ end
 
 ## Maximum length per line
 
-Each line cannot exceed 80 characters. If it exceeds, you need to wrap and 
align:
+Each line cannot exceed 100 characters. If it exceeds, you need to wrap and 
align:
 
 ```lua
 --No



[apisix] branch master updated (960077f -> c32d05d)

2020-10-29 Thread membphis
This is an automated email from the ASF dual-hosted git repository.

membphis pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/apisix.git.


from 960077f  fix(echo): modify response body correctly (#2561)
 add c32d05d  fix: English style mentioned by #2558 (#2559)

No new revisions were added by this update.

Summary of changes:
 doc/architecture-design.md | 4 ++--
 doc/discovery.md   | 2 +-
 doc/grpc-proxy.md  | 2 +-
 doc/plugins/basic-auth.md  | 2 +-
 doc/plugins/hmac-auth.md   | 2 +-
 doc/plugins/jwt-auth.md| 2 +-
 6 files changed, 7 insertions(+), 7 deletions(-)



[apisix] branch master updated: doc: fixed some typo and incorrect examples in getting-started.md and syslog.md (#2458)

2020-10-28 Thread membphis
This is an automated email from the ASF dual-hosted git repository.

membphis pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/apisix.git


The following commit(s) were added to refs/heads/master by this push:
 new e472d2c  doc: fixed some typo and incorrect examples in 
getting-started.md and syslog.md (#2458)
e472d2c is described below

commit e472d2c2dbf667c0b40a61a24f917048cfdd2b09
Author: dabue <53054094+da...@users.noreply.github.com>
AuthorDate: Wed Oct 28 22:24:32 2020 +0800

doc: fixed some typo and incorrect examples in getting-started.md and 
syslog.md (#2458)

fix #2457
---
 doc/getting-started.md   |  2 +-
 doc/plugins/syslog.md| 33 +++--
 doc/zh-cn/getting-started.md |  2 +-
 doc/zh-cn/plugins/syslog.md  | 33 +++--
 4 files changed, 32 insertions(+), 38 deletions(-)

diff --git a/doc/getting-started.md b/doc/getting-started.md
index 65e1bea..25269ab 100644
--- a/doc/getting-started.md
+++ b/doc/getting-started.md
@@ -237,7 +237,7 @@ curl http://127.0.0.1:9080/apisix/admin/routes/5 -H 
'X-API-KEY: edd1c9f034335f13
 Now you can invoke the route with the following command:
 
 ```bash
-curl -i -X GET http://127.0.0.1:9080/samplePrefix/get?param1=foo=bar -H 
'apikey: superSecretAPIKey'
+curl -i -X GET 'http://127.0.0.1:9080/samplePrefix/get?param1=foo=bar' 
-H 'apikey: superSecretAPIKey'
 ```
 
 ## APISIX Dashboard
diff --git a/doc/plugins/syslog.md b/doc/plugins/syslog.md
index 60f0e10..e61d6f9 100644
--- a/doc/plugins/syslog.md
+++ b/doc/plugins/syslog.md
@@ -57,25 +57,22 @@ This will provide the ability to send Log data requests as 
JSON objects.
 The following is an example on how to enable the sys-logger for a specific 
route.
 
 ```shell
-curl http://127.0.0.1:9080/apisix/admin/consumers -H 'X-API-KEY: 
edd1c9f034335f136f87ad84b625c8f1' -X PUT -d '
+curl http://127.0.0.1:9080/apisix/admin/routes/1 -H 'X-API-KEY: 
edd1c9f034335f136f87ad84b625c8f1' -X PUT -d '
 {
-"username": "foo",
 "plugins": {
-  "plugins": {
-"syslog": {
- "host" : "127.0.0.1",
- "port" : 5044,
- "flush_limit" : 1
-  }
-   },
-  "upstream": {
-   "type": "roundrobin",
-   "nodes": {
-   "127.0.0.1:1980": 1
-   }
-  },
-  "uri": "/hello"
-}
+"syslog": {
+"host" : "127.0.0.1",
+"port" : 5044,
+"flush_limit" : 1
+}
+},
+"upstream": {
+"type": "roundrobin",
+"nodes": {
+"127.0.0.1:1980": 1
+}
+},
+"uri": "/hello"
 }'
 ```
 
@@ -96,7 +93,7 @@ Remove the corresponding json configuration in the plugin 
configuration to disab
 APISIX plugins are hot-reloaded, therefore no need to restart APISIX.
 
 ```shell
-$ curl http://127.0.0.1:2379/apisix/admin/routes/1  -H 'X-API-KEY: 
edd1c9f034335f136f87ad84b625c8f1' -X PUT -d value='
+$ curl http://127.0.0.1:9080/apisix/admin/routes/1  -H 'X-API-KEY: 
edd1c9f034335f136f87ad84b625c8f1' -X PUT -d '
 {
 "methods": ["GET"],
 "uri": "/hello",
diff --git a/doc/zh-cn/getting-started.md b/doc/zh-cn/getting-started.md
index 5cbc1d8..0478d88 100644
--- a/doc/zh-cn/getting-started.md
+++ b/doc/zh-cn/getting-started.md
@@ -232,7 +232,7 @@ curl http://127.0.0.1:9080/apisix/admin/routes/5 -H 
'X-API-KEY: edd1c9f034335f13
 现在可以使用以下命令调用路由:
 
 ```bash
-curl -i -X GET http://127.0.0.1:9080/samplePrefix/get?param1=foo=bar -H 
'apikey: superSecretAPIKey'
+curl -i -X GET 'http://127.0.0.1:9080/samplePrefix/get?param1=foo=bar' 
-H 'apikey: superSecretAPIKey'
 ```
 
 ## Apache APISIX 控制台
diff --git a/doc/zh-cn/plugins/syslog.md b/doc/zh-cn/plugins/syslog.md
index 11e9d01..e8fe5dd 100644
--- a/doc/zh-cn/plugins/syslog.md
+++ b/doc/zh-cn/plugins/syslog.md
@@ -57,25 +57,22 @@
 1. 下面例子展示了如何为指定路由开启 `sys-logger` 插件的。
 
 ```shell
-curl http://127.0.0.1:9080/apisix/admin/consumers -H 'X-API-KEY: 
edd1c9f034335f136f87ad84b625c8f1' -X PUT -d '
+curl http://127.0.0.1:9080/apisix/admin/routes/1 -H 'X-API-KEY: 
edd1c9f034335f136f87ad84b625c8f1' -X PUT -d '
 {
-"username": "foo",
 "plugins": {
-  "plugins": {
-  "syslog": {
-   "host" : "127.0.0.1",
-   "port" : 5044,
-   "flush_limit" : 1
-}
-   },
-  "upstream": {
-   "type": "roundro

[apisix] branch master updated: feature: prometheus plugin `apisix_http_status` metric `route` tag Improve recognition (#2497)

2020-10-27 Thread membphis
This is an automated email from the ASF dual-hosted git repository.

membphis pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/apisix.git


The following commit(s) were added to refs/heads/master by this push:
 new 9b63fd5  feature: prometheus plugin `apisix_http_status` metric 
`route` tag Improve recognition (#2497)
9b63fd5 is described below

commit 9b63fd5710427820a9002920f8b48cb43bf06cd8
Author: tzssangglass 
AuthorDate: Wed Oct 28 13:22:25 2020 +0800

feature: prometheus plugin `apisix_http_status` metric `route` tag Improve 
recognition (#2497)

fix #1574
---
 apisix/http/router/radixtree_host_uri.lua |   8 ++-
 apisix/http/router/radixtree_uri.lua  |   6 +-
 apisix/init.lua   |   4 ++
 apisix/plugins/prometheus/exporter.lua|  12 +++-
 rockspec/apisix-master-0.rockspec |   2 +-
 t/plugin/prometheus.t | 109 +-
 6 files changed, 131 insertions(+), 10 deletions(-)

diff --git a/apisix/http/router/radixtree_host_uri.lua 
b/apisix/http/router/radixtree_host_uri.lua
index 25dec65..97bad34 100644
--- a/apisix/http/router/radixtree_host_uri.lua
+++ b/apisix/http/router/radixtree_host_uri.lua
@@ -61,9 +61,10 @@ local function push_host_router(route, host_routes, 
only_uri_routes)
or route.value.remote_addr,
 vars = route.value.vars,
 filter_fun = filter_fun,
-handler = function (api_ctx)
+handler = function (api_ctx, match_opts)
 api_ctx.matched_params = nil
 api_ctx.matched_route = route
+api_ctx.curr_req_matched = match_opts.matched
 end
 }
 
@@ -130,16 +131,17 @@ function _M.match(api_ctx)
 match_opts.remote_addr = api_ctx.var.remote_addr
 match_opts.vars = api_ctx.var
 match_opts.host = api_ctx.var.host
+match_opts.matched = core.tablepool.fetch("matched_route_record", 0, 4)
 
 if host_router then
 local host_uri = api_ctx.var.host
-local ok = host_router:dispatch(host_uri:reverse(), match_opts, 
api_ctx)
+local ok = host_router:dispatch(host_uri:reverse(), match_opts, 
api_ctx, match_opts)
 if ok then
 return true
 end
 end
 
-local ok = only_uri_router:dispatch(api_ctx.var.uri, match_opts, api_ctx)
+local ok = only_uri_router:dispatch(api_ctx.var.uri, match_opts, api_ctx, 
match_opts)
 return ok
 end
 
diff --git a/apisix/http/router/radixtree_uri.lua 
b/apisix/http/router/radixtree_uri.lua
index fe6dfbd..812b84c 100644
--- a/apisix/http/router/radixtree_uri.lua
+++ b/apisix/http/router/radixtree_uri.lua
@@ -62,9 +62,10 @@ local function create_radixtree_router(routes)
or route.value.remote_addr,
 vars = route.value.vars,
 filter_fun = filter_fun,
-handler = function (api_ctx)
+handler = function (api_ctx, match_opts)
 api_ctx.matched_params = nil
 api_ctx.matched_route = route
+api_ctx.curr_req_matched = match_opts.matched
 end
 })
 
@@ -94,8 +95,9 @@ function _M.match(api_ctx)
 match_opts.host = api_ctx.var.host
 match_opts.remote_addr = api_ctx.var.remote_addr
 match_opts.vars = api_ctx.var
+match_opts.matched = core.tablepool.fetch("matched_route_record", 0, 4)
 
-local ok = uri_router:dispatch(api_ctx.var.uri, match_opts, api_ctx)
+local ok = uri_router:dispatch(api_ctx.var.uri, match_opts, api_ctx, 
match_opts)
 return ok
 end
 
diff --git a/apisix/init.lua b/apisix/init.lua
index 3a51f4b..7324438 100644
--- a/apisix/init.lua
+++ b/apisix/init.lua
@@ -692,6 +692,10 @@ function _M.http_log_phase()
 core.tablepool.release("plugins", api_ctx.plugins)
 end
 
+if api_ctx.curr_req_matched then
+core.tablepool.release("matched_route_record", 
api_ctx.curr_req_matched)
+end
+
 core.tablepool.release("api_ctx", api_ctx)
 end
 
diff --git a/apisix/plugins/prometheus/exporter.lua 
b/apisix/plugins/prometheus/exporter.lua
index 35eeeae..78c2af6 100644
--- a/apisix/plugins/prometheus/exporter.lua
+++ b/apisix/plugins/prometheus/exporter.lua
@@ -102,7 +102,7 @@ function _M.init()
 -- no consumer in request.
 metrics.status = prometheus:counter("http_status",
 "HTTP status codes per service in APISIX",
-{"code", "route", "service", "consumer", "node"})
+{"code", "route", "matched_uri", "matched_host", "service", 
"consumer", "node"})
 
 metrics.latency = prometheus:histogram("http_latency",
 "HTTP request latency in milliseconds per service in APISIX",
@@ -136,8 +136,16 @@ 

[apisix] branch master updated: doc: add videos of ApacheCon. (#2534)

2020-10-27 Thread membphis
This is an automated email from the ASF dual-hosted git repository.

membphis pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/apisix.git


The following commit(s) were added to refs/heads/master by this push:
 new 0ba62a8  doc: add videos of ApacheCon. (#2534)
0ba62a8 is described below

commit 0ba62a8b98049acf4d38b269033b98891d832c58
Author: Wen Ming 
AuthorDate: Wed Oct 28 13:19:37 2020 +0800

doc: add videos of ApacheCon. (#2534)
---
 README.md| 3 ++-
 README_CN.md | 3 ++-
 2 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/README.md b/README.md
index 3b591c2..1627c9a 100644
--- a/README.md
+++ b/README.md
@@ -320,7 +320,8 @@ Benchmark comparison test [details 
data](https://gist.github.com/membphis/137db9
 ![contributor-over-time](./doc/images/contributor-over-time.png)
 
 ## Videos And Articles
-
+- [Apache APISIX: How to implement plugin orchestration in API 
Gateway](https://www.youtube.com/watch?v=iEegNXOtEhQ)
+- [Improve Apache APISIX observability with Apache 
Skywalking](https://www.youtube.com/watch?v=DleVJwPs4i4)
 - [APISIX technology selection, testing and continuous 
integration](https://medium.com/@ming_wen/apache-apisixs-technology-selection-testing-and-continuous-integration-313221b02542)
 - [Analysis of Excellent Performance of Apache APISIX Microservices 
Gateway](https://medium.com/@ming_wen/analysis-of-excellent-performance-of-apache-apisix-microservices-gateway-fc77db4090b5)
 
diff --git a/README_CN.md b/README_CN.md
index d7a3d0b..5022d1f 100644
--- a/README_CN.md
+++ b/README_CN.md
@@ -319,7 +319,8 @@ Dashboard 默认只允许 127.0.0.1 访问。你可以自行修改 `conf/config.
 ![contributor-over-time](./doc/images/contributor-over-time.png)
 
 ## 视频和文章
-
+- 2020.10.16 [Apache APISIX: How to implement plugin orchestration in API 
Gateway](https://www.youtube.com/watch?v=iEegNXOtEhQ)
+- 2020.10.16 [Improve Apache APISIX observability with Apache 
Skywalking](https://www.youtube.com/watch?v=DleVJwPs4i4)
 - 2020.1.17 [API 网关 Apache APISIX 和 Kong 
的选型对比](https://mp.weixin.qq.com/s/c51apneVj0O9yxiZAHF34Q)
 - 2019.12.14 [从 0 到 1:Apache APISIX 的 Apache 
之路](https://zhuanlan.zhihu.com/p/99620158)
 - 2019.12.14 [基于 Apache APISIX 
的下一代微服务架构](https://www.upyun.com/opentalk/445.html)



[apisix] branch master updated: doc: fix steps of install from source code. (#2545)

2020-10-27 Thread membphis
This is an automated email from the ASF dual-hosted git repository.

membphis pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/apisix.git


The following commit(s) were added to refs/heads/master by this push:
 new bf3300a  doc: fix steps of install from source code. (#2545)
bf3300a is described below

commit bf3300ae908952a2c08511af2b6861c92bba29cc
Author: Wen Ming 
AuthorDate: Wed Oct 28 13:18:26 2020 +0800

doc: fix steps of install from source code. (#2545)
---
 README.md| 3 ++-
 README_CN.md | 5 +++--
 2 files changed, 5 insertions(+), 3 deletions(-)

diff --git a/README.md b/README.md
index bccb111..3b591c2 100644
--- a/README.md
+++ b/README.md
@@ -167,12 +167,13 @@ There are several ways to install the Apache Release 
version of APISIX:
- Installation runtime dependencies: OpenResty and etcd, and compilation 
dependencies: luarocks. Refer to [install dependencies 
documentation](doc/install-dependencies.md)
- Download the latest source code release package:
  ```shell
+ $ mkdir apisix-2.0
+ $ cd apisix-2.0
  $ wget https://downloads.apache.org/apisix/2.0/apache-apisix-2.0-src.tgz
  $ tar zxvf apache-apisix-2.0-src.tgz
  ```
- Install the dependencies:
  ```shell
- $ cd apache-apisix-2.0
  $ make deps
  ```
- check version of APISIX:
diff --git a/README_CN.md b/README_CN.md
index 71d1dee..d7a3d0b 100644
--- a/README_CN.md
+++ b/README_CN.md
@@ -165,12 +165,13 @@ CentOS 7, Ubuntu 16.04, Ubuntu 18.04, Debian 9, Debian 
10, macOS, **ARM64** Ubun
- 安装运行时依赖:OpenResty 和 
etcd,以及编译的依赖:luarocks。参考[依赖安装文档](doc/zh-cn/install-dependencies.md)
- 下载最新的源码发布包:
  ```shell
- $ wget http://www.apache.org/dist/apisix/2.0/apache-apisix-2.0-src.tgz
+ $ mkdir apisix-2.0
+ $ cd apisix-2.0
+ $ wget https://downloads.apache.org/apisix/2.0/apache-apisix-2.0-src.tgz
  $ tar zxvf apache-apisix-2.0-src.tgz
  ```
- 安装运行时依赖的 Lua 库:
  ```shell
- $ cd apache-apisix-2.0
  $ make deps
  ```
- 检查 APISIX 的版本号:



[apisix] branch master updated: feat(docs): update README (#2539)

2020-10-27 Thread membphis
This is an automated email from the ASF dual-hosted git repository.

membphis pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/apisix.git


The following commit(s) were added to refs/heads/master by this push:
 new 16f9753  feat(docs): update README (#2539)
16f9753 is described below

commit 16f9753fde4822b7877810604612b21ea821eb23
Author: 琚致远 
AuthorDate: Tue Oct 27 21:51:12 2020 +0800

feat(docs): update README (#2539)

more beautiful
---
 README.md| 380 +-
 README_CN.md | 383 ++-
 2 files changed, 440 insertions(+), 323 deletions(-)

diff --git a/README.md b/README.md
index be741b7..bccb111 100644
--- a/README.md
+++ b/README.md
@@ -17,20 +17,25 @@
 #
 -->
 
-- [Chinese](README_CN.md)
-
-## APISIX
+# Apache APISIX
 
 [![Build 
Status](https://travis-ci.org/apache/apisix.svg?branch=master)](https://travis-ci.org/apache/apisix)
 
[![License](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](https://github.com/apache/apisix/blob/master/LICENSE)
 
-- Mail list: Mail to dev-subscr...@apisix.apache.org, follow the reply to 
subscribe the mail list.
-- **QQ Group**: 578997126(recommended), 552030619
-- Join in `apisix` channel at [Apache 
Slack](http://s.apache.org/slack-invite). If the link is not working, find the 
latest one at [Apache INFRA 
WIKI](https://cwiki.apache.org/confluence/display/INFRA/Slack+Guest+Invites).
-- ![Twitter 
Follow](https://img.shields.io/twitter/follow/ApacheAPISIX?style=social)
-- [bilibili video](https://space.bilibili.com/551921247)
+
+  https://github.com/apache/apisix;>English •
+  https://github.com/apache/apisix/blob/master/README_CN.md;>中文
+
+
+
+  https://apisix.apache.org/;>Website •
+  https://github.com/apache/apisix/tree/master/doc;>Docs •
+  https://github.com/apache/apisix-dashboard;>Dashboard •
+  https://twitter.com/apacheapisix;>Twitter
+
 
 ## What's Apache APISIX?
+
 Apache APISIX is a dynamic, real-time, high-performance API gateway, based on 
the Nginx library and etcd.
 
 APISIX provides rich traffic management features such as load balancing, 
dynamic upstream, canary release, circuit breaking, authentication, 
observability, and more.
@@ -43,173 +48,208 @@ The technical architecture of Apache APISIX:
 
 ![](doc/images/apisix.png)
 
+## Contents
+
+- [Features](#features)
+- [Documentation](#documentation)
+- [Get Started](#get-started)
+- [Dashboard](#dashboard)
+- [Benchmark](#benchmark)
+- [Apache APISIX vs Kong](#apache-apisix-vs-kong)
+- [Open Governance](#open-governance)
+- [Community](#community)
+- [Videos And Articles](#videos-and-articles)
+- [User Stories](#user-stories)
+- [Who Uses APISIX?](#who-uses-apisix)
+- [Landscape](#landscape)
+- [Logos](#logos)
+- [Contributing](#contributing)
+- [Acknowledgments](#acknowledgments)
+- [License](#license)
+
 ## Features
+
 You can use Apache APISIX as a traffic entrance to process all business data, 
including dynamic routing, dynamic upstream, dynamic certificates,
 A/B testing, canary release, blue-green deployment, limit rate, defense 
against malicious attacks, metrics, monitoring alarms, service observability, 
service governance, etc.
 
 - **All platforms**
-- Cloud-Native: Platform agnostic, No vendor lock-in, APISIX can run from 
bare-metal to Kubernetes.
-- Run Environment: Both OpenResty and Tengine are supported.
-- Supports ARM64: Don't worry about the lock-in of the infra technology.
+
+  - Cloud-Native: Platform agnostic, No vendor lock-in, APISIX can run from 
bare-metal to Kubernetes.
+  - Run Environment: Both OpenResty and Tengine are supported.
+  - Supports ARM64: Don't worry about the lock-in of the infra technology.
 
 - **Multi protocols**
-- [TCP/UDP Proxy](doc/stream-proxy.md): Dynamic TCP/UDP proxy.
-- [Dynamic MQTT Proxy](doc/plugins/mqtt-proxy.md): Supports to load 
balance MQTT by `client_id`, both support MQTT 
[3.1.*](http://docs.oasis-open.org/mqtt/mqtt/v3.1.1/os/mqtt-v3.1.1-os.html), 
[5.0](https://docs.oasis-open.org/mqtt/mqtt/v5.0/mqtt-v5.0.html).
-- [gRPC proxy](doc/grpc-proxy.md): Proxying gRPC traffic.
-- [gRPC transcoding](doc/plugins/grpc-transcode.md): Supports protocol 
transcoding so that clients can access your gRPC API by using HTTP/JSON.
-- Proxy Websocket
-- Proxy Protocol
-- Proxy Dubbo: Dubbo Proxy based on Tengine.
-- HTTP(S) Forward Proxy
-- [SSL](doc/https.md): Dynamically load an SSL certificate.
+
+  - [TCP/UDP Proxy](doc/stream-proxy.md): Dynamic TCP/UDP proxy.
+  - [Dynamic MQTT Proxy](doc/plugins/mqtt-proxy.md): Supports to load balance 
MQTT by `client_id`, both support MQTT 
[3.1.\*](http://docs.oasis-open.org/mqtt/mqtt/v3.1.1/os/mqtt-v3.1.1-os.html), 
[5.0](https://docs.oasis-open.org/mqtt/mqtt/v5.0/mqtt-v5.0.html).
+  - [gRPC proxy](doc/grpc-proxy.md): Proxying gRPC traffic.
+  - [gRPC transcod

[apisix] branch master updated: feature: support percentage for fault injection (#2516)

2020-10-27 Thread membphis
This is an automated email from the ASF dual-hosted git repository.

membphis pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/apisix.git


The following commit(s) were added to refs/heads/master by this push:
 new 3306a3e  feature: support percentage for fault injection (#2516)
3306a3e is described below

commit 3306a3ed3ca58ad319a280e484b700fc20dc221b
Author: Alex Zhang 
AuthorDate: Tue Oct 27 14:10:44 2020 +0800

feature: support percentage for fault injection (#2516)
---
 apisix/plugins/fault-injection.lua   |  27 +++--
 doc/plugins/fault-injection.md   |   2 +
 doc/zh-cn/plugins/fault-injection.md |   2 +
 t/plugin/fault-injection.t   | 112 +++
 4 files changed, 139 insertions(+), 4 deletions(-)

diff --git a/apisix/plugins/fault-injection.lua 
b/apisix/plugins/fault-injection.lua
index 8cf8b8d..aace3e2 100644
--- a/apisix/plugins/fault-injection.lua
+++ b/apisix/plugins/fault-injection.lua
@@ -14,8 +14,10 @@
 -- See the License for the specific language governing permissions and
 -- limitations under the License.
 --
-local core  = require("apisix.core")
-local sleep = core.sleep
+local core = require("apisix.core")
+
+local sleep = core.sleep
+local random = math.random
 
 local plugin_name   = "fault-injection"
 
@@ -28,6 +30,7 @@ local schema = {
 properties = {
 http_status = {type = "integer", minimum = 200},
 body = {type = "string", minLength = 0},
+percentage = {type = "integer", minimum = 0, maximum = 100}
 },
 minProperties = 1,
 },
@@ -35,6 +38,7 @@ local schema = {
 type = "object",
 properties = {
 duration = {type = "number", minimum = 0},
+percentage = {type = "integer", minimum = 0, maximum = 100}
 },
 minProperties = 1,
 }
@@ -51,6 +55,15 @@ local _M = {
 }
 
 
+local function sample_hit(percentage)
+if not percentage then
+return true
+end
+
+return random(0, 100) <= percentage
+end
+
+
 function _M.check_schema(conf)
 local ok, err = core.schema.check(schema, conf)
 if not ok then
@@ -64,11 +77,17 @@ end
 function _M.rewrite(conf, ctx)
 core.log.info("plugin rewrite phase, conf: ", core.json.delay_encode(conf))
 
-if conf.delay and conf.delay.duration ~= nil then
+if conf.delay
+   and conf.delay.duration ~= nil
+   and sample_hit(conf.delay.percentage)
+then
 sleep(conf.delay.duration)
 end
 
-if conf.abort and conf.abort.http_status ~= nil then
+if conf.abort
+   and conf.abort.http_status ~= nil
+   and sample_hit(conf.abort.percentage)
+then
 return conf.abort.http_status, conf.abort.body
 end
 end
diff --git a/doc/plugins/fault-injection.md b/doc/plugins/fault-injection.md
index 7209018..ff09cfc 100644
--- a/doc/plugins/fault-injection.md
+++ b/doc/plugins/fault-injection.md
@@ -29,7 +29,9 @@ Fault injection plugin, this plugin can be used with other 
plugins and will be e
 | - | --- | --- | --- | -- | 
 |
 | abort.http_status | integer | optional| | [200, ...] | 
user-specified http code returned to the client. |
 | abort.body| string  | optional| || response 
data returned to the client.|
+| abort.percentage  | integer | optional| | [0, 100]   | 
percentage of requests to be aborted.|
 | delay.duration| number  | optional| || delay 
time (can be decimal). |
+| delay.percentage  | integer | optional| | [0, 100]   | 
percentage of requests to be delayed.|
 
 Note: One of `abort` and `delay` must be specified.
 
diff --git a/doc/zh-cn/plugins/fault-injection.md 
b/doc/zh-cn/plugins/fault-injection.md
index eb50de8..ad40492 100644
--- a/doc/zh-cn/plugins/fault-injection.md
+++ b/doc/zh-cn/plugins/fault-injection.md
@@ -29,7 +29,9 @@
 | - | --- | -- | -- | -- | 
-- |
 | abort.http_status | integer | 可选   || [200, ...] | 返回给客户端的 http 状态码 |
 | abort.body| string  | 可选   ||| 返回给客户端的响应数据 |
+| abort.percentage  | integer | 可选   || [0, 100]   | 将被中断的请求占比 
|
 | delay.duration| number  | 可选   ||| 延迟时间,可以指定小数 |
+| delay.percentage  | integer | 可选   || [0, 100]   | 将被延迟的请求占比 
|
 
 注:参数 abort 和 delay 至少要存在一个。
 
diff --git a/t/plugin/fault-injection.t b/t/plugin/fault-injection.t
index 9a44745..c427714 100644
--- a/t/plugin/fault-injection.t
+++ b/t/plugin/fault-injection.t
@@ -523,3 +523,115 @@ GET /hello HTTP/1.1
 F

[apisix] branch master updated: feat: implement api breaker plugin. (#2455)

2020-10-26 Thread membphis
This is an automated email from the ASF dual-hosted git repository.

membphis pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/apisix.git


The following commit(s) were added to refs/heads/master by this push:
 new 6a7dfa6  feat: implement api breaker plugin. (#2455)
6a7dfa6 is described below

commit 6a7dfa677562876538f3afe8b61f25ad2af39e20
Author: YuanSheng Wang 
AuthorDate: Tue Oct 27 13:40:23 2020 +0800

feat: implement api breaker plugin. (#2455)

Co-authored-by: liuheng 
---
 apisix/plugins/api-breaker.lua   | 248 +++
 bin/apisix   |   1 +
 conf/config-default.yaml |   1 +
 doc/plugins/api-breaker.md   | 117 +++
 doc/zh-cn/plugins/api-breaker.md | 116 +++
 t/APISIX.pm  |   1 +
 t/admin/plugins.t|   2 +-
 t/debug/debug-mode.t |   1 +
 t/lib/server.lua |   9 +
 t/plugin/api-breaker.t   | 651 +++
 10 files changed, 1146 insertions(+), 1 deletion(-)

diff --git a/apisix/plugins/api-breaker.lua b/apisix/plugins/api-breaker.lua
new file mode 100644
index 000..d97577d
--- /dev/null
+++ b/apisix/plugins/api-breaker.lua
@@ -0,0 +1,248 @@
+--
+-- Licensed to the Apache Software Foundation (ASF) under one or more
+-- contributor license agreements.  See the NOTICE file distributed with
+-- this work for additional information regarding copyright ownership.
+-- The ASF licenses this file to You under the Apache License, Version 2.0
+-- (the "License"); you may not use this file except in compliance with
+-- the License.  You may obtain a copy of the License at
+--
+-- http://www.apache.org/licenses/LICENSE-2.0
+--
+-- Unless required by applicable law or agreed to in writing, software
+-- distributed under the License is distributed on an "AS IS" BASIS,
+-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+-- See the License for the specific language governing permissions and
+-- limitations under the License.
+--
+
+local core = require("apisix.core")
+local plugin_name = "api-breaker"
+local ngx = ngx
+local math = math
+local error = error
+local ipairs = ipairs
+
+local shared_buffer = ngx.shared['plugin-'.. plugin_name]
+if not shared_buffer then
+error("failed to get ngx.shared dict when load plugin " .. plugin_name)
+end
+
+
+local schema = {
+type = "object",
+properties = {
+break_response_code = {
+type = "integer",
+minimum = 200,
+maximum = 599,
+},
+max_breaker_sec = {
+type = "integer",
+minimum = 3,
+default = 300,
+},
+unhealthy = {
+type = "object",
+properties = {
+http_statuses = {
+type = "array",
+minItems = 1,
+items = {
+type = "integer",
+minimum = 500,
+maximum = 599,
+},
+uniqueItems = true,
+default = {500}
+},
+failures = {
+type = "integer",
+minimum = 1,
+default = 3,
+}
+},
+default = {http_statuses = {500}, failures = 3}
+},
+healthy = {
+type = "object",
+properties = {
+http_statuses = {
+type = "array",
+minItems = 1,
+items = {
+type = "integer",
+minimum = 200,
+maximum = 499,
+},
+uniqueItems = true,
+default = {200}
+},
+successes = {
+type = "integer",
+minimum = 1,
+default = 3,
+}
+},
+default = {http_statuses = {200}, successes = 3}
+}
+},
+required = {"break_response_code"},
+}
+
+
+-- todo: we can move this into `core.talbe`
+local function array_find(array, val)
+for i, v in ipairs(array) do
+if v == val then
+return i
+end
+end
+
+return nil
+end
+
+
+local function gen_healthy_key(ctx)
+return "healthy-" .. core.request.get_host(ctx) .. ctx.var.uri
+end
+
+
+local function gen_unhealthy_key(ctx)
+return "unhealthy-" .. core.request.get_host(ctx) .. ctx.var.uri
+end
+
+
+local function gen_lasttime_key(ctx)
+return "unhealthy-lastime" .. core.request.get_host(ctx) .. ctx.var.uri
+end
+
+
+local _M = {
+versi

[apisix] branch master updated: feat:The limit-conn plugin supports 'consumer_name' field (#2415)

2020-10-26 Thread membphis
This is an automated email from the ASF dual-hosted git repository.

membphis pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/apisix.git


The following commit(s) were added to refs/heads/master by this push:
 new e2f450f  feat:The limit-conn plugin supports 'consumer_name' field 
(#2415)
e2f450f is described below

commit e2f450fa1a3e62c67b2c28b7c204e750dfc437b9
Author: JinChen <36916582+jayc...@users.noreply.github.com>
AuthorDate: Tue Oct 27 10:44:44 2020 +0800

feat:The limit-conn plugin supports 'consumer_name' field (#2415)

The limit-conn plugin supports the` consumer_name` field
The method of PR is referred: #2333
---
 apisix/plugins/limit-conn.lua   |   2 +-
 doc/plugins/limit-conn.md   |   2 +-
 doc/zh-cn/plugins/limit-conn.md |   2 +-
 t/plugin/limit-conn.t   | 242 +++-
 4 files changed, 244 insertions(+), 4 deletions(-)

diff --git a/apisix/plugins/limit-conn.lua b/apisix/plugins/limit-conn.lua
index ca8ca3c..2b80a3b 100644
--- a/apisix/plugins/limit-conn.lua
+++ b/apisix/plugins/limit-conn.lua
@@ -28,7 +28,7 @@ local schema = {
 default_conn_delay = {type = "number", exclusiveMinimum = 0},
 key = {type = "string",
 enum = {"remote_addr", "server_addr", "http_x_real_ip",
-"http_x_forwarded_for"},
+"http_x_forwarded_for", "consumer_name"},
 },
 rejected_code = {type = "integer", minimum = 200, default = 503},
 },
diff --git a/doc/plugins/limit-conn.md b/doc/plugins/limit-conn.md
index 0b3c7c7..5a50629 100644
--- a/doc/plugins/limit-conn.md
+++ b/doc/plugins/limit-conn.md
@@ -37,7 +37,7 @@ Limiting request concurrency plugin.
 | conn   | integer | required| | [0,...]   
   | the maximum number of 
concurrent requests allowed. Requests exceeding this ratio (and below `conn` + 
`burst`) will get delayed to conform to this threshold. 


[...]
 | burst  | integer | required| | [0,...]   
   | the number of excessive 
concurrent requests (or connections) allowed to be delayed. 



 [...]
 | default_conn_delay | number  | required| | [0,...]   
   | the default processing 
latency of a typical connection (or request).   



  [...]
-| key| object  | required| | ["remote_addr", 
"server_addr", "http_x_real_ip", "http_x_forwarded_for"] | to limit the 
concurrency level. For example, one can use the host name (or server zone) 
as the key so that we limit concurrency per host name. Otherwise, we can also 
use the client address as the key so that we can avoid a single client from 
flooding our service with too many parallel connections or requests.  Now 
accept those as key: "remote_addr"(c [...]
+| key| object  | required| | ["remote_addr", 
"server_addr", "http_x_real_ip", "http_x_forwarded_for", "consumer_name"] | to 
limit the concurrency level. For example, one can use the host name (or 
server zone) as the key so that we limit concurrency per host name. Otherwise, 
we can also use the client address as the key so that we can avoid a single 
client from flooding our service with too many parallel connections or 
requests.  Now accept those as key [...]
 | rejected_code  | string  | optional| 503 | [200,...] 
   | returned when the request 
exceeds `conn` + `burst` will be rejected.  



   [...]
 
 **Key can be customized 

[apisix] branch master updated: doc(readme): Contributor Over Time (#2454)

2020-10-26 Thread membphis
This is an automated email from the ASF dual-hosted git repository.

membphis pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/apisix.git


The following commit(s) were added to refs/heads/master by this push:
 new dfc50fd  doc(readme): Contributor Over Time (#2454)
dfc50fd is described below

commit dfc50fd95b2e9cf23434c3cdd8a0b9468aa9ca24
Author: Yousa 
AuthorDate: Tue Oct 27 10:42:15 2020 +0800

doc(readme): Contributor Over Time (#2454)
---
 README.md|   4 
 README_CN.md |   4 
 doc/images/contributor-over-time.png | Bin 0 -> 199476 bytes
 3 files changed, 8 insertions(+)

diff --git a/README.md b/README.md
index 509c635..9e66351 100644
--- a/README.md
+++ b/README.md
@@ -287,6 +287,10 @@ A wide variety of companies and organizations use APISIX 
for research, productio
 
 Users are encouraged to add themselves to the [Powered By](doc/powered-by.md) 
page.
 
+## Contributor Over Time
+
+![contributor-over-time](./doc/images/contributor-over-time.png)
+
 ## Landscape
 
 https://landscape.cncf.io/images/left-logo.svg; 
width="150">https://landscape.cncf.io/images/right-logo.svg; width="200">
diff --git a/README_CN.md b/README_CN.md
index 63f80a4..f27e320 100644
--- a/README_CN.md
+++ b/README_CN.md
@@ -291,6 +291,10 @@ Dashboard 默认只允许 127.0.0.1 访问。你可以自行修改 `conf/config.
 
 欢迎用户把自己加入到 [Powered By](doc/powered-by.md) 页面。
 
+## 贡献者变化
+
+![contributor-over-time](./doc/images/contributor-over-time.png)
+
 ## 全景图
 
 https://landscape.cncf.io/images/left-logo.svg; 
width="150">https://landscape.cncf.io/images/right-logo.svg; width="200">
diff --git a/doc/images/contributor-over-time.png 
b/doc/images/contributor-over-time.png
new file mode 100644
index 000..b245519
Binary files /dev/null and b/doc/images/contributor-over-time.png differ



[apisix] branch master updated (443e7b4 -> 80affa0)

2020-10-26 Thread membphis
This is an automated email from the ASF dual-hosted git repository.

membphis pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/apisix.git.


from 443e7b4  release: release 2.0 version. (#2283)
 add 80affa0  feat: The limit-count plugin supports service_id field. 
(#2521)

No new revisions were added by this update.

Summary of changes:
 apisix/plugins/limit-count.lua   |   2 +-
 doc/plugins/limit-count.md   |  12 +--
 doc/zh-cn/plugins/limit-count.md |  20 ++--
 t/plugin/limit-count.t   | 207 +++
 4 files changed, 228 insertions(+), 13 deletions(-)



[apisix] branch master updated: doc: correct the guide of creating consumer guide in AdminAPI (#2513)

2020-10-26 Thread membphis
This is an automated email from the ASF dual-hosted git repository.

membphis pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/apisix.git


The following commit(s) were added to refs/heads/master by this push:
 new 5be8d85  doc: correct the guide of creating consumer guide in AdminAPI 
(#2513)
5be8d85 is described below

commit 5be8d850c0651302bf8e647df59c7dd41ddb2e78
Author: Joey 
AuthorDate: Mon Oct 26 22:07:37 2020 +0800

doc: correct the guide of creating consumer guide in AdminAPI (#2513)

Fix #2512
---
 doc/admin-api.md   | 3 +--
 doc/zh-cn/admin-api.md | 3 +--
 2 files changed, 2 insertions(+), 4 deletions(-)

diff --git a/doc/admin-api.md b/doc/admin-api.md
index 2e95ff7..eb6e0e3 100644
--- a/doc/admin-api.md
+++ b/doc/admin-api.md
@@ -410,7 +410,7 @@ Return response from etcd currently.
 
 *API*:/apisix/admin/consumers/{id}
 
-*Description*:Consumers are consumers of certain types of services and can 
only be used in conjunction with a user authentication system.
+*Description*:Consumers are consumers of certain types of services and can 
only be used in conjunction with a user authentication system. Consumer regards 
the `username` property as the identity, so only the HTTP `PUT` method is 
supported for creating a new consumer.
 
 > Request Methods:
 
@@ -418,7 +418,6 @@ Return response from etcd currently.
 |-|-|--|--|
 |GET  |/apisix/admin/consumers/{id}|NULL|Fetch resource|
 |PUT  |/apisix/admin/consumers/{id}|{...}|Create resource by ID|
-|POST |/apisix/admin/consumers |{...}|Create resource, and ID is 
generated by server|
 |DELETE   |/apisix/admin/consumers/{id}|NULL|Remove resource|
 
 > Request Body Parameters:
diff --git a/doc/zh-cn/admin-api.md b/doc/zh-cn/admin-api.md
index 8e958e7..f971446 100644
--- a/doc/zh-cn/admin-api.md
+++ b/doc/zh-cn/admin-api.md
@@ -423,7 +423,7 @@ HTTP/1.1 200 OK
 
 *地址*:/apisix/admin/consumers/{id}
 
-*说明*:Consumer 是某类服务的消费者,需与用户认证体系配合才能使用。
+*说明*:Consumer 是某类服务的消费者,需与用户认证体系配合才能使用。Consumer 使用 `username` 作为唯一标识,只支持使用 
HTTP `PUT` 方法创建 Consumer。
 
 > 请求方法:
 
@@ -431,7 +431,6 @@ HTTP/1.1 200 OK
 |-|-|--|--|
 |GET  |/apisix/admin/consumers/{id}|无|获取资源|
 |PUT  |/apisix/admin/consumers/{id}|{...}|根据 id 创建资源|
-|POST |/apisix/admin/consumers |{...}|创建资源,id 由后台服务自动生成|
 |DELETE   |/apisix/admin/consumers/{id}|无|删除资源|
 
 > body 请求参数:



[apisix] branch master updated: doc(http-logger): sync Chinese doc to the English one (#2510)

2020-10-24 Thread membphis
This is an automated email from the ASF dual-hosted git repository.

membphis pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/apisix.git


The following commit(s) were added to refs/heads/master by this push:
 new d5dc0e0  doc(http-logger): sync Chinese doc to the English one (#2510)
d5dc0e0 is described below

commit d5dc0e08d104b877362bd14058af8c47b5f395be
Author: 罗泽轩 
AuthorDate: Sun Oct 25 07:54:38 2020 +0800

doc(http-logger): sync Chinese doc to the English one (#2510)
---
 doc/plugins/http-logger.md   | 29 +
 doc/zh-cn/plugins/http-logger.md | 11 ++-
 2 files changed, 35 insertions(+), 5 deletions(-)

diff --git a/doc/plugins/http-logger.md b/doc/plugins/http-logger.md
index 3fd5b9e..8c4f20b 100644
--- a/doc/plugins/http-logger.md
+++ b/doc/plugins/http-logger.md
@@ -25,6 +25,7 @@
 - [**Attributes**](#attributes)
 - [**How To Enable**](#how-to-enable)
 - [**Test Plugin**](#test-plugin)
+- [**Metadata**](#metadata)
 - [**Disable Plugin**](#disable-plugin)
 
 
@@ -83,6 +84,34 @@ HTTP/1.1 200 OK
 hello, world
 ```
 
+## Metadata
+
+| Name | Type| Requirement | Default   | Valid   | 
Description 
 |
+|  | --- | --- | - | --- | 

 |
+| log_format   | object  | optional|   | | Log 
format declared as JSON object. Only string is supported in the `value` part. 
If the value starts with `$`, the value is [Nginx 
variable](http://nginx.org/en/docs/varindex.html). |
+
+ Note that the metadata configuration is applied in global scope, which means 
it will take effect on all Route or Service which use http-logger plugin.
+
+### Example
+
+```shell
+curl http://127.0.0.1:9080/apisix/admin/plugin_metadata/http-logger -H 
'X-API-KEY: edd1c9f034335f136f87ad84b625c8f1' -X PUT -d '
+{
+"log_format": {
+"host": "$host",
+"@timestamp": "$time_iso8601",
+"client_ip": "$remote_addr"
+}
+}'
+```
+
+It is expected to see some logs like that:
+
+```shell
+{"host":"localhost","@timestamp":"2020-09-23T19:05:05-04:00","client_ip":"127.0.0.1","route_id":"1"}
+{"host":"localhost","@timestamp":"2020-09-23T19:05:05-04:00","client_ip":"127.0.0.1","route_id":"1"}
+```
+
 ## Disable Plugin
 
 Remove the corresponding json configuration in the plugin configuration to 
disable the `http-logger`.
diff --git a/doc/zh-cn/plugins/http-logger.md b/doc/zh-cn/plugins/http-logger.md
index 5569432..b45947e 100644
--- a/doc/zh-cn/plugins/http-logger.md
+++ b/doc/zh-cn/plugins/http-logger.md
@@ -21,11 +21,12 @@
 
 # 目录
 
-- [**定义**](#name)
-- [**属性列表**](#attributes)
-- [**如何开启**](#how-to-enable)
-- [**测试插件**](#test-plugin)
-- [**禁用插件**](#disable-plugin)
+- [**定义**](#定义)
+- [**属性列表**](#属性列表)
+- [**如何开启**](#如何开启)
+- [**测试插件**](#测试插件)
+- [**插件元数据设置**](#插件元数据设置)
+- [**禁用插件**](#禁用插件)
 
 ## 定义
 



[apisix] branch master updated: feat(hmac-auth): remove auth headers for hmac-auth plugin. (#2491)

2020-10-24 Thread membphis
This is an automated email from the ASF dual-hosted git repository.

membphis pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/apisix.git


The following commit(s) were added to refs/heads/master by this push:
 new 853a7be  feat(hmac-auth): remove auth headers for hmac-auth plugin. 
(#2491)
853a7be is described below

commit 853a7be0f4f81cf080a52c13e2a284b3e0b2e5a2
Author: Firstsawyou <52862365+firstsaw...@users.noreply.github.com>
AuthorDate: Sun Oct 25 07:33:11 2020 +0800

feat(hmac-auth): remove auth headers for hmac-auth plugin. (#2491)

fix #2490
---
 apisix/plugins/hmac-auth.lua   |  34 
 doc/plugins/hmac-auth.md   |  11 +-
 doc/zh-cn/plugins/hmac-auth.md |   1 +
 t/plugin/hmac-auth.t   | 385 +
 4 files changed, 426 insertions(+), 5 deletions(-)

diff --git a/apisix/plugins/hmac-auth.lua b/apisix/plugins/hmac-auth.lua
index edb3a78..57160d7 100644
--- a/apisix/plugins/hmac-auth.lua
+++ b/apisix/plugins/hmac-auth.lua
@@ -67,6 +67,11 @@ local consumer_schema = {
 maxLength = 50,
 }
 },
+keep_headers = {
+type = "boolean",
+title = "whether to keep the http request header",
+default = false,
+}
 },
 required = {"access_key", "secret_key"},
 additionalProperties = false,
@@ -118,6 +123,17 @@ local function array_to_map(arr)
 end
 
 
+local function remove_headers(...)
+local headers = { ... }
+if headers and #headers > 0 then
+for _, header in ipairs(headers) do
+core.log.info("remove_header: ", header)
+core.request.set_header(header, nil)
+end
+end
+end
+
+
 local create_consumer_cache
 do
 local consumer_ids = {}
@@ -291,6 +307,17 @@ local function validate(ctx, params)
 return consumer
 end
 
+
+local function get_keep_headers(access_key)
+local consumer, err = get_consumer(access_key)
+if err then
+return false, err
+end
+
+return consumer.auth_conf.keep_headers
+end
+
+
 local function get_params(ctx)
 local params = {}
 local local_conf = core.config.local_conf()
@@ -343,6 +370,13 @@ local function get_params(ctx)
 params.date  = date or ""
 params.signed_headers = signed_headers and ngx_re.split(signed_headers, 
";")
 
+local keep_headers = get_keep_headers(params.access_key)
+core.log.info("keep_headers: ", keep_headers)
+
+if not keep_headers then
+remove_headers(signature_key, algorithm_key, signed_headers_key)
+end
+
 core.log.info("params: ", core.json.delay_encode(params))
 
 return params
diff --git a/doc/plugins/hmac-auth.md b/doc/plugins/hmac-auth.md
index 753addd..8c1bf10 100644
--- a/doc/plugins/hmac-auth.md
+++ b/doc/plugins/hmac-auth.md
@@ -21,11 +21,11 @@
 
 # Summary
 
-- [**Name**](#name)
-- [**Attributes**](#attributes)
-- [**How To Enable**](#how-to-enable)
-- [**Test Plugin**](#test-plugin)
-- [**Disable Plugin**](#disable-plugin)
+  - [**Name**](#name)
+  - [**Attributes**](#attributes)
+  - [**How To Enable**](#how-to-enable)
+  - [**Test Plugin**](#test-plugin)
+  - [**Disable Plugin**](#disable-plugin)
 
 ## Name
 
@@ -42,6 +42,7 @@ The `consumer` then adds its key to request header to verify 
its request.
 | algorithm  | string| optional| "hmac-sha256" | ["hmac-sha1", 
"hmac-sha256", "hmac-sha512"] | Encryption algorithm.   


  |
 | clock_skew | integer   | optional| 0   | 
| The clock skew allowed by the signature in 
seconds. For example, if the time is allowed to skew by 10 seconds, then it 
should be set to `10`. especially, `0` means not checking `Date`
|
 | signed_headers | array[string] | optional|   |   
  | Restrict the headers that are added to the 
encrypted calculation. After the specified, the client request can only specify 
the headers within this range. When this item is empty, all the headers 
specified by the client request will be added to the encrypted calculation |
+| keep_headers | boolean | optional| false   |   [ true, 
false ]  | Whether it is necessary to keep the request headers 
of `X-HMAC-SIGNATURE`, `X-HMAC-ALGORITHM` and `X-HMAC-SIGNED-HEADERS` in the 
http request after successful authentication. true: means to keep the http 
request header, false: means to remove the http request

[apisix-dashboard] branch master updated: doc: update docs about preinstall in deployment (#597)

2020-10-24 Thread membphis
This is an automated email from the ASF dual-hosted git repository.

membphis pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/apisix-dashboard.git


The following commit(s) were added to refs/heads/master by this push:
 new a050e84  doc: update docs about preinstall in deployment (#597)
a050e84 is described below

commit a050e8464165c973663fc14fa5a7ecfd7255f1ae
Author: nic-chen <33000667+nic-c...@users.noreply.github.com>
AuthorDate: Sun Oct 25 07:25:58 2020 +0800

doc: update docs about preinstall in deployment (#597)

* fix: update docs about preinstall in deployment

* fix: use the exists schema.json so we don't need Lua on building

Co-authored-by: 琚致远 
---
 api/run.sh   | 8 
 docs/deploy.md   | 5 -
 docs/deploy.zh-CN.md | 4 +++-
 3 files changed, 11 insertions(+), 6 deletions(-)

diff --git a/api/run.sh b/api/run.sh
index 737cd24..a45061d 100755
--- a/api/run.sh
+++ b/api/run.sh
@@ -41,8 +41,8 @@ if [[ ! -f "dag-to-lua-1.1/lib/dag-to-lua.lua" ]]; then
 fi
 
 
-# generate json schema
-if [[ ! -f "${pwd}/schema.json" ]]; then
+# generate json schema if need a new one
+if [[ ! -f "${pwd}/api/conf/schema.json" ]]; then
 rm master.zip
 rm -rf ./api/build-tools/apisix/
 wget https://github.com/apache/apisix/archive/master.zip
@@ -50,8 +50,8 @@ if [[ ! -f "${pwd}/schema.json" ]]; then
 mkdir -p ./api/build-tools/apisix/
 mv ./apisix-master/apisix/* ./api/build-tools/apisix/
 rm -rf ./apisix-master
-cd ./api/build-tools/ && lua schema-sync.lua > ${pwd}/schema.json
-cd ../../
+cd ./api/build-tools/ && lua schema-sync.lua > ${pwd}/api/conf/schema.json
+cd ../../
 fi
 
 # build
diff --git a/docs/deploy.md b/docs/deploy.md
index 53ebad1..a91dc3d 100644
--- a/docs/deploy.md
+++ b/docs/deploy.md
@@ -31,7 +31,9 @@ $ cd apisix-dashboard
 
 The `manager-api` is used to provide APIs for Dashboard, just like a bridge 
between the Apache APISIX and the Dashboard. Here are the steps to build it 
manually:
 
-1. We need `Go` 1.13+ and `Lua` 5.1+ to be preinstalled.
+1. We need `Go` 1.13+ to be preinstalled.
+
+NOTE: You also need to install `Lua` 5.1+ if you want to use the Plugin 
Orchestration, we will improve this part and omit Lua's dependency in the 
future.
 
 2. Check environment variables
 
@@ -84,4 +86,5 @@ $ yarn build
 ```
 
 5. The bundled files are under `/dist` folder if the step 4 is successful.
+
 6. Move files under `dist` folder to manager-api's `dist` folder, then visit 
`http://127.0.0.1:8080` in your browser, `8080` is the default listen port of 
manager-api.
diff --git a/docs/deploy.zh-CN.md b/docs/deploy.zh-CN.md
index 01c2159..f8a899b 100644
--- a/docs/deploy.zh-CN.md
+++ b/docs/deploy.zh-CN.md
@@ -31,7 +31,9 @@ $ cd apisix-dashboard
 
 `manager-api` 用于为控制台提供接口,就像 Apache APISIX 和控制台之间的桥梁。下面是手动构建步骤:
 
-1. 需要预先安装 `Go` 1.13+ 、`Lua` 5.1+
+1. 需要预先安装 `Go` 1.13+
+
+注意:如果使用插件编排,需要同时预先安装 `Lua` 5.1+ ,后续版本会对此进行优化,取消对 `Lua` 的依赖。
 
 2. 检查环境变量
 



[apisix] branch master updated (26ad5cf -> cb04193)

2020-10-19 Thread membphis
This is an automated email from the ASF dual-hosted git repository.

membphis pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/apisix.git.


from 26ad5cf  doc(echo): mark it as production-unready (#2461)
 add cb04193  bugfix: modify json schema definition for plugin 
request-validation (#2451)

No new revisions were added by this update.

Summary of changes:
 apisix/plugins/request-validation.lua | 20 ++--
 1 file changed, 14 insertions(+), 6 deletions(-)



[apisix] branch master updated (26ad5cf -> cb04193)

2020-10-19 Thread membphis
This is an automated email from the ASF dual-hosted git repository.

membphis pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/apisix.git.


from 26ad5cf  doc(echo): mark it as production-unready (#2461)
 add cb04193  bugfix: modify json schema definition for plugin 
request-validation (#2451)

No new revisions were added by this update.

Summary of changes:
 apisix/plugins/request-validation.lua | 20 ++--
 1 file changed, 14 insertions(+), 6 deletions(-)



[apisix] branch master updated: plugin(consumer-restriction): use draft7 way to rewrite the JSON Schema. (#2440)

2020-10-18 Thread membphis
This is an automated email from the ASF dual-hosted git repository.

membphis pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/apisix.git


The following commit(s) were added to refs/heads/master by this push:
 new 5fcbb4d  plugin(consumer-restriction): use draft7 way to rewrite the 
JSON Schema. (#2440)
5fcbb4d is described below

commit 5fcbb4de9cdaac2570f8132fca98fc2bd2a93a0a
Author: JinChen <36916582+jayc...@users.noreply.github.com>
AuthorDate: Mon Oct 19 09:55:08 2020 +0800

plugin(consumer-restriction): use draft7 way to rewrite the JSON Schema. 
(#2440)

fix: #2402
---
 apisix/plugins/consumer-restriction.lua | 54 +
 t/plugin/consumer-restriction.t |  7 +++--
 2 files changed, 38 insertions(+), 23 deletions(-)

diff --git a/apisix/plugins/consumer-restriction.lua 
b/apisix/plugins/consumer-restriction.lua
index f80e096..68b1711 100644
--- a/apisix/plugins/consumer-restriction.lua
+++ b/apisix/plugins/consumer-restriction.lua
@@ -19,27 +19,41 @@ local core  = require("apisix.core")
 
 local schema = {
 type = "object",
-properties = {
-type = {
-type = "string",
-enum = {"consumer_name", "service_id"},
-default = "consumer_name"
-},
-whitelist = {
-type = "array",
-items = {type = "string"},
-minItems = 1
-},
-blacklist = {
-type = "array",
-items = {type = "string"},
-minItems = 1
-},
-rejected_code = {type = "integer", minimum = 200, default = 403}
-},
 oneOf = {
-{required = {"whitelist"}},
-{required = {"blacklist"}}
+{
+title = "blacklist",
+properties = {
+type = {
+type = "string",
+enum = {"consumer_name", "service_id"},
+default = "consumer_name"
+   },
+   blacklist = {
+type = "array",
+minItems = 1,
+items = {type = "string"}
+},
+rejected_code = {type = "integer", minimum = 200, default = 
403}
+},
+required = {"blacklist"},
+},
+{
+title = "whitelist",
+properties = {
+   type = {
+type = "string",
+enum = {"consumer_name", "service_id"},
+default = "consumer_name"
+   },
+whitelist = {
+type = "array",
+minItems = 1,
+items = {type = "string"}
+  },
+   rejected_code = {type = "integer", minimum = 200, default = 403}
+},
+required = {"whitelist"},
+}
 }
 }
 
diff --git a/t/plugin/consumer-restriction.t b/t/plugin/consumer-restriction.t
index afa7492..bca9817 100644
--- a/t/plugin/consumer-restriction.t
+++ b/t/plugin/consumer-restriction.t
@@ -30,8 +30,9 @@ __DATA__
 location /t {
 content_by_lua_block {
 local plugin = require("apisix.plugins.consumer-restriction")
-local conf = {
-whitelist = {
+local conf = {
+   title = "whitelist",
+   whitelist = {
 "jack1",
 "jack2"
 }
@@ -47,7 +48,7 @@ __DATA__
 --- request
 GET /t
 --- response_body
-{"rejected_code":403,"type":"consumer_name","whitelist":["jack1","jack2"]}
+{"type":"consumer_name","title":"whitelist","rejected_code":403,"whitelist":["jack1","jack2"]}
 --- no_error_log
 [error]
 



[apisix] branch master updated (9e1030e -> c939262)

2020-10-17 Thread membphis
This is an automated email from the ASF dual-hosted git repository.

membphis pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/apisix.git.


from 9e1030e  feat: `limit-count` plugin supports limiting requests by 
consumer name. (#2421)
 add c939262  bugfix: empty `allow_admin` means that any IP is allowed to 
access Admin API and Dashboard (#1979)

No new revisions were added by this update.

Summary of changes:
 .travis/apisix_cli_test.sh | 33 -
 bin/apisix | 12 
 2 files changed, 44 insertions(+), 1 deletion(-)



[apisix] branch master updated (3bb670b -> 9e1030e)

2020-10-17 Thread membphis
This is an automated email from the ASF dual-hosted git repository.

membphis pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/apisix.git.


from 3bb670b  bugfix: set route priority for router `radixtree_host_uri`. 
(#2447)
 add 9e1030e  feat: `limit-count` plugin supports limiting requests by 
consumer name. (#2421)

No new revisions were added by this update.

Summary of changes:
 apisix/plugins/limit-count.lua   |  2 +-
 doc/plugins/limit-count.md   |  2 +-
 doc/zh-cn/plugins/limit-count.md |  2 +-
 t/plugin/limit-count.t   | 85 
 4 files changed, 88 insertions(+), 3 deletions(-)



[apisix] branch master updated (a92331c -> 3bb670b)

2020-10-17 Thread membphis
This is an automated email from the ASF dual-hosted git repository.

membphis pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/apisix.git.


from a92331c  feature: add managed fields in json schema for resources, 
such as create_time and update_time (#2444)
 add 3bb670b  bugfix: set route priority for router `radixtree_host_uri`. 
(#2447)

No new revisions were added by this update.

Summary of changes:
 apisix/http/router/radixtree_host_uri.lua  |  1 +
 ...e-host-uri2.t => radixtree-host-uri-priority.t} | 72 --
 2 files changed, 25 insertions(+), 48 deletions(-)
 copy t/router/{radixtree-host-uri2.t => radixtree-host-uri-priority.t} (75%)



[apisix] branch master updated: feat: In dns parse, when the parameter `resolvers` is empty, the local dns is used as `resolvers` by default (#2424)

2020-10-16 Thread membphis
This is an automated email from the ASF dual-hosted git repository.

membphis pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/apisix.git


The following commit(s) were added to refs/heads/master by this push:
 new d1729c0  feat: In dns parse, when the parameter `resolvers` is empty, 
the local dns is used as `resolvers` by default  (#2424)
d1729c0 is described below

commit d1729c0af3bc416a88904568b4d2718c99a1982d
Author: Firstsawyou <52862365+firstsaw...@users.noreply.github.com>
AuthorDate: Sat Oct 17 13:44:53 2020 +0800

feat: In dns parse, when the parameter `resolvers` is empty, the local dns 
is used as `resolvers` by default  (#2424)

fix #2422
---
 apisix/core/utils.lua  | 10 --
 apisix/init.lua|  4 +++-
 t/core/utils.t | 47 ++
 t/node/upstream-node-dns.t | 16 
 4 files changed, 66 insertions(+), 11 deletions(-)

diff --git a/apisix/core/utils.lua b/apisix/core/utils.lua
index 9e8fc1e..e29784f 100644
--- a/apisix/core/utils.lua
+++ b/apisix/core/utils.lua
@@ -69,7 +69,8 @@ function _M.split_uri(uri)
 end
 
 
-local function dns_parse(resolvers, domain)
+local function dns_parse(domain, resolvers)
+resolvers = resolvers or _M.resolvers
 local r, err = resolver:new{
 nameservers = table.clone(resolvers),
 retrans = 5,  -- 5 retransmissions on receive timeout
@@ -100,11 +101,16 @@ local function dns_parse(resolvers, domain)
 return nil, "unsupport DNS answer"
 end
 
-return dns_parse(resolvers, answer.cname)
+return dns_parse(answer.cname, resolvers)
 end
 _M.dns_parse = dns_parse
 
 
+function _M.set_resolver(resolvers)
+_M.resolvers = resolvers
+end
+
+
 local function rfind_char(s, ch, idx)
 local b = str_byte(ch)
 for i = idx or #s, 1, -1 do
diff --git a/apisix/init.lua b/apisix/init.lua
index 3beec45..de51cd3 100644
--- a/apisix/init.lua
+++ b/apisix/init.lua
@@ -45,6 +45,7 @@ local ver_header= "APISIX/" .. core.version.VERSION
 
 local function parse_args(args)
 dns_resolver = args and args["dns_resolver"]
+core.utils.set_resolver(dns_resolver)
 core.log.info("dns resolver", core.json.delay_encode(dns_resolver, true))
 end
 
@@ -177,7 +178,7 @@ end
 
 
 local function parse_domain(host)
-local ip_info, err = core.utils.dns_parse(dns_resolver, host)
+local ip_info, err = core.utils.dns_parse(host)
 if not ip_info then
 core.log.error("failed to parse domain: ", host, ", error: ",err)
 return nil, err
@@ -219,6 +220,7 @@ local function parse_domain_for_nodes(nodes)
 return new_nodes
 end
 
+
 local function compare_upstream_node(old_t, new_t)
 if type(old_t) ~= "table" then
 return false
diff --git a/t/core/utils.t b/t/core/utils.t
index 9c19f29..25b0419 100644
--- a/t/core/utils.t
+++ b/t/core/utils.t
@@ -68,3 +68,50 @@ qr/random seed \d+\ntwice: false/
 GET /t
 --- no_error_log
 [error]
+
+
+
+=== TEST 3: specify resolvers
+--- config
+location /t {
+content_by_lua_block {
+local core = require("apisix.core")
+local resolvers = {"8.8.8.8"}
+core.utils.set_resolver(resolvers)
+local ip_info, err = core.utils.dns_parse("github.com", resolvers)
+if not ip_info then
+core.log.error("failed to parse domain: ", host, ", error: 
",err)
+end
+ngx.say(core.json.encode(ip_info))
+}
+}
+--- request
+GET /t
+--- response_body eval
+qr/"address":.+,"name":"github.com"/
+--- no_error_log
+[error]
+
+
+
+=== TEST 4: default resolvers
+--- config
+location /t {
+content_by_lua_block {
+local core = require("apisix.core")
+local ip_info, err = core.utils.dns_parse("github.com")
+if not ip_info then
+core.log.error("failed to parse domain: ", host, ", error: 
",err)
+end
+core.log.info("ip_info: ", core.json.encode(ip_info))
+ngx.say("resolvers: ", core.json.encode(core.utils.resolvers))
+}
+}
+--- request
+GET /t
+--- response_body
+resolvers: ["8.8.8.8","114.114.114.114"]
+--- error_log eval
+qr/"address":.+,"name":"github.com"/
+--- no_error_log
+[error]
diff --git a/t/node/upstream-node-dns.t b/t/node/upstream-node-dns.t
index ef15dc2..b539873 100644
--- a/t/node/upstream-node-dns.t
+++ b/t/node/upstream-node-dns.t
@@ -79,7 +79,7 @@ passed
 apisix.http_init()
 
 local utils = require("apisix.core.utils")
-utils.dns_parse = function (resolvers, domain)  -- mock: DNS parser
+utils.dns_parse = function (domain, resolvers)  -- mock

[apisix] branch master updated: feature: plugin `limit-count` support to use `redis` cluster (#2406)

2020-10-16 Thread membphis
This is an automated email from the ASF dual-hosted git repository.

membphis pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/apisix.git


The following commit(s) were added to refs/heads/master by this push:
 new c65f5c9  feature: plugin `limit-count` support to use `redis` cluster 
(#2406)
c65f5c9 is described below

commit c65f5c9465d2c0ad212545382adc57d90edea674
Author: YuanSheng Wang 
AuthorDate: Sat Oct 17 08:21:47 2020 +0800

feature: plugin `limit-count` support to use `redis` cluster (#2406)

fix #638

Co-authored-by: liuheng 
---
 .github/workflows/build.yml|  19 ++
 apisix/plugins/limit-count.lua |  37 ++-
 ...unt-redis.lua => limit-count-redis-cluster.lua} |  84 ++---
 apisix/plugins/limit-count/limit-count-redis.lua   |   5 +-
 bin/apisix |   1 +
 doc/plugins/limit-count.md |  37 ++-
 doc/zh-cn/plugins/limit-count.md   |  58 +++-
 rockspec/apisix-master-0.rockspec  |   1 +
 t/APISIX.pm|   5 +
 t/plugin/limit-count-redis-cluster.t   | 363 +
 10 files changed, 544 insertions(+), 66 deletions(-)

diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml
index c46c97f..bfc72ed 100644
--- a/.github/workflows/build.yml
+++ b/.github/workflows/build.yml
@@ -35,6 +35,25 @@ jobs:
 if: matrix.platform == 'ubuntu-18.04'
 run: sudo ./.travis/${{ matrix.os_name }}_runner.sh before_install
 
+  - name: Install Redis Cluster
+if: matrix.os_name == 'linux_openresty'
+uses: vishnudxb/redis-cluster@1.0.5
+with:
+  master1-port: 5000
+  master2-port: 5001
+  master3-port: 5002
+  slave1-port: 5003
+  slave2-port: 5004
+  slave3-port: 5005
+
+  - name: Running Redis Cluster Test
+if: matrix.os_name == 'linux_openresty'
+run: |
+  sudo apt-get install -y redis-tools
+  docker ps -a
+  redis-cli -h 127.0.0.1 -p 5000 ping
+  redis-cli -h 127.0.0.1 -p 5000 cluster nodes
+
   - name: Linux Install
 if: matrix.platform == 'ubuntu-18.04'
 run: sudo ./.travis/${{ matrix.os_name }}_runner.sh do_install
diff --git a/apisix/plugins/limit-count.lua b/apisix/plugins/limit-count.lua
index 216b82d..94adc56 100644
--- a/apisix/plugins/limit-count.lua
+++ b/apisix/plugins/limit-count.lua
@@ -17,10 +17,14 @@
 local limit_local_new = require("resty.limit.count").new
 local core = require("apisix.core")
 local plugin_name = "limit-count"
+local limit_redis_cluster_new
 local limit_redis_new
 do
 local redis_src = "apisix.plugins.limit-count.limit-count-redis"
 limit_redis_new = require(redis_src).new
+
+local cluster_src = "apisix.plugins.limit-count.limit-count-redis-cluster"
+limit_redis_cluster_new = require(cluster_src).new
 end
 
 
@@ -40,7 +44,7 @@ local schema = {
 },
 policy = {
 type = "string",
-enum = {"local", "redis"},
+enum = {"local", "redis", "redis-cluster"},
 default = "local",
 }
 },
@@ -70,11 +74,31 @@ local schema = {
 type = "string", minLength = 0,
 },
 redis_timeout = {
-type = "integer", minimum = 1,
-default = 1000,
+type = "integer", minimum = 1, default = 1000,
 },
 },
 required = {"redis_host"},
+},
+{
+properties = {
+policy = {
+enum = {"redis-cluster"},
+},
+redis_cluster_nodes = {
+type = "array",
+minItems = 2,
+items = {
+type = "string", minLength = 2, maxLength = 100
+},
+},
+redis_password = {
+type = "string", minLength = 0,
+},
+redis_timeout = {
+type = "integer", minimum = 1, default = 1000,
+},
+},
+required = {"redis_cluster_nodes"},
 }
 }
 }
@@ -83,7 +107,7 @@ local schema = {
 
 
 local _M = {
-version = 0.3,
+version = 0.4,
 priority = 1002,
 name = plugin_na

[apisix] branch master updated (1afa8f7 -> 7cb9563)

2020-10-16 Thread membphis
This is an automated email from the ASF dual-hosted git repository.

membphis pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/apisix.git.


from 1afa8f7  style: move localized require in front of directives which 
calling it. (#2414)
 add 7cb9563  style: fixed some code style problems (#2438)

No new revisions were added by this update.

Summary of changes:
 apisix/plugins/jwt-auth.lua | 7 ++-
 1 file changed, 6 insertions(+), 1 deletion(-)



[apisix] branch master updated (b5fe9ce -> 78910d8)

2020-10-15 Thread membphis
This is an automated email from the ASF dual-hosted git repository.

membphis pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/apisix.git.


from b5fe9ce  change: use 405 as the error code for unsupported HTTP method 
(#2418)
 add 78910d8  CI: turn off the Lua code coverage check in CI. (#2435)

No new revisions were added by this update.

Summary of changes:
 .travis/linux_openresty_runner.sh | 3 ++-
 t/stream-node/random.t| 5 +
 2 files changed, 7 insertions(+), 1 deletion(-)



[apisix] branch master updated (85ed4cc -> b5fe9ce)

2020-10-15 Thread membphis
This is an automated email from the ASF dual-hosted git repository.

membphis pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/apisix.git.


from 85ed4cc  doc: correct the doc of plugin ip-restriction (#2420)
 add b5fe9ce  change: use 405 as the error code for unsupported HTTP method 
(#2418)

No new revisions were added by this update.

Summary of changes:
 apisix/admin/consumers.lua   |  2 +-
 apisix/admin/plugin_metadata.lua |  2 +-
 t/admin/consumers.t  | 26 +-
 3 files changed, 27 insertions(+), 3 deletions(-)



[apisix] branch master updated (85ed4cc -> b5fe9ce)

2020-10-15 Thread membphis
This is an automated email from the ASF dual-hosted git repository.

membphis pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/apisix.git.


from 85ed4cc  doc: correct the doc of plugin ip-restriction (#2420)
 add b5fe9ce  change: use 405 as the error code for unsupported HTTP method 
(#2418)

No new revisions were added by this update.

Summary of changes:
 apisix/admin/consumers.lua   |  2 +-
 apisix/admin/plugin_metadata.lua |  2 +-
 t/admin/consumers.t  | 26 +-
 3 files changed, 27 insertions(+), 3 deletions(-)



[apisix] branch master updated: doc: added milestone info in README.md and README_CN.md (#2401)

2020-10-12 Thread membphis
This is an automated email from the ASF dual-hosted git repository.

membphis pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/apisix.git


The following commit(s) were added to refs/heads/master by this push:
 new 97cec5d  doc: added milestone info in README.md and README_CN.md 
(#2401)
97cec5d is described below

commit 97cec5d42242f1d7bde9d59ce2bace10e3b3269d
Author: li1234yun 
AuthorDate: Tue Oct 13 10:38:56 2020 +0800

doc: added milestone info in README.md and README_CN.md (#2401)
---
 README.md| 4 
 README_CN.md | 4 
 2 files changed, 8 insertions(+)

diff --git a/README.md b/README.md
index ed415c5..bdba061 100644
--- a/README.md
+++ b/README.md
@@ -265,6 +265,10 @@ Using AWS's 8 core server, APISIX's QPS reach to 140,000 
with a latency of only
 
 Benchmark comparison test [details 
data](https://gist.github.com/membphis/137db97a4bf64d3653aa42f3e016bd01)
 
+## Milestones
+- [2.0](https://github.com/apache/apisix/milestone/7)
+- [2.1](https://github.com/apache/apisix/milestone/8)
+
 ## Videos And Articles
 - [APISIX technology selection, testing and continuous 
integration](https://medium.com/@ming_wen/apache-apisixs-technology-selection-testing-and-continuous-integration-313221b02542)
 - [Analysis of Excellent Performance of Apache APISIX Microservices 
Gateway](https://medium.com/@ming_wen/analysis-of-excellent-performance-of-apache-apisix-microservices-gateway-fc77db4090b5)
diff --git a/README_CN.md b/README_CN.md
index 571ecfb..13080d1 100644
--- a/README_CN.md
+++ b/README_CN.md
@@ -263,6 +263,10 @@ Dashboard 默认只允许 127.0.0.1 访问。你可以自行修改 `conf/config.
 
 
性能对比测试[详细内容如下](https://gist.github.com/membphis/137db97a4bf64d3653aa42f3e016bd01)。
 
+## 开发计划
+- [2.0](https://github.com/apache/apisix/milestone/7)
+- [2.1](https://github.com/apache/apisix/milestone/8)
+
 ## 视频和文章
 - 2020.1.17 [API 网关 Apache APISIX 和 Kong 
的选型对比](https://mp.weixin.qq.com/s/c51apneVj0O9yxiZAHF34Q)
 - 2019.12.14 [从 0 到 1:Apache APISIX 的 Apache 
之路](https://zhuanlan.zhihu.com/p/99620158)



[apisix] branch master updated: CI: run the APISIX instance in an empty folder for `linux_apisix_current_luarocks`. (#2385)

2020-10-10 Thread membphis
This is an automated email from the ASF dual-hosted git repository.

membphis pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/apisix.git


The following commit(s) were added to refs/heads/master by this push:
 new 72eef02  CI: run the APISIX instance in an empty folder for 
`linux_apisix_current_luarocks`. (#2385)
72eef02 is described below

commit 72eef02061a709869d16440490d6103068a8376f
Author: YuanSheng Wang 
AuthorDate: Sun Oct 11 12:59:54 2020 +0800

CI: run the APISIX instance in an empty folder for 
`linux_apisix_current_luarocks`. (#2385)

fix #2384
---
 .travis/linux_apisix_current_luarocks_runner.sh | 10 +++---
 .travis/linux_apisix_master_luarocks_runner.sh  |  9 -
 2 files changed, 7 insertions(+), 12 deletions(-)

diff --git a/.travis/linux_apisix_current_luarocks_runner.sh 
b/.travis/linux_apisix_current_luarocks_runner.sh
index 894542a..23bb3f9 100755
--- a/.travis/linux_apisix_current_luarocks_runner.sh
+++ b/.travis/linux_apisix_current_luarocks_runner.sh
@@ -60,6 +60,8 @@ script() {
 sudo luarocks install rockspec/apisix-master-0.rockspec --only-deps  > 
build.log 2>&1 || (cat build.log && exit 1)
 sudo luarocks make rockspec/apisix-master-0.rockspec > build.log 2>&1 || 
(cat build.log && exit 1)
 
+mkdir cli_tmp && cd cli_tmp
+
 # show install file
 luarocks show apisix
 
@@ -68,15 +70,17 @@ script() {
 sudo PATH=$PATH apisix start
 sudo PATH=$PATH apisix stop
 
-# apisix cli test
-sudo PATH=$PATH .travis/apisix_cli_test.sh
-
 cat /usr/local/apisix/logs/error.log | grep '\[error\]' > /tmp/error.log | 
true
 if [ -s /tmp/error.log ]; then
 echo "=found error log="
 cat /usr/local/apisix/logs/error.log
 exit 1
 fi
+
+cd ..
+
+# apisix cli test
+sudo PATH=$PATH .travis/apisix_cli_test.sh
 }
 
 case_opt=$1
diff --git a/.travis/linux_apisix_master_luarocks_runner.sh 
b/.travis/linux_apisix_master_luarocks_runner.sh
index a657d91..1a992ae 100755
--- a/.travis/linux_apisix_master_luarocks_runner.sh
+++ b/.travis/linux_apisix_master_luarocks_runner.sh
@@ -64,10 +64,6 @@ script() {
 sudo mkdir -p /usr/local/apisix/deps
 sudo PATH=$PATH ./utils/install-apisix.sh install > build.log 2>&1 || (cat 
build.log && exit 1)
 
-# REMOVE ME  after PR merged: 
https://github.com/apache/apisix/pull/2383
-sudo mkdir -p /usr/local/apisix/apisix/ssl/router
-sudo wget -P /usr/local/apisix/apisix/ssl/router/ 
https://raw.githubusercontent.com/apache/apisix/master/apisix/ssl/router/radixtree_sni.lua
-
 sudo PATH=$PATH apisix help
 sudo PATH=$PATH apisix init
 sudo PATH=$PATH apisix start
@@ -78,11 +74,6 @@ script() {
 # install APISIX by luarocks
 sudo luarocks install $APISIX_MAIN > build.log 2>&1 || (cat build.log && 
exit 1)
 
-# REMOVE ME  after PR merged: 
https://github.com/apache/apisix/pull/2383
-sudo mkdir -p /usr/local/apisix/apisix/ssl/router
-sudo wget -P /usr/local/apisix/apisix/ssl/router/ 
https://raw.githubusercontent.com/apache/apisix/master/apisix/ssl/router/radixtree_sni.lua
-ls /usr/local/apisix/apisix/ssl/router
-
 # show install files
 luarocks show apisix
 



[apisix] branch master updated (647d8d9 -> d6b00bb)

2020-10-10 Thread membphis
This is an automated email from the ASF dual-hosted git repository.

membphis pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/apisix.git.


from 647d8d9  bugfix: check every etcd version, rather than only check the 
first one (#2380)
 add d6b00bb  bugfix: install the Lua files in `apisix/ssl/router` . (#2383)

No new revisions were added by this update.

Summary of changes:
 .travis/linux_apisix_master_luarocks_runner.sh | 9 +
 Makefile   | 9 ++---
 2 files changed, 15 insertions(+), 3 deletions(-)



[apisix] branch master updated: fix: wget -O always leave a file enven though download fail (#2376)

2020-10-10 Thread membphis
This is an automated email from the ASF dual-hosted git repository.

membphis pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/apisix.git


The following commit(s) were added to refs/heads/master by this push:
 new f05cba0  fix: wget -O always leave a file enven though download fail 
(#2376)
f05cba0 is described below

commit f05cba014524b89cf3e712a5410933741944ab3a
Author: RocFang 
AuthorDate: Sat Oct 10 20:49:14 2020 +0800

fix: wget -O always leave a file enven though download fail (#2376)
---
 Makefile | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/Makefile b/Makefile
index 665271e..cd80123 100644
--- a/Makefile
+++ b/Makefile
@@ -58,7 +58,7 @@ endif
 .PHONY: utils
 utils:
 ifeq ("$(wildcard utils/lj-releng)", "")
-   wget -O utils/lj-releng 
https://raw.githubusercontent.com/iresty/openresty-devel-utils/master/lj-releng
+   wget -P utils 
https://raw.githubusercontent.com/iresty/openresty-devel-utils/master/lj-releng
chmod a+x utils/lj-releng
 endif
 



[apisix] branch master updated: chore: upload apisix logo image (#2371)

2020-10-10 Thread membphis
This is an automated email from the ASF dual-hosted git repository.

membphis pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/apisix.git


The following commit(s) were added to refs/heads/master by this push:
 new ea25f85  chore: upload apisix logo image (#2371)
ea25f85 is described below

commit ea25f85529e3b19e04df625885e13367bf44875a
Author: YuanSheng Wang 
AuthorDate: Sat Oct 10 16:18:51 2020 +0800

chore: upload apisix logo image (#2371)

added link in readme.
---
 README.md   |   8 +++-
 README_CN.md|   8 +++-
 logos/apache-apisix.png | Bin 0 -> 573324 bytes
 3 files changed, 14 insertions(+), 2 deletions(-)

diff --git a/README.md b/README.md
index 814913e..ed415c5 100644
--- a/README.md
+++ b/README.md
@@ -17,7 +17,8 @@
 #
 -->
 
-[Chinese](README_CN.md)
+- [Chinese](README_CN.md)
+
 ## APISIX
 
 [![Build 
Status](https://travis-ci.org/apache/apisix.svg?branch=master)](https://travis-ci.org/apache/apisix)
@@ -291,6 +292,11 @@ APISIX enriches the https://landscape.cncf.io/category=api-gateway
 CNCF API Gateway Landscape.
 
 
+## Logos
+
+- [Apache APISIX logo(PNG)](logos/apache-apisix.png)
+- [Apache APISIX logo source](https://apache.org/logos/#apisix)
+
 ## Contributing
 
 See [CONTRIBUTING](CONTRIBUTING.md) for details on submitting patches and the 
contribution workflow.
diff --git a/README_CN.md b/README_CN.md
index c887370..571ecfb 100644
--- a/README_CN.md
+++ b/README_CN.md
@@ -17,7 +17,8 @@
 #
 -->
 
-[English](README.md)
+- [English](README.md)
+
 ## APISIX
 
 [![Build 
Status](https://travis-ci.org/apache/apisix.svg?branch=master)](https://travis-ci.org/apache/apisix)
@@ -294,6 +295,11 @@ Dashboard 默认只允许 127.0.0.1 访问。你可以自行修改 `conf/config.
 APISIX 被纳入 https://landscape.cncf.io/category=api-gateway=card-mode=category;>
 云原生软件基金会 API 网关全景图
 
 
+## Logo
+
+- [Apache APISIX logo(PNG)](logos/apache-apisix.png)
+- [Apache APISIX logo 源文件](https://apache.org/logos/#apisix)
+
 ## 致谢
 
 灵感来自 Kong 和 Orange。
diff --git a/logos/apache-apisix.png b/logos/apache-apisix.png
new file mode 100644
index 000..6e3aefc
Binary files /dev/null and b/logos/apache-apisix.png differ



[apisix] branch master updated: doc: add user story about eFactory. (#2373)

2020-10-10 Thread membphis
This is an automated email from the ASF dual-hosted git repository.

membphis pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/apisix.git


The following commit(s) were added to refs/heads/master by this push:
 new f2e65d6  doc: add user story about eFactory. (#2373)
f2e65d6 is described below

commit f2e65d6e0a818cb33a98413f10c9894e923fc749
Author: Wen Ming 
AuthorDate: Sat Oct 10 16:18:00 2020 +0800

doc: add user story about eFactory. (#2373)
---
 README.md| 1 +
 README_CN.md | 1 +
 2 files changed, 2 insertions(+)

diff --git a/README.md b/README.md
index 1f4d5e9..814913e 100644
--- a/README.md
+++ b/README.md
@@ -269,6 +269,7 @@ Benchmark comparison test [details 
data](https://gist.github.com/membphis/137db9
 - [Analysis of Excellent Performance of Apache APISIX Microservices 
Gateway](https://medium.com/@ming_wen/analysis-of-excellent-performance-of-apache-apisix-microservices-gateway-fc77db4090b5)
 
 ## User Stories
+- [European Factory Platform: API Security Gateway – Using APISIX in the 
eFactory 
Platform](https://www.efactory-project.eu/post/api-security-gateway-using-apisix-in-the-efactory-platform)
 - [ke.com: How to Build a Gateway Based on Apache 
APISIX(Chinese)](https://mp.weixin.qq.com/s/yZl9MWPyF1-gOyCp8plflA)
 - [360: Apache APISIX Practice in OPS 
Platform(Chinese)](https://mp.weixin.qq.com/s/zHF_vlMaPOSoiNvqw60tVw)
 - [HelloTalk: Exploring Globalization Based on OpenResty and Apache 
APISIX(Chinese)](https://www.upyun.com/opentalk/447.html)
diff --git a/README_CN.md b/README_CN.md
index 28b8136..c887370 100644
--- a/README_CN.md
+++ b/README_CN.md
@@ -273,6 +273,7 @@ Dashboard 默认只允许 127.0.0.1 访问。你可以自行修改 `conf/config.
 - 2019.7.6 [APISIX 高性能实战](https://www.upyun.com/opentalk/429.html)
 
 ## 用户实际使用案例
+- [欧盟数字工厂平台: API Security Gateway – Using APISIX in the eFactory 
Platform](https://www.efactory-project.eu/post/api-security-gateway-using-apisix-in-the-efactory-platform)
 - [贝壳找房:如何基于 Apache APISIX 
搭建网关](https://mp.weixin.qq.com/s/yZl9MWPyF1-gOyCp8plflA)
 - [360:Apache APISIX 
在基础运维平台项目中的实践](https://mp.weixin.qq.com/s/zHF_vlMaPOSoiNvqw60tVw)
 - [HelloTalk:基于 OpenResty 和 Apache APISIX 
的全球化探索之路](https://www.upyun.com/opentalk/447.html)



[apisix] branch membphis-patch-1 updated (b0a54bb -> 5ecf755)

2020-10-09 Thread membphis
This is an automated email from the ASF dual-hosted git repository.

membphis pushed a change to branch membphis-patch-1
in repository https://gitbox.apache.org/repos/asf/apisix.git.


from b0a54bb  chore: apisix logo
 add 5ecf755  chore: added link in readme.

No new revisions were added by this update.

Summary of changes:
 README.md|   8 +++-
 README_CN.md |   8 +++-
 apache-apisix.png => logos/apache-apisix.png | Bin
 3 files changed, 14 insertions(+), 2 deletions(-)
 rename apache-apisix.png => logos/apache-apisix.png (100%)



[apisix] branch membphis-patch-1 updated: chore: apisix logo

2020-10-09 Thread membphis
This is an automated email from the ASF dual-hosted git repository.

membphis pushed a commit to branch membphis-patch-1
in repository https://gitbox.apache.org/repos/asf/apisix.git


The following commit(s) were added to refs/heads/membphis-patch-1 by this push:
 new b0a54bb  chore: apisix logo
b0a54bb is described below

commit b0a54bbb794d4c8985276c51a91c0e5fa34aa26a
Author: YuanSheng Wang 
AuthorDate: Sat Oct 10 09:22:44 2020 +0800

chore: apisix logo
---
 apache-apisix.png | Bin 0 -> 573324 bytes
 1 file changed, 0 insertions(+), 0 deletions(-)

diff --git a/apache-apisix.png b/apache-apisix.png
new file mode 100644
index 000..6e3aefc
Binary files /dev/null and b/apache-apisix.png differ



[apisix] branch membphis-patch-1 created (now 251625d)

2020-10-09 Thread membphis
This is an automated email from the ASF dual-hosted git repository.

membphis pushed a change to branch membphis-patch-1
in repository https://gitbox.apache.org/repos/asf/apisix.git.


  at 251625d  bugfix: set random seed for each worker process at 
`init_worker` phase, only `init` phase is not enough. (#2357)

No new revisions were added by this update.



[apisix] branch master updated: bugfix: set random seed for each worker process at `init_worker` phase, only `init` phase is not enough. (#2357)

2020-10-09 Thread membphis
This is an automated email from the ASF dual-hosted git repository.

membphis pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/apisix.git


The following commit(s) were added to refs/heads/master by this push:
 new 251625d  bugfix: set random seed for each worker process at 
`init_worker` phase, only `init` phase is not enough. (#2357)
251625d is described below

commit 251625d8ab969b0b46d12041beff44f329e95321
Author: YuanSheng Wang 
AuthorDate: Fri Oct 9 16:39:49 2020 +0800

bugfix: set random seed for each worker process at `init_worker` phase, 
only `init` phase is not enough. (#2357)
---
 apisix/core/id.lua |  1 +
 apisix/init.lua| 25 -
 t/core/random.t| 76 ++
 t/stream-node/random.t | 76 ++
 4 files changed, 171 insertions(+), 7 deletions(-)

diff --git a/apisix/core/id.lua b/apisix/core/id.lua
index 5470f7a..d6e728d 100644
--- a/apisix/core/id.lua
+++ b/apisix/core/id.lua
@@ -65,6 +65,7 @@ function _M.init()
 return
 end
 
+uuid.seed()
 apisix_uid = uuid.generate_v4()
 log.notice("not found apisix uid, generate a new one: ", apisix_uid)
 
diff --git a/apisix/init.lua b/apisix/init.lua
index 3d9ffea..5d773ab 100644
--- a/apisix/init.lua
+++ b/apisix/init.lua
@@ -63,13 +63,6 @@ function _M.http_init(args)
  "maxrecord=8000", "sizemcode=64",
  "maxmcode=4000", "maxirconst=1000")
 
---
-local seed, err = core.utils.get_seed_from_urandom()
-if not seed then
-core.log.warn('failed to get seed from urandom: ', err)
-seed = ngx_now() * 1000 + ngx.worker.pid()
-end
-math.randomseed(seed)
 parse_args(args)
 core.id.init()
 
@@ -82,6 +75,15 @@ end
 
 
 function _M.http_init_worker()
+local seed, err = core.utils.get_seed_from_urandom()
+if not seed then
+core.log.warn('failed to get seed from urandom: ', err)
+seed = ngx_now() * 1000 + ngx.worker.pid()
+end
+math.randomseed(seed)
+-- for testing only
+core.log.info("random test in [1, 1]: ", math.random(1, 100))
+
 local we = require("resty.worker.events")
 local ok, err = we.configure({shm = "worker-events", interval = 0.1})
 if not ok then
@@ -759,6 +761,15 @@ end
 
 function _M.stream_init_worker()
 core.log.info("enter stream_init_worker")
+local seed, err = core.utils.get_seed_from_urandom()
+if not seed then
+core.log.warn('failed to get seed from urandom: ', err)
+seed = ngx_now() * 1000 + ngx.worker.pid()
+end
+math.randomseed(seed)
+-- for testing only
+core.log.info("random stream test in [1, 1]: ", math.random(1, 
100))
+
 router.stream_init_worker()
 plugin.init_worker()
 
diff --git a/t/core/random.t b/t/core/random.t
new file mode 100644
index 000..8d7d403
--- /dev/null
+++ b/t/core/random.t
@@ -0,0 +1,76 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements.  See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License.  You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+use t::APISIX 'no_plan';
+
+master_on();
+workers(4);
+repeat_each(1);
+no_long_string();
+no_root_location();
+log_level("info");
+
+run_tests;
+
+__DATA__
+
+=== TEST 1: generate different random number in different worker process
+--- config
+location /t {
+content_by_lua_block {
+local log_file = ngx.config.prefix() .. "logs/error.log"
+local file = io.open(log_file, "r")
+local log = file:read("*a")
+
+local it, err = ngx.re.gmatch(log, [[random test in \[1, 1\]: 
(\d+)]], "jom")
+if not it then
+ngx.log(ngx.ERR, "failed to gmatch: ", err)
+return
+end
+
+local random_nums = {}
+while true do
+local m, err = it()
+if err then
+ngx.log(ngx.ERR, "error: ", err)
+return
+end
+
+if not m then
+

[apisix] branch master updated: feat: implemented `referer-restriction` plugin (#2352)

2020-10-06 Thread membphis
This is an automated email from the ASF dual-hosted git repository.

membphis pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/apisix.git


The following commit(s) were added to refs/heads/master by this push:
 new 5b97223  feat: implemented `referer-restriction` plugin (#2352)
5b97223 is described below

commit 5b97223592c9584e5280c397968e9d9c4739e3d4
Author: 罗泽轩 
AuthorDate: Tue Oct 6 18:20:17 2020 +0800

feat: implemented `referer-restriction` plugin (#2352)
---
 README.md|   1 +
 README_CN.md |   1 +
 apisix/plugins/referer-restriction.lua   | 124 
 conf/config-default.yaml |   1 +
 doc/README.md|   1 +
 doc/_sidebar.md  |   1 +
 doc/plugins/referer-restriction.md   | 116 +++
 doc/zh-cn/README.md  |   1 +
 doc/zh-cn/plugins/referer-restriction.md | 111 ++
 t/admin/plugins.t|   2 +-
 t/debug/debug-mode.t |   1 +
 t/plugin/referer-restriction.t   | 189 +++
 12 files changed, 548 insertions(+), 1 deletion(-)

diff --git a/README.md b/README.md
index c856505..1f4d5e9 100644
--- a/README.md
+++ b/README.md
@@ -86,6 +86,7 @@ A/B testing, canary release, blue-green deployment, limit 
rate, defense against
 - **Security**
 - Authentications: [key-auth](doc/plugins/key-auth.md), 
[JWT](doc/plugins/jwt-auth.md), [basic-auth](doc/plugins/basic-auth.md), 
[wolf-rbac](doc/plugins/wolf-rbac.md)
 - [IP Whitelist/Blacklist](doc/plugins/ip-restriction.md)
+- [Referer Whitelist/Blacklist](doc/plugins/referer-restriction.md)
 - [IdP](doc/plugins/openid-connect.md): Support external authentication 
services, such as Auth0, okta, etc., users can use this to connect to OAuth 2.0 
and other authentication methods.
 - [Limit-req](doc/plugins/limit-req.md)
 - [Limit-count](doc/plugins/limit-count.md)
diff --git a/README_CN.md b/README_CN.md
index 829633f..28b8136 100644
--- a/README_CN.md
+++ b/README_CN.md
@@ -85,6 +85,7 @@ A/B 测试、金丝雀发布(灰度发布)、蓝绿部署、限流限速、抵
 - **安全防护**
 - 多种身份认证方式: [key-auth](doc/zh-cn/plugins/key-auth.md), 
[JWT](doc/zh-cn/plugins/jwt-auth.md), 
[basic-auth](doc/zh-cn/plugins/basic-auth.md), 
[wolf-rbac](doc/zh-cn/plugins/wolf-rbac.md)。
 - [IP 黑白名单](doc/zh-cn/plugins/ip-restriction.md)
+- [Referer 白名单](doc/zh-cn/plugins/referer-restriction.md)
 - [IdP 支持](doc/plugins/openid-connect.md): 支持外部的身份认证服务,比如 
Auth0,Okta,Authing 等,用户可以借此来对接 Oauth2.0 等认证方式。
 - [限制速率](doc/zh-cn/plugins/limit-req.md)
 - [限制请求数](doc/zh-cn/plugins/limit-count.md)
diff --git a/apisix/plugins/referer-restriction.lua 
b/apisix/plugins/referer-restriction.lua
new file mode 100644
index 000..e67b455
--- /dev/null
+++ b/apisix/plugins/referer-restriction.lua
@@ -0,0 +1,124 @@
+--
+-- Licensed to the Apache Software Foundation (ASF) under one or more
+-- contributor license agreements.  See the NOTICE file distributed with
+-- this work for additional information regarding copyright ownership.
+-- The ASF licenses this file to You under the Apache License, Version 2.0
+-- (the "License"); you may not use this file except in compliance with
+-- the License.  You may obtain a copy of the License at
+--
+-- http://www.apache.org/licenses/LICENSE-2.0
+--
+-- Unless required by applicable law or agreed to in writing, software
+-- distributed under the License is distributed on an "AS IS" BASIS,
+-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+-- See the License for the specific language governing permissions and
+-- limitations under the License.
+--
+local ipairs= ipairs
+local core  = require("apisix.core")
+local http  = require "resty.http"
+local lrucache  = core.lrucache.new({
+ttl = 300, count = 512
+})
+
+
+local schema = {
+type = "object",
+properties = {
+bypass_missing = {
+type = "boolean",
+default = false,
+},
+whitelist = {
+type = "array",
+items = core.schema.host_def,
+minItems = 1
+},
+},
+required = {"whitelist"},
+additionalProperties = false,
+}
+
+
+local plugin_name = "referer-restriction"
+
+
+local _M = {
+version = 0.1,
+priority = 2990,
+name = plugin_name,
+schema = schema,
+}
+
+
+function _M.check_schema(conf)
+return core.schema.check(schema, conf)
+end
+
+
+local function match_host(matcher, host)
+ if matcher.map[host] then
+return true
+end
+for _, h in ipairs(matcher.suffixes) do
+if core.string.has_suffix(host, h) then
+return true
+end
+end
+return false
+end
+
+
+local function create_host_matcher(hosts)

[apisix] branch master updated: feature: support `consumer_name` as key for `limit-req` plugin. (#2270)

2020-10-06 Thread membphis
This is an automated email from the ASF dual-hosted git repository.

membphis pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/apisix.git


The following commit(s) were added to refs/heads/master by this push:
 new c3de84e  feature: support `consumer_name` as key for `limit-req` 
plugin.  (#2270)
c3de84e is described below

commit c3de84e28519e74f3b07d25d06a6cab0cad4bdc4
Author: Firstsawyou <52862365+firstsaw...@users.noreply.github.com>
AuthorDate: Tue Oct 6 18:18:22 2020 +0800

feature: support `consumer_name` as key for `limit-req` plugin.  (#2270)

fix #2267
---
 apisix/plugins/limit-req.lua   |  14 +-
 doc/plugins/limit-req.md   | 112 +--
 doc/zh-cn/plugins/limit-req.md | 110 +--
 t/admin/plugins.t  |   2 +-
 t/plugin/limit-req.t   | 313 -
 5 files changed, 524 insertions(+), 27 deletions(-)

diff --git a/apisix/plugins/limit-req.lua b/apisix/plugins/limit-req.lua
index 1caadce..7602e9b 100644
--- a/apisix/plugins/limit-req.lua
+++ b/apisix/plugins/limit-req.lua
@@ -27,7 +27,7 @@ local schema = {
 burst = {type = "number",  minimum = 0},
 key = {type = "string",
 enum = {"remote_addr", "server_addr", "http_x_real_ip",
-"http_x_forwarded_for"},
+"http_x_forwarded_for", "consumer_name"},
 },
 rejected_code = {type = "integer", minimum = 200, default = 503},
 },
@@ -67,7 +67,17 @@ function _M.access(conf, ctx)
 return 500
 end
 
-local key = (ctx.var[conf.key] or "") .. ctx.conf_type .. ctx.conf_version
+local key
+if conf.key == "consumer_name" then
+if not ctx.consumer_id then
+core.log.error("consumer not found.")
+return 500, { message = "Consumer not found."}
+end
+key = ctx.consumer_id .. ctx.conf_type .. ctx.conf_version
+
+else
+key = (ctx.var[conf.key] or "") .. ctx.conf_type .. ctx.conf_version
+end
 core.log.info("limit key: ", key)
 
 local delay, err = lim:incoming(key, true)
diff --git a/doc/plugins/limit-req.md b/doc/plugins/limit-req.md
index ca090d9..c3d983e 100644
--- a/doc/plugins/limit-req.md
+++ b/doc/plugins/limit-req.md
@@ -20,14 +20,14 @@
 - [中文](../zh-cn/plugins/limit-req.md)
 
 # Summary
+  - [Introduction](#introduction)
+  - [Attributes](#attributes)
+  - [Example](#example)
+- [How to enable on the `route` or 
`serivce`](#how-to-enable-on-the-route-or-serivce)
+- [How to enable on the `consumer`](#how-to-enable-on-the-consumer)
+  - [Disable Plugin](#disable-plugin)
 
-- [**Name**](#name)
-- [**Attributes**](#attributes)
-- [**How To Enable**](#how-to-enable)
-- [**Test Plugin**](#test-plugin)
-- [**Disable Plugin**](#disable-plugin)
-
-## Name
+## Introduction
 
 limit request rate using the "leaky bucket" method.
 
@@ -37,14 +37,16 @@ limit request rate using the "leaky bucket" method.
 | - | --- | --- | --- | 
 | 
-
 |
 | rate  | integer | required| | [0,...]
  | the specified request rate 
(number per second) threshold. Requests exceeding this rate (and below `burst`) 
will get delayed to conform to the rate.   |
 | burst | integer | required| | [0,...]
  | the number of excessive 
requests per second allowed to be delayed. Requests exceeding this hard limit 
will get rejected immediately.  |
-| key   | string  | required| | ["remote_addr", 
"server_addr", "http_x_real_ip", "http_x_forwarded_for"] | the user specified 
key to limit the rate, now accept those as key: "remote_addr"(client's IP), 
"server_addr"(server's IP), "X-Forwarded-For/X-Real-IP" in request header. |
-| rejected_code | string  | optional| 503 | [200,...]  
  | The HTTP status code returned 
when the request exceeds the threshold is rejected. The default is 503. 
|
+| key   | string  | required| | ["remote_addr", 
"server_addr", "http_x_real_ip", "http_x_forwarded_for", "

[apisix] branch master updated: fix: Update error message when Route doesn't exist (#2304)

2020-10-05 Thread membphis
This is an automated email from the ASF dual-hosted git repository.

membphis pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/apisix.git


The following commit(s) were added to refs/heads/master by this push:
 new 720d135  fix: Update error message when Route doesn't exist (#2304)
720d135 is described below

commit 720d135fd28677ae80a7922d959ba86e978df727
Author: L 
AuthorDate: Tue Oct 6 11:48:52 2020 +0800

fix: Update error message when Route doesn't exist (#2304)

Fixes #2302

Co-authored-by: YuanSheng Wang 
---
 apisix/init.lua  |  2 +-
 t/core/etcd.t| 10 +-
 t/debug/hook.t   |  2 +-
 t/node/filter_func.t |  2 +-
 t/node/global-rule.t |  4 ++--
 t/node/hosts.t   |  4 ++--
 t/node/invalid-route.t   |  2 +-
 t/node/invalid-service.t |  2 +-
 t/node/invalid-upstream.t|  2 +-
 t/node/merge-route.t |  2 +-
 t/node/not-exist-upstream.t  |  2 +-
 t/node/remote-addr-ipv6.t|  6 +++---
 t/node/remote-addr.t |  4 ++--
 t/node/remote_addrs.t|  2 +-
 t/node/route-domain-with-local-dns.t |  2 +-
 t/node/route-domain.t|  2 +-
 t/node/route-filter-func.t   |  2 +-
 t/node/route-host.t  |  6 +++---
 t/node/route-parameter-uri.t | 10 +-
 t/node/sanity-radixtree.t|  4 ++--
 t/node/upstream-domain.t |  2 +-
 t/node/upstream-ipv6.t   |  2 +-
 t/node/upstream-retries.t|  2 +-
 t/node/upstream.t|  2 +-
 t/node/vars.t| 16 
 t/node/wildcard-host.t   |  4 ++--
 t/router/radixtree-host-uri.t| 10 +-
 t/router/radixtree-uri-host.t|  6 +++---
 t/router/radixtree-uri-multiple.t|  2 +-
 t/router/radixtree-uri-sanity.t  | 10 +-
 30 files changed, 64 insertions(+), 64 deletions(-)

diff --git a/apisix/init.lua b/apisix/init.lua
index cc7902b..3d9ffea 100644
--- a/apisix/init.lua
+++ b/apisix/init.lua
@@ -372,7 +372,7 @@ function _M.http_access_phase()
 local route = api_ctx.matched_route
 if not route then
 return core.response.exit(404,
-{error_msg = "failed to match any routes"})
+{error_msg = "404 Route Not Found"})
 end
 
 if route.value.service_protocol == "grpc" then
diff --git a/t/core/etcd.t b/t/core/etcd.t
index 197f7e9..7dc3a38 100644
--- a/t/core/etcd.t
+++ b/t/core/etcd.t
@@ -104,8 +104,8 @@ Host: foo.com
 --- error_code eval
 [201, 200, 200, 200, 200, 404, 201, 200, 200, 200, 200, 404]
 --- response_body eval
-["passed\n", "hello world\n", "passed\n", "hello world\n", "passed\n", 
"{\"error_msg\":\"failed to match any routes\"}\n",
-"passed\n", "hello world\n", "passed\n", "hello world\n", "passed\n", 
"{\"error_msg\":\"failed to match any routes\"}\n"]
+["passed\n", "hello world\n", "passed\n", "hello world\n", "passed\n", 
"{\"error_msg\":\"404 Route Not Found\"}\n",
+"passed\n", "hello world\n", "passed\n", "hello world\n", "passed\n", 
"{\"error_msg\":\"404 Route Not Found\"}\n"]
 --- no_error_log
 [error]
 --- timeout: 5
@@ -227,8 +227,8 @@ Host: foo.com
 --- error_code eval
 [201, 200, 200, 404, 200, 200, 404, 201, 200, 200, 404, 200, 200, 404]
 --- response_body eval
-["passed\n", "hello world\n", "passed\n", "{\"error_msg\":\"failed to match 
any routes\"}\n", "ok\n", "passed\n", "{\"error_msg\":\"failed to match any 
routes\"}\n",
-"passed\n", "hello world\n", "passed\n", "{\"error_msg\":\"failed to match any 
routes\"}\n", "hello1 world\n", "passed\n", "{\"error_msg\":\"failed to match 
any routes\"}\n"]
+["passed\n", "hello world\n", "passed\n", "{\"error_msg\":\"404 Route Not 
Found\"}\n", "ok\n", "passed\n", "{\"error_msg\":\"404 Route Not Found\"}\n",
+"passed\n", "hello world\n", "passed\n", "{\"error_msg\":\"404 Route Not 
Found\"}\n", "hello1 world\n", "passed\n", "{\"error_msg\":\"404 Route Not 
Found\"}\n"]
 --- no_error_log
 [error]
 --- timeout: 5
@@ -329,7 +329,7

[apisix] branch master updated: feat: also call picker.after_balance before retry (#2350)

2020-10-05 Thread membphis
This is an automated email from the ASF dual-hosted git repository.

membphis pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/apisix.git


The following commit(s) were added to refs/heads/master by this push:
 new 16a2d4d  feat: also call picker.after_balance before retry (#2350)
16a2d4d is described below

commit 16a2d4dfa97a8b10cf37936aed8c0173b374d4a4
Author: 罗泽轩 
AuthorDate: Mon Oct 5 23:19:40 2020 +0800

feat: also call picker.after_balance before retry (#2350)
---
 apisix/balancer.lua  | 4 
 apisix/balancer/ewma.lua | 7 ++-
 apisix/init.lua  | 2 +-
 3 files changed, 11 insertions(+), 2 deletions(-)

diff --git a/apisix/balancer.lua b/apisix/balancer.lua
index cfe53b9..f2eec90 100644
--- a/apisix/balancer.lua
+++ b/apisix/balancer.lua
@@ -172,6 +172,10 @@ local function pick_server(route, ctx)
 return nil, "no valid upstream node"
 end
 
+if ctx.server_picker and ctx.server_picker.after_balance then
+ctx.server_picker.after_balance(ctx, true)
+end
+
 if up_conf.timeout then
 local timeout = up_conf.timeout
 local ok, err = set_timeouts(timeout.connect, timeout.send,
diff --git a/apisix/balancer/ewma.lua b/apisix/balancer/ewma.lua
index 5198c28..bdc7722 100644
--- a/apisix/balancer/ewma.lua
+++ b/apisix/balancer/ewma.lua
@@ -146,7 +146,12 @@ local function _ewma_find(ctx, up_nodes)
 end
 
 
-local function _ewma_after_balance(ctx)
+local function _ewma_after_balance(ctx, before_retry)
+if before_retry then
+-- don't count tries which fail to complete
+return nil
+end
+
 local response_time = tonumber(ctx.var.upstream_response_time) or 0
 local connect_time = tonumber(ctx.var.upstream_connect_time) or 0
 local rtt = connect_time + response_time
diff --git a/apisix/init.lua b/apisix/init.lua
index 780757f..cc7902b 100644
--- a/apisix/init.lua
+++ b/apisix/init.lua
@@ -672,7 +672,7 @@ function _M.http_log_phase()
 healcheck_passive(api_ctx)
 
 if api_ctx.server_picker and api_ctx.server_picker.after_balance then
-api_ctx.server_picker.after_balance(api_ctx)
+api_ctx.server_picker.after_balance(api_ctx, false)
 end
 
 if api_ctx.uri_parse_param then



[apisix] branch master updated: bugfix: create etcd object in `xpcall`, this step may fail (#2312)

2020-10-04 Thread membphis
This is an automated email from the ASF dual-hosted git repository.

membphis pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/apisix.git


The following commit(s) were added to refs/heads/master by this push:
 new 50c99a5  bugfix: create etcd object in `xpcall`, this step may fail 
(#2312)
50c99a5 is described below

commit 50c99a5e3ba9b6bb2cd1422b903de038bbce256c
Author: YuanSheng Wang 
AuthorDate: Mon Oct 5 10:22:28 2020 +0800

bugfix: create etcd object in `xpcall`, this step may fail (#2312)

* bugfix: create the etcd object in `xpcall`, it may fail, the return 
values of `etcd.new` should be `res, err`.

fix issue: #2310

1. The old process, if creating etcd fails, etcd data will no longer be 
synchronized. We need to create the etcd object in xpcall.
2. the return value should be res, err of etcd.new.

* test: old test case is unstable, should delete some checkpoint which is 
wrong.
---
 apisix/core/config_etcd.lua | 23 -
 t/core/config_etcd.t| 49 +
 t/node/invalid-service.t| 13 +---
 3 files changed, 68 insertions(+), 17 deletions(-)

diff --git a/apisix/core/config_etcd.lua b/apisix/core/config_etcd.lua
index 28590e3..4f3fd55 100644
--- a/apisix/core/config_etcd.lua
+++ b/apisix/core/config_etcd.lua
@@ -82,13 +82,13 @@ end
 
 local function readdir(etcd_cli, key)
 if not etcd_cli then
-return nil, nil, "not inited"
+return nil, "not inited"
 end
 
 local res, err = etcd_cli:readdir(key)
 if not res then
 -- log.error("failed to get key from etcd: ", err)
-return nil, nil, err
+return nil, err
 end
 
 if type(res.body) ~= "table" then
@@ -407,16 +407,20 @@ local function _automatic_fetch(premature, self)
 return
 end
 
-local etcd_cli, _, err = etcd.new(self.etcd_conf)
-if not etcd_cli then
-error("failed to start a etcd instance: " .. err)
-end
-self.etcd_cli = etcd_cli
-
 local i = 0
 while not exiting() and self.running and i <= 32 do
 i = i + 1
+
 local ok, err = xpcall(function()
+if not self.etcd_cli then
+local etcd_cli, err = etcd.new(self.etcd_conf)
+if not etcd_cli then
+error("failed to create etcd instance for key ["
+  .. self.key .. "]: " .. (err or "unknown"))
+end
+self.etcd_cli = etcd_cli
+end
+
 local ok, err = sync_data(self)
 if err then
 if err ~= "timeout" and err ~= "Key not found"
@@ -437,6 +441,7 @@ local function _automatic_fetch(premature, self)
 elseif not ok then
 ngx_sleep(0.05)
 end
+
 end, debug.traceback)
 
 if not ok then
@@ -499,7 +504,7 @@ function _M.new(key, opts)
 ngx_timer_at(0, _automatic_fetch, obj)
 
 else
-local etcd_cli, _, err = etcd.new(etcd_conf)
+local etcd_cli, err = etcd.new(etcd_conf)
 if not etcd_cli then
 return nil, "failed to start a etcd instance: " .. err
 end
diff --git a/t/core/config_etcd.t b/t/core/config_etcd.t
new file mode 100644
index 000..7944537
--- /dev/null
+++ b/t/core/config_etcd.t
@@ -0,0 +1,49 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements.  See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License.  You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+use t::APISIX 'no_plan';
+
+repeat_each(1);
+no_long_string();
+no_root_location();
+log_level("info");
+
+run_tests;
+
+__DATA__
+
+=== TEST 1: wrong etcd port
+--- yaml_config
+apisix:
+  node_listen: 1984
+etcd:
+  host:
+- "http://127.0.0.1:;  -- wrong etcd port
+  timeout: 1
+--- config
+location /t {
+content_by_lua_block {
+ngx.sleep(8)
+ngx.say(body)
+}
+}
+--- timeout: 12
+--- request
+GET /t
+--- grep_error_log eval
+qr{failed to fetch data from etcd: connection refused,  etcd key: .*routes}
+--- grep_error_log_out eval
+qr/(failed to fetch data from etcd: connection refus

[apisix] branch master updated: test: use the absolute path of `$apisix_home` instead of `.`, search the lua source fine in the folder `$apisix_home`. (#2348)

2020-10-04 Thread membphis
This is an automated email from the ASF dual-hosted git repository.

membphis pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/apisix.git


The following commit(s) were added to refs/heads/master by this push:
 new 5d172d6  test: use the absolute path of `$apisix_home` instead of `.`, 
search the lua source fine in the folder `$apisix_home`. (#2348)
5d172d6 is described below

commit 5d172d606f4debd0034b8061b5865d46738d47ac
Author: YuanSheng Wang 
AuthorDate: Mon Oct 5 08:42:13 2020 +0800

test: use the absolute path of `$apisix_home` instead of `.`, search the 
lua source fine in the folder `$apisix_home`. (#2348)
---
 t/APISIX.pm | 8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/t/APISIX.pm b/t/APISIX.pm
index c951cd9..7d90a9b 100644
--- a/t/APISIX.pm
+++ b/t/APISIX.pm
@@ -141,8 +141,8 @@ _EOC_
 
 my $stream_enable = $block->stream_enable;
 my $stream_config = $block->stream_config // <<_EOC_;
-lua_package_path 
"./?.lua;./?/init.lua;$apisix_home/deps/share/lua/5.1/?.lua;$apisix_home/apisix/?.lua;$apisix_home/t/?.lua;;";
-lua_package_cpath 
"./?.so;$apisix_home/deps/lib/lua/5.1/?.so;$apisix_home/deps/lib64/lua/5.1/?.so;;";
+lua_package_path 
"$apisix_home/?.lua;$apisix_home/?/init.lua;$apisix_home/deps/share/lua/5.1/?.lua;$apisix_home/apisix/?.lua;$apisix_home/t/?.lua;;";
+lua_package_cpath 
"$apisix_home/?.so;$apisix_home/deps/lib/lua/5.1/?.so;$apisix_home/deps/lib64/lua/5.1/?.so;;";
 
 lua_socket_log_errors off;
 
@@ -222,8 +222,8 @@ _EOC_
 
 my $http_config = $block->http_config // '';
 $http_config .= <<_EOC_;
-lua_package_path 
"./?.lua;./?/init.lua;$apisix_home/deps/share/lua/5.1/?.lua;$apisix_home/apisix/?.lua;$apisix_home/t/?.lua;;";
-lua_package_cpath 
"./?.so;$apisix_home/deps/lib/lua/5.1/?.so;$apisix_home/deps/lib64/lua/5.1/?.so;;";
+lua_package_path 
"$apisix_home/?.lua;$apisix_home/?/init.lua;$apisix_home/deps/share/lua/5.1/?.lua;$apisix_home/apisix/?.lua;$apisix_home/t/?.lua;;";
+lua_package_cpath 
"$apisix_home/?.so;$apisix_home/deps/lib/lua/5.1/?.so;$apisix_home/deps/lib64/lua/5.1/?.so;;";
 
 lua_shared_dict plugin-limit-req 10m;
 lua_shared_dict plugin-limit-count   10m;



[apisix] branch membphis-patch-1 updated (09b840a -> 5deeadf)

2020-09-30 Thread membphis
This is an automated email from the ASF dual-hosted git repository.

membphis pushed a change to branch membphis-patch-1
in repository https://gitbox.apache.org/repos/asf/apisix.git.


from 09b840a  doc: field `key` should be optional in `upstream` object.
 add 05840ca  test: wait for more time and check the error log, old way is 
unstable. (#2341)
 add 5deeadf  Merge branch 'master' into membphis-patch-1

No new revisions were added by this update.

Summary of changes:
 t/node/ewma.t   |  2 +-
 t/node/invalid-route.t  |  3 +++
 t/node/invalid-service.t| 16 +---
 t/node/invalid-upstream.t   |  2 ++
 t/node/service-empty.t  |  1 -
 t/plugin/consumer-restriction.t |  1 +
 6 files changed, 16 insertions(+), 9 deletions(-)



[apisix] branch master updated (8947919 -> 05840ca)

2020-09-30 Thread membphis
This is an automated email from the ASF dual-hosted git repository.

membphis pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/apisix.git.


from 8947919  bugfix: use correct version of etcd in 
linux_apisix_master_luarocks (#2343)
 add 05840ca  test: wait for more time and check the error log, old way is 
unstable. (#2341)

No new revisions were added by this update.

Summary of changes:
 t/node/ewma.t   |  2 +-
 t/node/invalid-route.t  |  3 +++
 t/node/invalid-service.t| 16 +---
 t/node/invalid-upstream.t   |  2 ++
 t/node/service-empty.t  |  1 -
 t/plugin/consumer-restriction.t |  1 +
 6 files changed, 16 insertions(+), 9 deletions(-)



[apisix] 01/01: doc: field `key` should be optional in `upstream` object.

2020-09-30 Thread membphis
This is an automated email from the ASF dual-hosted git repository.

membphis pushed a commit to branch membphis-patch-1
in repository https://gitbox.apache.org/repos/asf/apisix.git

commit 09b840a1f3afe12a7d9d0389a0ef8a05c3096a58
Author: YuanSheng Wang 
AuthorDate: Wed Sep 30 15:36:00 2020 +0800

doc: field `key` should be optional in `upstream` object.
---
 doc/admin-api.md | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/doc/admin-api.md b/doc/admin-api.md
index a130a67..29041c4 100644
--- a/doc/admin-api.md
+++ b/doc/admin-api.md
@@ -498,7 +498,7 @@ In addition to the basic complex equalization algorithm 
selection, APISIX's Upst
 |nodes   |required if `k8s_deployment_info` not configured|Hash table, 
the key of the internal element is the upstream machine address list, the 
format is `Address + Port`, where the address part can be IP or domain name, 
such as `192.168.1.100:80`, `foo.com:80`, etc. Value is the weight of the node. 
In particular, when the weight value is `0`, it has a special meaning, which 
usually means that the upstream node is invalid and never wants to be selected.|
 |k8s_deployment_info|required if `nodes` not configured|fields: 
`namespace`、`deploy_name`、`service_name`、`port`、`backend_type`, `port` is 
number, `backend_type` is `pod` or `service`, others is string. |
 |hash_on |optional|This option is only valid if the `type` is `chash`. 
Supported types `vars`(Nginx variables), `header`(custom header), `cookie`, 
`consumer`, the default value is `vars`.|
-|key |required|This option is only valid if the `type` is `chash`. 
Find the corresponding node `id` according to `hash_on` and `key`. When 
`hash_on` is set as `vars`, `key` is the required parameter, for now, it 
support nginx built-in variables like `uri, server_name, server_addr, 
request_uri, remote_port, remote_addr, query_string, host, hostname, arg_***`, 
`arg_***` is arguments in the request line, [Nginx variables 
list](http://nginx.org/en/docs/varindex.html). When `hash_ [...]
+|key |optional|This option is only valid if the `type` is `chash`. 
Find the corresponding node `id` according to `hash_on` and `key`. When 
`hash_on` is set as `vars`, `key` is the required parameter, for now, it 
support nginx built-in variables like `uri, server_name, server_addr, 
request_uri, remote_port, remote_addr, query_string, host, hostname, arg_***`, 
`arg_***` is arguments in the request line, [Nginx variables 
list](http://nginx.org/en/docs/varindex.html). When `hash_ [...]
 |checks  |optional|Configure the parameters of the health check. For 
details, refer to [health-check](health-check.md).|
 |retries |optional|Pass the request to the next upstream using the 
underlying Nginx retry mechanism, the retry mechanism is enabled by default and 
set the number of retries according to the number of backend nodes. If 
`retries` option is explicitly set, it will override the default value. `0` 
means disable retry mechanism.|
 |enable_websocket|optional| enable `websocket`(boolean), default `false`.|



[apisix] branch membphis-patch-1 created (now 09b840a)

2020-09-30 Thread membphis
This is an automated email from the ASF dual-hosted git repository.

membphis pushed a change to branch membphis-patch-1
in repository https://gitbox.apache.org/repos/asf/apisix.git.


  at 09b840a  doc: field `key` should be optional in `upstream` object.

This branch includes the following new commits:

 new 09b840a  doc: field `key` should be optional in `upstream` object.

The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.




[apisix] branch master updated: feat: Add labels for upstream object (#2279)

2020-09-27 Thread membphis
This is an automated email from the ASF dual-hosted git repository.

membphis pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/apisix.git


The following commit(s) were added to refs/heads/master by this push:
 new ebe4f66  feat: Add labels for upstream object (#2279)
ebe4f66 is described below

commit ebe4f6620a8aefd60df265ca64fa1a09b4859090
Author: Joey 
AuthorDate: Mon Sep 28 11:20:09 2020 +0800

feat: Add labels for upstream object (#2279)
---
 apisix/schema_def.lua|  18 +
 doc/architecture-design.md   |   1 +
 doc/zh-cn/architecture-design.md |   1 +
 t/admin/upstream.t   | 166 +++
 4 files changed, 186 insertions(+)

diff --git a/apisix/schema_def.lua b/apisix/schema_def.lua
index a277510..2653069 100644
--- a/apisix/schema_def.lua
+++ b/apisix/schema_def.lua
@@ -64,6 +64,16 @@ local remote_addr_def = {
 }
 
 
+local label_value_def = {
+description = "value of label",
+type = "string",
+pattern = [[^[a-zA-Z0-9-_.]+$]],
+maxLength = 64,
+minLength = 1
+}
+_M.label_value_def = label_value_def
+
+
 local health_checker = {
 type = "object",
 properties = {
@@ -332,6 +342,14 @@ local upstream_schema = {
 description = "enable websocket for request",
 type= "boolean"
 },
+labels = {
+description = "key/value pairs to specify attributes",
+type = "object",
+patternProperties = {
+[".*"] = label_value_def
+},
+maxProperties = 16
+},
 pass_host = {
 description = "mod of host passing",
 type = "string",
diff --git a/doc/architecture-design.md b/doc/architecture-design.md
index 068da16..5b5078a 100644
--- a/doc/architecture-design.md
+++ b/doc/architecture-design.md
@@ -265,6 +265,7 @@ In addition to the basic complex equalization algorithm 
selection, APISIX's Upst
 |enable_websocket|optional| enable `websocket`(boolean), default `false`.|
 |timeout|optional| Set the timeout for connection, sending and receiving 
messages. |
 |desc |optional|Identifies route names, usage scenarios, and more.|
+|labels   |optional|The key/value pairs to specify attributes. |
 |pass_host|optional|`pass` pass the client request host, `node` 
not pass the client request host, using the upstream node host, `rewrite` 
rewrite host by the configured `upstream_host`.|
 |upstream_host|optional|This option is only valid if the `pass_host` is 
`rewrite`.|
 
diff --git a/doc/zh-cn/architecture-design.md b/doc/zh-cn/architecture-design.md
index c56a226..f2f0787 100644
--- a/doc/zh-cn/architecture-design.md
+++ b/doc/zh-cn/architecture-design.md
@@ -273,6 +273,7 @@ APISIX 的 Upstream 除了基本的复杂均衡算法选择外,还支持对上
 |checks  |可选|配置健康检查的参数,详细可参考[health-check](../health-check.md)|
 |retries |可选|使用底层的 Nginx 重试机制将请求传递给下一个上游,默认 APISIX 
会启用重试机制,根据配置的后端节点个数设置重试次数,如果此参数显式被设置将会覆盖系统默认设置的重试次数。|
 |enable_websocket|可选| 是否启用 `websocket`(布尔值),默认不启用|
+|labels  |可选| 用于标识属性的键值对。 |
 |pass_host|可选|`pass` 透传客户端请求的 host, `node` 不透传客户端请求的 host, 使用 
upstream node 配置的 host, `rewrite` 使用 `upstream_host` 配置的值重写 host 。|
 |upstream_host|可选|只在 `pass_host` 配置为 `rewrite` 时有效。|
 
diff --git a/t/admin/upstream.t b/t/admin/upstream.t
index 3bd5be8..92c1bb8 100644
--- a/t/admin/upstream.t
+++ b/t/admin/upstream.t
@@ -1637,3 +1637,169 @@ GET /t
 --- error_code: 400
 --- no_error_log
 [error]
+
+
+
+=== TEST 50: set upstream(with labels)
+--- config
+location /t {
+content_by_lua_block {
+local t = require("lib.test_admin").test
+local code, body = t('/apisix/admin/upstreams/1',
+ngx.HTTP_PUT,
+[[{
+"nodes": {
+"127.0.0.1:8080": 1
+},
+"type": "roundrobin",
+"labels": {
+"build":"16",
+"env":"prodution",
+"version":"v2"
+}
+}]],
+[[{
+"node": {
+"value": {
+"nodes": {
+"127.0.0.1:8080": 1
+},
+"type": "roundrobin",
+"labels": {
+"build":"16",
+"env":"prodution",
+"version":"v2"
+}
+

[apisix] branch master updated: feat: replace timestamp with date and time in GMT format in plugin `hmac-auth` (#2301)

2020-09-27 Thread membphis
This is an automated email from the ASF dual-hosted git repository.

membphis pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/apisix.git


The following commit(s) were added to refs/heads/master by this push:
 new c375bd0  feat: replace timestamp with date and time in GMT format in 
plugin `hmac-auth` (#2301)
c375bd0 is described below

commit c375bd0cac6de4470782fa964323960e798cca40
Author: nic-chen <33000667+nic-c...@users.noreply.github.com>
AuthorDate: Mon Sep 28 09:10:26 2020 +0800

feat: replace timestamp with date and time in GMT format in plugin 
`hmac-auth` (#2301)
---
 apisix/plugins/hmac-auth.lua|  30 ++-
 doc/plugins/hmac-auth.md|  43 ---
 doc/zh-cn/plugins/hmac-auth.md  |  44 ---
 t/APISIX.pm |   2 +-
 t/plugin/consumer-restriction.t |  30 +++
 t/plugin/custom_hmac_auth.t |  39 --
 t/plugin/hmac-auth.t| 116 +++-
 7 files changed, 213 insertions(+), 91 deletions(-)

diff --git a/apisix/plugins/hmac-auth.lua b/apisix/plugins/hmac-auth.lua
index 33c1ddf..0c37ad7 100644
--- a/apisix/plugins/hmac-auth.lua
+++ b/apisix/plugins/hmac-auth.lua
@@ -32,7 +32,7 @@ local ngx_decode_base64 = ngx.decode_base64
 
 local SIGNATURE_KEY = "X-HMAC-SIGNATURE"
 local ALGORITHM_KEY = "X-HMAC-ALGORITHM"
-local TIMESTAMP_KEY = "X-HMAC-TIMESTAMP"
+local DATE_KEY = "Date"
 local ACCESS_KEY= "X-HMAC-ACCESS-KEY"
 local SIGNED_HEADERS_KEY = "X-HMAC-SIGNED-HEADERS"
 local plugin_name   = "hmac-auth"
@@ -57,7 +57,7 @@ local schema = {
 },
 clock_skew = {
 type = "integer",
-default = 300
+default = 0
 },
 signed_headers = {
 type = "array",
@@ -218,7 +218,7 @@ local function generate_signature(ctx, secret_key, params)
 
 local signing_string = request_method .. canonical_uri
 .. canonical_query_string
-.. params.access_key .. params.timestamp
+.. params.access_key .. params.date
 .. core.table.concat(canonical_headers, "")
 
 core.log.info("signing_string:", signing_string,
@@ -246,10 +246,16 @@ local function validate(ctx, params)
 
 core.log.info("clock_skew: ", conf.clock_skew)
 if conf.clock_skew and conf.clock_skew > 0 then
-local diff = abs(ngx_time() - params.timestamp)
-core.log.info("timestamp diff: ", diff)
+local time = ngx.parse_http_time(params.date)
+core.log.info("params.date: ", params.date, " time: ", time)
+if not time then
+return nil, {message = "Invalid GMT format time"}
+end
+
+local diff = abs(ngx_time() - time)
+core.log.info("gmt diff: ", diff)
 if diff > conf.clock_skew then
-  return nil, {message = "Invalid timestamp"}
+return nil, {message = "Clock skew exceeded"}
 end
 end
 
@@ -285,7 +291,7 @@ local function get_params(ctx)
 local access_key = ACCESS_KEY
 local signature_key = SIGNATURE_KEY
 local algorithm_key = ALGORITHM_KEY
-local timestamp_key = TIMESTAMP_KEY
+local date_key = DATE_KEY
 local signed_headers_key = SIGNED_HEADERS_KEY
 
 if try_attr(local_conf, "plugin_attr", "hmac-auth") then
@@ -293,14 +299,14 @@ local function get_params(ctx)
 access_key = attr.access_key or access_key
 signature_key = attr.signature_key or signature_key
 algorithm_key = attr.algorithm_key or algorithm_key
-timestamp_key = attr.timestamp_key or timestamp_key
+date_key = attr.date_key or date_key
 signed_headers_key = attr.signed_headers_key or signed_headers_key
 end
 
 local app_key = core.request.header(ctx, access_key)
 local signature = core.request.header(ctx, signature_key)
 local algorithm = core.request.header(ctx, algorithm_key)
-local timestamp = core.request.header(ctx, timestamp_key)
+local date = core.request.header(ctx, date_key)
 local signed_headers = core.request.header(ctx, signed_headers_key)
 core.log.info("signature_key: ", signature_key)
 
@@ -316,11 +322,11 @@ local function get_params(ctx)
   #auth_data, " auth_data: ",
   core.json.delay_encode(auth_data))
 
-if #auth_data == 6 and auth_data[1] == "hmac-auth-v2" then
+if #auth_data == 6 and auth_data[1] == "hmac-auth-v1" then
 app_key = auth_data[2]
 signature = auth_data[3]
 algorithm = auth_data[4]
-t

[apisix] branch master updated: feat: support to fetch `route_id` and `service_id` via `ctx.var` (#2326)

2020-09-27 Thread membphis
This is an automated email from the ASF dual-hosted git repository.

membphis pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/apisix.git


The following commit(s) were added to refs/heads/master by this push:
 new b1770d4  feat: support to fetch `route_id` and `service_id` via 
`ctx.var` (#2326)
b1770d4 is described below

commit b1770d4ca7e4e8d0f92e655d093b9c5563cc9be6
Author: Firstsawyou <52862365+firstsaw...@users.noreply.github.com>
AuthorDate: Sun Sep 27 22:29:59 2020 +0800

feat: support to fetch `route_id` and `service_id` via `ctx.var` (#2326)
---
 apisix/core/ctx.lua |   7 ++
 t/core/ctx.t| 187 
 2 files changed, 194 insertions(+)

diff --git a/apisix/core/ctx.lua b/apisix/core/ctx.lua
index 0d6e364..7b87e68 100644
--- a/apisix/core/ctx.lua
+++ b/apisix/core/ctx.lua
@@ -28,6 +28,7 @@ local ngx_var  = ngx.var
 local re_gsub  = ngx.re.gsub
 local type = type
 local error= error
+local ngx  = ngx
 
 
 ffi.cdef[[
@@ -89,6 +90,12 @@ do
 key = re_gsub(key, "-", "_", "jo")
 val = get_var(key, t._request)
 
+elseif key == "route_id" then
+val = ngx.ctx.api_ctx and ngx.ctx.api_ctx.route_id
+
+elseif key == "service_id" then
+val = ngx.ctx.api_ctx and ngx.ctx.api_ctx.service_id
+
 else
 val = get_var(key, t._request)
 end
diff --git a/t/core/ctx.t b/t/core/ctx.t
index cea8ca5..ae02b52 100644
--- a/t/core/ctx.t
+++ b/t/core/ctx.t
@@ -155,3 +155,190 @@ GET /t?a=aaa
 --- error_code: 500
 --- error_log
 invalid argument, expect string value
+
+
+
+=== TEST 7: add route and get `route_id`
+--- config
+location /t {
+content_by_lua_block {
+local t = require("lib.test_admin").test
+local code, body = t('/apisix/admin/routes/1',
+ngx.HTTP_PUT,
+[[{
+"methods": ["GET"],
+"plugins": {
+"serverless-pre-function": {
+"phase": "access",
+"functions" : ["return function() 
ngx.log(ngx.INFO, \"route_id: \", ngx.ctx.api_ctx.var.route_id) end"]
+}
+},
+"upstream": {
+"type": "roundrobin",
+"nodes": {
+"127.0.0.1:1980": 1
+}
+},
+"uri": "/hello"
+}]]
+)
+
+if code >= 300 then
+ngx.status = code
+end
+ngx.say(body)
+}
+}
+--- request
+GET /t
+--- response_body
+passed
+--- no_error_log
+[error]
+
+
+
+=== TEST 8: `url` exist and `route_id` is 1
+--- request
+GET /hello
+--- response_body
+hello world
+--- error_log
+route_id: 1
+--- no_error_log
+[error]
+
+
+
+=== TEST 9: create a service and `service_id` is 1
+--- config
+location /t {
+content_by_lua_block {
+local t = require("lib.test_admin").test
+local code, body = t('/apisix/admin/services/1',
+ ngx.HTTP_PUT,
+ [[{
+"desc": "new_service"
+}]],
+[[{
+"node": {
+"value": {
+"desc": "new_service"
+},
+"key": "/apisix/services/1"
+},
+"action": "set"
+}]]
+)
+
+ngx.status = code
+ngx.say(body)
+}
+}
+--- request
+GET /t
+--- response_body
+passed
+--- no_error_log
+[error]
+
+
+
+=== TEST 10: the route object not bind any service object
+--- config
+location /t {
+content_by_lua_block {
+local t = require("lib.test_admin").test
+local code, body = t('/apisix/admin/routes/1',
+ngx.HTTP_PUT,
+[[{
+"methods": ["GET"],
+"plugins": {
+"serverless-pre-function": {
+"phase": "access",
+"functions" : ["return function() 
ngx.log(ngx.INFO, \"service_id: \", ngx.ctx.api_ctx.var.service_id or 'empty 
route_id') end"]
+}
+},
+  

[apisix] branch master updated: Revert "feat(http-logger): support for specified the log formats via admin API (#2294)" (#2307)

2020-09-24 Thread membphis
This is an automated email from the ASF dual-hosted git repository.

membphis pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/apisix.git


The following commit(s) were added to refs/heads/master by this push:
 new 13b0968  Revert "feat(http-logger): support for specified the log 
formats via admin API (#2294)" (#2307)
13b0968 is described below

commit 13b09683400e41529258fe21f013668880a6a5ba
Author: Wen Ming 
AuthorDate: Thu Sep 24 23:50:22 2020 +0800

Revert "feat(http-logger): support for specified the log formats via admin 
API (#2294)" (#2307)

This reverts commit 89f89f30044e12c04b67508623d0b4a85cb77709.
---
 apisix/core/table.lua|   2 +-
 apisix/plugin.lua|  16 
 apisix/plugins/http-logger.lua   |  83 +++-
 bin/apisix   |   2 +-
 doc/zh-cn/plugins/http-logger.md |  28 +--
 t/node/route-domain-with-local-dns.t |   4 +-
 t/node/route-domain.t|   6 +-
 t/plugin/http-logger-log-format.t| 147 ---
 8 files changed, 17 insertions(+), 271 deletions(-)

diff --git a/apisix/core/table.lua b/apisix/core/table.lua
index 2324840..4ad92ca 100644
--- a/apisix/core/table.lua
+++ b/apisix/core/table.lua
@@ -26,6 +26,7 @@ local ngx_re   = require("ngx.re")
 
 
 local _M = {
+version = 0.2,
 new = new_tab,
 clear   = require("table.clear"),
 nkeys   = nkeys,
@@ -34,7 +35,6 @@ local _M = {
 sort= table.sort,
 clone   = require("table.clone"),
 isarray = require("table.isarray"),
-empty_tab = {},
 }
 
 
diff --git a/apisix/plugin.lua b/apisix/plugin.lua
index c2d40ce..8c49883 100644
--- a/apisix/plugin.lua
+++ b/apisix/plugin.lua
@@ -25,7 +25,6 @@ local type  = type
 local local_plugins = core.table.new(32, 0)
 local ngx   = ngx
 local tostring  = tostring
-local error = error
 local local_plugins_hash= core.table.new(0, 32)
 local stream_local_plugins  = core.table.new(32, 0)
 local stream_local_plugins_hash = core.table.new(0, 32)
@@ -392,21 +391,6 @@ end
 
 function _M.init_worker()
 _M.load()
-
-local plugin_metadatas, err = core.config.new("/plugin_metadata",
-{automatic = true}
-)
-if not plugin_metadatas then
-error("failed to create etcd instance for fetching /plugin_metadatas : 
"
-  .. err)
-end
-
-_M.plugin_metadatas = plugin_metadatas
-end
-
-
-function _M.plugin_metadata(name)
-return _M.plugin_metadatas:get(name)
 end
 
 
diff --git a/apisix/plugins/http-logger.lua b/apisix/plugins/http-logger.lua
index a483ab1..4694b60 100644
--- a/apisix/plugins/http-logger.lua
+++ b/apisix/plugins/http-logger.lua
@@ -14,25 +14,16 @@
 -- See the License for the specific language governing permissions and
 -- limitations under the License.
 --
-
+local core = require("apisix.core")
+local log_util = require("apisix.utils.log-util")
 local batch_processor = require("apisix.utils.batch-processor")
-local log_util= require("apisix.utils.log-util")
-local core= require("apisix.core")
-local http= require("resty.http")
-local url = require("net.url")
-local plugin  = require("apisix.plugin")
-local ngx  = ngx
-local tostring = tostring
-local pairs= pairs
-local ipairs = ipairs
-
-
 local plugin_name = "http-logger"
+local ngx = ngx
+local tostring = tostring
+local http = require "resty.http"
+local url = require "net.url"
 local buffers = {}
-local lru_log_format = core.lrucache.new({
-ttl = 300, count = 512
-})
-
+local ipairs = ipairs
 
 local schema = {
 type = "object",
@@ -54,24 +45,11 @@ local schema = {
 }
 
 
-local metadata_schema = {
-type = "object",
-properties = {
-log_format = {
-type = "object",
-default = {},
-},
-},
-additionalProperties = false,
-}
-
-
 local _M = {
 version = 0.1,
 priority = 410,
 name = plugin_name,
 schema = schema,
-metadata_schema = metadata_schema,
 }
 
 
@@ -139,51 +117,8 @@ local function send_http_data(conf, log_message)
 end
 
 
-local function gen_log_format(metadata)
-local log_format = core.table.empty_tab
-if not metadata or
-   not metadata.value or
-   not metadata.value.log_format or
-   core.table.nkeys(metadata.value.log_format) == 0
-then
-return log_format
-end
-
-for k, var_name in pairs(metadata.value.log_format) do
-if var_name:sub(1, 1) == "$" then
-log_format[k] = {true, var_name:sub(2)}
-else
-log_format[k] = {false, var_name}
-end
-end
-core.log.info("log_format: ",

[apisix] branch master updated (3f9685f -> 89f89f3)

2020-09-24 Thread membphis
This is an automated email from the ASF dual-hosted git repository.

membphis pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/apisix.git.


from 3f9685f  feat(http-logger): support to concat multiple log with 
separator. (#2286)
 add 89f89f3  feat(http-logger): support for specified the log formats via 
admin API (#2294)

No new revisions were added by this update.

Summary of changes:
 apisix/core/table.lua  |   2 +-
 apisix/plugin.lua  |  16 +++
 apisix/plugins/http-logger.lua |  83 +--
 bin/apisix |   2 +-
 doc/zh-cn/plugins/http-logger.md   |  28 -
 t/node/route-domain-with-local-dns.t   |   4 +-
 t/node/route-domain.t  |   6 +-
 .../http-logger-log-format.t}  | 117 +
 8 files changed, 172 insertions(+), 86 deletions(-)
 copy t/{node/remote-addr.t => plugin/http-logger-log-format.t} (55%)



[apisix] branch master updated: feat(http-logger): support to concat multiple log with separator. (#2286)

2020-09-23 Thread membphis
This is an automated email from the ASF dual-hosted git repository.

membphis pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/apisix.git


The following commit(s) were added to refs/heads/master by this push:
 new 3f9685f  feat(http-logger): support to concat multiple log with 
separator. (#2286)
3f9685f is described below

commit 3f9685f823050f3c3324d20ffacafec4e3e70150
Author: YuanSheng Wang 
AuthorDate: Thu Sep 24 10:58:44 2020 +0800

feat(http-logger): support to concat multiple log with separator. (#2286)
---
 apisix/plugins/http-logger.lua   |  37 ---
 doc/plugins/http-logger.md   |   8 +-
 doc/zh-cn/plugins/http-logger.md |   3 +-
 t/lib/server.lua |   6 ++
 t/plugin/http-logger-new-line.t  | 223 +++
 5 files changed, 260 insertions(+), 17 deletions(-)

diff --git a/apisix/plugins/http-logger.lua b/apisix/plugins/http-logger.lua
index 44df6ae..4694b60 100644
--- a/apisix/plugins/http-logger.lua
+++ b/apisix/plugins/http-logger.lua
@@ -23,6 +23,7 @@ local tostring = tostring
 local http = require "resty.http"
 local url = require "net.url"
 local buffers = {}
+local ipairs = ipairs
 
 local schema = {
 type = "object",
@@ -36,7 +37,9 @@ local schema = {
 buffer_duration = {type = "integer", minimum = 1, default = 60},
 inactive_timeout = {type = "integer", minimum = 1, default = 5},
 batch_max_size = {type = "integer", minimum = 1, default = 1000},
-include_req_body = {type = "boolean", default = false}
+include_req_body = {type = "boolean", default = false},
+concat_method = {type = "string", default = "json",
+ enum = {"json", "new_line"}}
 },
 required = {"uri"}
 }
@@ -110,13 +113,6 @@ local function send_http_data(conf, log_message)
 .. "body[" .. httpc_res:read_body() .. "]"
 end
 
--- keep the connection alive
-ok, err = httpc:set_keepalive(conf.keepalive)
-
-if not ok then
-core.log.debug("failed to keep the connection alive", err)
-end
-
 return res, err_msg
 end
 
@@ -139,10 +135,26 @@ function _M.log(conf)
 -- Generate a function to be executed by the batch processor
 local func = function(entries, batch_max_size)
 local data, err
-if batch_max_size == 1 then
-data, err = core.json.encode(entries[1]) -- encode as single {}
-else
-data, err = core.json.encode(entries) -- encode as array [{}]
+if conf.concat_method == "json" then
+if batch_max_size == 1 then
+data, err = core.json.encode(entries[1]) -- encode as single {}
+else
+data, err = core.json.encode(entries) -- encode as array [{}]
+end
+
+elseif conf.concat_method == "new_line" then
+if batch_max_size == 1 then
+data, err = core.json.encode(entries[1]) -- encode as single {}
+else
+local t = core.table.new(#entries, 0)
+for i, entrie in ipairs(entries) do
+t[i], err = core.json.encode(entrie)
+if err then
+break
+end
+end
+data = core.table.concat(t, "\n") -- encode as multiple string
+end
 end
 
 if not data then
@@ -173,4 +185,5 @@ function _M.log(conf)
 log_buffer:push(entry)
 end
 
+
 return _M
diff --git a/doc/plugins/http-logger.md b/doc/plugins/http-logger.md
index f8c0941..3fd5b9e 100644
--- a/doc/plugins/http-logger.md
+++ b/doc/plugins/http-logger.md
@@ -20,6 +20,7 @@
 - [中文](../zh-cn/plugins/http-logger.md)
 
 # Summary
+
 - [**Name**](#name)
 - [**Attributes**](#attributes)
 - [**How To Enable**](#how-to-enable)
@@ -35,7 +36,6 @@ This will provide the ability to send Log data requests as 
JSON objects to Monit
 
 ## Attributes
 
-
 | Name | Type| Requirement | Default   | Valid   | 
Description 
 |
 |  | --- | --- | - | --- | 

 |
 | uri  | string  | required|   | | URI of 
the server  
  |
@@ -48,6 +48,7 @@ This will provide the ability to send Log data requests as 
JSON objects to Monit
 | max_retry_count  | integer | optional| 0 | [0,...] | Maximum 
number of retries before removing from the processing pipe line 
 |
 | retry_delay  | integer | optional| 1 | [0,...] | Number

[apisix] branch master updated: fix: increase wait to avoid fail (#2290)

2020-09-23 Thread membphis
This is an automated email from the ASF dual-hosted git repository.

membphis pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/apisix.git


The following commit(s) were added to refs/heads/master by this push:
 new 7beafd3  fix: increase wait to avoid fail (#2290)
7beafd3 is described below

commit 7beafd345a96b5fc14d9230731f284429ad7168e
Author: Vinci Xu <277040...@qq.com>
AuthorDate: Wed Sep 23 22:48:34 2020 +0800

fix: increase wait to avoid fail (#2290)
---
 t/plugin/tcp-logger.t | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/t/plugin/tcp-logger.t b/t/plugin/tcp-logger.t
index 7343f0d..05bd3c4 100644
--- a/t/plugin/tcp-logger.t
+++ b/t/plugin/tcp-logger.t
@@ -233,4 +233,4 @@ GET /t
 --- error_log
 failed to connect to TCP server: host[312.0.0.1] port[2000]
 [error]
 wait: 1.5
+--- wait: 3



[apisix] branch master updated (44e05b0 -> 1b24f36)

2020-09-23 Thread membphis
This is an automated email from the ASF dual-hosted git repository.

membphis pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/apisix.git.


from 44e05b0  doc: removed qrcode of qq group. (#2246)
 add 1b24f36  feat: support storing metadata for plugins (#2268)

No new revisions were added by this update.

Summary of changes:
 apisix/admin/init.lua  |   1 +
 apisix/admin/plugin_metadata.lua   | 122 +
 apisix/plugins/example-plugin.lua  |  10 ++
 doc/admin-api.md   |  32 ++
 doc/plugin-develop.md  |  25 +
 doc/zh-cn/admin-api.md |  32 ++
 doc/zh-cn/plugin-develop.md|  24 +
 t/admin/{consumers.t => plugin-metadata.t} | 164 +
 8 files changed, 366 insertions(+), 44 deletions(-)
 create mode 100644 apisix/admin/plugin_metadata.lua
 copy t/admin/{consumers.t => plugin-metadata.t} (53%)



[apisix] branch master updated: feature: allow empty `service` object, it does not contain any `upstream` and `plugin` (#2259)

2020-09-21 Thread membphis
This is an automated email from the ASF dual-hosted git repository.

membphis pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/apisix.git


The following commit(s) were added to refs/heads/master by this push:
 new a651a29  feature: allow empty `service` object, it does not contain 
any `upstream` and `plugin` (#2259)
a651a29 is described below

commit a651a29e206a11920edcbdff3054cf7bfbd27462
Author: Firstsawyou <52862365+firstsaw...@users.noreply.github.com>
AuthorDate: Mon Sep 21 16:52:18 2020 +0800

feature: allow empty `service` object, it does not contain any `upstream` 
and `plugin` (#2259)
---
 apisix/schema_def.lua  |   6 ---
 t/admin/schema.t   |  23 ++--
 t/admin/services.t |  94 ++
 t/node/service-empty.t | 100 +
 4 files changed, 213 insertions(+), 10 deletions(-)

diff --git a/apisix/schema_def.lua b/apisix/schema_def.lua
index e8d4249..a277510 100644
--- a/apisix/schema_def.lua
+++ b/apisix/schema_def.lua
@@ -473,12 +473,6 @@ _M.service = {
 desc = {type = "string", maxLength = 256},
 script = {type = "string", minLength = 10, maxLength = 102400},
 },
-anyOf = {
-{required = {"upstream"}},
-{required = {"upstream_id"}},
-{required = {"plugins"}},
-{required = {"script"}},
-},
 additionalProperties = false,
 }
 
diff --git a/t/admin/schema.t b/t/admin/schema.t
index 1acc3f6..5f78635 100644
--- a/t/admin/schema.t
+++ b/t/admin/schema.t
@@ -36,11 +36,26 @@ qr/"plugins":\{"type":"object"}/
 
 
 
-=== TEST 2: get service schema
+=== TEST 2: get service schema and check if it contains `anyOf`
+--- config
+location /t {
+content_by_lua_block {
+local core = require("apisix.core")
+local t = require("lib.test_admin").test
+local code, _, res_body = t('/apisix/admin/schema/service', 
ngx.HTTP_GET)
+local res_data = core.json.decode(res_body)
+if res_data["anyOf"] then
+ngx.say("found `anyOf`")
+return
+end
+
+ngx.say("passed") 
+}
+}
 --- request
-GET /apisix/admin/schema/service
 response_body eval
-qr/"required":\["upstream"\]/
+GET /t
+--- response_body
+passed
 --- no_error_log
 [error]
 
diff --git a/t/admin/services.t b/t/admin/services.t
index b7ec741..5dcb8ad 100644
--- a/t/admin/services.t
+++ b/t/admin/services.t
@@ -1085,3 +1085,97 @@ GET /t
 --- error_code: 400
 --- no_error_log
 [error]
+
+
+
+=== TEST 31: set empty service. (id: 1)(allow empty `service` object)
+--- config
+location /t {
+content_by_lua_block {
+local t = require("lib.test_admin").test
+local code, body = t('/apisix/admin/services/1',
+ngx.HTTP_PUT,
+{},
+[[{
+"node": {
+"value": {"id":"1"}
+},
+"action": "set"
+}]]
+)
+
+ngx.status = code
+ngx.say(body)
+}
+}
+--- request
+GET /t
+--- response_body
+passed
+--- no_error_log
+[error]
+
+
+
+=== TEST 32: patch content to the empty service.
+--- config
+location /t {
+content_by_lua_block {
+local t = require("lib.test_admin").test
+local code, body = t('/apisix/admin/services/1',
+ngx.HTTP_PATCH,
+[[{
+"desc": "empty service",
+"plugins": {
+"limit-count": {
+"count": 2,
+"time_window": 60,
+"rejected_code": 503,
+"key": "remote_addr"
+}
+},
+"upstream": {
+"type": "roundrobin",
+"nodes": {
+"127.0.0.1:80": 1
+}
+}
+}]],
+[[{ 
+"node":{
+"value":{
+"desc":"empty service",
+"plugins":{
+"limit-count":{
+"time_window":60,
+

[apisix] branch master updated: test: also lint the test helpers (#2252)

2020-09-19 Thread membphis
This is an automated email from the ASF dual-hosted git repository.

membphis pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/apisix.git


The following commit(s) were added to refs/heads/master by this push:
 new 8493a60  test: also lint the test helpers (#2252)
8493a60 is described below

commit 8493a607ce869ab335eac1d0e799ffecff10fb93
Author: 罗泽轩 
AuthorDate: Sat Sep 19 19:07:39 2020 +0800

test: also lint the test helpers (#2252)

Close #2215
---
 t/lib/server.lua  | 13 +
 t/lib/test_admin.lua  |  1 +
 utils/check-lua-code-style.sh |  2 +-
 3 files changed, 11 insertions(+), 5 deletions(-)

diff --git a/t/lib/server.lua b/t/lib/server.lua
index 68ba81a..c9e89e9 100644
--- a/t/lib/server.lua
+++ b/t/lib/server.lua
@@ -154,7 +154,8 @@ function _M.mock_zipkin()
 ngx.exit(400)
 end
 
-if span.localEndpoint.serviceName ~= 'APISIX' and 
span.localEndpoint.serviceName ~= 'apisix' then
+if span.localEndpoint.serviceName ~= 'APISIX'
+  and span.localEndpoint.serviceName ~= 'apisix' then
 ngx.exit(400)
 end
 
@@ -205,7 +206,9 @@ function _M.wolf_rbac_access_check()
 local args = ngx.req.get_uri_args()
 local resName = args.resName
 if resName == '/hello' or resName == '/wolf/rbac/custom/headers' then
-ngx.say(json_encode({ok=true, data={ 
userInfo={nickname="administrator",username="admin", id="100"} }}))
+ngx.say(json_encode({ok=true,
+data={ userInfo={nickname="administrator",
+username="admin", id="100"} }}))
 else
 ngx.status = 401
 ngx.say(json_encode({ok=false, reason="no permission to access"}))
@@ -220,7 +223,8 @@ function _M.wolf_rbac_user_info()
 ngx.exit(0)
 end
 
-ngx.say(json_encode({ok=true, data={ userInfo={nickname="administrator", 
username="admin", id="100"} }}))
+ngx.say(json_encode({ok=true,
+data={ userInfo={nickname="administrator", 
username="admin", id="100"} }}))
 end
 
 function _M.wolf_rbac_change_pwd()
@@ -237,7 +241,8 @@ end
 
 function _M.wolf_rbac_custom_headers()
 local headers = ngx.req.get_headers()
-ngx.say('id:' .. headers['X-UserId'] .. ',username:' .. 
headers['X-Username'] .. ',nickname:' .. headers['X-Nickname'])
+ngx.say('id:' .. headers['X-UserId'] .. ',username:' .. 
headers['X-Username']
+.. ',nickname:' .. headers['X-Nickname'])
 end
 
 function _M.websocket_handshake()
diff --git a/t/lib/test_admin.lua b/t/lib/test_admin.lua
index dc245c3..ac6d22e 100644
--- a/t/lib/test_admin.lua
+++ b/t/lib/test_admin.lua
@@ -16,6 +16,7 @@
 --
 local http  = require("resty.http")
 local json  = require("cjson.safe")
+local core  = require("apisix.core")
 local aes   = require "resty.aes"
 local ngx_encode_base64 = ngx.encode_base64
 local str_find  = string.find
diff --git a/utils/check-lua-code-style.sh b/utils/check-lua-code-style.sh
index 6cb80d3..2dfff59 100755
--- a/utils/check-lua-code-style.sh
+++ b/utils/check-lua-code-style.sh
@@ -19,7 +19,7 @@
 
 set -ex
 
-luacheck -q apisix
+luacheck -q apisix t/lib
 
 find apisix -name '*.lua' -exec ./utils/lj-releng {} + > \
 /tmp/check.log 2>&1 || (cat /tmp/check.log && exit 1)



[apisix] branch master updated: feature: `consumer` provides access to a collection of `service` (#2241)

2020-09-19 Thread membphis
This is an automated email from the ASF dual-hosted git repository.

membphis pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/apisix.git


The following commit(s) were added to refs/heads/master by this push:
 new e94a5b3  feature: `consumer` provides access to a collection of 
`service`  (#2241)
e94a5b3 is described below

commit e94a5b3f584024744c7c602984f70fedd37a9f7e
Author: Firstsawyou <52862365+firstsaw...@users.noreply.github.com>
AuthorDate: Sat Sep 19 18:21:21 2020 +0800

feature: `consumer` provides access to a collection of `service`  (#2241)

* test: add more test cases.

Co-authored-by: Yuansheng Wang 
---
 apisix/init.lua |   2 +
 apisix/plugins/consumer-restriction.lua |  33 +-
 t/plugin/consumer-restriction.t | 711 +++-
 3 files changed, 735 insertions(+), 11 deletions(-)

diff --git a/apisix/init.lua b/apisix/init.lua
index 63275c1..9f8b38b 100644
--- a/apisix/init.lua
+++ b/apisix/init.lua
@@ -403,11 +403,13 @@ function _M.http_access_phase()
 api_ctx.conf_type = "route"
 api_ctx.conf_version = route.modifiedIndex .. "&" .. 
service.modifiedIndex
 api_ctx.conf_id = route.value.id .. "&" .. service.value.id
+api_ctx.service_id = service.value.id
 else
 api_ctx.conf_type = "route"
 api_ctx.conf_version = route.modifiedIndex
 api_ctx.conf_id = route.value.id
 end
+api_ctx.route_id = route.value.id
 
 local enable_websocket
 local up_id = route.value.upstream_id
diff --git a/apisix/plugins/consumer-restriction.lua 
b/apisix/plugins/consumer-restriction.lua
index 912e212..f80e096 100644
--- a/apisix/plugins/consumer-restriction.lua
+++ b/apisix/plugins/consumer-restriction.lua
@@ -20,6 +20,11 @@ local core  = require("apisix.core")
 local schema = {
 type = "object",
 properties = {
+type = {
+type = "string",
+enum = {"consumer_name", "service_id"},
+default = "consumer_name"
+},
 whitelist = {
 type = "array",
 items = {type = "string"},
@@ -29,7 +34,8 @@ local schema = {
 type = "array",
 items = {type = "string"},
 minItems = 1
-}
+},
+rejected_code = {type = "integer", minimum = 200, default = 403}
 },
 oneOf = {
 {required = {"whitelist"}},
@@ -37,10 +43,8 @@ local schema = {
 }
 }
 
-
 local plugin_name = "consumer-restriction"
 
-
 local _M = {
 version = 0.1,
 priority = 2400,
@@ -48,6 +52,15 @@ local _M = {
 schema = schema,
 }
 
+local fetch_val_funcs = {
+["service_id"] = function(ctx)
+return ctx.service_id
+end,
+["consumer_name"] = function(ctx)
+return ctx.consumer_id
+end
+}
+
 local function is_include(value, tab)
 for k,v in ipairs(tab) do
 if v == value then
@@ -57,6 +70,7 @@ local function is_include(value, tab)
 return false
 end
 
+
 function _M.check_schema(conf)
 local ok, err = core.schema.check(schema, conf)
 
@@ -67,26 +81,29 @@ function _M.check_schema(conf)
 return true
 end
 
+
 function _M.access(conf, ctx)
-if not ctx.consumer then
-return 401, { message = "Missing authentication or identity 
verification." }
+local value = fetch_val_funcs[conf.type](ctx)
+if not value then
+return 401, { message = "Missing authentication or identity 
verification."}
 end
+core.log.info("value: ", value)
 
 local block = false
 if conf.blacklist and #conf.blacklist > 0 then
-if is_include(ctx.consumer.username, conf.blacklist) then
+if is_include(value, conf.blacklist) then
 block = true
 end
 end
 
 if conf.whitelist and #conf.whitelist > 0 then
-if not is_include(ctx.consumer.username, conf.whitelist) then
+if not is_include(value, conf.whitelist) then
 block = true
 end
 end
 
 if block then
-return 403, { message = "The consumer is not allowed" }
+return conf.rejected_code, { message = "The " .. conf.type .. " is 
forbidden." }
 end
 end
 
diff --git a/t/plugin/consumer-restriction.t b/t/plugin/consumer-restriction.t
index 57bbed3..69708ea 100644
--- a/t/plugin/consumer-restriction.t
+++ b/t/plugin/consumer-restriction.t
@@ -47,7 +47,7 @@ __DATA__
 --- request
 GET /t
 --- response_body
-{"whitelist":["jack1","jack2"]}
+{"rejected_code":403,"type":"consumer_name","whitelist":["jack1","jack2"]}
 --- no_error_log
 [error]
 
@@ -237,7 +2

[apisix] branch master updated: fix[key-auth]: skip consumer when config has no key (#2120)

2020-09-18 Thread membphis
This is an automated email from the ASF dual-hosted git repository.

membphis pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/apisix.git


The following commit(s) were added to refs/heads/master by this push:
 new 89f4389  fix[key-auth]: skip consumer when config has no key (#2120)
89f4389 is described below

commit 89f4389ba726dc839660b9801b3c7ff825635d99
Author: Vinci Xu <277040...@qq.com>
AuthorDate: Fri Sep 18 21:49:01 2020 +0800

fix[key-auth]: skip consumer when config has no key (#2120)
---
 apisix/plugins/key-auth.lua |  4 +++-
 t/plugin/key-auth.t | 57 +++--
 2 files changed, 58 insertions(+), 3 deletions(-)

diff --git a/apisix/plugins/key-auth.lua b/apisix/plugins/key-auth.lua
index 15c451f..50fbdbf 100644
--- a/apisix/plugins/key-auth.lua
+++ b/apisix/plugins/key-auth.lua
@@ -46,7 +46,9 @@ do
 
 for _, consumer in ipairs(consumers.nodes) do
 core.log.info("consumer node: ", core.json.delay_encode(consumer))
-consumer_ids[consumer.auth_conf.key] = consumer
+if consumer.auth_conf.key then
+consumer_ids[consumer.auth_conf.key] = consumer
+end
 end
 
 return consumer_ids
diff --git a/t/plugin/key-auth.t b/t/plugin/key-auth.t
index a47292e..2909ccc 100644
--- a/t/plugin/key-auth.t
+++ b/t/plugin/key-auth.t
@@ -73,7 +73,7 @@ done
 location /t {
 content_by_lua_block {
 local t = require("lib.test_admin").test
-local code, body = t('/apisix/admin/consumers',
+local code, body = t('/apisix/admin/consumers/1',
 ngx.HTTP_PUT,
 [[{
 "username": "jack",
@@ -194,7 +194,7 @@ GET /hello
 for i = 1, 20 do
 username = "user_" .. tostring(i)
 key = "auth-" .. tostring(i)
-code, body = t('/apisix/admin/consumers',
+code, body = t(string.format('/apisix/admin/consumers/%d', 
tostring(i)),
 ngx.HTTP_PUT,
 
string.format('{"username":"%s","plugins":{"key-auth":{"key":"%s"}}}', 
username, key),
 
string.format('{"node":{"value":{"username":"%s","plugins":{"key-auth":{"key":"%s","action":"set"}',
 username, key)
@@ -215,3 +215,56 @@ apikey: auth-13
 ["passed\n", "hello world\n"]
 --- no_error_log
 [error]
+
+
+
+=== TEST 9: add consumer with empty key
+--- config
+location /t {
+content_by_lua_block {
+local t = require("lib.test_admin").test
+local code, body = t('/apisix/admin/consumers',
+ngx.HTTP_PUT,
+[[{
+"username": "error",
+"plugins": {
+"key-auth": {
+}
+}
+}]],
+[[{
+"node": {
+"value": {
+"username": "error",
+"plugins": {
+"key-auth": {
+}
+}
+}
+},
+"action": "set"
+}]]
+)
+
+ngx.status = code
+ngx.say(body)
+}
+}
+--- request
+GET /t
+--- response_body
+passed
+--- no_error_log
+[error]
+
+
+
+=== TEST 10: valid consumer
+--- request
+GET /hello
+--- more_headers
+apikey: auth-one
+--- response_body
+hello world
+--- no_error_log
+[error]



[apisix] branch master updated: feat: `hmac-auth` add signed headers to calculate signature (#2239)

2020-09-18 Thread membphis
This is an automated email from the ASF dual-hosted git repository.

membphis pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/apisix.git


The following commit(s) were added to refs/heads/master by this push:
 new 0a4bc95  feat: `hmac-auth` add signed headers to  calculate signature 
(#2239)
0a4bc95 is described below

commit 0a4bc95e3d705ba7a7bb9cf077649f020121131d
Author: nic-chen <33000667+nic-c...@users.noreply.github.com>
AuthorDate: Fri Sep 18 20:25:41 2020 +0800

feat: `hmac-auth` add signed headers to  calculate signature (#2239)

Co-authored-by: YuanSheng Wang 
---
 apisix/plugins/hmac-auth.lua   |  98 -
 doc/plugins/hmac-auth.md   |  19 ++--
 doc/zh-cn/plugins/hmac-auth.md |  19 ++--
 t/APISIX.pm|   1 +
 t/plugin/custom_hmac_auth.t|  11 ++-
 t/plugin/hmac-auth.t   | 194 ++---
 6 files changed, 298 insertions(+), 44 deletions(-)

diff --git a/apisix/plugins/hmac-auth.lua b/apisix/plugins/hmac-auth.lua
index ad578c4..33c1ddf 100644
--- a/apisix/plugins/hmac-auth.lua
+++ b/apisix/plugins/hmac-auth.lua
@@ -34,12 +34,18 @@ local SIGNATURE_KEY = "X-HMAC-SIGNATURE"
 local ALGORITHM_KEY = "X-HMAC-ALGORITHM"
 local TIMESTAMP_KEY = "X-HMAC-TIMESTAMP"
 local ACCESS_KEY= "X-HMAC-ACCESS-KEY"
+local SIGNED_HEADERS_KEY = "X-HMAC-SIGNED-HEADERS"
 local plugin_name   = "hmac-auth"
 
 local schema = {
 type = "object",
 oneOf = {
 {
+title = "work with route or service object",
+properties = {},
+additionalProperties = false,
+},
+{
 title = "work with consumer object",
 properties = {
 access_key = {type = "string", minLength = 1, maxLength = 256},
@@ -52,16 +58,19 @@ local schema = {
 clock_skew = {
 type = "integer",
 default = 300
-}
+},
+signed_headers = {
+type = "array",
+items = {
+type = "string",
+minLength = 1,
+maxLength = 50,
+}
+},
 },
 required = {"access_key", "secret_key"},
 additionalProperties = false,
 },
-{
-title = "work with route or service object",
-properties = {},
-additionalProperties = false,
-}
 }
 }
 
@@ -101,6 +110,16 @@ local function try_attr(t, ...)
 end
 
 
+local function array_to_map(arr)
+local map = core.table.new(0, #arr)
+for _, v in ipairs(arr) do
+  map[v] = true
+end
+
+return map
+end
+
+
 local create_consumer_cache
 do
 local consumer_ids = {}
@@ -182,13 +201,29 @@ local function generate_signature(ctx, secret_key, params)
 canonical_query_string = core.table.concat(query_tab, "&")
 end
 
-local req_body = core.request.get_body()
-req_body = req_body or ""
+local canonical_headers = {}
+
+core.log.info("all headers: ",
+  core.json.delay_encode(core.request.headers(ctx), true))
+
+if params.signed_headers then
+for _, h in ipairs(params.signed_headers) do
+local canonical_header = core.request.header(ctx, h) or ""
+core.table.insert(canonical_headers, canonical_header)
+core.log.info("canonical_header name:", core.json.delay_encode(h))
+core.log.info("canonical_header value: ",
+  core.json.delay_encode(canonical_header))
+end
+end
 
 local signing_string = request_method .. canonical_uri
-.. canonical_query_string .. req_body
+.. canonical_query_string
 .. params.access_key .. params.timestamp
-.. secret_key
+.. core.table.concat(canonical_headers, "")
+
+core.log.info("signing_string:", signing_string,
+  " params.signed_headers:",
+  core.json.delay_encode(params.signed_headers))
 
 return hmac_funcs[params.algorithm](secret_key, signing_string)
 end
@@ -209,21 +244,33 @@ local function validate(ctx, params)
 return nil, {message = "algorithm " .. params.algorithm .. " not 
supported"}
 end
 
-core.log.info("conf.clock_skew: ", conf.clock_skew)
+core.log.info("clock_skew: ", conf.clock_skew)
 if conf.clock_skew and conf.clock_skew > 0 then
 local diff = abs(ngx_time() - params.ti

[apisix] branch master updated: test: before creating and deleting routes in batches, clear all routes first (#2253)

2020-09-18 Thread membphis
This is an automated email from the ASF dual-hosted git repository.

membphis pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/apisix.git


The following commit(s) were added to refs/heads/master by this push:
 new 03d818e  test: before creating and deleting routes in batches, clear 
all routes first (#2253)
03d818e is described below

commit 03d818e175f7fe6f55135f4d2c979ceac7728229
Author: YuanSheng Wang 
AuthorDate: Fri Sep 18 18:43:02 2020 +0800

test: before creating and deleting routes in batches, clear all routes 
first (#2253)

* test: set larger timeout.
---
 t/node/healthcheck.t  |  1 +
 t/node/route-delete.t | 58 +++
 2 files changed, 46 insertions(+), 13 deletions(-)

diff --git a/t/node/healthcheck.t b/t/node/healthcheck.t
index 424d96f..b6e754f 100644
--- a/t/node/healthcheck.t
+++ b/t/node/healthcheck.t
@@ -695,6 +695,7 @@ GET /t
 qr/^.*?\[warn\].*/
 --- grep_error_log_out eval
 qr/unhealthy TCP increment.*foo.com.*127.0.0.1:1988/
+--- timeout: 5
 
 
 
diff --git a/t/node/route-delete.t b/t/node/route-delete.t
index 298..4e05ca8 100644
--- a/t/node/route-delete.t
+++ b/t/node/route-delete.t
@@ -26,13 +26,36 @@ run_tests();
 
 __DATA__
 
-=== TEST 1: create 130 routes + delete them
+=== TEST 1: clear all routes
 --- config
 location /t {
 content_by_lua_block {
 local t = require("lib.test_admin").test
 
-for i = 1, 130 do
+for i = 1, 200 do
+t('/apisix/admin/routes/' .. i, ngx.HTTP_DELETE)
+end
+
+ngx.say("done")
+}
+}
+--- request
+GET /t
+--- response_body
+done
+--- no_error_log
+[error]
+--- timeout: 5
+
+
+
+=== TEST 2: create 106 routes + delete them
+--- config
+location /t {
+content_by_lua_block {
+local t = require("lib.test_admin").test
+
+for i = 1, 106 do
 local code, body = t('/apisix/admin/routes/' .. i,
 ngx.HTTP_PUT,
 [[{
@@ -47,7 +70,9 @@ __DATA__
 )
 end
 
-for i = 1, 130 do
+ngx.sleep(0.5)
+
+for i = 1, 106 do
 local code, body = t('/apisix/admin/routes/' .. i,
 ngx.HTTP_PUT,
 [[{
@@ -62,13 +87,17 @@ __DATA__
 )
 end
 
-for i = 1, 130 do
+ngx.sleep(0.5)
+
+for i = 1, 106 do
 local code, body = t('/apisix/admin/routes/' .. i,
 ngx.HTTP_DELETE
 )
 end
 
-for i = 1, 130 do
+ngx.sleep(0.5)
+
+for i = 1, 106 do
 local code, body = t('/apisix/admin/routes/' .. i,
 ngx.HTTP_PUT,
 [[{
@@ -83,7 +112,9 @@ __DATA__
 )
 end
 
-for i = 1, 130 do
+ngx.sleep(0.5)
+
+for i = 1, 106 do
 local code, body = t('/apisix/admin/routes/' .. i,
 ngx.HTTP_DELETE
 )
@@ -98,12 +129,13 @@ GET /t
 done
 --- no_error_log
 [error]
+--- wait: 1
 --- grep_error_log eval
-qr/\w+ (data by key: 126)/
+qr/\w+ (data by key: 103)/
 --- grep_error_log_out
-insert data by key: 126
-update data by key: 126
-delete data by key: 126
-insert data by key: 126
-delete data by key: 126
 timeout: 20
+insert data by key: 103
+update data by key: 103
+delete data by key: 103
+insert data by key: 103
+delete data by key: 103
+--- timeout: 30



[apisix] branch master updated (4f90039 -> 973c481)

2020-09-18 Thread membphis
This is an automated email from the ASF dual-hosted git repository.

membphis pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/apisix.git.


from 4f90039  bugfix: independently check the "disabled" field to avoid 
`schema` ve… (#2099)
 add 973c481  chore: get the complete error stack when sync etcd data, it 
is very useful when a (#2251)

No new revisions were added by this update.

Summary of changes:
 apisix/core/config_etcd.lua | 48 +++--
 1 file changed, 25 insertions(+), 23 deletions(-)



[apisix] branch master updated: bugfix: independently check the "disabled" field to avoid `schema` ve… (#2099)

2020-09-17 Thread membphis
This is an automated email from the ASF dual-hosted git repository.

membphis pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/apisix.git


The following commit(s) were added to refs/heads/master by this push:
 new 4f90039  bugfix: independently check the "disabled" field to avoid 
`schema` ve… (#2099)
4f90039 is described below

commit 4f900390f90b3bdf181f5eb298a94cee3b437b0d
Author: YuanSheng Wang 
AuthorDate: Thu Sep 17 22:31:02 2020 +0800

bugfix: independently check the "disabled" field to avoid `schema` ve… 
(#2099)

* bugfix: independently check the "disabled" field to avoid `schema` 
verification
  with other parameters.
---
 apisix/admin/plugins.lua  | 41 --
 apisix/plugin.lua |  8 
 apisix/schema_def.lua |  5 +
 t/admin/plugins.t | 14 +++--
 t/admin/routes.t  | 32 +-
 t/admin/schema.t  | 20 +++
 t/node/merge-route.t  |  4 
 t/plugin/example.t| 50 +++
 t/plugin/ip-restriction.t | 35 +
 9 files changed, 169 insertions(+), 40 deletions(-)

diff --git a/apisix/admin/plugins.lua b/apisix/admin/plugins.lua
index 7b835e1..88aa6f6 100644
--- a/apisix/admin/plugins.lua
+++ b/apisix/admin/plugins.lua
@@ -26,18 +26,7 @@ local table_sort = table.sort
 local table_insert = table.insert
 
 
-local _M = {
-version = 0.1,
-}
-
-
-local disable_schema = {
-type = "object",
-properties = {
-disable = {type = "boolean", enum={true}}
-},
-required = {"disable"}
-}
+local _M = {}
 
 
 function _M.check_schema(plugins_conf)
@@ -50,14 +39,16 @@ function _M.check_schema(plugins_conf)
 end
 
 if plugin_obj.check_schema then
-local ok = core.schema.check(disable_schema, plugin_conf)
+local disable = plugin_conf.disable
+plugin_conf.disable = nil
+
+local ok, err = plugin_obj.check_schema(plugin_conf)
 if not ok then
-local ok, err = plugin_obj.check_schema(plugin_conf)
-if not ok then
-return false, "failed to check the configuration of plugin 
"
-  .. name .. " err: " .. err
-end
+return false, "failed to check the configuration of plugin "
+  .. name .. " err: " .. err
 end
+
+plugin_conf.disable = disable
 end
 end
 
@@ -75,14 +66,16 @@ function _M.stream_check_schema(plugins_conf)
 end
 
 if plugin_obj.check_schema then
-local ok = core.schema.check(disable_schema, plugin_conf)
+local disable = plugin_conf.disable
+plugin_conf.disable = nil
+
+local ok, err = plugin_obj.check_schema(plugin_conf)
 if not ok then
-local ok, err = plugin_obj.check_schema(plugin_conf)
-if not ok then
-return false, "failed to check the configuration of "
-  .. "stream plugin [" .. name .. "]: " .. err
-end
+return false, "failed to check the configuration of "
+  .. "stream plugin [" .. name .. "]: " .. err
 end
+
+plugin_conf.disable = disable
 end
 end
 
diff --git a/apisix/plugin.lua b/apisix/plugin.lua
index bcd5e35..8c49883 100644
--- a/apisix/plugin.lua
+++ b/apisix/plugin.lua
@@ -78,6 +78,14 @@ local function load_plugin(name, plugins_list, 
is_stream_plugin)
 return
 end
 
+if plugin.schema and plugin.schema.type == "object" then
+if not plugin.schema.properties or
+   core.table.nkeys(plugin.schema.properties) == 0
+then
+plugin.schema.properties = core.schema.plugin_disable_schema
+end
+end
+
 plugin.name = name
 core.table.insert(plugins_list, plugin)
 
diff --git a/apisix/schema_def.lua b/apisix/schema_def.lua
index 52a7f42..e8d4249 100644
--- a/apisix/schema_def.lua
+++ b/apisix/schema_def.lua
@@ -606,6 +606,11 @@ _M.stream_route = {
 _M.id_schema = id_schema
 
 
+_M.plugin_disable_schema = {
+disable = {type = "boolean"}
+}
+
+
 setmetatable(_M, {
 __index = schema,
 __newindex = function() error("no modification allowed") end,
diff --git a/t/admin/plugins.t b/t/admin/plugins.t
index fa69ec6..6ca86af 100644
--- a/t/admin/plugins.t
+++ b/t/admin/plugins.t
@@ -61,6 +61,16 @@ GET /apisix/admin/plugins/limit-req
 --- request
 GET /apisix/admin/plugins/node-status
 --- response_body
-{"additionalProperties":false,"type":"ob

[apisix] branch master updated: chore: bump `lua-resty-etcd` to version 1.2 (#2242)

2020-09-16 Thread membphis
This is an automated email from the ASF dual-hosted git repository.

membphis pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/apisix.git


The following commit(s) were added to refs/heads/master by this push:
 new 9d1a210  chore: bump `lua-resty-etcd` to version 1.2  (#2242)
9d1a210 is described below

commit 9d1a210413944b8aef0492c67ddfd77cc57a5be2
Author: Shuyang Wu 
AuthorDate: Thu Sep 17 13:15:52 2020 +0800

chore: bump `lua-resty-etcd` to version 1.2  (#2242)

fix #2238
---
 rockspec/apisix-master-0.rockspec | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/rockspec/apisix-master-0.rockspec 
b/rockspec/apisix-master-0.rockspec
index 5a32099..b88a3c7 100644
--- a/rockspec/apisix-master-0.rockspec
+++ b/rockspec/apisix-master-0.rockspec
@@ -32,7 +32,7 @@ description = {
 
 dependencies = {
 "lua-resty-template = 1.9",
-"lua-resty-etcd = 1.1",
+"lua-resty-etcd = 1.2",
 "lua-resty-balancer = 0.02rc5",
 "lua-resty-ngxvar = 0.5",
 "lua-resty-jit-uuid = 0.0.7",



[apisix] branch master updated (84ce7ba -> d1fe72c)

2020-09-16 Thread membphis
This is an automated email from the ASF dual-hosted git repository.

membphis pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/apisix.git.


from 84ce7ba  feat: add AK/SK(HMAC) auth plugin. (#2192)
 add d1fe72c  bugfix: fixed wrong zipkin Arguments (#2193)

No new revisions were added by this update.

Summary of changes:
 apisix/plugins/zipkin.lua   | 22 --
 apisix/plugins/zipkin/codec.lua | 22 +-
 2 files changed, 21 insertions(+), 23 deletions(-)



[apisix] branch master updated (98da870 -> 4b756ec)

2020-09-14 Thread membphis
This is an automated email from the ASF dual-hosted git repository.

membphis pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/apisix.git.


from 98da870  doc: fixed typo in `health-check.md` (#2200)
 add 4b756ec  doc: fix formatting (#2210)

No new revisions were added by this update.

Summary of changes:
 doc/architecture-design.md   | 3 ++-
 doc/zh-cn/architecture-design.md | 4 ++--
 2 files changed, 4 insertions(+), 3 deletions(-)



[apisix] branch master updated (98da870 -> 4b756ec)

2020-09-14 Thread membphis
This is an automated email from the ASF dual-hosted git repository.

membphis pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/apisix.git.


from 98da870  doc: fixed typo in `health-check.md` (#2200)
 add 4b756ec  doc: fix formatting (#2210)

No new revisions were added by this update.

Summary of changes:
 doc/architecture-design.md   | 3 ++-
 doc/zh-cn/architecture-design.md | 4 ++--
 2 files changed, 4 insertions(+), 3 deletions(-)



[apisix] branch master updated: doc: fixed typo in `health-check.md` (#2200)

2020-09-10 Thread membphis
This is an automated email from the ASF dual-hosted git repository.

membphis pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/apisix.git


The following commit(s) were added to refs/heads/master by this push:
 new 98da870  doc: fixed typo in `health-check.md` (#2200)
98da870 is described below

commit 98da870976a4893a87b31300276c8c548dac14c0
Author: 琚致远 
AuthorDate: Thu Sep 10 19:15:45 2020 +0800

doc: fixed typo in `health-check.md` (#2200)
---
 doc/health-check.md | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/doc/health-check.md b/doc/health-check.md
index 3c34c16..748fbf4 100644
--- a/doc/health-check.md
+++ b/doc/health-check.md
@@ -22,7 +22,7 @@
 Health Check of APISIX is based on 
[lua-resty-healthcheck](https://github.com/Kong/lua-resty-healthcheck),
 you can use it for upstream.
 
-The following is a example of health check:
+The following is an example of health check:
 
 ```shell
 curl http://127.0.0.1:9080/apisix/admin/routes/1 -H 'X-API-KEY: 
edd1c9f034335f136f87ad84b625c8f1' -X PUT -d '



[apisix] branch juzhiyuan-patch-1 updated (4af66a2 -> 5c038e5)

2020-09-10 Thread membphis
This is an automated email from the ASF dual-hosted git repository.

membphis pushed a change to branch juzhiyuan-patch-1
in repository https://gitbox.apache.org/repos/asf/apisix.git.


from 4af66a2  Merge branch 'master' into juzhiyuan-patch-1
 add 087f87a  bugfix: grpc-transcode plugin converts http/json parameters 
abnormally (#2139)
 add 5c038e5  Merge branch 'master' into juzhiyuan-patch-1

No new revisions were added by this update.

Summary of changes:
 .travis/linux_openresty_runner.sh  |  2 +-
 .travis/linux_tengine_runner.sh|  2 +-
 .travis/osx_openresty_runner.sh|  2 +-
 apisix/plugins/grpc-transcode/util.lua | 45 ++--
 t/plugin/grpc-transcode.t  | 94 ++
 5 files changed, 126 insertions(+), 19 deletions(-)



[apisix] branch juzhiyuan-patch-1 updated (77a9fcc -> 4af66a2)

2020-09-10 Thread membphis
This is an automated email from the ASF dual-hosted git repository.

membphis pushed a change to branch juzhiyuan-patch-1
in repository https://gitbox.apache.org/repos/asf/apisix.git.


from 77a9fcc  Merge branch 'master' into juzhiyuan-patch-1
 add 37817e4  chore: add string utility for simplicity and correctness 
(#2181)
 add 4af66a2  Merge branch 'master' into juzhiyuan-patch-1

No new revisions were added by this update.

Summary of changes:
 apisix/admin/ssl.lua |   3 +-
 apisix/core.lua  |   1 +
 apisix/core/string.lua   |  68 
 apisix/http/router/radixtree_sni.lua |   2 +-
 t/core/string.t  | 145 +++
 5 files changed, 216 insertions(+), 3 deletions(-)
 create mode 100644 apisix/core/string.lua
 create mode 100644 t/core/string.t



[apisix] branch juzhiyuan-patch-1 updated (9e5b3b1 -> 77a9fcc)

2020-09-10 Thread membphis
This is an automated email from the ASF dual-hosted git repository.

membphis pushed a change to branch juzhiyuan-patch-1
in repository https://gitbox.apache.org/repos/asf/apisix.git.


from 9e5b3b1  Update health-check.md
 add 1556cd0  improve: cache parsed certs and pkeys to LRU cache (#2163)
 add 77a9fcc  Merge branch 'master' into juzhiyuan-patch-1

No new revisions were added by this update.

Summary of changes:
 apisix/http/router/radixtree_sni.lua | 60 ---
 t/router/radixtree-sni.t | 93 
 2 files changed, 136 insertions(+), 17 deletions(-)



[apisix] branch master updated: fix: log-rotate.t is unstable (#2164)

2020-09-05 Thread membphis
This is an automated email from the ASF dual-hosted git repository.

membphis pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/apisix.git


The following commit(s) were added to refs/heads/master by this push:
 new d421683  fix: log-rotate.t is unstable (#2164)
d421683 is described below

commit d4216831e3c65ac26f4a600fa6b216471ecda6d7
Author: gy 
AuthorDate: Sun Sep 6 12:10:42 2020 +0800

fix: log-rotate.t is unstable (#2164)

fix #2138
---
 t/plugin/log-rotate.t | 29 -
 1 file changed, 24 insertions(+), 5 deletions(-)

diff --git a/t/plugin/log-rotate.t b/t/plugin/log-rotate.t
index 9896865..3cf08cb 100644
--- a/t/plugin/log-rotate.t
+++ b/t/plugin/log-rotate.t
@@ -51,17 +51,36 @@ __DATA__
 content_by_lua_block {
 ngx.log(ngx.ERR, "start xx")
 ngx.sleep(2.5)
-
+local has_split_access_file = false
+local has_split_error_file = false
 local lfs = require("lfs")
-for file in lfs.dir(ngx.config.prefix() .. "/logs/") do
-ngx.say(file)
+for file_name in lfs.dir(ngx.config.prefix() .. "/logs/") do
+if string.match(file_name, "__access.log$") then
+has_split_access_file = true
+end
+
+if string.match(file_name, "__error.log$") then
+local f = assert(io.open(ngx.config.prefix() .. "/logs/" 
.. file_name, "r"))
+local content = f:read("*all")
+f:close()
+local index = string.find(content, "start xx")
+if index then
+has_split_error_file = true
+end
+end
 end
+
+if not has_split_error_file or not has_split_error_file then 
+   ngx.status = 500
+else
+   ngx.status = 200
+end
 }
 }
 --- request
 GET /t
 response_body_like eval
-qr/\_error\.log[\s\S]*\_access\.log/
+--- error_code eval
+[200]
 --- no_error_log
 [error]
 



[apisix] branch master updated: feat: support different modes to pass host to upstream (#2132)

2020-08-30 Thread membphis
This is an automated email from the ASF dual-hosted git repository.

membphis pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/apisix.git


The following commit(s) were added to refs/heads/master by this push:
 new 502310b  feat: support different modes to pass host to upstream (#2132)
502310b is described below

commit 502310bef6c6b77410e17bf3b805437fe4c705f9
Author: nic-chen <33000667+nic-c...@users.noreply.github.com>
AuthorDate: Sun Aug 30 22:43:28 2020 +0800

feat: support different modes to pass host to upstream (#2132)

* test: using `httpbin.org` for test cases.
* doc: add doc
* remove golang apt repository and runtime in travis.
* download proto file
Co-authored-by: Yuansheng 
---
 .travis/linux_apisix_current_luarocks_runner.sh |   1 -
 .travis/linux_apisix_master_luarocks_runner.sh  |   1 -
 .travis/linux_openresty_mtls_runner.sh  |   1 -
 .travis/linux_openresty_runner.sh   |   3 -
 .travis/linux_tengine_runner.sh |   3 -
 .travis/osx_openresty_runner.sh |   2 -
 apisix/admin/upstreams.lua  |  13 +++
 apisix/init.lua |  43 
 apisix/schema_def.lua   |   7 ++
 doc/admin-api.md|   3 +
 doc/architecture-design.md  |   2 +
 doc/zh-cn/admin-api.md  |   2 +
 doc/zh-cn/architecture-design.md|   2 +
 t/admin/routes.t|  33 ++
 t/admin/upstream.t  |  59 ++
 t/node/merge-route.t|   3 +-
 t/node/route-domain.t   |  90 +++
 t/node/upstream.t   | 141 
 18 files changed, 396 insertions(+), 13 deletions(-)

diff --git a/.travis/linux_apisix_current_luarocks_runner.sh 
b/.travis/linux_apisix_current_luarocks_runner.sh
index 0264fc5..5a48932 100755
--- a/.travis/linux_apisix_current_luarocks_runner.sh
+++ b/.travis/linux_apisix_current_luarocks_runner.sh
@@ -27,7 +27,6 @@ do_install() {
 sudo apt-get -y update --fix-missing
 sudo apt-get -y install software-properties-common
 sudo add-apt-repository -y "deb http://openresty.org/package/ubuntu 
$(lsb_release -sc) main"
-sudo add-apt-repository -y ppa:longsleep/golang-backports
 
 sudo apt-get update
 sudo apt-get install openresty-debug lua5.1 liblua5.1-0-dev
diff --git a/.travis/linux_apisix_master_luarocks_runner.sh 
b/.travis/linux_apisix_master_luarocks_runner.sh
index 6b63f3a..a7b684c 100755
--- a/.travis/linux_apisix_master_luarocks_runner.sh
+++ b/.travis/linux_apisix_master_luarocks_runner.sh
@@ -28,7 +28,6 @@ do_install() {
 sudo apt-get -y update --fix-missing
 sudo apt-get -y install software-properties-common
 sudo add-apt-repository -y "deb http://openresty.org/package/ubuntu 
$(lsb_release -sc) main"
-sudo add-apt-repository -y ppa:longsleep/golang-backports
 
 sudo apt-get update
 sudo apt-get install openresty-debug lua5.1 liblua5.1-0-dev
diff --git a/.travis/linux_openresty_mtls_runner.sh 
b/.travis/linux_openresty_mtls_runner.sh
index d0a7ceb..876c868 100755
--- a/.travis/linux_openresty_mtls_runner.sh
+++ b/.travis/linux_openresty_mtls_runner.sh
@@ -44,7 +44,6 @@ do_install() {
 sudo apt-get -y update --fix-missing
 sudo apt-get -y install software-properties-common
 sudo add-apt-repository -y "deb http://openresty.org/package/ubuntu 
$(lsb_release -sc) main"
-sudo add-apt-repository -y ppa:longsleep/golang-backports
 
 sudo apt-get update
 sudo apt-get install openresty-debug lua5.1 liblua5.1-0-dev
diff --git a/.travis/linux_openresty_runner.sh 
b/.travis/linux_openresty_runner.sh
index 6cc48b4..42ff254 100755
--- a/.travis/linux_openresty_runner.sh
+++ b/.travis/linux_openresty_runner.sh
@@ -59,7 +59,6 @@ do_install() {
 sudo apt-get -y update --fix-missing
 sudo apt-get -y install software-properties-common
 sudo add-apt-repository -y "deb http://openresty.org/package/ubuntu 
$(lsb_release -sc) main"
-sudo add-apt-repository -y ppa:longsleep/golang-backports
 
 sudo apt-get update
 sudo apt-get install openresty-debug lua5.1 liblua5.1-0-dev
@@ -75,8 +74,6 @@ do_install() {
 
 sudo luarocks install luacheck > build.log 2>&1 || (cat build.log && exit 
1)
 
-export GO111MOUDULE=on
-
 if [ ! -f "build-cache/apisix-master-0.rockspec" ]; then
 create_lua_deps
 
diff --git a/.travis/linux_tengine_runner.sh b/.travis/linux_tengine_runner.sh
index ec73c16..2404978 100755
--- a/.travis/linux_tengine_runner.sh
+++ b/.travis/linux_tengine_runner.sh
@@ -228,7 +228,6 @@ do_install() {
 
 sudo apt-get -y update --fix-missing
 sudo apt-get -y install software-properties-common
-sud

[apisix] branch master updated: chore: restrict the apisix/admin routers (#2130)

2020-08-30 Thread membphis
This is an automated email from the ASF dual-hosted git repository.

membphis pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/apisix.git


The following commit(s) were added to refs/heads/master by this push:
 new ff90202  chore: restrict the apisix/admin routers (#2130)
ff90202 is described below

commit ff902025668f77ded38a3c766b493ad21ae6298b
Author: 罗泽轩 
AuthorDate: Sun Aug 30 17:07:20 2020 +0800

chore: restrict the apisix/admin routers (#2130)

1. /stream_routes needs to be ended with '/'
2. /list only needs GET method
---
 apisix/admin/init.lua | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/apisix/admin/init.lua b/apisix/admin/init.lua
index 71cb25e..99a41c3 100644
--- a/apisix/admin/init.lua
+++ b/apisix/admin/init.lua
@@ -267,13 +267,13 @@ local uri_route = {
 handler = run,
 },
 {
-paths = [[/apisix/admin/stream_routes*]],
+paths = [[/apisix/admin/stream_routes/*]],
 methods = {"GET", "PUT", "POST", "DELETE", "PATCH"},
 handler = run_stream,
 },
 {
 paths = [[/apisix/admin/plugins/list]],
-methods = {"GET", "PUT", "POST", "DELETE"},
+methods = {"GET"},
 handler = get_plugins_list,
 },
 {



[apisix] branch master updated: feature: implement `ewma` balancer for upstream node (#2001)

2020-08-29 Thread membphis
This is an automated email from the ASF dual-hosted git repository.

membphis pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/apisix.git


The following commit(s) were added to refs/heads/master by this push:
 new 98bb593  feature: implement `ewma` balancer for upstream node (#2001)
98bb593 is described below

commit 98bb5933d64229ddf8e3dd0fdf1c31f90072c2cb
Author: redynasc 
AuthorDate: Sat Aug 29 23:14:16 2020 +0800

feature: implement `ewma` balancer for upstream node (#2001)

ewma is a different balancing implementation that will generate a weight 
for every backend IP based on the last server response time, basically it tries 
to dispatch more requests to the backends that reply faster, supposing that 
they are less loaded.

fix #1996
---
 LICENSE  |  11 +++
 apisix/balancer.lua  |   4 +-
 apisix/balancer/ewma.lua | 191 +
 apisix/init.lua  |   4 +
 apisix/schema_def.lua|   2 +-
 bin/apisix   |   3 +
 doc/admin-api.md |   2 +-
 t/APISIX.pm  |   3 +
 t/lib/server.lua |  10 +++
 t/node/ewma.t| 217 +++
 10 files changed, 443 insertions(+), 4 deletions(-)

diff --git a/LICENSE b/LICENSE
index 261eeb9..2351cfd 100644
--- a/LICENSE
+++ b/LICENSE
@@ -199,3 +199,14 @@
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
+
+===
+Apache ApiSix Subcomponents:
+
+The Apache ApiSix project contains subcomponents with separate copyright
+notices and license terms. Your use of the source code for the these
+subcomponents is subject to the terms and conditions of the following
+licenses.
+
+   ewma.lua file from kubernetes/ingress-nginx: 
https://github.com/kubernetes/ingress-nginx Apache 2.0
+
diff --git a/apisix/balancer.lua b/apisix/balancer.lua
index 36f4f32..cfe53b9 100644
--- a/apisix/balancer.lua
+++ b/apisix/balancer.lua
@@ -30,9 +30,9 @@ local module_name = "balancer"
 local pickers = {
 roundrobin = require("apisix.balancer.roundrobin"),
 chash = require("apisix.balancer.chash"),
+ewma = require("apisix.balancer.ewma")
 }
 
-
 local lrucache_server_picker = core.lrucache.new({
 ttl = 300, count = 256
 })
@@ -245,7 +245,7 @@ local function pick_server(route, ctx)
 core.log.error("failed to parse server addr: ", server, " err: ", err)
 return core.response.exit(502)
 end
-
+ctx.server_picker = server_picker
 return res
 end
 
diff --git a/apisix/balancer/ewma.lua b/apisix/balancer/ewma.lua
new file mode 100644
index 000..ba429d9
--- /dev/null
+++ b/apisix/balancer/ewma.lua
@@ -0,0 +1,191 @@
+--
+-- Licensed to the Apache Software Foundation (ASF) under one or more
+-- contributor license agreements.  See the NOTICE file distributed with
+-- this work for additional information regarding copyright ownership.
+-- The ASF licenses this file to You under the Apache License, Version 2.0
+-- (the "License"); you may not use this file except in compliance with
+-- the License.  You may obtain a copy of the License at
+--
+-- http://www.apache.org/licenses/LICENSE-2.0
+--
+-- Unless required by applicable law or agreed to in writing, software
+-- distributed under the License is distributed on an "AS IS" BASIS,
+-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+-- See the License for the specific language governing permissions and
+-- limitations under the License.
+--
+
+
+local core = require("apisix.core")
+local ngx = ngx
+local ngx_shared = ngx.shared
+local ngx_now = ngx.now
+local math = math
+local pairs = pairs
+local next = next
+local tonumber = tonumber
+
+local _M = {}
+local DECAY_TIME = 10 -- this value is in seconds
+
+local shm_ewma = ngx_shared.balancer_ewma
+local shm_last_touched_at= ngx_shared.balancer_ewma_last_touched_at
+
+local lrucache_addr = core.lrucache.new({
+ttl = 300, count = 1024
+})
+local lrucache_trans_format = core.lrucache.new({
+ttl = 300, count = 256
+})
+
+
+local function decay_ewma(ewma, last_touched_at, rtt, now)
+local td = now - last_touched_at
+td = math.max(td, 0)
+local weight = math.exp(-td / DECAY_TIME)
+
+ewma = ewma * weight + rtt * (1.0 - weight)
+return ewma
+end
+
+
+local function store_stats(upstream, ewma, now)
+local success, err, forcible = shm_last_touched_at:set(upstream, now)
+if not success then
+core.log.error("balancer_ewma_last_touched_at:set failed ", err)
+end
+if forcible then
+core.log.warn("balancer_ewma_last_touched_at:set valid items forcibly 
overwritten")
+end

[apisix] branch master updated: fix: wait time is too short it will easy fail in some bad hardware environment (#2127)

2020-08-27 Thread membphis
This is an automated email from the ASF dual-hosted git repository.

membphis pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/apisix.git


The following commit(s) were added to refs/heads/master by this push:
 new a3f865a  fix: wait time is too short it will easy fail in some bad 
hardware environment (#2127)
a3f865a is described below

commit a3f865aa4bb9aa8324ad5025c46360977aed8bec
Author: Vinci Xu <277040...@qq.com>
AuthorDate: Thu Aug 27 16:47:09 2020 +0800

fix: wait time is too short it will easy fail in some bad hardware 
environment (#2127)
---
 t/plugin/tcp-logger.t | 2 +-
 t/plugin/udp-logger.t | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/t/plugin/tcp-logger.t b/t/plugin/tcp-logger.t
index bb92476..7343f0d 100644
--- a/t/plugin/tcp-logger.t
+++ b/t/plugin/tcp-logger.t
@@ -161,7 +161,7 @@ GET /hello
 hello world
 --- no_error_log
 [error]
 wait: 0.2
+--- wait: 1
 
 
 
diff --git a/t/plugin/udp-logger.t b/t/plugin/udp-logger.t
index 3112680..2e1530e 100644
--- a/t/plugin/udp-logger.t
+++ b/t/plugin/udp-logger.t
@@ -160,7 +160,7 @@ GET /opentracing
 opentracing
 --- no_error_log
 [error]
 wait: 0.2
+--- wait: 1
 
 
 



[apisix] branch master updated: plugin(fault-injection): use draft7 way to rewrite the JSON Schema. (#2105)

2020-08-26 Thread membphis
This is an automated email from the ASF dual-hosted git repository.

membphis pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/apisix.git


The following commit(s) were added to refs/heads/master by this push:
 new 4d5ecc1  plugin(fault-injection): use draft7 way to rewrite the JSON 
Schema. (#2105)
4d5ecc1 is described below

commit 4d5ecc1a4001d3c511f0f540076561aa8cd53d03
Author: YuanSheng Wang 
AuthorDate: Thu Aug 27 11:47:04 2020 +0800

plugin(fault-injection): use draft7 way to rewrite the JSON Schema. (#2105)

fix #2088
---
 apisix/plugins/fault-injection.lua   | 7 +--
 doc/plugins/fault-injection.md   | 4 ++--
 doc/zh-cn/plugins/fault-injection.md | 8 
 3 files changed, 11 insertions(+), 8 deletions(-)

diff --git a/apisix/plugins/fault-injection.lua 
b/apisix/plugins/fault-injection.lua
index 3e72494..8484352 100644
--- a/apisix/plugins/fault-injection.lua
+++ b/apisix/plugins/fault-injection.lua
@@ -19,6 +19,7 @@ local sleep = ngx.sleep
 
 local plugin_name   = "fault-injection"
 
+
 local schema = {
 type = "object",
 properties = {
@@ -28,19 +29,20 @@ local schema = {
 http_status = {type = "integer", minimum = 200},
 body = {type = "string", minLength = 0},
 },
-required = {"http_status"}
+minProperties = 1,
 },
 delay = {
 type = "object",
 properties = {
 duration = {type = "number", minimum = 0},
 },
-required = {"duration"}
+minProperties = 1,
 }
 },
 minProperties = 1,
 }
 
+
 local _M = {
 version = 0.1,
 priority = 11000,
@@ -48,6 +50,7 @@ local _M = {
 schema = schema,
 }
 
+
 function _M.check_schema(conf)
 local ok, err = core.schema.check(schema, conf)
 if not ok then
diff --git a/doc/plugins/fault-injection.md b/doc/plugins/fault-injection.md
index 30ab7db..f2e9681 100644
--- a/doc/plugins/fault-injection.md
+++ b/doc/plugins/fault-injection.md
@@ -27,9 +27,9 @@ Fault injection plugin, this plugin can be used with other 
plugins and will be e
 
 |Name  |Requirement  |Description|
 |--- |-|--|
-|abort.http_status|required|user-specified http code returned to the client|
+|abort.http_status|optional|user-specified http code returned to the client|
 |abort.body|optional|response data returned to the client|
-|delay.duration|required|delay time(can be decimal)|
+|delay.duration|optional|delay time(can be decimal)|
 
 Note: `abort` and `delay` must have at least one.
 
diff --git a/doc/zh-cn/plugins/fault-injection.md 
b/doc/zh-cn/plugins/fault-injection.md
index e5d8b3b..9274173 100644
--- a/doc/zh-cn/plugins/fault-injection.md
+++ b/doc/zh-cn/plugins/fault-injection.md
@@ -27,11 +27,11 @@
 
 |名称|必须|描述|
 |--- |-|--|
-|abort.http_status|是|返回给客户端的 http 状态码|
-|abort.body|否|返回给客户端的响应数据|
-|delay.duration|是|延迟时间,可以指定小数|
+|abort.http_status|可选|返回给客户端的 http 状态码|
+|abort.body|可选|返回给客户端的响应数据|
+|delay.duration|可选|延迟时间,可以指定小数|
 
-注:参数 abort 和 delay 至少要存在一个
+注:参数 abort 和 delay 至少要存在一个。
 
 ## 示例
 



[apisix] branch master updated (c54aec8 -> fad7894)

2020-08-26 Thread membphis
This is an automated email from the ASF dual-hosted git repository.

membphis pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/apisix.git.


from c54aec8  feat: support custom access log format (#2122)
 add fad7894  doc: add more companies to power-by page  (#2109)

No new revisions were added by this update.

Summary of changes:
 doc/powered-by.md | 15 +++
 1 file changed, 11 insertions(+), 4 deletions(-)



[apisix] branch master updated (9070a4f -> c54aec8)

2020-08-26 Thread membphis
This is an automated email from the ASF dual-hosted git repository.

membphis pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/apisix.git.


from 9070a4f  feature: implemented plugin `log-rotate`, rotate log by 
interval time. (#2097)
 add c54aec8  feat: support custom access log format (#2122)

No new revisions were added by this update.

Summary of changes:
 .travis/apisix_cli_test.sh | 23 +++
 bin/apisix |  2 +-
 conf/config-default.yaml   |  1 +
 3 files changed, 25 insertions(+), 1 deletion(-)



[apisix] branch master updated (cd6d355 -> 0bb8f46)

2020-08-26 Thread membphis
This is an automated email from the ASF dual-hosted git repository.

membphis pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/apisix.git.


from cd6d355  doc: fix doc use 4 spaces instead of  key (#2108)
 add 0bb8f46  change: allow users to see warnings by default (#2116)

No new revisions were added by this update.

Summary of changes:
 .travis/apisix_cli_test.sh | 11 ++-
 bin/apisix |  2 +-
 2 files changed, 11 insertions(+), 2 deletions(-)



[apisix] branch master updated (8fdb0c2 -> cd6d355)

2020-08-25 Thread membphis
This is an automated email from the ASF dual-hosted git repository.

membphis pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/apisix.git.


from 8fdb0c2  doc: updated the architecture diagram to remove RDS. (#2117)
 add cd6d355  doc: fix doc use 4 spaces instead of  key (#2108)

No new revisions were added by this update.

Summary of changes:
 doc/plugins/authz-keycloak.md   | 20 ++--
 doc/plugins/request-id.md   | 16 
 doc/plugins/request-validation.md   | 16 
 doc/zh-cn/plugins/authz-keycloak.md | 20 ++--
 doc/zh-cn/plugins/request-id.md | 16 
 doc/zh-cn/plugins/request-validation.md | 16 
 6 files changed, 52 insertions(+), 52 deletions(-)



[apisix] branch master updated (8fdb0c2 -> cd6d355)

2020-08-25 Thread membphis
This is an automated email from the ASF dual-hosted git repository.

membphis pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/apisix.git.


from 8fdb0c2  doc: updated the architecture diagram to remove RDS. (#2117)
 add cd6d355  doc: fix doc use 4 spaces instead of  key (#2108)

No new revisions were added by this update.

Summary of changes:
 doc/plugins/authz-keycloak.md   | 20 ++--
 doc/plugins/request-id.md   | 16 
 doc/plugins/request-validation.md   | 16 
 doc/zh-cn/plugins/authz-keycloak.md | 20 ++--
 doc/zh-cn/plugins/request-id.md | 16 
 doc/zh-cn/plugins/request-validation.md | 16 
 6 files changed, 52 insertions(+), 52 deletions(-)



[apisix] branch master updated: doc: fixed broken link of CONTRIBUTING.md in README (#2104)

2020-08-23 Thread membphis
This is an automated email from the ASF dual-hosted git repository.

membphis pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/apisix.git


The following commit(s) were added to refs/heads/master by this push:
 new 2c98dd7  doc: fixed broken link of CONTRIBUTING.md in README (#2104)
2c98dd7 is described below

commit 2c98dd757edb7187034c5da36b2d8559e5c1727b
Author: Shuyang Wu 
AuthorDate: Sun Aug 23 19:17:12 2020 +0800

doc: fixed broken link of CONTRIBUTING.md in README (#2104)
---
 README.md | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/README.md b/README.md
index 5d9426f..81e4633 100644
--- a/README.md
+++ b/README.md
@@ -293,7 +293,7 @@ CNCF API Gateway Landscape.
 
 ## Contributing
 
-See [CONTRIBUTING](Contributing.md) for details on submitting patches and the 
contribution workflow.
+See [CONTRIBUTING](CONTRIBUTING.md) for details on submitting patches and the 
contribution workflow.
 
 ## Acknowledgments
 



[apisix] branch etcd-v2 created (now 6ffd8b9)

2020-08-23 Thread membphis
This is an automated email from the ASF dual-hosted git repository.

membphis pushed a change to branch etcd-v2
in repository https://gitbox.apache.org/repos/asf/apisix.git.


  at 6ffd8b9  doc: Chinese version of plugins request-id (#2103)

No new revisions were added by this update.



[apisix] branch master updated: doc: Chinese version of plugins request-id (#2103)

2020-08-22 Thread membphis
This is an automated email from the ASF dual-hosted git repository.

membphis pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/apisix.git


The following commit(s) were added to refs/heads/master by this push:
 new 6ffd8b9  doc: Chinese version of plugins request-id (#2103)
6ffd8b9 is described below

commit 6ffd8b9956e4e923fac5f6b6cbfdecd22a18e3b8
Author: Shuyang Wu 
AuthorDate: Sun Aug 23 11:17:18 2020 +0800

doc: Chinese version of plugins request-id (#2103)

fix #2027
---
 doc/plugins/request-id.md   |  4 +--
 doc/{ => zh-cn}/plugins/request-id.md   | 43 -
 doc/zh-cn/plugins/request-validation.md |  4 +--
 3 files changed, 25 insertions(+), 26 deletions(-)

diff --git a/doc/plugins/request-id.md b/doc/plugins/request-id.md
index 0857e0e..ad852a0 100644
--- a/doc/plugins/request-id.md
+++ b/doc/plugins/request-id.md
@@ -17,7 +17,7 @@
 #
 -->
 
-[Chinese](../zh-cn/plugins/request-validation.md)
+[Chinese](../zh-cn/plugins/request-id.md)
 
 # Summary
 - [**Name**](#name)
@@ -71,7 +71,7 @@ HTTP/1.1 200 OK
 
 ## Disable Plugin
 
-Remove the corresponding json configuration in the plugin configuration to 
disable the `request-validation`.
+Remove the corresponding json configuration in the plugin configuration to 
disable the `request-id`.
 APISIX plugins are hot-reloaded, therefore no need to restart APISIX.
 
 ```shell
diff --git a/doc/plugins/request-id.md b/doc/zh-cn/plugins/request-id.md
similarity index 57%
copy from doc/plugins/request-id.md
copy to doc/zh-cn/plugins/request-id.md
index 0857e0e..17fdcac 100644
--- a/doc/plugins/request-id.md
+++ b/doc/zh-cn/plugins/request-id.md
@@ -17,32 +17,32 @@
 #
 -->
 
-[Chinese](../zh-cn/plugins/request-validation.md)
+[English](../plugins/request-id.md)
 
-# Summary
-- [**Name**](#name)
-- [**Attributes**](#attributes)
-- [**How To Enable**](#how-to-enable)
-- [**Test Plugin**](#test-plugin)
-- [**Disable Plugin**](#disable-plugin)
-- [**Examples**](#examples)
+# 目录
 
+- [**名称**](#名称)
+- [**属性**](#属性)
+- [**如何启用**](#如何启用)
+- [**测试插件**](#测试插件)
+- [**禁用插件**](#禁用插件)
+- [**示例**](#示例)
 
-## Name
 
-`request-id` plugin adds a unique ID (UUID) to each request proxied through 
APISIX. This plugin can be used to track an
-API request. The plugin will not add a request id if the `header_name` is 
already present in the request.
+## 名称
 
-## Attributes
+`request-id` 插件通过 APISIX 为每一个请求代理添加唯一 ID(UUID),以用于追踪 API 请求。该插件在 `header_name` 
已经在请求中存在时不会为请求添加新的 ID
 
-|Name   |Requirement|Description|
-|-  |   |---|
-| header_name   |optional   |Request ID header name (default: 
X-Request-Id)|
-| include_in_response   |optional   |Option to include the unique request 
ID in the response header (default: true)|
+## 属性
 
-## How To Enable
+| 名称| 必选项 | 描述|
+| --- | -- | --- |
+| header_name | 可选   | Request ID header name (默认: X-Request-Id) |
+| include_in_response | 可选   | 是否需要在返回头中包含该唯一ID (默认: true) |
 
-Create a route and enable the request-id plugin on the route:
+## 如何启用
+
+创建一条路由并在该路由上启用 `request-id` 插件:
 
 ```shell
 curl http://127.0.0.1:9080/apisix/admin/routes/5 -H 'X-API-KEY: 
edd1c9f034335f136f87ad84b625c8f1' -X PUT -d '
@@ -62,17 +62,16 @@ curl http://127.0.0.1:9080/apisix/admin/routes/5 -H 
'X-API-KEY: edd1c9f034335f13
 }
 ```
 
-## Test Plugin
+## 测试插件
 
 ```shell
 $ curl -i http://127.0.0.1:9080/hello
 HTTP/1.1 200 OK
 ```
 
-## Disable Plugin
+## 禁用插件
 
-Remove the corresponding json configuration in the plugin configuration to 
disable the `request-validation`.
-APISIX plugins are hot-reloaded, therefore no need to restart APISIX.
+在路由 `plugins` 配置块中删除 `request-id 配置,即可禁用该插件,无需重启 APISIX。
 
 ```shell
 curl http://127.0.0.1:9080/apisix/admin/routes/5 -H 'X-API-KEY: 
edd1c9f034335f136f87ad84b625c8f1' -X PUT -d '
diff --git a/doc/zh-cn/plugins/request-validation.md 
b/doc/zh-cn/plugins/request-validation.md
index 6142ef1..1c94d02 100644
--- a/doc/zh-cn/plugins/request-validation.md
+++ b/doc/zh-cn/plugins/request-validation.md
@@ -20,14 +20,14 @@
 - [English](../../plugins/request-validation.md)
 
 # 目录
-- [**名字**](#名字)
+- [**名称**](#名称)
 - [**属性**](#属性)
 - [**如何启用**](#如何启用)
 - [**测试插件**](#测试插件)
 - [**禁用插件**](#禁用插件)
 - [**示例**](#示例)
 
-## 名字
+## 名称
 
 `request-validation` 插件用于提前验证请求向上游转发请求,可以验证请求的 `body` 及 `header` 数据。
 



[apisix] branch master updated: change: use draft7 style of JSON Schema. (#2100)

2020-08-22 Thread membphis
This is an automated email from the ASF dual-hosted git repository.

membphis pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/apisix.git


The following commit(s) were added to refs/heads/master by this push:
 new d974c18  change: use draft7 style of JSON Schema. (#2100)
d974c18 is described below

commit d974c1871a981150d5f48ed370ee5307a82c6e0f
Author: YuanSheng Wang 
AuthorDate: Sat Aug 22 21:43:21 2020 +0800

change: use draft7 style of JSON Schema. (#2100)

fix #2083.
---
 apisix/plugins/basic-auth.lua | 20 ++--
 t/plugin/basic-auth.t |  2 +-
 2 files changed, 15 insertions(+), 7 deletions(-)

diff --git a/apisix/plugins/basic-auth.lua b/apisix/plugins/basic-auth.lua
index 70325c0..352f11d 100644
--- a/apisix/plugins/basic-auth.lua
+++ b/apisix/plugins/basic-auth.lua
@@ -26,13 +26,21 @@ local lrucache = core.lrucache.new({
 
 local schema = {
 type = "object",
-properties = {
-username = { type = "string" },
-password = { type = "string" },
-},
 oneOf = {
-{required = {"username", "password"}},
-{required = {}}
+{
+title = "work with route or service object",
+properties = {
+username = { type = "string" },
+password = { type = "string" },
+},
+required = {"username", "password"},
+additionalProperties = false,
+},
+{
+title = "work with consumer object",
+properties = {},
+additionalProperties = false,
+}
 }
 }
 
diff --git a/t/plugin/basic-auth.t b/t/plugin/basic-auth.t
index 464bb02..85a67ba 100644
--- a/t/plugin/basic-auth.t
+++ b/t/plugin/basic-auth.t
@@ -62,7 +62,7 @@ done
 --- request
 GET /t
 --- response_body
-property "username" validation failed: wrong type: expected string, got number
+value should match only one schema, but matches none
 done
 --- no_error_log
 [error]



[apisix] branch master updated: chore: should improve the prometheus metric naming (#2073)

2020-08-18 Thread membphis
This is an automated email from the ASF dual-hosted git repository.

membphis pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/apisix.git


The following commit(s) were added to refs/heads/master by this push:
 new 36bb0a8  chore: should improve the prometheus metric naming (#2073)
36bb0a8 is described below

commit 36bb0a8d3ebe12d9425e33e273371770450d3e60
Author: 罗泽轩 
AuthorDate: Tue Aug 18 20:42:05 2020 +0800

chore: should improve the prometheus metric naming (#2073)

By looking at name like `apisix_bandwidth` or `apisix_http_latency`,
it is hard to guess their units. Also, it is not so clear for where does
the overhead come from for `apisix_http_overhead` at the first glance.
---
 apisix/plugins/prometheus/exporter.lua | 13 +++--
 1 file changed, 11 insertions(+), 2 deletions(-)

diff --git a/apisix/plugins/prometheus/exporter.lua 
b/apisix/plugins/prometheus/exporter.lua
index 82ccf45..6547456 100644
--- a/apisix/plugins/prometheus/exporter.lua
+++ b/apisix/plugins/prometheus/exporter.lua
@@ -69,6 +69,14 @@ function _M.init()
 
 clear_tab(metrics)
 
+-- Newly added metrics should follow the naming best pratices described in
+-- https://prometheus.io/docs/practices/naming/#metric-names
+-- For example,
+-- 1. Add unit as the suffix
+-- 2. Add `_total` as the suffix if the metric type is counter
+-- 3. Use base unit
+-- We keep the old metric names for the compatibility.
+
 -- across all services
 prometheus = base_prometheus.init("prometheus-metrics", "apisix_")
 metrics.connections = prometheus:gauge("nginx_http_current_connections",
@@ -93,11 +101,12 @@ function _M.init()
 {"code", "route", "service", "node"})
 
 metrics.latency = prometheus:histogram("http_latency",
-"HTTP request latency per service in APISIX",
+"HTTP request latency in milliseconds per service in APISIX",
 {"type", "service", "node"}, DEFAULT_BUCKETS)
 
 metrics.overhead = prometheus:histogram("http_overhead",
-"HTTP request overhead per service in APISIX",
+"HTTP request overhead added by APISIX in milliseconds per service " ..
+"in APISIX",
 {"type", "service", "node"}, DEFAULT_BUCKETS)
 
 metrics.bandwidth = prometheus:counter("bandwidth",



[apisix] branch master updated: feature: divide config.yaml into two files config-custom.yaml & confi… (#2023)

2020-08-18 Thread membphis
This is an automated email from the ASF dual-hosted git repository.

membphis pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/apisix.git


The following commit(s) were added to refs/heads/master by this push:
 new cf882bd  feature: divide config.yaml into two files config-custom.yaml 
& confi… (#2023)
cf882bd is described below

commit cf882bda1e36abf00f57cbaeb9a77ddaa7edf8a7
Author: YuanSheng Wang 
AuthorDate: Tue Aug 18 20:18:55 2020 +0800

feature: divide config.yaml into two files config-custom.yaml & confi… 
(#2023)

* feature: divide config.yaml into two files config-custom.yaml & 
config-default.yaml .

fix #1923
---
 .travis/apisix_cli_test.sh |  46 +--
 .travis/linux_apisix_master_luarocks_runner.sh |   6 +-
 .travis/linux_openresty_mtls_runner.sh |  17 ++-
 Makefile   |   1 +
 apisix/core.lua|   5 +-
 apisix/core/config_local.lua   | 108 ++-
 bin/apisix |  68 +-
 conf/{config.yaml => config-default.yaml}  |   5 +
 conf/config.yaml   | 175 +
 doc/architecture-design.md |  26 ++--
 doc/plugin-develop.md  |   4 +-
 doc/zh-cn/architecture-design.md   |  25 ++--
 doc/zh-cn/plugin-develop.md|   4 +-
 t/APISIX.pm|  27 ++--
 t/admin/stream-routes-disable.t|  23 +---
 t/admin/token.t|  20 +--
 t/config-center-yaml/route-service.t   |  19 +--
 t/config-center-yaml/route-upstream.t  |  19 +--
 t/config-center-yaml/route.t   |  19 +--
 t/core/config-default.t|  93 +
 t/core/config.t|   7 +-
 t/core/profile.t   |  14 +-
 t/debug/debug-mode.t   |  17 +--
 t/discovery/eureka.t   |  43 +++---
 t/node/rr-balance.t|   9 --
 t/node/upstream-node-dns.t |  23 +---
 t/plugin/example.t |   3 +-
 t/router/radixtree-host-uri.t  |  20 +--
 t/router/radixtree-host-uri2.t |  24 ++--
 t/router/radixtree-uri-host.t  |  24 
 t/router/radixtree-uri-keep-end-slash.t|  20 +--
 t/router/radixtree-uri-multiple.t  |  22 
 t/router/radixtree-uri-priority.t  |  19 ---
 t/router/radixtree-uri-sanity.t|  28 
 34 files changed, 460 insertions(+), 523 deletions(-)

diff --git a/.travis/apisix_cli_test.sh b/.travis/apisix_cli_test.sh
index 020a90a..bfa3ce3 100755
--- a/.travis/apisix_cli_test.sh
+++ b/.travis/apisix_cli_test.sh
@@ -47,7 +47,11 @@ fi
 echo "passed: nginx.conf file contains reuseport configuration"
 
 # check default ssl port
-sed  -i 's/listen_port: 9443/listen_port: 8443/g'  conf/config.yaml
+echo "
+apisix:
+ssl:
+listen_port: 8443
+" > conf/config.yaml
 
 make init
 
@@ -66,8 +70,7 @@ fi
 echo "passed: change default ssl port"
 
 # check nameserver imported
-
-sed -i '/dns_resolver:/,+4s/^/#/'  conf/config.yaml
+git checkout conf/config.yaml
 
 make init
 
@@ -82,11 +85,15 @@ do
   fi
 done
 
-sed -i '/dns_resolver:/,+4s/^#//'  conf/config.yaml
 echo "passed: system nameserver imported"
 
 # enable enable_dev_mode
-sed  -i 's/enable_dev_mode: false/enable_dev_mode: true/g'  conf/config.yaml
+git checkout conf/config.yaml
+
+echo "
+apisix:
+enable_dev_mode: true
+" > conf/config.yaml
 
 make init
 
@@ -102,9 +109,11 @@ if [ $count -ne 0 ]; then
 exit 1
 fi
 
-git checkout conf/config.yaml
+echo "passed: enable enable_dev_mode"
+
+# check whether the 'worker_cpu_affinity' is in nginx.conf
 
-# check whether the 'worker_cpu_affinity' is in nginx.conf .
+git checkout conf/config.yaml
 
 make init
 
@@ -118,8 +127,13 @@ echo "passed: nginx.conf file contains worker_cpu_affinity 
configuration"
 
 # check admin https enabled
 
-sed  -i 's/\# port_admin: 9180/port_admin: 9180/'  conf/config.yaml
-sed  -i 's/\# https_admin: true/https_admin: true/'  conf/config.yaml
+git checkout conf/config.yaml
+
+echo "
+apisix:
+port_admin: 9180
+https_admin: true
+" > conf/config.yaml
 
 make init
 
@@ -137,14 +151,13 @@ if [ ! $code -eq 200 ]; then
 exit 1
 fi
 
+make stop
+
 echo "passed: admin https enabled"
 
 # rollback to the default
 
-make stop
-
-sed  -i 's/port_admin: 9180/\# port_admin: 9180/'  conf/config.yaml
-sed  -i 's/https_admin: true/\# https_admin: true/'  conf/config.yaml
+git checkout conf/config.yaml
 
 make init
 
@@ -174,7 +187,12 @@ echo "passed: worker_shutdo

[apisix] branch master updated: update radixtree to version 2.2 . (#2061)

2020-08-16 Thread membphis
This is an automated email from the ASF dual-hosted git repository.

membphis pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/apisix.git


The following commit(s) were added to refs/heads/master by this push:
 new c2a7359  update radixtree to version 2.2 . (#2061)
c2a7359 is described below

commit c2a7359b2773a946b80e66c48c6d24697273e6f5
Author: YuanSheng Wang 
AuthorDate: Sun Aug 16 16:32:29 2020 +0800

update radixtree to version 2.2 . (#2061)

fix #2058

* fixed test
---
 rockspec/apisix-master-0.rockspec |  2 +-
 t/node/route-parameter-uri.t  | 70 +++
 2 files changed, 71 insertions(+), 1 deletion(-)

diff --git a/rockspec/apisix-master-0.rockspec 
b/rockspec/apisix-master-0.rockspec
index 5f49530..3028097 100644
--- a/rockspec/apisix-master-0.rockspec
+++ b/rockspec/apisix-master-0.rockspec
@@ -41,7 +41,7 @@ dependencies = {
 "lua-resty-cookie = 0.1.0",
 "lua-resty-session = 2.24",
 "opentracing-openresty = 0.1",
-"lua-resty-radixtree = 2.1",
+"lua-resty-radixtree = 2.2",
 "lua-protobuf = 0.3.1",
 "lua-resty-openidc = 1.7.2-1",
 "luafilesystem = 1.7.0-2",
diff --git a/t/node/route-parameter-uri.t b/t/node/route-parameter-uri.t
index 1e1b460..8499c0c 100644
--- a/t/node/route-parameter-uri.t
+++ b/t/node/route-parameter-uri.t
@@ -126,3 +126,73 @@ GET /name/json/bar
 qr/404 Not Found/
 --- no_error_log
 [error]
+
+
+
+=== TEST 7: set route,uri=/:name/foo
+--- config
+location /t {
+content_by_lua_block {
+local t = require("lib.test_admin").test
+local code, body = t('/apisix/admin/routes/1',
+ngx.HTTP_PUT,
+[[{
+"upstream": {
+"nodes": {
+"127.0.0.1:1980": 1
+},
+"type": "roundrobin"
+},
+"uri": "/:name/foo"
+}]],
+[[{
+"node": {
+"value": {
+"uri": "/:name/foo",
+"upstream": {
+"nodes": {
+"127.0.0.1:1980": 1
+},
+"type": "roundrobin"
+}
+},
+"key": "/apisix/routes/1"
+},
+"action": "set"
+}]]
+)
+
+if code >= 300 then
+ngx.status = code
+end
+ngx.say(body)
+}
+}
+--- request
+GET /t
+--- response_body
+passed
+--- no_error_log
+[error]
+
+
+
+=== TEST 8: /json/foo
+--- request
+GET /json/foo
+--- error_code: 404
+--- response_body eval
+qr/404 Not Found/
+--- no_error_log
+[error]
+
+
+
+=== TEST 9: /json/bbb/foo
+--- request
+GET /json/bbb/foo
+--- error_code: 404
+--- response_body
+{"error_msg":"failed to match any routes"}
+--- no_error_log
+[error]



[apisix] branch master updated: feat(prometheus): add prometheus metrics `node_info`(hostname) (#2063)

2020-08-15 Thread membphis
This is an automated email from the ASF dual-hosted git repository.

membphis pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/apisix.git


The following commit(s) were added to refs/heads/master by this push:
 new 7525f1f  feat(prometheus): add prometheus metrics 
`node_info`(hostname)  (#2063)
7525f1f is described below

commit 7525f1fcc93de1d9dd4767124359198eb053177a
Author: nic-chen <33000667+nic-c...@users.noreply.github.com>
AuthorDate: Sun Aug 16 09:59:55 2020 +0800

feat(prometheus): add prometheus metrics `node_info`(hostname)  (#2063)

* using a new metric `node_info` to store the hostname
---
 apisix/plugins/prometheus/exporter.lua | 10 ++
 t/plugin/prometheus.t  | 10 ++
 2 files changed, 20 insertions(+)

diff --git a/apisix/plugins/prometheus/exporter.lua 
b/apisix/plugins/prometheus/exporter.lua
index 8e6d74d..82ccf45 100644
--- a/apisix/plugins/prometheus/exporter.lua
+++ b/apisix/plugins/prometheus/exporter.lua
@@ -78,6 +78,11 @@ function _M.init()
 metrics.etcd_reachable = prometheus:gauge("etcd_reachable",
 "Config server etcd reachable from APISIX, 0 is unreachable")
 
+
+metrics.node_info = prometheus:gauge("node_info",
+"Info of APISIX node",
+{"hostname"})
+
 metrics.etcd_modify_indexes = prometheus:gauge("etcd_modify_indexes",
 "Etcd modify index for APISIX keys",
 {"key"})
@@ -98,6 +103,7 @@ function _M.init()
 metrics.bandwidth = prometheus:counter("bandwidth",
 "Total bandwidth in bytes consumed per service in APISIX",
 {"type", "route", "service", "node"})
+
 end
 
 
@@ -265,6 +271,8 @@ function _M.collect()
 etcd_modify_index()
 
 -- config server status
+local vars = ngx.var or {}
+local hostname = vars.hostname or ""
 local config = core.config.new()
 local version, err = config:server_version()
 if version then
@@ -276,6 +284,8 @@ function _M.collect()
"processing metrics endpoint: ", err)
 end
 
+metrics.node_info:set(1, gen_arr(hostname))
+
 local res, _ = config:getkey("/routes")
 if res and res.headers then
 clear_tab(key_values)
diff --git a/t/plugin/prometheus.t b/t/plugin/prometheus.t
index 3a7d5c7..9a43def 100644
--- a/t/plugin/prometheus.t
+++ b/t/plugin/prometheus.t
@@ -773,3 +773,13 @@ GET /apisix/prometheus/metrics
 qr/apisix_etcd_modify_indexes\{key="x_etcd_index"\} \d+/
 --- no_error_log
 [error]
+
+
+
+=== TEST 43: fetch the prometheus metric data -- hostname
+--- request
+GET /apisix/prometheus/metrics
+--- response_body eval
+qr/apisix_node_info\{hostname=".*"\} 1/
+--- no_error_log
+[error]



[apisix] branch master updated: bugfix: avoid setting Server header twice (#2065)

2020-08-15 Thread membphis
This is an automated email from the ASF dual-hosted git repository.

membphis pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/apisix.git


The following commit(s) were added to refs/heads/master by this push:
 new 0b00e82  bugfix: avoid setting Server header twice (#2065)
0b00e82 is described below

commit 0b00e82773bd71f988d5306ee886d9d1b795708f
Author: 罗泽轩 
AuthorDate: Sat Aug 15 17:19:35 2020 +0800

bugfix: avoid setting Server header twice (#2065)

Fix #2064.
---
 .travis/apisix_cli_test.sh | 10 ++
 bin/apisix |  1 -
 2 files changed, 10 insertions(+), 1 deletion(-)

diff --git a/.travis/apisix_cli_test.sh b/.travis/apisix_cli_test.sh
index d27df6b..020a90a 100755
--- a/.travis/apisix_cli_test.sh
+++ b/.travis/apisix_cli_test.sh
@@ -25,6 +25,16 @@ set -ex
 
 git checkout conf/config.yaml
 
+# check 'Server: APISIX' is not in nginx.conf. We already added it in Lua code.
+make init
+
+if grep "Server: APISIX" conf/nginx.conf > /dev/null; then
+echo "failed: 'Server: APISIX' should not be added twice"
+exit 1
+fi
+
+echo "passed: 'Server: APISIX' not in nginx.conf"
+
 # check whether the 'reuseport' is in nginx.conf .
 make init
 
diff --git a/bin/apisix b/bin/apisix
index bc1e4e1..625f584 100755
--- a/bin/apisix
+++ b/bin/apisix
@@ -238,7 +238,6 @@ http {
 send_timeout {* http.send_timeout *};
 
 server_tokens off;
-more_set_headers 'Server: APISIX web server';
 
 include mime.types;
 charset utf-8;



[apisix] branch master updated: feature: add apisix-version info to headers in APISIX core (#1961)

2020-08-14 Thread membphis
This is an automated email from the ASF dual-hosted git repository.

membphis pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/apisix.git


The following commit(s) were added to refs/heads/master by this push:
 new 6e0da45  feature: add apisix-version info to headers in APISIX core 
(#1961)
6e0da45 is described below

commit 6e0da454d1b5291e6ee22b9b05b254de056b63c5
Author: Swayam Raina 
AuthorDate: Sat Aug 15 04:54:33 2020 +0530

feature: add apisix-version info to headers in APISIX core (#1961)

related #1877
---
 apisix/init.lua| 5 -
 t/node/remote-addr-ipv6.t  | 1 +
 t/plugin/redirect.t| 1 +
 t/router/multi-ssl-certs.t | 1 +
 t/router/radixtree-sni.t   | 3 +++
 5 files changed, 10 insertions(+), 1 deletion(-)

diff --git a/apisix/init.lua b/apisix/init.lua
index 4ec618f..a285cc6 100644
--- a/apisix/init.lua
+++ b/apisix/init.lua
@@ -23,7 +23,7 @@ local service_fetch = require("apisix.http.service").get
 local admin_init= require("apisix.admin.init")
 local get_var   = require("resty.ngxvar").fetch
 local router= require("apisix.router")
-local set_upstream = require("apisix.upstream").set_by_route
+local set_upstream  = require("apisix.upstream").set_by_route
 local ipmatcher = require("resty.ipmatcher")
 local ngx   = ngx
 local get_method= ngx.req.get_method
@@ -40,6 +40,7 @@ local load_balancer
 local local_conf
 local dns_resolver
 local lru_resolved_domain
+local ver_header= "APISIX/" .. core.version.VERSION
 
 
 local function parse_args(args)
@@ -301,6 +302,8 @@ function _M.http_access_phase()
 
 core.ctx.set_vars_meta(api_ctx)
 
+core.response.set_header("Server", ver_header)
+
 -- load and run global rule
 if router.global_rules and router.global_rules.values
and #router.global_rules.values > 0 then
diff --git a/t/node/remote-addr-ipv6.t b/t/node/remote-addr-ipv6.t
index 26e4830..c4faa94 100644
--- a/t/node/remote-addr-ipv6.t
+++ b/t/node/remote-addr-ipv6.t
@@ -114,6 +114,7 @@ request sent: 59
 received: HTTP/1.1 200 OK
 received: Content-Type: text/plain
 received: Connection: close
+received: Server: APISIX/\d\.\d+(\.\d+)?
 received: Server: \w+
 received: 
 received: hello world
diff --git a/t/plugin/redirect.t b/t/plugin/redirect.t
index 1415db2..c624be8 100644
--- a/t/plugin/redirect.t
+++ b/t/plugin/redirect.t
@@ -669,6 +669,7 @@ sent http request: 58 bytes.
 received: HTTP/1.1 200 OK
 received: Content-Type: text/plain
 received: Connection: close
+received: Server: APISIX/\d\.\d+(\.\d+)?
 received: Server: \w+
 received: \nreceived: hello world
 close: 1 nil}
diff --git a/t/router/multi-ssl-certs.t b/t/router/multi-ssl-certs.t
index 6c968cb..d887535 100644
--- a/t/router/multi-ssl-certs.t
+++ b/t/router/multi-ssl-certs.t
@@ -160,6 +160,7 @@ sent http request: 62 bytes.
 received: HTTP/1.1 200 OK
 received: Content-Type: text/plain
 received: Connection: close
+received: Server: APISIX/\d\.\d+(\.\d+)?
 received: Server: \w+
 received: \nreceived: hello world
 close: 1 nil}
diff --git a/t/router/radixtree-sni.t b/t/router/radixtree-sni.t
index 5fe1ccd..80e1a5b 100644
--- a/t/router/radixtree-sni.t
+++ b/t/router/radixtree-sni.t
@@ -160,6 +160,7 @@ sent http request: 62 bytes.
 received: HTTP/1.1 200 OK
 received: Content-Type: text/plain
 received: Connection: close
+received: Server: APISIX/\d\.\d+(\.\d+)?
 received: Server: \w+
 received: \nreceived: hello world
 close: 1 nil}
@@ -313,6 +314,7 @@ sent http request: 62 bytes.
 received: HTTP/1.1 200 OK
 received: Content-Type: text/plain
 received: Connection: close
+received: Server: APISIX/\d\.\d+(\.\d+)?
 received: Server: \w+
 received: \nreceived: hello world
 close: 1 nil}
@@ -426,6 +428,7 @@ sent http request: 58 bytes.
 received: HTTP/1.1 200 OK
 received: Content-Type: text/plain
 received: Connection: close
+received: Server: APISIX/\d\.\d+(\.\d+)?
 received: Server: \w+
 received: \nreceived: hello world
 close: 1 nil}



[apisix] branch master updated: feature: implemented `request-id` plugin to uniquely track requests in APISIX (#2026)

2020-08-12 Thread membphis
This is an automated email from the ASF dual-hosted git repository.

membphis pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/apisix.git


The following commit(s) were added to refs/heads/master by this push:
 new 240942e  feature: implemented `request-id` plugin to uniquely track 
requests in APISIX (#2026)
240942e is described below

commit 240942e9416ef0cd771e8cd6f2f7336553b45de2
Author: Nirojan Selvanathan 
AuthorDate: Wed Aug 12 17:09:39 2020 +0200

feature: implemented `request-id` plugin to uniquely track requests in 
APISIX (#2026)

fix #2022
---
 apisix/plugins/request-id.lua |  68 
 conf/config.yaml  |   1 +
 doc/plugins/request-id.md |  90 ++
 t/admin/plugins.t |   2 +-
 t/debug/debug-mode.t  |   1 +
 t/plugin/request-id.t | 376 ++
 6 files changed, 537 insertions(+), 1 deletion(-)

diff --git a/apisix/plugins/request-id.lua b/apisix/plugins/request-id.lua
new file mode 100644
index 000..0de07fa
--- /dev/null
+++ b/apisix/plugins/request-id.lua
@@ -0,0 +1,68 @@
+--
+-- Licensed to the Apache Software Foundation (ASF) under one or more
+-- contributor license agreements.  See the NOTICE file distributed with
+-- this work for additional information regarding copyright ownership.
+-- The ASF licenses this file to You under the Apache License, Version 2.0
+-- (the "License"); you may not use this file except in compliance with
+-- the License.  You may obtain a copy of the License at
+--
+-- http://www.apache.org/licenses/LICENSE-2.0
+--
+-- Unless required by applicable law or agreed to in writing, software
+-- distributed under the License is distributed on an "AS IS" BASIS,
+-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+-- See the License for the specific language governing permissions and
+-- limitations under the License.
+--
+local core  = require("apisix.core")
+local plugin_name   = "request-id"
+local ngx   = ngx
+local uuid  = require("resty.jit-uuid")
+
+local schema = {
+type = "object",
+properties = {
+header_name = {type = "string", default = "X-Request-Id"},
+include_in_response = {type = "boolean", default = true}
+}
+}
+
+
+local _M = {
+version = 0.1,
+priority = 11010,
+name = plugin_name,
+schema = schema,
+}
+
+
+function _M.check_schema(conf)
+return core.schema.check(schema, conf)
+end
+
+
+function _M.rewrite(conf, ctx)
+local headers = ngx.req.get_headers()
+local uuid_val = uuid()
+if not headers[conf.header_name] then
+core.request.set_header(conf.header_name, uuid_val)
+end
+
+if conf.include_in_response then
+ctx.x_request_id = uuid_val
+end
+end
+
+
+function _M.header_filter(conf, ctx)
+if not conf.include_in_response then
+return
+end
+
+local headers = ngx.resp.get_headers()
+if not headers[conf.header_name] then
+core.response.set_header(conf.header_name, ctx.x_request_id)
+end
+end
+
+return _M
diff --git a/conf/config.yaml b/conf/config.yaml
index aa0361f..047f775 100644
--- a/conf/config.yaml
+++ b/conf/config.yaml
@@ -178,6 +178,7 @@ plugins:  # plugin list
   - request-validation
   - proxy-cache
   - proxy-mirror
+  - request-id
 
 stream_plugins:
   - mqtt-proxy
diff --git a/doc/plugins/request-id.md b/doc/plugins/request-id.md
new file mode 100644
index 000..0857e0e
--- /dev/null
+++ b/doc/plugins/request-id.md
@@ -0,0 +1,90 @@
+
+
+[Chinese](../zh-cn/plugins/request-validation.md)
+
+# Summary
+- [**Name**](#name)
+- [**Attributes**](#attributes)
+- [**How To Enable**](#how-to-enable)
+- [**Test Plugin**](#test-plugin)
+- [**Disable Plugin**](#disable-plugin)
+- [**Examples**](#examples)
+
+
+## Name
+
+`request-id` plugin adds a unique ID (UUID) to each request proxied through 
APISIX. This plugin can be used to track an
+API request. The plugin will not add a request id if the `header_name` is 
already present in the request.
+
+## Attributes
+
+|Name   |Requirement|Description|
+|-  |   |---|
+| header_name   |optional   |Request ID header name (default: 
X-Request-Id)|
+| include_in_response   |optional   |Option to include the unique request 
ID in the response header (default: true)|
+
+## How To Enable
+
+Create a route and enable the request-id plugin on the route:
+
+```shell
+curl http://127.0.0.1:9080/apisix/admin/routes/5 -H 'X-API-KEY: 
edd1c9f034335f136f87ad84b625c8f1' -X PUT -d '
+{
+"uri": "/get",
+"plugins": {
+"request-id": {
+"include_in_response": true
+}
+},
+"upstream": {
+   "type": "roundrobin&qu

[apisix-docker] branch master updated: change: remove incubator in repo url. (#71)

2020-08-12 Thread membphis
This is an automated email from the ASF dual-hosted git repository.

membphis pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/apisix-docker.git


The following commit(s) were added to refs/heads/master by this push:
 new 71be19e  change: remove incubator in repo url. (#71)
71be19e is described below

commit 71be19e1318dab7ab0b4b91dc60bd240909f6744
Author: Jared Tan 
AuthorDate: Wed Aug 12 23:01:27 2020 +0800

change: remove incubator in repo url. (#71)
---
 alpine-dev/Dockerfile  | 2 +-
 alpine/Dockerfile  | 4 ++--
 build.md   | 2 +-
 centos/Dockerfile  | 2 +-
 example/gen-config-yaml.sh | 2 +-
 5 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/alpine-dev/Dockerfile b/alpine-dev/Dockerfile
index 7afced1..0abd98a 100644
--- a/alpine-dev/Dockerfile
+++ b/alpine-dev/Dockerfile
@@ -9,7 +9,7 @@ RUN set -x \
 pkgconfig \
 cmake \
 git \
-&& luarocks install 
https://github.com/apache/incubator-apisix/raw/master/rockspec/apisix-master-0.rockspec
 --tree=/usr/local/apisix/deps \
+&& luarocks install 
https://github.com/apache/apisix/raw/master/rockspec/apisix-master-0.rockspec 
--tree=/usr/local/apisix/deps \
 && cp -v 
/usr/local/apisix/deps/lib/luarocks/rocks-5.1/apisix/master-0/bin/apisix 
/usr/bin/ \
 && bin='#! /usr/local/openresty/luajit/bin/luajit\npackage.path = 
"/usr/local/apisix/?.lua;" .. package.path' \
 && sed -i "1s@.*@$bin@" /usr/bin/apisix \
diff --git a/alpine/Dockerfile b/alpine/Dockerfile
index 536960d..007fc61 100644
--- a/alpine/Dockerfile
+++ b/alpine/Dockerfile
@@ -5,7 +5,7 @@ ARG APISIX_VERSION=1.3
 RUN set -x \
 && /bin/sed -i 
's,http://dl-cdn.alpinelinux.org,https://mirrors.aliyun.com,g' 
/etc/apk/repositories \
 && apk add --no-cache --virtual .build-deps git \
-&& git clone -b ${APISIX_VERSION} 
https://github.com/apache/incubator-apisix.git /tmp/apisix \
+&& git clone -b ${APISIX_VERSION} https://github.com/apache/apisix.git 
/tmp/apisix \
 && cd /tmp/apisix \
 && git submodule init \
 && git submodule update \
@@ -26,7 +26,7 @@ RUN set -x \
 pkgconfig \
 cmake \
 git \
-&& luarocks install 
https://github.com/apache/incubator-apisix/raw/master/rockspec/apisix-${APISIX_VERSION}-0.rockspec
 --tree=/usr/local/apisix/deps \
+&& luarocks install 
https://github.com/apache/apisix/raw/master/rockspec/apisix-${APISIX_VERSION}-0.rockspec
 --tree=/usr/local/apisix/deps \
 && cp -v 
/usr/local/apisix/deps/lib/luarocks/rocks-5.1/apisix/${APISIX_VERSION}-0/bin/apisix
 /usr/bin/ \
 && bin='#! /usr/local/openresty/luajit/bin/luajit\npackage.path = 
"/usr/local/apisix/?.lua;" .. package.path' \
 && sed -i "1s@.*@$bin@" /usr/bin/apisix \
diff --git a/build.md b/build.md
index ff43f85..1978239 100644
--- a/build.md
+++ b/build.md
@@ -4,7 +4,7 @@
 
 1. install release version (Apache releases are beginning from version 0.9):
 ```
-# Assign Apache release version number to variable `APISIX_VERSION`, for 
example: 1.2 . The latest version can be find at 
`https://github.com/apache/incubator-apisix/releases`
+# Assign Apache release version number to variable `APISIX_VERSION`, for 
example: 1.2 . The latest version can be find at 
`https://github.com/apache/apisix/releases`
 
 APISIX_VERSION=1.2
 docker build -t apisix:${APISIX_VERSION}-alpine --build-arg 
APISIX_VERSION=${APISIX_VERSION} -f alpine/Dockerfile alpine
diff --git a/centos/Dockerfile b/centos/Dockerfile
index 35d0b51..81f76ca 100644
--- a/centos/Dockerfile
+++ b/centos/Dockerfile
@@ -6,7 +6,7 @@ LABEL apisix_version="${APISIX_VERSION}"
 RUN yum -y install yum-utils\
&& yum-config-manager --add-repo 
https://openresty.org/package/centos/openresty.repo \
&& yum install -y openresty \
-   && yum install -y 
https://github.com/apache/incubator-apisix/releases/download/$APISIX_VERSION/apisix-$APISIX_VERSION-0.el7.noarch.rpm
 \
+   && yum install -y 
https://github.com/apache/apisix/releases/download/$APISIX_VERSION/apisix-$APISIX_VERSION-0.el7.noarch.rpm
 \
&& yum clean all \
&& sed -i 's/PASS_MAX_DAYS\t9/PASS_MAX_DAYS\t60/g' /etc/login.defs
 
diff --git a/example/gen-config-yaml.sh b/example/gen-config-yaml.sh
index 6bdc436..b2d9eeb 100644
--- a/example/gen-config-yaml.sh
+++ b/example/gen-config-yaml.sh
@@ -2,7 +2,7 @@
 
 export etcd_url='http://172.18.5.10:2379'
 
-wget 
https://raw.githubusercontent.com/apache/incubator-apisix/master/conf/config.yaml
+wget https://raw.githubusercontent.com/apache/apisix/master/conf/config.yaml
 
 sed -i -e ':a' -e 'N' -e '$!ba' -e "s/allow_admin[a-z: #\/._]*\n\( *- 
[0-9a-zA-Z: #\/._',]*\n*\)*//g" config.yaml
 



[apisix] branch master updated: doc: unified plugins document link format and path of Chinese and English. (#2040)

2020-08-12 Thread membphis
This is an automated email from the ASF dual-hosted git repository.

membphis pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/apisix.git


The following commit(s) were added to refs/heads/master by this push:
 new 31b210f  doc: unified plugins document link format and path of Chinese 
and English. (#2040)
31b210f is described below

commit 31b210f963398ed92c1412b719893069d32a33dd
Author: Janko 
AuthorDate: Wed Aug 12 22:54:11 2020 +0800

doc: unified plugins document link format and path of Chinese and English. 
(#2040)

fix #2039
---
 doc/plugins/authz-keycloak.md | 2 +-
 doc/plugins/basic-auth.md | 2 +-
 doc/plugins/batch-requests.md | 2 +-
 doc/plugins/consumer-restriction.md   | 2 +-
 doc/plugins/cors.md   | 2 +-
 doc/plugins/echo.md   | 2 ++
 doc/plugins/fault-injection.md| 2 +-
 doc/plugins/grpc-transcode.md | 2 +-
 doc/plugins/http-logger.md| 2 ++
 doc/plugins/ip-restriction.md | 2 +-
 doc/plugins/jwt-auth.md   | 2 +-
 doc/plugins/kafka-logger.md   | 2 ++
 doc/plugins/key-auth.md   | 2 +-
 doc/plugins/limit-conn.md | 2 +-
 doc/plugins/limit-count.md| 2 +-
 doc/plugins/limit-req.md  | 2 +-
 doc/plugins/mqtt-proxy.md | 2 +-
 doc/plugins/openid-connect.md | 2 ++
 doc/plugins/prometheus.md | 3 ++-
 doc/plugins/proxy-cache.md| 2 +-
 doc/plugins/proxy-mirror.md   | 2 +-
 doc/plugins/proxy-rewrite.md  | 2 +-
 doc/plugins/redirect.md   | 2 +-
 doc/plugins/request-validation.md | 2 +-
 doc/plugins/response-rewrite.md   | 2 +-
 doc/plugins/serverless.md | 2 +-
 doc/plugins/skywalking.md | 2 +-
 doc/plugins/syslog.md | 2 ++
 doc/plugins/tcp-logger.md | 2 ++
 doc/plugins/udp-logger.md | 2 ++
 doc/plugins/uri-blocker.md| 2 +-
 doc/plugins/wolf-rbac.md  | 2 +-
 doc/plugins/zipkin.md | 2 +-
 doc/zh-cn/plugins/authz-keycloak.md   | 2 +-
 doc/zh-cn/plugins/basic-auth.md   | 2 +-
 doc/zh-cn/plugins/batch-requests.md   | 2 +-
 doc/zh-cn/plugins/consumer-restriction.md | 2 +-
 doc/zh-cn/plugins/cors.md | 2 +-
 doc/zh-cn/plugins/echo.md | 2 ++
 doc/zh-cn/plugins/fault-injection.md  | 2 +-
 doc/zh-cn/plugins/grpc-transcode.md   | 2 +-
 doc/zh-cn/plugins/http-logger.md  | 2 ++
 doc/zh-cn/plugins/ip-restriction.md   | 2 +-
 doc/zh-cn/plugins/jwt-auth.md | 2 +-
 doc/zh-cn/plugins/kafka-logger.md | 2 ++
 doc/zh-cn/plugins/key-auth.md | 2 +-
 doc/zh-cn/plugins/limit-conn.md   | 3 ++-
 doc/zh-cn/plugins/limit-count.md  | 2 +-
 doc/zh-cn/plugins/limit-req.md| 2 +-
 doc/zh-cn/plugins/mqtt-proxy.md   | 3 +--
 doc/zh-cn/plugins/openid-connect.md   | 2 ++
 doc/zh-cn/plugins/prometheus.md   | 2 +-
 doc/zh-cn/plugins/proxy-cache.md  | 2 +-
 doc/zh-cn/plugins/proxy-mirror.md | 2 +-
 doc/zh-cn/plugins/proxy-rewrite.md| 3 ++-
 doc/zh-cn/plugins/redirect.md | 2 +-
 doc/zh-cn/plugins/request-validation.md   | 2 +-
 doc/zh-cn/plugins/response-rewrite.md | 2 +-
 doc/zh-cn/plugins/serverless.md   | 2 +-
 doc/zh-cn/plugins/skywalking.md   | 2 +-
 doc/zh-cn/plugins/syslog.md   | 2 ++
 doc/zh-cn/plugins/tcp-logger.md   | 2 ++
 doc/zh-cn/plugins/udp-logger.md   | 2 ++
 doc/zh-cn/plugins/uri-blocker.md  | 2 +-
 doc/zh-cn/plugins/wolf-rbac.md| 2 +-
 doc/zh-cn/plugins/zipkin.md   | 2 +-
 66 files changed, 83 insertions(+), 53 deletions(-)

diff --git a/doc/plugins/authz-keycloak.md b/doc/plugins/authz-keycloak.md
index 7fb6a13..68cf69e 100644
--- a/doc/plugins/authz-keycloak.md
+++ b/doc/plugins/authz-keycloak.md
@@ -17,7 +17,7 @@
 #
 -->
 
-[中文](../zh-cn/plugins/authz-keycloak.md)
+- [中文](../zh-cn/plugins/authz-keycloak.md)
 
 # Summary
 - [**Name**](#name)
diff --git a/doc/plugins/basic-auth.md b/doc/plugins/basic-auth.md
index dda4cba..b84a311 100644
--- a/doc/plugins/basic-auth.md
+++ b/doc/plugins/basic-auth.md
@@ -17,7 +17,7 @@
 #
 -->
 
-# [Chinese](../zh-cn/plugins/basic-auth.md)
+- [中文](../zh-cn/plugins/basic-auth.md)
 
 # Summary
 
diff --git a/doc/plugins/batch-requests.md b/doc/plugins/batch-requests.md
index b3ea993..5e5deed 100644
--- a/doc/plugins/batch-requests.md
+++ b/doc/plugins/batch-requests.md
@@ -17,7 +17,7 @@
 #
 -->
 
-# [Chinese](../zh-cn/plugins/batch-requests.md)
+- [中文](../zh-cn/plugins/batch-requests.md)
 
 # Summary
 
diff --git a/doc/plugins/consumer-restriction.md 
b/doc/plugins/consumer-restriction.md
index 60dafa8..e2bea

[apisix] branch master updated: feat: `Vary` needs to be used when Access-Control-Allow-Origin is not '*' (#2046)

2020-08-11 Thread membphis
This is an automated email from the ASF dual-hosted git repository.

membphis pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/apisix.git


The following commit(s) were added to refs/heads/master by this push:
 new 149a66a  feat: `Vary` needs to be used when 
Access-Control-Allow-Origin is not '*' (#2046)
149a66a is described below

commit 149a66ad409e5b9be702c0887eee30a9dafe0424
Author: 罗泽轩 
AuthorDate: Wed Aug 12 09:12:58 2020 +0800

feat: `Vary` needs to be used when Access-Control-Allow-Origin is not '*' 
(#2046)

See https://fetch.spec.whatwg.org/#cors-protocol-and-http-caches.
---
 apisix/plugins/cors.lua | 4 
 t/plugin/cors.t | 3 +++
 2 files changed, 7 insertions(+)

diff --git a/apisix/plugins/cors.lua b/apisix/plugins/cors.lua
index bb9ec90..1cc4ec0 100644
--- a/apisix/plugins/cors.lua
+++ b/apisix/plugins/cors.lua
@@ -128,6 +128,10 @@ local function set_cors_headers(conf, ctx)
 end
 
 core.response.set_header("Access-Control-Allow-Origin", 
ctx.cors_allow_origins)
+if ctx.cors_allow_origins ~= "*" then
+core.response.set_header("Vary", "Origin")
+end
+
 core.response.set_header("Access-Control-Allow-Methods", allow_methods)
 core.response.set_header("Access-Control-Max-Age", conf.max_age)
 core.response.set_header("Access-Control-Expose-Headers", 
conf.expose_headers)
diff --git a/t/plugin/cors.t b/t/plugin/cors.t
index aa61f72..4b0b6b1 100644
--- a/t/plugin/cors.t
+++ b/t/plugin/cors.t
@@ -244,6 +244,7 @@ GET /hello HTTP/1.1
 hello world
 --- response_headers
 Access-Control-Allow-Origin: *
+Vary:
 Access-Control-Allow-Methods: *
 Access-Control-Allow-Headers: *
 Access-Control-Expose-Headers: *
@@ -306,6 +307,7 @@ Origin: http://sub2.domain.com
 hello world
 --- response_headers
 Access-Control-Allow-Origin: http://sub2.domain.com
+Vary: Origin
 Access-Control-Allow-Methods: GET,POST
 Access-Control-Allow-Headers: headr1,headr2
 Access-Control-Expose-Headers: ex-headr1,ex-headr2
@@ -389,6 +391,7 @@ Access-Control-Request-Headers: req-header1,req-header2
 hello world
 --- response_headers
 Access-Control-Allow-Origin: https://sub.domain.com
+Vary: Origin
 Access-Control-Allow-Methods: 
GET,POST,PUT,DELETE,PATCH,HEAD,OPTIONS,CONNECT,TRACE
 Access-Control-Allow-Headers: req-header1,req-header2
 Access-Control-Expose-Headers: *



<    1   2   3   4   5   6   7   8   >