Skip to content

Commit

Permalink
Added TLS/SSL support to the HTML real-time report.
Browse files Browse the repository at this point in the history
  • Loading branch information
allinurl committed Oct 30, 2016
1 parent f5c35b0 commit 73a5797
Show file tree
Hide file tree
Showing 6 changed files with 512 additions and 25 deletions.
10 changes: 10 additions & 0 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,15 @@ esac
AC_MSG_RESULT([$with_rdyanimc])
AM_CONDITIONAL([WITH_RDYNAMIC], [test "x$with_rdyanimc" = "xyes"])

# Build with OpenSSL
AC_ARG_WITH([openssl],AC_HELP_STRING([--with-openssl], [build with OpenSSL support]),
[openssl="$withval"],[openssl="no"])

if test "$openssl" = 'yes'; then
AC_CHECK_LIB([ssl], [SSL_library_init],,[AC_MSG_ERROR([ssl library missing])])
AC_CHECK_LIB([crypto], [CRYPTO_num_locks],,[AC_MSG_ERROR([crypto library missing])])
fi

# GeoIP
AC_ARG_ENABLE(geoip, [ --enable-geoip Enable GeoIP country lookup. Default is disabled],
[geoip="$enableval"], geoip=no)
Expand Down Expand Up @@ -266,6 +275,7 @@ Your build configuration:
Version : $VERSION
Storage method : $storage
GNU getline : $with_getline
TLS/SSL : $openssl
Compiler flags : $CFLAGS
Linker flags : $LIBS $LDFLAGS
Bugs : $PACKAGE_BUGREPORT
Expand Down
4 changes: 4 additions & 0 deletions src/gwsocket.c
Original file line number Diff line number Diff line change
Expand Up @@ -350,6 +350,10 @@ start_server (void *ptr_data)
ws_set_config_port (conf.port);
if (conf.origin)
ws_set_config_origin (conf.origin);
if (conf.sslcert)
ws_set_config_sslcert (conf.sslcert);
if (conf.sslkey)
ws_set_config_sslkey (conf.sslkey);
writer->server->onopen = onopen;
set_self_pipe (writer->server->self_pipe);

Expand Down
14 changes: 14 additions & 0 deletions src/options.c
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,10 @@ struct option long_opts[] = {
{"real-time-html" , no_argument , 0 , 0 } ,
{"sort-panel" , required_argument , 0 , 0 } ,
{"static-file" , required_argument , 0 , 0 } ,
#ifdef HAVE_LIBSSL
{"ssl-cert" , required_argument , 0 , 0 } ,
{"ssl-key" , required_argument , 0 , 0 } ,
#endif
{"time-format" , required_argument , 0 , 0 } ,
{"ws-url" , required_argument , 0 , 0 } ,
#ifdef HAVE_LIBGEOIP
Expand Down Expand Up @@ -182,6 +186,8 @@ cmd_help (void)
" --port=<port> - Specify the port to use.\n"
" --real-time-html - Enable real-time HTML output.\n"
" --ws-url=<url> - URL to which the WebSocket server responds.\n"
" --ssl-cert=<cert.crt> - Path to TLS/SSL certificate.\n"
" --ssl-key=<priv.key> - Path to TLS/SSL private key.\n"
"\n"

/* File Options */
Expand Down Expand Up @@ -448,6 +454,14 @@ parse_long_opt (const char *name, const char *oarg)
conf.port = oarg;
}

/* TLS/SSL certificate */
if (!strcmp ("ssl-cert", name))
conf.sslcert = oarg;

/* TLS/SSL private key */
if (!strcmp ("ssl-key", name))
conf.sslkey = oarg;

/* double decode */
if (!strcmp ("double-decode", name))
conf.double_decode = 1;
Expand Down
2 changes: 2 additions & 0 deletions src/settings.h
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,8 @@ typedef struct GConf_
const char *addr; /* IP address to bind to */
const char *origin; /* WebSocket origin */
const char *port; /* port to use */
const char *sslcert; /* TLS/SSL path to certificate */
const char *sslkey; /* TLS/SSL path to private key */

/* User flags */
int all_static_files; /* parse all static files */
Expand Down
Loading

0 comments on commit 73a5797

Please sign in to comment.