[GitHub] trafficserver pull request #1127: TS-4990: Support new apis in ts_lua.

2016-11-04 Thread shukitchan
Github user shukitchan closed the pull request at:

https://github.com/apache/trafficserver/pull/1127


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] trafficserver pull request #1127: TS-4990: Support new apis in ts_lua.

2016-11-02 Thread jpeach
Github user jpeach commented on a diff in the pull request:

https://github.com/apache/trafficserver/pull/1127#discussion_r86285707
  
--- Diff: doc/admin-guide/plugins/ts_lua.en.rst ---
@@ -1424,6 +1460,38 @@ We will get the output:
 
 `TOP <#ts-lua-plugin>`_
 
+ts.server_request.server_addr.set_addr
+--
+**syntax:** *ts.server_request.server_addr.set_addr()*
+
+**context:** no later than function @ TS_LUA_HOOK_OS_DNS hook point
+
+**description**: This function can be used to set socket address of the 
origin server.
+
+The ts.server_request.server_addr.set_addr function requires three inputs, 
ip is a string, port and family is number.
+
+Here is an example:
+
+::
+
+function do_global_read_request()
+ts.server_request.server_addr.set_addr("192,168,231,17", 80, 
TS_LUA_AF_INET)
--- End diff --

Commas?


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] trafficserver pull request #1127: [TS-4990] support new apis in ts_lua

2016-10-26 Thread jpeach
Github user jpeach commented on a diff in the pull request:

https://github.com/apache/trafficserver/pull/1127#discussion_r85235598
  
--- Diff: plugins/experimental/ts_lua/ts_lua_server_request.c ---
@@ -755,3 +765,46 @@ ts_lua_server_request_server_addr_get_addr(lua_State 
*L)
 
   return 3;
 }
+
+static int
+ts_lua_server_request_server_addr_set_addr(lua_State *L)
+{
+  struct sockaddr_in addr4;
+  struct sockaddr_in6 addr6;
--- End diff --

```C
union {
struct sockaddr_in sin4;
struct sockaddr_in6 sin6;
struct sockaddr sa;
} addr;
...

TSHttpTxnServerAddrSet(http_ctx->txnp, );


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] trafficserver pull request #1127: [TS-4990] support new apis in ts_lua

2016-10-26 Thread jpeach
Github user jpeach commented on a diff in the pull request:

https://github.com/apache/trafficserver/pull/1127#discussion_r85234779
  
--- Diff: plugins/experimental/ts_lua/ts_lua_http.c ---
@@ -387,6 +411,52 @@ ts_lua_http_set_cache_lookup_url(lua_State *L)
 }
 
 static int
+ts_lua_http_get_parent_proxy(lua_State *L)
+{
+  const char *hostname = NULL;
+  int port = 0;
+  ts_lua_http_ctx *http_ctx;
+
+  GET_HTTP_CONTEXT(http_ctx, L);
+
+  TSHttpTxnParentProxyGet(http_ctx->txnp, , );
+
+  if (hostname == NULL) {
+lua_pushnil(L);
+  } else {
+lua_pushstring(L, hostname);
+  }
+  lua_pushnumber(L, port);
+
+  return 2;
+}
+
+static int
+ts_lua_http_set_parent_proxy(lua_State *L)
+{
+  int n = 0;
+  const char *hostname;
+  size_t hostname_len;
+  int port = 0;
+  const char *target;
+
+  ts_lua_http_ctx *http_ctx;
+
+  GET_HTTP_CONTEXT(http_ctx, L);
+
+  n = lua_gettop(L);
+
+  if (n == 2) {
--- End diff --

Throw an error if `n != 2`?


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] trafficserver pull request #1127: [TS-4990] support new apis in ts_lua

2016-10-26 Thread jpeach
Github user jpeach commented on a diff in the pull request:

https://github.com/apache/trafficserver/pull/1127#discussion_r85234954
  
--- Diff: plugins/experimental/ts_lua/ts_lua_http.c ---
@@ -526,6 +596,69 @@ ts_lua_http_resp_cache_untransformed(lua_State *L)
 }
 
 static int
+ts_lua_http_get_client_protocol_stack(lua_State *L)
+{
+  char const *results[10];
+  int count = 0;
+  ts_lua_http_ctx *http_ctx;
+
+  GET_HTTP_CONTEXT(http_ctx, L);
+
+  TSHttpTxnClientProtocolStackGet(http_ctx->txnp, 10, results, );
+  for (int i = 0; i < count; i++) {
+lua_pushstring(L, results[i]);
+  }
+
+  return count;
+}
+
+static int
+ts_lua_http_server_push(lua_State *L)
+{
+  const char *url;
+  const char *push_url;
+  size_t url_len;
+  ts_lua_http_ctx *http_ctx;
+
+  GET_HTTP_CONTEXT(http_ctx, L);
+
+  url  = luaL_checklstring(L, 1, _len);
+  push_url = TSstrndup(url, url_len);
+  TSHttpTxnServerPush(http_ctx->txnp, push_url, url_len);
+
+  return 0;
+}
+
+static int
+ts_lua_http_is_websocket(lua_State *L)
+{
+  ts_lua_http_ctx *http_ctx;
+
+  GET_HTTP_CONTEXT(http_ctx, L);
+
+  if (TSHttpTxnIsWebsocket(http_ctx->txnp)) {
--- End diff --

Consider:
```C
lua_pushboolean(L, TSHttpTxnIsWebsocket(http_ctx->txnp));
```


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] trafficserver pull request #1127: [TS-4990] support new apis in ts_lua

2016-10-19 Thread shukitchan
GitHub user shukitchan opened a pull request:

https://github.com/apache/trafficserver/pull/1127

[TS-4990] support new apis in ts_lua

support new apis in ts_lua

@jpeach pls take a look and review. Thanks.

You can merge this pull request into a Git repository by running:

$ git pull https://github.com/shukitchan/trafficserver newapi

Alternatively you can review and apply these changes as the patch at:

https://github.com/apache/trafficserver/pull/1127.patch

To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:

This closes #1127


commit 47657cdf5a901e8fcdba61809188b1dd588b8318
Author: Kit Chan 
Date:   2016-10-19T09:14:52Z

adding new APIs support

commit 220db583c032f18a338a7fe58e697614ee0e3b80
Author: Kit Chan 
Date:   2016-10-20T01:16:31Z

doc error fix




---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---