Add :compression() connection method to get the compression method in use (if any)

Fri, 08 Oct 2010 21:09:39 +0100

author
Tobias Markmann <tm@ayena.de>
date
Fri, 08 Oct 2010 21:09:39 +0100
changeset 3
bd2b1836f0ba
parent 2
0cfca30f1ce3
child 4
718837c61318

Add :compression() connection method to get the compression method in use (if any)

src/ssl.c file | annotate | diff | comparison | revisions
--- a/src/ssl.c	Sat Jul 24 20:10:15 2010 +0100
+++ b/src/ssl.c	Fri Oct 08 21:09:39 2010 +0100
@@ -356,6 +356,22 @@
   return 1;
 }
 
+/**
+ * Return the compression method used.
+ */
+static int meth_compression(lua_State *L)
+{
+  const COMP_METHOD *comp;
+  p_ssl ssl = (p_ssl)luaL_checkudata(L, 1, "SSL:Connection");
+  comp = SSL_get_current_compression(ssl->ssl);
+  if (comp) {
+    lua_pushstring(L, SSL_COMP_get_name(comp));
+    return 1;
+  } else {
+    lua_pushboolean(L, 0);
+    return 1;
+  }
+}
 /*---------------------------------------------------------------------------*/
 
 
@@ -363,15 +379,16 @@
  * SSL metamethods 
  */
 static luaL_Reg meta[] = {
-  {"close",       meth_close},
-  {"getfd",       meth_getfd},
-  {"dirty",       meth_dirty},
-  {"dohandshake", meth_handshake},
-  {"receive",     meth_receive},
-  {"send",        meth_send},
-  {"settimeout",  meth_settimeout},
-  {"want",        meth_want},
-  {NULL,          NULL}
+  {"close",             meth_close},
+  {"getfd",             meth_getfd},
+  {"dirty",             meth_dirty},
+  {"dohandshake",       meth_handshake},
+  {"receive",           meth_receive},
+  {"send",              meth_send},
+  {"settimeout",        meth_settimeout},
+  {"want",              meth_want},
+  {"compression",       meth_compression},
+  {NULL,                NULL}
 };
 
 /**

mercurial