diff options
author | Rob Crittenden <rcritten@redhat.com> | 2015-09-24 17:13:20 -0400 |
---|---|---|
committer | Rob Crittenden <rcritten@redhat.com> | 2015-10-02 16:51:56 -0400 |
commit | 00fe09480dfd28674661830d8a045e0f560bbe51 (patch) | |
tree | f13ebc99b09ee029ddbc75bba74aa60cb3e9dc66 /nss_util.c | |
parent | ea7584f67ef0e522254c3806cc0356e89594c711 (diff) | |
download | mod_nss-00fe09480dfd28674661830d8a045e0f560bbe51.tar.gz mod_nss-00fe09480dfd28674661830d8a045e0f560bbe51.tar.xz mod_nss-00fe09480dfd28674661830d8a045e0f560bbe51.zip |
Add support for Server Name Indication (SNI)
Uses a hash table to pair up server names and nicknames and
a lookup is done during the handshake to determine which
nickname to be used, and therefore which VirtualHost.
Based heavily on patch from Stanislav Tokos <stokos@suse.de>
Diffstat (limited to 'nss_util.c')
-rw-r--r-- | nss_util.c | 51 |
1 files changed, 50 insertions, 1 deletions
@@ -13,7 +13,6 @@ * limitations under the License. */ - #include "mod_nss.h" #include "ap_mpm.h" #include "apr_thread_mutex.h" @@ -100,3 +99,53 @@ char *nss_util_readfilter(server_rec *s, apr_pool_t *p, const char *cmd, return buf; } + +static void initializeHashVhostNick() { + if (NULL != ht) + return; + apr_pool_create(&mp, NULL); + ht = apr_hash_make(mp); +} + +char *searchHashVhostbyNick(char *vhost_id) { + char *searchVal = NULL; + + if (NULL == ht) + return NULL; + + searchVal = apr_hash_get(ht, vhost_id, APR_HASH_KEY_STRING); + + return searchVal; +} + +char *searchHashVhostbyNick_match(char *vhost_id) +{ + char *searchValReg = NULL; + apr_hash_index_t *hi; + + if (NULL == ht) + return NULL; + + for (hi = apr_hash_first(NULL, ht); hi; hi = apr_hash_next(hi)) { + const char *k = NULL; + const char *v = NULL; + + apr_hash_this(hi, (const void**)&k, NULL, (void**)&v); + if (!ap_strcasecmp_match(vhost_id, k)) { + searchValReg = apr_hash_get(ht, k, APR_HASH_KEY_STRING); + return searchValReg; + } + } + return NULL; +} + +void addHashVhostNick(char *vhost_id, char *nickname) { + if (ht == NULL) { + initializeHashVhostNick(); + } + + if (searchHashVhostbyNick(vhost_id) == NULL) { + apr_hash_set(ht, apr_pstrdup(mp, vhost_id), APR_HASH_KEY_STRING, + apr_pstrdup(mp, nickname)); + } +} |