add lws_is_ssl api
authorAndy Green <andy.green@linaro.org>
Sat, 16 Aug 2014 01:54:27 +0000 (09:54 +0800)
committerAndy Green <andy.green@linaro.org>
Sat, 16 Aug 2014 01:54:27 +0000 (09:54 +0800)
Suggested by Michael Harbler on the mailing list

Signed-off-by: Andy Green <andy.green@linaro.org>
changelog
lib/libwebsockets.c
lib/libwebsockets.h

index 1652fe8..8e59225 100644 (file)
--- a/changelog
+++ b/changelog
@@ -16,6 +16,11 @@ be used by the user code to mark the selected protocol by user-defined version
 or capabliity flag information, for the case multiple versions of a protocol are
 supported.
 
+int lws_is_ssl(wsi) added to allow user code to know if the connection was made
+over ssl or not.  If LWS_SERVER_OPTION_ALLOW_NON_SSL_ON_SSL_PORT is used, both
+ssl and non-ssl connections are possible and may need to be treated differently
+in the user code.
+
 
 v1.3-chrome37-firefox30
 =======================
index ee88e2e..a5ec698 100644 (file)
@@ -755,3 +755,17 @@ LWS_VISIBLE void lws_set_log_level(int level, void (*log_emit_function)(int leve
        if (log_emit_function)
                lwsl_emit = log_emit_function;
 }
+
+/**
+ * lws_use_ssl() - Find out if connection is using SSL
+ * @wsi:       websocket connection to check
+ *
+ *     Returns 0 if the connection is not using SSL, 1 if using SSL and
+ *     using verified cert, and 2 if using SSL but the cert was not
+ *     checked (appears for client wsi told to skip check on connection)
+ */
+LWS_VISIBLE int
+lws_is_ssl(struct libwebsocket *wsi)
+{
+       return wsi->use_ssl;
+}
index e6cc2a0..3cd5b59 100644 (file)
@@ -1181,6 +1181,9 @@ lws_send_pipe_choked(struct libwebsocket *wsi);
 LWS_VISIBLE LWS_EXTERN int
 lws_frame_is_binary(struct libwebsocket *wsi);
 
+LWS_VISIBLE LWS_EXTERN int
+lws_is_ssl(struct libwebsocket *wsi);
+
 LWS_VISIBLE LWS_EXTERN unsigned char *
 libwebsockets_SHA1(const unsigned char *d, size_t n, unsigned char *md);