VYPR
Unrated severityNVD Advisory· Published Jun 29, 2020· Updated Aug 4, 2024

Improper Initialization in coturn

CVE-2020-4067

Description

In coturn before version 4.5.1.3, there is an issue whereby STUN/TURN response buffer is not initialized properly. There is a leak of information between different client connections. One client (an attacker) could use their connection to intelligently query coturn to get interesting bytes in the padding bytes from the connection of another client. This has been fixed in 4.5.1.3.

Affected products

1

Patches

1
bf945bf72fb0

New upstream version 4.5.1.3

https://github.com/coturn/coturnMészáros MihályJun 25, 2020via osv
111 files changed · +4501 3381
  • ChangeLog+80 0 modified
    @@ -1,3 +1,83 @@
    +24/06/2020 Oleg Moskalenko <mom040267@gmail.com> Mihály Mészáros <misi@majd.eu>
    +Version 4.5.1.3 'dan Eider':
    +	- merge PR #575: (by osterik)
    +		* fix rpm packaging
    +	- merge PR #576: (by osterik)
    +		* tell tar to not include the metadata into release
    +	- merge PR #574: (by DevRockstarZ)
    +		* change Docker turnserver.conf to latest turnserver.conf
    +	- merge PR #566: (by bpcurse)
    +		* Remove reference to SSLv3
    +	- merge PR #579: (by islamoglus)
    +		*Ignore MD5 for BoringSSL
    +	- merge PR #577: (by osterik)
    +		*build RPM from local folder instead of git repo
    +	- Fix for CVE-2020-4067
    +		* STUN response buffer not initialized properly
    +		* The issue found and reported #583 by Felix Dörre all credits belongs to him.
    +
    +30/04/2020 Oleg Moskalenko <mom040267@gmail.com> Mihály Mészáros <misi@majd.eu>
    +Version 4.5.1.2 'dan Eider':
    +	- merge regression fix: (by Mathieu Brunot)
    +		* Do not display empty CLI passwd alert if CLI is not enabled
    +	- merge PR #359: (by bradleythughes)
    +		* Remove turn_free_simple
    +		* Remove turn_malloc()
    +		* Remote turn_realloc()
    +		* Remote turn_free()
    +		* Remove turn_calloc()
    +		* Remove turn_strdup()
    +		* Remove SSL_NEW() and SSL_FREE()
    +		* Remove pointer debugging machinery
    +		* Remove ns_bzero(), ns_bcopy(), and ns_bcmp()
    +		* Remove [su]{08,16,32,64}bits type defines
    +	- merge PR #327 (by Alexander Terczka)
    +		* Strip white-spaces from config file lines end
    +	- merge PR #386 (by Thibaut ACKERMANN)
    +		* fix the webadmin ip permission add/delete sql injection
    +	- merge PR #390 (by Thibaut ACKERMANN)
    +		* fix mongo driver crash when invalid connection string is used
    +	- merge PR #392 enhanced fread return length check (by islamoglus)
    +	- merge PR #367 disconnect database gracefully (by Shu Muto)
    +	- merge PR #382 (by islamoglus)
    +		* Using SSL_get_version method for BoringSSL compatibility
    +		* Now we put in turn_session_info->tls_method the real TLS version.
    +		  Earlier we put UNKNOWN in this field if it was a TLS protocol
    +		  that was not defined supportel TLS protocol during compile time.
    +	- merge PR #276 Add systemd service example (by Liberasys)
    +	- merge PR #284 Add bandwidth usage reporting packet/bandwidth usage by peers
    +	- merge PR #381 Modifying configure to enable compile with private libraries
    +	- merge PR #455 Typo corrected (by chanduthedev)
    +	- merge PR #417 Append only to log files rather to override them (by robert-scheck)
    +	- merge PR #442 Updated incorrect string length check for 'ssh' (by chanduthedev)
    +	- merge PR #449 Fix Dockerfile for latest Debian (by rao-donut)
    +	- http server NULL dereference
    +		* Reported (by quarkslab.com, cisco/talos)
    +		* CVE-2020-6061 / TALOS-2020-0984
    +	- http server out of bound read
    +		* Reported (by quarkslab.com, cisco/talos)
    +		* CVE-2020-6061 / TALOS-2020-0984
    +	- merge PR #472 STUN input validation (by bobsayshilol)
    +	- merge PR #398 FIPS (by  byronclark)
    +	- merge PR #478 prod (by alepolidori)
    +	- merge PR #463 fix typos and grammar (by xthursdayx)
    +	- update travis config ubuntu/mac images
    +	- merge PR #466 added null check for second char (by chanduthedev)
    +	- merge PR #470 compiler warning fixes (by bobsayshilol)
    +	- merge PR #475 Update README.docker (by raksonibs)
    +	- merge PR #471 Fix a memory leak when an SHATYPE isn't supported (by bobsayshilol)
    +	- merge PR #488 Fix typos about INSTALL filenames (by raccoonback)
    +	- fix compiler warning comparison between signed and unsigned integer expressions
    +	- fix compiler warning string truncation
    +	- change Diffie Hellman default key length from 1066 to 2066
    +	- merge PR #522 drop of supplementary group IDs (by weberhofer)
    +	- merge PR #514 Unify spelling of Coturn (by paulmenzel)
    +	- merge PR#506 Rename "prod" config option to "no-software-attribute" (by dbrgn)
    +	- merge PR #519 fix config extension in README.docker (by ooookai)
    +	- merge PR #516 change sql data dir in docker-compose-all.yml (by raghumuppa)
    +	- merge PR #513 remove trailing spaces from READMEs (by paulmenzel)
    +	- merge PR #525 add flags to disable periodic use of dynamic tables (by gfodor)
    +
     02/03/2019 Oleg Moskalenko <mom040267@gmail.com> Mihály Mészáros <misi@majd.eu>
     Version 4.5.1.1 'dan Eider':
     	- merge PR #330 missing \r\n after http Connection:close (by gribunin)
    
  • configure+141 110 modified
    @@ -63,14 +63,16 @@ testlibevent2_comp() {
     }
     
     testhiredis() {
    -    for inc in ${INCLUDEDIR}/hiredis /usr/local/include/hiredis /usr/hiredis /usr/include/hiredis
    -    do
    -        if [ -d ${inc} ] ; then
    -            HIREDISCFLAGS="${HIREDISCFLAGS} -I${inc}"
    -        fi
    -    done
    -    HIREDISLIBS=-lhiredis
    -    ${CC} ${HR_TMPCPROGC} -o ${HR_TMPCPROGB} ${OSCFLAGS} ${DBLIBS} ${HIREDISCFLAGS} ${HIREDISLIBS} ${OSLIBS} 2>>/dev/null
    +    if [ -z "${HIREDIS_CFLAGS}" ] || [ -z "${HIREDIS_LIBS}" ]; then
    +        for inc in ${INCLUDEDIR}/hiredis /usr/local/include/hiredis /usr/hiredis /usr/include/hiredis
    +        do
    +            if [ -d ${inc} ] ; then
    +                HIREDIS_CFLAGS="${HIREDIS_CFLAGS} -I${inc}"
    +            fi
    +        done
    +        HIREDIS_LIBS=-lhiredis
    +    fi
    +    ${CC} ${HR_TMPCPROGC} -o ${HR_TMPCPROGB} ${OSCFLAGS} ${DBLIBS} ${HIREDIS_CFLAGS} ${HIREDIS_LIBS} ${OSLIBS} 2>>/dev/null
         ER=$?
         if ! [ ${ER} -eq 0 ] ; then
     		${ECHO_CMD}
    @@ -80,27 +82,29 @@ testhiredis() {
     		${ECHO_CMD}
     		return 0
         else
    -		DBCFLAGS="${DBCFLAGS} ${HIREDISCFLAGS}"
    -		DBLIBS="${DBLIBS} ${HIREDISLIBS}"
    +		DBCFLAGS="${DBCFLAGS} ${HIREDIS_CFLAGS}"
    +		DBLIBS="${DBLIBS} ${HIREDIS_LIBS}"
     		return 1
         fi
     }
     
     testlibpq() {
    -    POSTCFLAGS="-I${PREFIX}/pgsql/include -I${PREFIX}/include/pgsql/ -I${PREFIX}/include/postgres/ -I${PREFIX}/postgres/include/ -I${PREFIX}/include/postgresql/ -I${PREFIX}/postgresql/include/"
    -    POSTCFLAGS="${POSTCFLAGS} -I/usr/local/pgsql/include -I/usr/local/include/pgsql/ -I/usr/local/include/postgres/ -I/usr/local/postgres/include/ -I/usr/local/include/postgresql/ -I/usr/local/postgresql/include/"
    -    POSTCFLAGS="${POSTCFLAGS} -I/usr/pgsql/include -I/usr/include/pgsql/ -I/usr/include/postgres/ -I/usr/postgres/include/ -I/usr/include/postgresql/ -I/usr/postgresql/include/"
    -    for ilib in ${PREFIX}/pgsql/lib ${PREFIX}/lib/pgsql ${PREFIX}/lib64/pgsql /usr/local/pgsql/lib /usr/local/lib/pgsql /usr/local/lib64/pgsql /usr/pgsql/lib /usr/lib/pgsql /usr/lib64/pgsql ${PREFIX}/postgres/lib ${PREFIX}/lib/postgres ${PREFIX}/lib64/postgres /usr/local/postgres/lib /usr/local/lib/postgres /usr/local/lib64/postgres /usr/postgres/lib /usr/lib/postgres /usr/lib64/postgres ${PREFIX}/postgresql/lib ${PREFIX}/lib/postgresql ${PREFIX}/lib64/postgresql /usr/local/postgresql/lib /usr/local/lib/postgresql /usr/local/lib64/postgresql /usr/postgresql/lib /usr/lib/postgresql /usr/lib64/postgresql
    -    do
    -	if [ -d ${ilib} ] ; then
    -    	    POSTLIBS="${POSTLIBS} -L${ilib}"
    -	    if ! [ -z "${TURN_ACCEPT_RPATH}" ] ; then
    -		TURN_RPATH="${TURN_RPATH} -Wl,-rpath,${ilib}"
    +    if [ -z "${PSQL_CFLAGS}" ] || [ -z "${PSQL_LIBS}" ]; then
    +        PSQL_CFLAGS="-I${PREFIX}/pgsql/include -I${PREFIX}/include/pgsql/ -I${PREFIX}/include/postgres/ -I${PREFIX}/postgres/include/ -I${PREFIX}/include/postgresql/ -I${PREFIX}/postgresql/include/"
    +        PSQL_CFLAGS="${PSQL_CFLAGS} -I/usr/local/pgsql/include -I/usr/local/include/pgsql/ -I/usr/local/include/postgres/ -I/usr/local/postgres/include/ -I/usr/local/include/postgresql/ -I/usr/local/postgresql/include/"
    +        PSQL_CFLAGS="${PSQL_CFLAGS} -I/usr/pgsql/include -I/usr/include/pgsql/ -I/usr/include/postgres/ -I/usr/postgres/include/ -I/usr/include/postgresql/ -I/usr/postgresql/include/"
    +        for ilib in ${PREFIX}/pgsql/lib ${PREFIX}/lib/pgsql ${PREFIX}/lib64/pgsql /usr/local/pgsql/lib /usr/local/lib/pgsql /usr/local/lib64/pgsql /usr/pgsql/lib /usr/lib/pgsql /usr/lib64/pgsql ${PREFIX}/postgres/lib ${PREFIX}/lib/postgres ${PREFIX}/lib64/postgres /usr/local/postgres/lib /usr/local/lib/postgres /usr/local/lib64/postgres /usr/postgres/lib /usr/lib/postgres /usr/lib64/postgres ${PREFIX}/postgresql/lib ${PREFIX}/lib/postgresql ${PREFIX}/lib64/postgresql /usr/local/postgresql/lib /usr/local/lib/postgresql /usr/local/lib64/postgresql /usr/postgresql/lib /usr/lib/postgresql /usr/lib64/postgresql
    +        do
    +	    if [ -d ${ilib} ] ; then
    +    	        PSQL_LIBS="${PSQL_LIBS} -L${ilib}"
    +	        if ! [ -z "${TURN_ACCEPT_RPATH}" ] ; then
    +		    TURN_RPATH="${TURN_RPATH} -Wl,-rpath,${ilib}"
    +	        fi
     	    fi
    -	fi
    -    done
    -    POSTLIBS="${OSLIBS} ${POSTLIBS} -lpq"
    -    ${CC} ${PQ_TMPCPROGC} -o ${PQ_TMPCPROGB} ${OSCFLAGS} ${DBCFLAGS} ${POSTCFLAGS} ${DBLIBS} ${POSTLIBS} ${OSLIBS} 2>>/dev/null 
    +        done
    +        PSQL_LIBS="${OSLIBS} ${PSQL_LIBS} -lpq"
    +    fi
    +    ${CC} ${PQ_TMPCPROGC} -o ${PQ_TMPCPROGB} ${OSCFLAGS} ${DBCFLAGS} ${PSQL_CFLAGS} ${DBLIBS} ${PSQL_LIBS} ${OSLIBS} 2>>/dev/null 
         ER=$?
         if ! [ ${ER} -eq 0 ] ; then
         	${ECHO_CMD}
    @@ -110,26 +114,28 @@ testlibpq() {
     		${ECHO_CMD}
     		return 0
         else
    -		DBCFLAGS="${DBCFLAGS} ${POSTCFLAGS}"
    -		DBLIBS="${DBLIBS} ${POSTLIBS}"
    +		DBCFLAGS="${DBCFLAGS} ${PSQL_CFLAGS}"
    +		DBLIBS="${DBLIBS} ${PSQL_LIBS}"
     		return 1
         fi
     }
     
     testlibmysql() {
    -    MYSQL_CFLAGS="-I${PREFIX}/mysql/include -I${PREFIX}/include/mysql/"
    -    MYSQL_CFLAGS="${MYSQL_CFLAGS} -I/usr/local/mysql/include -I/usr/local/include/mysql/"
    -    MYSQL_CFLAGS="${MYSQL_CFLAGS} -I/usr/mysql/include -I/usr/include/mysql/"
    -    for ilib in ${PREFIX}/mysql/lib ${PREFIX}/lib/mysql ${PREFIX}/lib64/mysql /usr/local/mysql/lib /usr/local/lib/mysql /usr/local/lib64/mysql /usr/mysql/lib /usr/lib/mysql /usr/lib64/mysql
    -    do
    -      if [ -d ${ilib} ] ; then
    -        MYSQL_LIBS="${MYSQL_LIBS} -L${ilib}"
    -	if ! [ -z "${TURN_ACCEPT_RPATH}" ] ; then
    -	    TURN_RPATH="${TURN_RPATH} -Wl,-rpath,${ilib}"
    -	fi
    -      fi
    -    done
    -    MYSQL_LIBS="${OSLIBS} ${MYSQL_LIBS} -lmysqlclient"
    +    if [ -z "${MYSQL_CFLAGS}" ] || [ -z "${MYSQL_LIBS}" ]; then
    +        MYSQL_CFLAGS="-I${PREFIX}/mysql/include -I${PREFIX}/include/mysql/"
    +        MYSQL_CFLAGS="${MYSQL_CFLAGS} -I/usr/local/mysql/include -I/usr/local/include/mysql/"
    +        MYSQL_CFLAGS="${MYSQL_CFLAGS} -I/usr/mysql/include -I/usr/include/mysql/"
    +        for ilib in ${PREFIX}/mysql/lib ${PREFIX}/lib/mysql ${PREFIX}/lib64/mysql /usr/local/mysql/lib /usr/local/lib/mysql /usr/local/lib64/mysql /usr/mysql/lib /usr/lib/mysql /usr/lib64/mysql
    +        do
    +            if [ -d ${ilib} ] ; then
    +                MYSQL_LIBS="${MYSQL_LIBS} -L${ilib}"
    +                if ! [ -z "${TURN_ACCEPT_RPATH}" ] ; then
    +                    TURN_RPATH="${TURN_RPATH} -Wl,-rpath,${ilib}"
    +                fi
    +            fi
    +        done
    +        MYSQL_LIBS="${OSLIBS} ${MYSQL_LIBS} -lmysqlclient"
    +    fi
         ${CC} ${MYSQL_TMPCPROGC} -o ${MYSQL_TMPCPROGB} ${OSCFLAGS} ${DBCFLAGS} ${DBLIBS} ${MYSQL_CFLAGS} ${MYSQL_LIBS} ${OSLIBS} 2>>/dev/null
         ER=$?
         if ! [ ${ER} -eq 0 ] ; then
    @@ -147,13 +153,15 @@ testlibmysql() {
     }
     
     testlibmongoc() {
    -    for inc in ${INCLUDEDIR}/libmongoc-1.0 ${INCLUDEDIR}/libbson-1.0 /usr/local/include/libmongoc-1.0 /usr/local/include/libbson-1.0 /usr/libmongoc-1.0 /usr/libbson-1.0 /usr/include/libbson-1.0/ /usr/include/libmongoc-1.0/
    -    do
    -      if [ -d ${inc} ] ; then
    -        MONGO_CFLAGS="${MONGO_CFLAGS} -I${inc}"
    -      fi
    -    done
    -    MONGO_LIBS="-lmongoc-1.0 -lbson-1.0"
    +    if [ -z "${MONGO_CFLAGS}" ] || [ -z "${MONGO_LIBS}" ]; then
    +        for inc in ${INCLUDEDIR}/libmongoc-1.0 ${INCLUDEDIR}/libbson-1.0 /usr/local/include/libmongoc-1.0 /usr/local/include/libbson-1.0 /usr/libmongoc-1.0 /usr/libbson-1.0 /usr/include/libbson-1.0/ /usr/include/libmongoc-1.0/
    +        do
    +            if [ -d ${inc} ] ; then
    +                MONGO_CFLAGS="${MONGO_CFLAGS} -I${inc}"
    +            fi
    +        done
    +        MONGO_LIBS="-lmongoc-1.0 -lbson-1.0"
    +    fi
         ${CC} ${MONGO_TMPCPROGC} -o ${MONGO_TMPCPROGB} ${OSCFLAGS} ${DBCFLAGS} ${DBLIBS} ${MONGO_CFLAGS} ${MONGO_LIBS} ${OSLIBS} 2>>/dev/null
         ER=$?
         if ! [ ${ER} -eq 0 ] ; then
    @@ -910,28 +918,39 @@ testdaemon
     # Test OpenSSL installation
     ###########################
     
    -testlib crypto
    -ER=$?
    -if ! [ ${ER} -eq 0 ] ; then
    -    ${ECHO_CMD} "Crypto SSL lib found."
    +if [ -n "${SSL_CFLAGS}" ] && [ -n "${SSL_LIBS}" ]; then
    +    ${CC} ${TMPCPROGC} ${SSL_CFLAGS} -o ${TMPCPROGB} ${OSCFLAGS} ${OSLIBS} ${SSL_LIBS} 2>>/dev/null
    +    ER=$?
    +    if ! [ ${ER} -eq 0 ] ; then
    +        ${ECHO_CMD} "Private SSL Library option cannot be used"
    +        exit
    +    else
    +        OSCFLAGS="${OSCFLAGS} ${SSL_CFLAGS}"
    +        OSLIBS="${OSLIBS} ${SSL_LIBS}"
    +    fi
     else
    -    ${ECHO_CMD} "ERROR: OpenSSL Crypto development libraries are not installed properly in required location."
    -    ${ECHO_CMD} "Abort."
    -    cleanup
    -    exit
    -fi
    +    testlib crypto
    +    ER=$?
    +    if ! [ ${ER} -eq 0 ] ; then
    +        ${ECHO_CMD} "Crypto SSL lib found."
    +    else
    +        ${ECHO_CMD} "ERROR: OpenSSL Crypto development libraries are not installed properly in required location."
    +        ${ECHO_CMD} "Abort."
    +        cleanup
    +        exit
    +    fi
     
    -testlib ssl
    -ER=$?
    -if ! [ ${ER} -eq 0 ] ; then
    -    ${ECHO_CMD} "SSL lib found."
    -else
    -    ${ECHO_CMD} "ERROR: OpenSSL development libraries are not installed properly in required location."
    -    ${ECHO_CMD} "Abort."
    -    cleanup
    -    exit
    +    testlib ssl
    +    ER=$?
    +    if ! [ ${ER} -eq 0 ] ; then
    +        ${ECHO_CMD} "SSL lib found."
    +    else
    +        ${ECHO_CMD} "ERROR: OpenSSL development libraries are not installed properly in required location."
    +        ${ECHO_CMD} "Abort."
    +        cleanup
    +        exit
    +    fi
     fi
    -
     ###########################
     # Can we use GCM cipher ?
     ###########################
    @@ -953,71 +972,83 @@ fi
     ###########################
     # Test Libevent2 setup
     ###########################
    -testlibevent2_comp
    -ER=$?
    -if ! [ ${ER} -eq 0 ] ; then
    -    ${ECHO_CMD} "Libevent2 development found."
    -else
    -    ${ECHO_CMD} "ERROR: Libevent2 development libraries are not installed properly in required location."
    -    ${ECHO_CMD} "ERROR: may be you have just too old libevent tool - then you have to upgrade it."
    -    ${ECHO_CMD} "See the INSTALL file."
    -    ${ECHO_CMD} "Abort."
    -    cleanup
    -    exit
    -fi
    -
    -testlib event_core
    -ER=$?
    -if ! [ ${ER} -eq 0 ] ; then
    -    ${ECHO_CMD} "Libevent2 runtime found."
    -    testlib event_extra
    +if [ -n "${EVENT_CFLAGS}" ] && [ -n "${EVENT_LIBS}" ]; then
    +    ${CC} ${TMPCPROGC} ${EVENT_CFLAGS} -o ${TMPCPROGB} ${OSCFLAGS} ${OSLIBS} ${EVENT_LIBS} 2>>/dev/null
         ER=$?
         if ! [ ${ER} -eq 0 ] ; then
    -	${ECHO_CMD} "Libevent2 runtime 'extra' found."
    +        ${ECHO_CMD} "Private Event Library option cannot be used"
    +        exit
         else
    -	${ECHO_CMD} "ERROR: Libevent2 'extra' runtime library is not installed properly in required location."
    -	${ECHO_CMD} "See the INSTALL file."
    -	${ECHO_CMD} "Abort."
    -	cleanup
    -	exit
    +        OSCFLAGS="${OSCFLAGS} ${EVENT_CFLAGS}"
    +        OSLIBS="${OSLIBS} ${EVENT_LIBS}"
         fi
     else
    -    testlib event
    +    testlibevent2_comp
         ER=$?
         if ! [ ${ER} -eq 0 ] ; then
    -		${ECHO_CMD} "Libevent2 runtime found (old style)."
    +        ${ECHO_CMD} "Libevent2 development found."
         else
    -		${ECHO_CMD} "ERROR: Libevent2 runtime libraries are not installed properly in required location."
    -		${ECHO_CMD} "See the INSTALL file."
    -		${ECHO_CMD} "Abort."
    -		cleanup
    -		exit
    +        ${ECHO_CMD} "ERROR: Libevent2 development libraries are not installed properly in required location."
    +        ${ECHO_CMD} "ERROR: may be you have just too old libevent tool - then you have to upgrade it."
    +        ${ECHO_CMD} "See the INSTALL file."
    +        ${ECHO_CMD} "Abort."
    +        cleanup
    +        exit
         fi
    -fi
     
    -if [ -z "${TURN_NO_TLS}" ] ; then
    +    testlib event_core
    +    ER=$?
    +    if ! [ ${ER} -eq 0 ] ; then
    +        ${ECHO_CMD} "Libevent2 runtime found."
    +        testlib event_extra
    +        ER=$?
    +        if ! [ ${ER} -eq 0 ] ; then
    +	    ${ECHO_CMD} "Libevent2 runtime 'extra' found."
    +        else
    +	    ${ECHO_CMD} "ERROR: Libevent2 'extra' runtime library is not installed properly in required location."
    +	    ${ECHO_CMD} "See the INSTALL file."
    +	    ${ECHO_CMD} "Abort."
    +	    cleanup
    +	    exit
    +        fi
    +    else
    +        testlib event
    +        ER=$?
    +        if ! [ ${ER} -eq 0 ] ; then
    +            ${ECHO_CMD} "Libevent2 runtime found (old style)."
    +        else
    +            ${ECHO_CMD} "ERROR: Libevent2 runtime libraries are not installed properly in required location."
    +            ${ECHO_CMD} "See the INSTALL file."
    +            ${ECHO_CMD} "Abort."
    +            cleanup
    +            exit
    +        fi
    +    fi
    +
    +    if [ -z "${TURN_NO_TLS}" ] ; then
     
     	testlib event_openssl
     	ER=$?
     	if ! [ ${ER} -eq 0 ] ; then
    -    	${ECHO_CMD} "Libevent2 openssl found."
    +    	    ${ECHO_CMD} "Libevent2 openssl found."
     	else
    -    	${ECHO_CMD} "ERROR: Libevent2 development libraries are not compiled with OpenSSL support."
    -    	${ECHO_CMD} "TLS will be disabled."
    -    	TURN_NO_TLS="-DTURN_NO_TLS"
    +    	    ${ECHO_CMD} "ERROR: Libevent2 development libraries are not compiled with OpenSSL support."
    +    	    ${ECHO_CMD} "TLS will be disabled."
    +    	    TURN_NO_TLS="-DTURN_NO_TLS"
     	fi
     
    -else
    +    else
     	TURN_NO_TLS="-DTURN_NO_TLS"
    -fi
    +    fi
     
    -testlib event_pthreads
    -ER=$?
    -if ! [ ${ER} -eq 0 ] ; then
    -	${ECHO_CMD} "Libevent2 pthreads found."
    -else
    -   	${ECHO_CMD} "ERROR: Libevent2 development libraries are not compiled with threads support."
    -	exit
    +    testlib event_pthreads
    +    ER=$?
    +    if ! [ ${ER} -eq 0 ] ; then
    +        ${ECHO_CMD} "Libevent2 pthreads found."
    +    else
    +        ${ECHO_CMD} "ERROR: Libevent2 development libraries are not compiled with threads support."
    +        exit
    +    fi
     fi
     
     ###########################
    
  • docker/coturn/Dockerfile+13 4 modified
    @@ -8,11 +8,11 @@ RUN export DEBIAN_FRONTEND=noninteractive && \
     	apt-get update && \
     	apt-get install -y build-essential git debhelper dpkg-dev libssl-dev libevent-dev sqlite3 libsqlite3-dev postgresql-client libpq-dev default-mysql-client default-libmysqlclient-dev libhiredis-dev libmongoc-dev libbson-dev
     
    -# Clone coTURN
    +# Clone Coturn
     WORKDIR ${BUILD_PREFIX}
     RUN git clone https://github.com/coturn/coturn.git
     
    -# Build coTURN
    +# Build Coturn
     WORKDIR coturn
     RUN ./configure
     RUN make
    @@ -34,8 +34,17 @@ COPY --from=coturn-build ${BUILD_PREFIX}/coturn/turndb ${INSTALL_PREFIX}/turndb
     # Install lib dependencies
     RUN export DEBIAN_FRONTEND=noninteractive && \
     	apt-get update && \
    -	apt-get install -y libc6>=2.15 libevent-core-2.0-5>=2.0.10-stable libevent-extra-2.0-5>=2.0.10-stable libevent-openssl-2.0-5>=2.0.10-stable libevent-pthreads-2.0-5>=2.0.10-stable libhiredis0.13>=0.13.1 libmariadbclient18>=5.5.36 libpq5>=8.4~ libsqlite3-0>=3.6.0 libssl1.1>=1.1.0 libmongoc-1.0 libbson-1.0
    -RUN	apt-get install -y mysql-client postgresql-client redis-tools mongodb-clients
    +	apt-get install -y libc6>=2.15 libevent-core-2.1-6>=libevent-core-2.1-6 libevent-extra-2.1-6>=2.1.8-stable-4 libevent-openssl-2.1-6>=2.1.8-stable-4 libevent-pthreads-2.1-6>=2.1.8-stable-4 libhiredis0.14>=0.14.0 libmariadbclient-dev>=10.3.17 libpq5>=8.4~ libsqlite3-0>=3.6.0 libssl1.1>=1.1.0 libmongoc-1.0 libbson-1.0
    +RUN apt-get install -y default-mysql-client postgresql-client redis-tools
    +
    +# Install MongoDB
    +RUN apt-get update && \
    +  apt-get install -y wget gnupg && \
    +  wget -qO - https://www.mongodb.org/static/pgp/server-4.0.asc | apt-key add - && \
    +  echo "deb http://repo.mongodb.org/apt/debian stretch/mongodb-org/4.0 main" | tee /etc/apt/sources.list.d/mongodb-org-4.0.list && \
    +  echo "deb http://deb.debian.org/debian/ stretch main" | tee /etc/apt/sources.list.d/debian-stretch.list && \
    +  apt-get update && \
    +  apt-get install -y libcurl3 mongodb-org mongodb-org-server mongodb-org
     
     RUN if ! getent group "$TURNSERVER_GROUP" >/dev/null; then \
             addgroup --system "$TURNSERVER_GROUP" || exit 1 ;\
    
  • docker/coturn/turnserver.conf+194 168 modified
    @@ -1,52 +1,60 @@
     # Coturn TURN SERVER configuration file
     #
    -# Boolean values note: where boolean value is supposed to be used,
    -# you can use '0', 'off', 'no', 'false', 'f' as 'false,
    -# and you can use '1', 'on', 'yes', 'true', 't' as 'true'
    -# If the value is missed, then it means 'true'.
    +# Boolean values note: where a boolean value is supposed to be used,
    +# you can use '0', 'off', 'no', 'false', or 'f' as 'false, 
    +# and you can use '1', 'on', 'yes', 'true', or 't' as 'true' 
    +# If the value is missing, then it means 'true' by default.
     #
     
     # Listener interface device (optional, Linux only).
    -# NOT RECOMMENDED.
    +# NOT RECOMMENDED. 
     #
     #listening-device=eth0
     
     # TURN listener port for UDP and TCP (Default: 3478).
    -# Note: actually, TLS & DTLS sessions can connect to the
    +# Note: actually, TLS & DTLS sessions can connect to the 
     # "plain" TCP & UDP port(s), too - if allowed by configuration.
     #
     listening-port=3478
     
     # TURN listener port for TLS (Default: 5349).
     # Note: actually, "plain" TCP & UDP sessions can connect to the TLS & DTLS
    -# port(s), too - if allowed by configuration. The TURN server
    +# port(s), too - if allowed by configuration. The TURN server 
     # "automatically" recognizes the type of traffic. Actually, two listening
     # endpoints (the "plain" one and the "tls" one) are equivalent in terms of
    -# functionality; but we keep both endpoints to satisfy the RFC 5766 specs.
    -# For secure TCP connections, we currently support SSL version 3 and
    +# functionality; but Coturn keeps both endpoints to satisfy the RFC 5766 specs.
    +# For secure TCP connections, Coturn currently supports SSL version 3 and 
     # TLS version 1.0, 1.1 and 1.2.
    -# For secure UDP connections, we support DTLS version 1.
    +# For secure UDP connections, Coturn supports DTLS version 1.
     #
     tls-listening-port=5349
     
     # Alternative listening port for UDP and TCP listeners;
    -# default (or zero) value means "listening port plus one".
    +# default (or zero) value means "listening port plus one". 
     # This is needed for RFC 5780 support
    -# (STUN extension specs, NAT behavior discovery). The TURN Server
    -# supports RFC 5780 only if it is started with more than one
    +# (STUN extension specs, NAT behavior discovery). The TURN Server 
    +# supports RFC 5780 only if it is started with more than one 
     # listening IP address of the same family (IPv4 or IPv6).
     # RFC 5780 is supported only by UDP protocol, other protocols
     # are listening to that endpoint only for "symmetry".
     #
     #alt-listening-port=0
    -
    +							 
     # Alternative listening port for TLS and DTLS protocols.
     # Default (or zero) value means "TLS listening port plus one".
     #
     #alt-tls-listening-port=0
     
    +# Some network setups will require using a TCP reverse proxy in front
    +# of the STUN server. If the proxy port option is set a single listener
    +# is started on the given port that accepts connections using the
    +# haproxy proxy protocol v2.
    +# (https://www.haproxy.org/download/1.8/doc/proxy-protocol.txt)
    +#
    +#tcp-proxy-port=5555
    +	
     # Listener IP address of relay server. Multiple listeners can be specified.
    -# If no IP(s) specified in the config file or in the command line options,
    +# If no IP(s) specified in the config file or in the command line options, 
     # then all IPv4 and IPv6 system IPs will be used for listening.
     #
     #listening-ip=172.17.19.101
    @@ -61,7 +69,7 @@ tls-listening-port=5349
     # they do not support STUN RFC 5780 functionality (CHANGE REQUEST).
     #
     # 2) Auxiliary servers also are never returning ALTERNATIVE-SERVER reply.
    -#
    +# 
     # Valid formats are 1.2.3.4:5555 for IPv4 and [1:2::3:4]:5555 for IPv6.
     #
     # There may be multiple aux-server options, each will be used for listening
    @@ -73,7 +81,7 @@ tls-listening-port=5349
     # (recommended for older Linuxes only)
     # Automatically balance UDP traffic over auxiliary servers (if configured).
     # The load balancing is using the ALTERNATE-SERVER mechanism.
    -# The TURN client must support 300 ALTERNATE-SERVER response for this
    +# The TURN client must support 300 ALTERNATE-SERVER response for this 
     # functionality.
     #
     #udp-self-balance
    @@ -83,13 +91,13 @@ tls-listening-port=5349
     #
     #relay-device=eth1
     
    -# Relay address (the local IP address that will be used to relay the
    +# Relay address (the local IP address that will be used to relay the 
     # packets to the peer).
     # Multiple relay addresses may be used.
     # The same IP(s) can be used as both listening IP(s) and relay IP(s).
     #
     # If no relay IP(s) specified, then the turnserver will apply the default
    -# policy: it will decide itself which relay addresses to be used, and it
    +# policy: it will decide itself which relay addresses to be used, and it 
     # will always be using the client socket IP address as the relay IP address
     # of the TURN session (if the requested relay address family is the same
     # as the family of the client socket).
    @@ -112,35 +120,33 @@ tls-listening-port=5349
     # that option must be used several times, each entry must
     # have form "-X <public-ip/private-ip>", to map all involved addresses.
     # RFC5780 NAT discovery STUN functionality will work correctly,
    -# if the addresses are mapped properly, even when the TURN server itself
    +# if the addresses are mapped properly, even when the TURN server itself 
     # is behind A NAT.
     #
     # By default, this value is empty, and no address mapping is used.
     #
    -#external-ip=60.70.80.91
    +external-ip=193.224.22.37
     #
     #OR:
     #
     #external-ip=60.70.80.91/172.17.19.101
     #external-ip=60.70.80.92/172.17.19.102
    -#external-ip=60.70.80.92/172.17.19.102
    -external-ip=193.224.22.37
     
     
     # Number of the relay threads to handle the established connections
     # (in addition to authentication thread and the listener thread).
    -# If explicitly set to 0 then application runs relay process in a
    -# single thread, in the same thread with the listener process
    +# If explicitly set to 0 then application runs relay process in a 
    +# single thread, in the same thread with the listener process 
     # (the authentication thread will still be a separate thread).
     #
    -# If this parameter is not set, then the default OS-dependent
    +# If this parameter is not set, then the default OS-dependent 
     # thread pattern algorithm will be employed. Usually the default
    -# algorithm is the most optimal, so you have to change this option
    -# only if you want to make some fine tweaks.
    +# algorithm is optimal, so you have to change this option
    +# if you want to make some fine tweaks. 
     #
     # In the older systems (Linux kernel before 3.9),
     # the number of UDP threads is always one thread per network listening
    -# endpoint - including the auxiliary endpoints - unless 0 (zero) or
    +# endpoint - including the auxiliary endpoints - unless 0 (zero) or 
     # 1 (one) value is set.
     #
     #relay-threads=0
    @@ -150,15 +156,15 @@ external-ip=193.224.22.37
     #
     min-port=49152
     max-port=65535
    -
    +	
     # Uncomment to run TURN server in 'normal' 'moderate' verbose mode.
     # By default the verbose mode is off.
     verbose
    -
    +	
     # Uncomment to run TURN server in 'extra' verbose mode.
     # This mode is very annoying and produces lots of output.
    -# Not recommended under any normal circumstances.
    -#
    +# Not recommended under normal circumstances.
    +#	
     #Verbose
     
     # Uncomment to use fingerprints in the TURN messages.
    @@ -171,11 +177,11 @@ fingerprint
     #
     lt-cred-mech
     
    -# This option is opposite to lt-cred-mech.
    +# This option is the opposite of lt-cred-mech. 
     # (TURN Server with no-auth option allows anonymous access).
     # If neither option is defined, and no users are defined,
    -# then no-auth is default. If at least one user is defined,
    -# in this file or in command line or in usersdb file, then
    +# then no-auth is default. If at least one user is defined, 
    +# in this file, in command line or in usersdb file, then
     # lt-cred-mech is default.
     #
     #no-auth
    @@ -185,44 +191,43 @@ lt-cred-mech
     # Flag that sets a special authorization option that is based upon authentication secret.
     #
     # This feature's purpose is to support "TURN Server REST API", see
    -# "TURN REST API" link in the project's page
    +# "TURN REST API" link in the project's page 
     # https://github.com/coturn/coturn/
     #
     # This option is used with timestamp:
    -#
    +# 
     # usercombo -> "timestamp:userid"
     # turn user -> usercombo
     # turn password -> base64(hmac(secret key, usercombo))
     #
     # This allows TURN credentials to be accounted for a specific user id.
    -# If you don't have a suitable id, the timestamp alone can be used.
    -# This option is just turning on secret-based authentication.
    -# The actual value of the secret is defined either by option static-auth-secret,
    +# If you don't have a suitable id, then the timestamp alone can be used.
    +# This option is enabled by turning on secret-based authentication.
    +# The actual value of the secret is defined either by the option static-auth-secret,
     # or can be found in the turn_secret table in the database (see below).
    -#
    +# 
     # Read more about it:
     #  - https://tools.ietf.org/html/draft-uberti-behave-turn-rest-00
     #  - https://www.ietf.org/proceedings/87/slides/slides-87-behave-10.pdf
     #
    -# Be aware that use-auth-secret overrides some part of lt-cred-mech.
    -# Notice that this feature depends internally on lt-cred-mech, so if you set
    -# use-auth-secret then it enables internally automatically lt-cred-mech option
    -# like if you enable both.
    -#
    -# You can use only one of the to auth mechanisms in the same time because,
    -# both mechanism use the username and password validation in different way.
    +# Be aware that use-auth-secret overrides some parts of lt-cred-mech.
    +# The use-auth-secret feature depends internally on lt-cred-mech, so if you set
    +# this option then it automatically enables lt-cred-mech internally
    +# as if you had enabled both.
     #
    -# This way be aware that you can't use both auth mechnaism in the same time!
    -# Use in config either the lt-cred-mech or the use-auth-secret
    +# Note that you can use only one auth mechanism at the same time! This is because,
    +# both mechanisms conduct username and password validation in different ways.
    +# 
    +# Use either lt-cred-mech or use-auth-secret in the conf
     # to avoid any confusion.
     #
     #use-auth-secret
     
    -# 'Static' authentication secret value (a string) for TURN REST API only.
    +# 'Static' authentication secret value (a string) for TURN REST API only. 
     # If not set, then the turn server
    -# will try to use the 'dynamic' value in turn_secret table
    -# in user database (if present). The database-stored  value can be changed on-the-fly
    -# by a separate program, so this is why that other mode is 'dynamic'.
    +# will try to use the 'dynamic' value in the turn_secret table
    +# in the user database (if present). The database-stored  value can be changed on-the-fly
    +# by a separate program, so this is why that mode is considered 'dynamic'.
     #
     #static-auth-secret=north
     
    @@ -236,10 +241,10 @@ lt-cred-mech
     #
     #oauth
     
    -# 'Static' user accounts for long term credentials mechanism, only.
    +# 'Static' user accounts for the long term credentials mechanism, only.
     # This option cannot be used with TURN REST API.
    -# 'Static' user accounts are NOT dynamically checked by the turnserver process,
    -# so that they can NOT be changed while the turnserver is running.
    +# 'Static' user accounts are NOT dynamically checked by the turnserver process, 
    +# so they can NOT be changed while the turnserver is running.
     #
     #user=username1:key1
     #user=username2:key2
    @@ -257,103 +262,91 @@ lt-cred-mech
     # password. If it has 0x then it is a key, otherwise it is a password).
     #
     # The corresponding user account entry in the config file will be:
    -#
    +# 
     #user=ninefingers:0xbc807ee29df3c9ffa736523fb2c4e8ee
     # Or, equivalently, with open clear password (less secure):
     #user=ninefingers:youhavetoberealistic
     #
     
     # SQLite database file name.
     #
    -# Default file name is /var/db/turndb or /usr/local/var/db/turndb or
    +# The default file name is /var/db/turndb or /usr/local/var/db/turndb or
     # /var/lib/turn/turndb.
    -#
    +# 
     #userdb=/var/db/turndb
     
    -# PostgreSQL database connection string in the case that we are using PostgreSQL
    +# PostgreSQL database connection string in the case that you are using PostgreSQL
     # as the user database.
    -# This database can be used for long-term credential mechanism
    -# and it can store the secret value for secret-based timed authentication in TURN RESP API.
    +# This database can be used for the long-term credential mechanism
    +# and it can store the secret value for secret-based timed authentication in TURN REST API. 
     # See http://www.postgresql.org/docs/8.4/static/libpq-connect.html for 8.x PostgreSQL
    -# versions connection string format, see
    +# versions connection string format, see 
     # http://www.postgresql.org/docs/9.2/static/libpq-connect.html#LIBPQ-CONNSTRING
     # for 9.x and newer connection string formats.
     #
     #psql-userdb="host=<host> dbname=<database-name> user=<database-user> password=<database-user-password> connect_timeout=30"
     
    -#psql-userdb="host=postgresql dbname=coturn user=coturn password=CHANGE_ME connect_timeout=30"
    -
    -# MySQL database connection string in the case that we are using MySQL
    +# MySQL database connection string in the case that you are using MySQL
     # as the user database.
    -# This database can be used for long-term credential mechanism
    -# and it can store the secret value for secret-based timed authentication in TURN RESP API.
    +# This database can be used for the long-term credential mechanism
    +# and it can store the secret value for secret-based timed authentication in TURN REST API.
     #
    -# Optional connection string parameters for the secure communications (SSL):
    -# ca, capath, cert, key, cipher
    -# (see http://dev.mysql.com/doc/refman/5.1/en/ssl-options.html for the
    +# Optional connection string parameters for the secure communications (SSL): 
    +# ca, capath, cert, key, cipher 
    +# (see http://dev.mysql.com/doc/refman/5.1/en/ssl-options.html for the 
     # command options description).
     #
    -# Use string format as below (space separated parameters, all optional):
    +# Use the string format below (space separated parameters, all optional):
     #
    -#mysql-userdb="host=<host> dbname=<database-name> user=<database-user> password=<database-user-password> port=<port> connect_timeout=<seconds> read_timeout=<seconds>"
    -
     mysql-userdb="host=mysql dbname=coturn user=coturn password=CHANGE_ME port=3306 connect_timeout=10 read_timeout=10"
     
    -# If you want to use in the MySQL connection string the password in encrypted format,
    -# then set in this option the MySQL password encryption secret key file.
    +# If you want to use an encrypted password in the MySQL connection string,
    +# then set the MySQL password encryption secret key file with this option.
     #
    -# Warning: If this option is set, then mysql password must be set in "mysql-userdb" in encrypted format!
    -# If you want to use cleartext password then do not set this option!
    +# Warning: If this option is set, then the mysql password must be set in "mysql-userdb" in an encrypted format! 
    +# If you want to use a cleartext password then do not set this option!
     #
    -# This is the file path which contain secret key of aes encryption while using password encryption.
    +# This is the file path for the aes encrypted secret key used for password encryption.
     #
     #secret-key-file=/path/
     
    -# MongoDB database connection string in the case that we are using MongoDB
    +# MongoDB database connection string in the case that you are using MongoDB
     # as the user database.
     # This database can be used for long-term credential mechanism
    -# and it can store the secret value for secret-based timed authentication in TURN RESP API.
    -# Use string format is described at http://hergert.me/docs/mongo-c-driver/mongoc_uri.html
    +# and it can store the secret value for secret-based timed authentication in TURN REST API. 
    +# Use the string format described at http://hergert.me/docs/mongo-c-driver/mongoc_uri.html
     #
     #mongo-userdb="mongodb://[username:password@]host1[:port1][,host2[:port2],...[,hostN[:portN]]][/[database][?options]]"
     
    -#mongo-userdb="mongodb://coturn:CHANGE_ME@mongodb/coturn"
    -#mongo-userdb="mongodb://mongodb/coturn"
    -
    -# Redis database connection string in the case that we are using Redis
    +# Redis database connection string in the case that you are using Redis
     # as the user database.
     # This database can be used for long-term credential mechanism
    -# and it can store the secret value for secret-based timed authentication in TURN RESP API.
    -# Use string format as below (space separated parameters, all optional):
    +# and it can store the secret value for secret-based timed authentication in TURN REST API. 
    +# Use the string format below (space separated parameters, all optional):
     #
     #redis-userdb="ip=<ip-address> dbname=<database-number> password=<database-user-password> port=<port> connect_timeout=<seconds>"
     
    -#redis-userdb="ip=redis dbname=2 password=CHANGE_ME connect_timeout=30"
    -
     # Redis status and statistics database connection string, if used (default - empty, no Redis stats DB used).
     # This database keeps allocations status information, and it can be also used for publishing
     # and delivering traffic and allocation event notifications.
    -# The connection string has the same parameters as redis-userdb connection string.
    -# Use string format as below (space separated parameters, all optional):
    +# The connection string has the same parameters as redis-userdb connection string. 
    +# Use the string format below (space separated parameters, all optional):
     #
     #redis-statsdb="ip=<ip-address> dbname=<database-number> password=<database-user-password> port=<port> connect_timeout=<seconds>"
     
    -#redis-statsdb="ip=redis dbname=2 password=CHANGE_ME connect_timeout=30"
    -
    -# The default realm to be used for the users when no explicit
    -# origin/realm relationship was found in the database, or if the TURN
    +# The default realm to be used for the users when no explicit 
    +# origin/realm relationship is found in the database, or if the TURN
     # server is not using any database (just the commands-line settings
    -# and the userdb file). Must be used with long-term credentials
    +# and the userdb file). Must be used with long-term credentials 
     # mechanism or with TURN REST API.
     #
    -# Note: If default realm is not specified at all, then realm falls back to the host domain name.
    -#       If domain name is empty string, or '(None)', then it is initialized to am empty string.
    +# Note: If the default realm is not specified, then realm falls back to the host domain name.
    +#       If the domain name string is empty, or set to '(None)', then it is initialized as an empty string.
     #
    -#realm=mycompany.org
     realm=example.org
     
    -# The flag that sets the origin consistency
    -# check: across the session, all requests must have the same
    +# This flag sets the origin consistency 
    +# check. Across the session, all requests must have the same
     # main ORIGIN attribute value (if the ORIGIN was
     # initially used by the session).
     #
    @@ -373,7 +366,7 @@ realm=example.org
     
     # Max bytes-per-second bandwidth a TURN session is allowed to handle
     # (input and output network streams are treated separately). Anything above
    -# that limit will be dropped or temporary suppressed (within
    +# that limit will be dropped or temporarily suppressed (within
     # the available buffer limits).
     # This option can also be set through the database, for a particular realm.
     #
    @@ -417,11 +410,11 @@ realm=example.org
     #no-tcp-relay
     
     # Uncomment if extra security is desired,
    -# with nonce value having limited lifetime.
    +# with nonce value having a limited lifetime.
     # By default, the nonce value is unique for a session,
    -# and has unlimited lifetime.
    -# Set this option to limit the nonce lifetime.
    -# It defaults to 600 secs (10 min) if no value is provided. After that delay,
    +# and has an unlimited lifetime. 
    +# Set this option to limit the nonce lifetime. 
    +# It defaults to 600 secs (10 min) if no value is provided. After that delay, 
     # the client will get 438 error and will have to re-authenticate itself.
     #
     #stale-nonce=600
    @@ -447,18 +440,17 @@ realm=example.org
     #permission-lifetime=300
     
     # Certificate file.
    -# Use an absolute path or path relative to the
    +# Use an absolute path or path relative to the 
     # configuration file.
    +# Use PEM file format.
     #
    -#cert=/usr/local/etc/turn_server_cert.pem
     cert=/etc/ssl/certs/cert.pem
     
     # Private key file.
    -# Use an absolute path or path relative to the
    +# Use an absolute path or path relative to the 
     # configuration file.
     # Use PEM file format.
     #
    -#pkey=/usr/local/etc/turn_server_pkey.pem
     pkey=/etc/ssl/private/privkey.pem
     
     # Private key file password, if it is in encoded format.
    @@ -471,51 +463,51 @@ pkey=/etc/ssl/private/privkey.pem
     #
     #cipher-list="DEFAULT"
     
    -# CA file in OpenSSL format.
    +# CA file in OpenSSL format. 
     # Forces TURN server to verify the client SSL certificates.
    -# By default it is not set: there is no default value and the client
    +# By default this is not set: there is no default value and the client
     # certificate is not checked.
     #
     # Example:
     #CA-file=/etc/ssh/id_rsa.cert
     
    -# Curve name for EC ciphers, if supported by OpenSSL
    -# library (TLS and DTLS). The default value is prime256v1,
    +# Curve name for EC ciphers, if supported by OpenSSL 
    +# library (TLS and DTLS). The default value is prime256v1, 
     # if pre-OpenSSL 1.0.2 is used. With OpenSSL 1.0.2+,
     # an optimal curve will be automatically calculated, if not defined
     # by this option.
     #
     #ec-curve-name=prime256v1
     
    -# Use 566 bits predefined DH TLS key. Default size of the key is 1066.
    +# Use 566 bits predefined DH TLS key. Default size of the key is 2066.
     #
     #dh566
     
    -# Use 2066 bits predefined DH TLS key. Default size of the key is 1066.
    +# Use 1066 bits predefined DH TLS key. Default size of the key is 2066.
     #
    -#dh2066
    +#dh1066
     
     # Use custom DH TLS key, stored in PEM format in the file.
     # Flags --dh566 and --dh2066 are ignored when the DH key is taken from a file.
     #
     #dh-file=<DH-PEM-file-name>
     
     # Flag to prevent stdout log messages.
    -# By default, all log messages are going to both stdout and to
    -# the configured log file. With this option everything will be
    -# going to the configured log only (unless the log file itself is stdout).
    +# By default, all log messages go to both stdout and to 
    +# the configured log file. With this option everything will 
    +# go to the configured log only (unless the log file itself is stdout).
     #
     #no-stdout-log
     
     # Option to set the log file name.
    -# By default, the turnserver tries to open a log file in
    -# /var/log, /var/tmp, /tmp and current directories directories
    -# (which open operation succeeds first that file will be used).
    +# By default, the turnserver tries to open a log file in 
    +# /var/log, /var/tmp, /tmp and the current directory
    +# (Whichever file open operation succeeds first will be used).
     # With this option you can set the definite log file name.
    -# The special names are "stdout" and "-" - they will force everything
    +# The special names are "stdout" and "-" - they will force everything 
     # to the stdout. Also, the "syslog" name will force everything to
    -# the system log (syslog).
    -# In the runtime, the logfile can be reset with the SIGHUP signal
    +# the system log (syslog). 
    +# In the runtime, the logfile can be reset with the SIGHUP signal 
     # to the turnserver process.
     #
     #log-file=/var/tmp/turn.log
    @@ -531,40 +523,40 @@ syslog
     #simple-log
     
     # Option to set the "redirection" mode. The value of this option
    -# will be the address of the alternate server for UDP & TCP service in form of
    +# will be the address of the alternate server for UDP & TCP service in the form of 
     # <ip>[:<port>]. The server will send this value in the attribute
     # ALTERNATE-SERVER, with error 300, on ALLOCATE request, to the client.
     # Client will receive only values with the same address family
    -# as the client network endpoint address family.
    -# See RFC 5389 and RFC 5766 for ALTERNATE-SERVER functionality description.
    +# as the client network endpoint address family. 
    +# See RFC 5389 and RFC 5766 for the description of ALTERNATE-SERVER functionality. 
     # The client must use the obtained value for subsequent TURN communications.
    -# If more than one --alternate-server options are provided, then the functionality
    -# can be more accurately described as "load-balancing" than a mere "redirection".
    -# If the port number is omitted, then the default port
    +# If more than one --alternate-server option is provided, then the functionality
    +# can be more accurately described as "load-balancing" than a mere "redirection". 
    +# If the port number is omitted, then the default port 
     # number 3478 for the UDP/TCP protocols will be used.
    -# Colon (:) characters in IPv6 addresses may conflict with the syntax of
    -# the option. To alleviate this conflict, literal IPv6 addresses are enclosed
    -# in square brackets in such resource identifiers, for example:
    -# [2001:db8:85a3:8d3:1319:8a2e:370:7348]:3478 .
    +# Colon (:) characters in IPv6 addresses may conflict with the syntax of 
    +# the option. To alleviate this conflict, literal IPv6 addresses are enclosed 
    +# in square brackets in such resource identifiers, for example: 
    +# [2001:db8:85a3:8d3:1319:8a2e:370:7348]:3478 . 
     # Multiple alternate servers can be set. They will be used in the
    -# round-robin manner. All servers in the pool are considered of equal weight and
    -# the load will be distributed equally. For example, if we have 4 alternate servers,
    -# then each server will receive 25% of ALLOCATE requests. A alternate TURN server
    -# address can be used more than one time with the alternate-server option, so this
    +# round-robin manner. All servers in the pool are considered of equal weight and 
    +# the load will be distributed equally. For example, if you have 4 alternate servers, 
    +# then each server will receive 25% of ALLOCATE requests. A alternate TURN server 
    +# address can be used more than one time with the alternate-server option, so this 
     # can emulate "weighting" of the servers.
     #
    -# Examples:
    +# Examples: 
     #alternate-server=1.2.3.4:5678
     #alternate-server=11.22.33.44:56789
     #alternate-server=5.6.7.8
     #alternate-server=[2001:db8:85a3:8d3:1319:8a2e:370:7348]:3478
    -
    -# Option to set alternative server for TLS & DTLS services in form of
    -# <ip>:<port>. If the port number is omitted, then the default port
    -# number 5349 for the TLS/DTLS protocols will be used. See the previous
    +			
    +# Option to set alternative server for TLS & DTLS services in form of 
    +# <ip>:<port>. If the port number is omitted, then the default port 
    +# number 5349 for the TLS/DTLS protocols will be used. See the previous 
     # option for the functionality description.
     #
    -# Examples:
    +# Examples: 
     #tls-alternate-server=1.2.3.4:5678
     #tls-alternate-server=11.22.33.44:56789
     #tls-alternate-server=[2001:db8:85a3:8d3:1319:8a2e:370:7348]:3478
    @@ -575,6 +567,15 @@ syslog
     #
     #stun-only
     
    +# Option to hide software version. Enhance security when used in production.
    +# Revealing the specific software version of the agent through the
    +# SOFTWARE attribute might allow them to become more vulnerable to
    +# attacks against software that is known to contain security holes.
    +# Implementers SHOULD make usage of the SOFTWARE attribute a
    +# configurable option (https://tools.ietf.org/html/rfc5389#section-16.1.2)
    +#
    +#no-software-attribute
    +
     # Option to suppress STUN functionality, only TURN requests will be processed.
     # Run as TURN server only, all STUN requests will be ignored.
     # By default, this option is NOT set.
    @@ -583,30 +584,37 @@ syslog
     
     # This is the timestamp/username separator symbol (character) in TURN REST API.
     # The default value is ':'.
    -# rest-api-separator=:
    +# rest-api-separator=:	
     
    -# Flag that can be used to disallow peers on the loopback addresses (127.x.x.x and ::1).
    +# Flag that can be used to allow peers on the loopback addresses (127.x.x.x and ::1).
     # This is an extra security measure.
     #
    -no-loopback-peers
    +# (To avoid any security issue that allowing loopback access may raise,
    +# the no-loopback-peers option is replaced by allow-loopback-peers.)
    +#
    +# Allow it only for testing in a development environment! 
    +# In production it adds a possible security vulnerability, so for security reasons 
    +# it is not allowed using it together with empty cli-password. 
    +#
    +#allow-loopback-peers
     
     # Flag that can be used to disallow peers on well-known broadcast addresses (224.0.0.0 and above, and FFXX:*).
     # This is an extra security measure.
     #
     #no-multicast-peers
     
    -# Option to set the max time, in seconds, allowed for full allocation establishment.
    +# Option to set the max time, in seconds, allowed for full allocation establishment. 
     # Default is 60 seconds.
     #
     #max-allocate-timeout=60
     
    -# Option to allow or ban specific ip addresses or ranges of ip addresses.
    -# If an ip address is specified as both allowed and denied, then the ip address is
    -# considered to be allowed. This is useful when you wish to ban a range of ip
    +# Option to allow or ban specific ip addresses or ranges of ip addresses. 
    +# If an ip address is specified as both allowed and denied, then the ip address is 
    +# considered to be allowed. This is useful when you wish to ban a range of ip 
     # addresses, except for a few specific ips within that range.
     #
     # This can be used when you do not want users of the turn server to be able to access
    -# machines reachable by the turn server, but would otherwise be unreachable from the
    +# machines reachable by the turn server, but would otherwise be unreachable from the 
     # internet (e.g. when the turn server is sitting behind a NAT)
     #
     # Examples:
    @@ -628,22 +636,22 @@ no-loopback-peers
     #
     #mobility
     
    -# Allocate Address Family according
    -# If enabled then TURN server allocates address family according  the TURN
    +# Allocate Address Family according 
    +# If enabled then TURN server allocates address family according  the TURN 
     # Client <=> Server communication address family.
    -# (By default coTURN works according RFC 6156.)
    +# (By default Coturn works according RFC 6156.)
     # !!Warning: Enabling this option breaks RFC6156 section-4.2 (violates use default IPv4)!!
     #
     #keep-address-family
     
     
     # User name to run the process. After the initialization, the turnserver process
    -# will make an attempt to change the current user ID to that user.
    +# will attempt to change the current user ID to that user.
     #
     #proc-user=<user-name>
     
     # Group name to run the process. After the initialization, the turnserver process
    -# will make an attempt to change the current group ID to that group.
    +# will attempt to change the current group ID to that group.
     #
     #proc-group=<group-name>
     
    @@ -663,22 +671,40 @@ cli-ip=127.0.0.1
     cli-port=5766
     
     # CLI access password. Default is empty (no password).
    -# For the security reasons, it is recommended to use the encrypted
    -# for of the password (see the -P command in the turnadmin utility).
    +# For the security reasons, it is recommended that you use the encrypted
    +# form of the password (see the -P command in the turnadmin utility).
     #
     # Secure form for password 'qwerty':
     #
     #cli-password=$5$79a316b350311570$81df9cfb9af7f5e5a76eada31e7097b663a0670f99a3c07ded3f1c8e59c5658a
     #
     # Or unsecure form for the same password:
     #
    -#cli-password=qwerty
     cli-password=CHANGE_ME
     
    -# Server relay. NON-STANDARD AND DANGEROUS OPTION.
    -# Only for those applications when we want to run
    +# Enable Web-admin support on https. By default it is Disabled.
    +# If it is enabled it also enables a http a simple static banner page
    +# with a small reminder that the admin page is available only on https.
    +#
    +#web-admin
    +
    +# Local system IP address to be used for Web-admin server endpoint. Default value is 127.0.0.1.
    +#
    +#web-admin-ip=127.0.0.1
    +
    +# Web-admin server port. Default is 8080.
    +#
    +#web-admin-port=8080
    +
    +# Web-admin server listen on STUN/TURN worker threads
    +# By default it is disabled for security resons! (Not recommended in any production environment!)
    +#
    +#web-admin-listen-on-workers
    +
    +# Server relay. NON-STANDARD AND DANGEROUS OPTION. 
    +# Only for those applications when you want to run 
     # server applications on the relay endpoints.
    -# This option eliminates the IP permissions check on
    +# This option eliminates the IP permissions check on 
     # the packets incoming to the relay endpoints.
     #
     #server-relay
    
  • docker/docker-compose-all.yml+3 3 modified
    @@ -7,7 +7,7 @@ services:
           context: ./mysql
         restart: unless-stopped
         volumes:
    -      - mysql-data:/var/lib/mysql/data
    +      - mysql-data:/var/lib/mysql
         env_file: 
           - mysql/mysql.env
         networks:
    @@ -19,7 +19,7 @@ services:
           context: ./postgresql
         restart: unless-stopped
         volumes:
    -      - postgresql-data:/var/lib/postgresql/data
    +      - postgresql-data:/var/lib/postgresql
         env_file: 
           - postgresql/postgresql.env
         networks:
    @@ -49,7 +49,7 @@ services:
           - backend
     
     
    -# coTURN
    +# Coturn
       coturn:
         build:
           context: ./coturn
    
  • docker/docker-compose-mongodb.yml+1 1 modified
    @@ -13,7 +13,7 @@ services:
           - backend
     
     
    -# coTURN
    +# Coturn
       coturn:
         build:
           context: ./coturn
    
  • docker/docker-compose-mysql.yml+1 1 modified
    @@ -14,7 +14,7 @@ services:
           - backend
     
     
    -# coTURN
    +# Coturn
       coturn:
         build:
           context: ./coturn
    
  • docker/docker-compose-postgresql.yml+1 1 modified
    @@ -14,7 +14,7 @@ services:
           - backend
     
     
    -# coTURN
    +# Coturn
       coturn:
         build:
           context: ./coturn
    
  • docker/docker-compose-redis.yml+1 1 modified
    @@ -14,7 +14,7 @@ services:
           - backend
     
     
    -# coTURN
    +# Coturn
       coturn:
         build:
           context: ./coturn
    
  • docker/README.docker+2 2 modified
    @@ -1,6 +1,6 @@
     Before you begin
    - * copy db schema run ./cp_schema.sh
    - * edit turnserver/turnserver.cfg according your db selection (mysql or postgresql or redis or mongodb)
    + * copy db schema run ./cp-schema.sh
    + * edit coturn/turnserver.conf according your db selection (mysql or postgresql or redis or mongodb)
     
     # start
     
    
  • examples/ca/CA/cacert.pem+80 0 added
    @@ -0,0 +1,80 @@
    +Certificate:
    +    Data:
    +        Version: 3 (0x2)
    +        Serial Number:
    +            4c:9b:ec:95:d1:21:49:1d:5d:65:a7:1a:61:46:67:dd:42:18:65:46
    +        Signature Algorithm: sha256WithRSAEncryption
    +        Issuer: C=HU, ST=Hungary, O=coTURN, CN=CA/emailAddress=misi@majd.eu
    +        Validity
    +            Not Before: Mar  5 09:05:10 2020 GMT
    +            Not After : Jul  7 09:05:10 3019 GMT
    +        Subject: C=HU, ST=Hungary, O=coTURN, CN=CA/emailAddress=misi@majd.eu
    +        Subject Public Key Info:
    +            Public Key Algorithm: rsaEncryption
    +                RSA Public-Key: (2048 bit)
    +                Modulus:
    +                    00:d8:76:2a:59:44:73:da:25:38:93:54:d8:c5:2b:
    +                    11:bd:30:80:21:5f:47:95:7d:eb:5e:3e:98:0d:a7:
    +                    a8:30:8c:07:6d:1a:ee:89:c1:4c:cc:64:81:90:b3:
    +                    ab:54:1f:9b:72:23:c5:2f:0a:32:52:be:27:ad:2f:
    +                    51:ee:62:9e:ed:44:d0:ba:aa:72:67:03:a2:ee:a0:
    +                    e3:5d:9e:37:ec:ee:0b:29:59:e8:d8:d5:84:a1:6d:
    +                    36:5d:85:6b:0d:73:a0:32:fe:b6:fa:99:ef:8c:78:
    +                    a9:02:f4:3a:bd:13:bc:1a:9b:72:55:0b:e7:0c:ed:
    +                    68:00:c2:e7:78:4a:df:ce:14:2a:99:f1:de:97:16:
    +                    60:44:f1:fc:f8:74:e5:33:31:cc:f9:ff:5d:9e:c1:
    +                    c7:c6:21:75:48:08:26:f5:7c:f1:56:ec:15:c5:7f:
    +                    24:0f:08:03:74:e0:da:10:bf:3d:90:67:09:1e:b2:
    +                    3f:b4:f4:15:df:53:e8:68:e8:d1:28:8e:2d:37:f9:
    +                    e0:3a:a3:29:00:3d:0a:66:7c:71:ab:54:e5:da:fe:
    +                    44:18:3c:b4:be:c5:ce:49:26:8c:cc:ab:88:8f:b7:
    +                    e3:ad:5b:df:b2:d4:a3:f8:a9:06:4f:38:6e:b7:05:
    +                    b3:3a:bd:63:cd:f7:26:15:e0:98:fd:30:7e:d3:33:
    +                    56:8d
    +                Exponent: 65537 (0x10001)
    +        X509v3 extensions:
    +            X509v3 Subject Key Identifier: 
    +                1C:27:5E:40:39:8C:EC:71:C7:ED:E9:2A:56:C9:9E:DF:48:EA:82:42
    +            X509v3 Authority Key Identifier: 
    +                keyid:1C:27:5E:40:39:8C:EC:71:C7:ED:E9:2A:56:C9:9E:DF:48:EA:82:42
    +
    +            X509v3 Basic Constraints: critical
    +                CA:TRUE
    +    Signature Algorithm: sha256WithRSAEncryption
    +         b4:d5:d9:7a:46:1e:1a:95:02:b5:7e:86:45:16:26:d5:8a:11:
    +         b9:34:98:58:df:cd:0c:d5:a5:f2:cc:24:1a:22:f4:c7:3e:50:
    +         39:40:f5:d6:e8:3b:9c:05:e9:f9:95:9b:c2:01:3b:69:d5:ba:
    +         4f:cf:7c:a6:7c:6e:f4:24:a3:d1:88:e2:29:60:ca:6d:b0:ee:
    +         a6:b8:d1:5f:49:d5:08:a6:c2:79:3a:3f:8a:63:ec:53:ef:48:
    +         00:8c:61:d2:0f:38:e0:00:ac:6d:a6:bf:ed:6a:42:c3:cf:4e:
    +         e3:0d:48:c5:a7:6d:5e:af:5a:e4:30:26:ba:19:2a:a5:57:da:
    +         ce:b7:b6:45:24:fb:36:b6:a3:6c:55:ca:9f:91:19:29:db:a4:
    +         22:d4:45:53:b9:79:6a:a7:5e:90:a3:4d:3b:c1:b6:2b:52:41:
    +         97:7d:9e:0c:cf:0a:5f:ce:0e:fe:bf:a9:e5:b7:60:17:f5:93:
    +         4b:b5:6d:2d:51:a6:c1:54:65:f9:e1:5c:21:8d:3d:19:0c:dc:
    +         2c:c9:17:40:65:15:d0:ad:98:06:a0:11:aa:87:b3:2d:03:29:
    +         37:24:f6:42:a8:d5:58:ae:55:20:c3:37:a3:62:33:36:34:73:
    +         98:bc:70:30:aa:33:b0:e4:86:b6:d9:22:79:1f:3f:68:6f:f5:
    +         66:75:e8:70
    +-----BEGIN CERTIFICATE-----
    +MIIDlzCCAn+gAwIBAgIUTJvsldEhSR1dZacaYUZn3UIYZUYwDQYJKoZIhvcNAQEL
    +BQAwWjELMAkGA1UEBhMCSFUxEDAOBgNVBAgMB0h1bmdhcnkxDzANBgNVBAoMBmNv
    +VFVSTjELMAkGA1UEAwwCQ0ExGzAZBgkqhkiG9w0BCQEWDG1pc2lAbWFqZC5ldTAg
    +Fw0yMDAzMDUwOTA1MTBaGA8zMDE5MDcwNzA5MDUxMFowWjELMAkGA1UEBhMCSFUx
    +EDAOBgNVBAgMB0h1bmdhcnkxDzANBgNVBAoMBmNvVFVSTjELMAkGA1UEAwwCQ0Ex
    +GzAZBgkqhkiG9w0BCQEWDG1pc2lAbWFqZC5ldTCCASIwDQYJKoZIhvcNAQEBBQAD
    +ggEPADCCAQoCggEBANh2KllEc9olOJNU2MUrEb0wgCFfR5V9614+mA2nqDCMB20a
    +7onBTMxkgZCzq1Qfm3IjxS8KMlK+J60vUe5inu1E0LqqcmcDou6g412eN+zuCylZ
    +6NjVhKFtNl2Faw1zoDL+tvqZ74x4qQL0Or0TvBqbclUL5wztaADC53hK384UKpnx
    +3pcWYETx/Ph05TMxzPn/XZ7Bx8YhdUgIJvV88VbsFcV/JA8IA3Tg2hC/PZBnCR6y
    +P7T0Fd9T6Gjo0SiOLTf54DqjKQA9CmZ8catU5dr+RBg8tL7FzkkmjMyriI+3461b
    +37LUo/ipBk84brcFszq9Y833JhXgmP0wftMzVo0CAwEAAaNTMFEwHQYDVR0OBBYE
    +FBwnXkA5jOxxx+3pKlbJnt9I6oJCMB8GA1UdIwQYMBaAFBwnXkA5jOxxx+3pKlbJ
    +nt9I6oJCMA8GA1UdEwEB/wQFMAMBAf8wDQYJKoZIhvcNAQELBQADggEBALTV2XpG
    +HhqVArV+hkUWJtWKEbk0mFjfzQzVpfLMJBoi9Mc+UDlA9dboO5wF6fmVm8IBO2nV
    +uk/PfKZ8bvQko9GI4ilgym2w7qa40V9J1Qimwnk6P4pj7FPvSACMYdIPOOAArG2m
    +v+1qQsPPTuMNSMWnbV6vWuQwJroZKqVX2s63tkUk+za2o2xVyp+RGSnbpCLURVO5
    +eWqnXpCjTTvBtitSQZd9ngzPCl/ODv6/qeW3YBf1k0u1bS1RpsFUZfnhXCGNPRkM
    +3CzJF0BlFdCtmAagEaqHsy0DKTck9kKo1ViuVSDDN6NiMzY0c5i8cDCqM7DkhrbZ
    +InkfP2hv9WZ16HA=
    +-----END CERTIFICATE-----
    
  • examples/ca/CA/careq.pem+17 0 added
    @@ -0,0 +1,17 @@
    +-----BEGIN CERTIFICATE REQUEST-----
    +MIICsjCCAZoCAQAwbTELMAkGA1UEBhMCSFUxEDAOBgNVBAgMB0h1bmdhcnkxETAP
    +BgNVBAcMCERlYnJlY2VuMQ8wDQYDVQQKDAZjb1RVUk4xCzAJBgNVBAMMAkNBMRsw
    +GQYJKoZIhvcNAQkBFgxtaXNpQG1hamQuZXUwggEiMA0GCSqGSIb3DQEBAQUAA4IB
    +DwAwggEKAoIBAQDYdipZRHPaJTiTVNjFKxG9MIAhX0eVfetePpgNp6gwjAdtGu6J
    +wUzMZIGQs6tUH5tyI8UvCjJSvietL1HuYp7tRNC6qnJnA6LuoONdnjfs7gspWejY
    +1YShbTZdhWsNc6Ay/rb6me+MeKkC9Dq9E7wam3JVC+cM7WgAwud4St/OFCqZ8d6X
    +FmBE8fz4dOUzMcz5/12ewcfGIXVICCb1fPFW7BXFfyQPCAN04NoQvz2QZwkesj+0
    +9BXfU+ho6NEoji03+eA6oykAPQpmfHGrVOXa/kQYPLS+xc5JJozMq4iPt+OtW9+y
    +1KP4qQZPOG63BbM6vWPN9yYV4Jj9MH7TM1aNAgMBAAGgADANBgkqhkiG9w0BAQsF
    +AAOCAQEAmvXWsoJQneJFFHb+qTNjkA3sHduyB+kQ5qUVlFoT6U6IKyWnVUqAKc9a
    +eFKw94yq/01cqOBd4MWKTg9k/wjjmkJA9WtXMrVq8HW1rKVRCCJxtzUKTR3pet/z
    +gs3YwbTlqpljtpn3qEzspMaeyvh391A4IVykDZHGR12+4LqZhoUyGl1QJ7KgQwGM
    ++Vi2TL3fY8PDxvGFmGvWnUIWYkB31vAuDz1xOqm2JlP0kTHMUPiVBlwJVuHdATy2
    +sWZEzsNnXBt2vAVwhTdFEajF4ut8guPQWW8XcTiaEOGJUIY8J4Yb2wqHk+4HsIFV
    +i2vua41jc90Ki3EA0+QDB7BJAvC4yw==
    +-----END CERTIFICATE REQUEST-----
    
  • examples/ca/CA/crlnumber+1 0 added
    @@ -0,0 +1 @@
    +01
    
  • examples/ca/CA/index.txt+3 0 added
    @@ -0,0 +1,3 @@
    +V	30190707090510Z		4C9BEC95D121491D5D65A71A614667DD42186546	unknown	/C=HU/ST=Hungary/O=coTURN/CN=CA/emailAddress=misi@majd.eu
    +V	300303090521Z		4C9BEC95D121491D5D65A71A614667DD42186547	unknown	/C=HU/ST=Hungary/L=Debrecen/O=coTURN/CN=Server/emailAddress=misi@majd.eu
    +V	300303090542Z		4C9BEC95D121491D5D65A71A614667DD42186548	unknown	/C=HU/ST=Hungary/L=Debrecen/O=coTURN/CN=Client/emailAddress=misi@majd.eu
    
  • examples/ca/CA/index.txt.attr+1 0 added
    @@ -0,0 +1 @@
    +unique_subject = yes
    
  • examples/ca/CA/index.txt.attr.old+1 0 added
    @@ -0,0 +1 @@
    +unique_subject = yes
    
  • examples/ca/CA/index.txt.old+2 0 added
    @@ -0,0 +1,2 @@
    +V	30190707090510Z		4C9BEC95D121491D5D65A71A614667DD42186546	unknown	/C=HU/ST=Hungary/O=coTURN/CN=CA/emailAddress=misi@majd.eu
    +V	300303090521Z		4C9BEC95D121491D5D65A71A614667DD42186547	unknown	/C=HU/ST=Hungary/L=Debrecen/O=coTURN/CN=Server/emailAddress=misi@majd.eu
    
  • examples/ca/CA/newcerts/4C9BEC95D121491D5D65A71A614667DD42186546.pem+80 0 added
    @@ -0,0 +1,80 @@
    +Certificate:
    +    Data:
    +        Version: 3 (0x2)
    +        Serial Number:
    +            4c:9b:ec:95:d1:21:49:1d:5d:65:a7:1a:61:46:67:dd:42:18:65:46
    +        Signature Algorithm: sha256WithRSAEncryption
    +        Issuer: C=HU, ST=Hungary, O=coTURN, CN=CA/emailAddress=misi@majd.eu
    +        Validity
    +            Not Before: Mar  5 09:05:10 2020 GMT
    +            Not After : Jul  7 09:05:10 3019 GMT
    +        Subject: C=HU, ST=Hungary, O=coTURN, CN=CA/emailAddress=misi@majd.eu
    +        Subject Public Key Info:
    +            Public Key Algorithm: rsaEncryption
    +                RSA Public-Key: (2048 bit)
    +                Modulus:
    +                    00:d8:76:2a:59:44:73:da:25:38:93:54:d8:c5:2b:
    +                    11:bd:30:80:21:5f:47:95:7d:eb:5e:3e:98:0d:a7:
    +                    a8:30:8c:07:6d:1a:ee:89:c1:4c:cc:64:81:90:b3:
    +                    ab:54:1f:9b:72:23:c5:2f:0a:32:52:be:27:ad:2f:
    +                    51:ee:62:9e:ed:44:d0:ba:aa:72:67:03:a2:ee:a0:
    +                    e3:5d:9e:37:ec:ee:0b:29:59:e8:d8:d5:84:a1:6d:
    +                    36:5d:85:6b:0d:73:a0:32:fe:b6:fa:99:ef:8c:78:
    +                    a9:02:f4:3a:bd:13:bc:1a:9b:72:55:0b:e7:0c:ed:
    +                    68:00:c2:e7:78:4a:df:ce:14:2a:99:f1:de:97:16:
    +                    60:44:f1:fc:f8:74:e5:33:31:cc:f9:ff:5d:9e:c1:
    +                    c7:c6:21:75:48:08:26:f5:7c:f1:56:ec:15:c5:7f:
    +                    24:0f:08:03:74:e0:da:10:bf:3d:90:67:09:1e:b2:
    +                    3f:b4:f4:15:df:53:e8:68:e8:d1:28:8e:2d:37:f9:
    +                    e0:3a:a3:29:00:3d:0a:66:7c:71:ab:54:e5:da:fe:
    +                    44:18:3c:b4:be:c5:ce:49:26:8c:cc:ab:88:8f:b7:
    +                    e3:ad:5b:df:b2:d4:a3:f8:a9:06:4f:38:6e:b7:05:
    +                    b3:3a:bd:63:cd:f7:26:15:e0:98:fd:30:7e:d3:33:
    +                    56:8d
    +                Exponent: 65537 (0x10001)
    +        X509v3 extensions:
    +            X509v3 Subject Key Identifier: 
    +                1C:27:5E:40:39:8C:EC:71:C7:ED:E9:2A:56:C9:9E:DF:48:EA:82:42
    +            X509v3 Authority Key Identifier: 
    +                keyid:1C:27:5E:40:39:8C:EC:71:C7:ED:E9:2A:56:C9:9E:DF:48:EA:82:42
    +
    +            X509v3 Basic Constraints: critical
    +                CA:TRUE
    +    Signature Algorithm: sha256WithRSAEncryption
    +         b4:d5:d9:7a:46:1e:1a:95:02:b5:7e:86:45:16:26:d5:8a:11:
    +         b9:34:98:58:df:cd:0c:d5:a5:f2:cc:24:1a:22:f4:c7:3e:50:
    +         39:40:f5:d6:e8:3b:9c:05:e9:f9:95:9b:c2:01:3b:69:d5:ba:
    +         4f:cf:7c:a6:7c:6e:f4:24:a3:d1:88:e2:29:60:ca:6d:b0:ee:
    +         a6:b8:d1:5f:49:d5:08:a6:c2:79:3a:3f:8a:63:ec:53:ef:48:
    +         00:8c:61:d2:0f:38:e0:00:ac:6d:a6:bf:ed:6a:42:c3:cf:4e:
    +         e3:0d:48:c5:a7:6d:5e:af:5a:e4:30:26:ba:19:2a:a5:57:da:
    +         ce:b7:b6:45:24:fb:36:b6:a3:6c:55:ca:9f:91:19:29:db:a4:
    +         22:d4:45:53:b9:79:6a:a7:5e:90:a3:4d:3b:c1:b6:2b:52:41:
    +         97:7d:9e:0c:cf:0a:5f:ce:0e:fe:bf:a9:e5:b7:60:17:f5:93:
    +         4b:b5:6d:2d:51:a6:c1:54:65:f9:e1:5c:21:8d:3d:19:0c:dc:
    +         2c:c9:17:40:65:15:d0:ad:98:06:a0:11:aa:87:b3:2d:03:29:
    +         37:24:f6:42:a8:d5:58:ae:55:20:c3:37:a3:62:33:36:34:73:
    +         98:bc:70:30:aa:33:b0:e4:86:b6:d9:22:79:1f:3f:68:6f:f5:
    +         66:75:e8:70
    +-----BEGIN CERTIFICATE-----
    +MIIDlzCCAn+gAwIBAgIUTJvsldEhSR1dZacaYUZn3UIYZUYwDQYJKoZIhvcNAQEL
    +BQAwWjELMAkGA1UEBhMCSFUxEDAOBgNVBAgMB0h1bmdhcnkxDzANBgNVBAoMBmNv
    +VFVSTjELMAkGA1UEAwwCQ0ExGzAZBgkqhkiG9w0BCQEWDG1pc2lAbWFqZC5ldTAg
    +Fw0yMDAzMDUwOTA1MTBaGA8zMDE5MDcwNzA5MDUxMFowWjELMAkGA1UEBhMCSFUx
    +EDAOBgNVBAgMB0h1bmdhcnkxDzANBgNVBAoMBmNvVFVSTjELMAkGA1UEAwwCQ0Ex
    +GzAZBgkqhkiG9w0BCQEWDG1pc2lAbWFqZC5ldTCCASIwDQYJKoZIhvcNAQEBBQAD
    +ggEPADCCAQoCggEBANh2KllEc9olOJNU2MUrEb0wgCFfR5V9614+mA2nqDCMB20a
    +7onBTMxkgZCzq1Qfm3IjxS8KMlK+J60vUe5inu1E0LqqcmcDou6g412eN+zuCylZ
    +6NjVhKFtNl2Faw1zoDL+tvqZ74x4qQL0Or0TvBqbclUL5wztaADC53hK384UKpnx
    +3pcWYETx/Ph05TMxzPn/XZ7Bx8YhdUgIJvV88VbsFcV/JA8IA3Tg2hC/PZBnCR6y
    +P7T0Fd9T6Gjo0SiOLTf54DqjKQA9CmZ8catU5dr+RBg8tL7FzkkmjMyriI+3461b
    +37LUo/ipBk84brcFszq9Y833JhXgmP0wftMzVo0CAwEAAaNTMFEwHQYDVR0OBBYE
    +FBwnXkA5jOxxx+3pKlbJnt9I6oJCMB8GA1UdIwQYMBaAFBwnXkA5jOxxx+3pKlbJ
    +nt9I6oJCMA8GA1UdEwEB/wQFMAMBAf8wDQYJKoZIhvcNAQELBQADggEBALTV2XpG
    +HhqVArV+hkUWJtWKEbk0mFjfzQzVpfLMJBoi9Mc+UDlA9dboO5wF6fmVm8IBO2nV
    +uk/PfKZ8bvQko9GI4ilgym2w7qa40V9J1Qimwnk6P4pj7FPvSACMYdIPOOAArG2m
    +v+1qQsPPTuMNSMWnbV6vWuQwJroZKqVX2s63tkUk+za2o2xVyp+RGSnbpCLURVO5
    +eWqnXpCjTTvBtitSQZd9ngzPCl/ODv6/qeW3YBf1k0u1bS1RpsFUZfnhXCGNPRkM
    +3CzJF0BlFdCtmAagEaqHsy0DKTck9kKo1ViuVSDDN6NiMzY0c5i8cDCqM7DkhrbZ
    +InkfP2hv9WZ16HA=
    +-----END CERTIFICATE-----
    
  • examples/ca/CA/newcerts/4C9BEC95D121491D5D65A71A614667DD42186547.pem+80 0 added
    @@ -0,0 +1,80 @@
    +Certificate:
    +    Data:
    +        Version: 3 (0x2)
    +        Serial Number:
    +            4c:9b:ec:95:d1:21:49:1d:5d:65:a7:1a:61:46:67:dd:42:18:65:47
    +        Signature Algorithm: sha256WithRSAEncryption
    +        Issuer: C=HU, ST=Hungary, O=coTURN, CN=CA/emailAddress=misi@majd.eu
    +        Validity
    +            Not Before: Mar  5 09:05:21 2020 GMT
    +            Not After : Mar  3 09:05:21 2030 GMT
    +        Subject: C=HU, ST=Hungary, L=Debrecen, O=coTURN, CN=Server/emailAddress=misi@majd.eu
    +        Subject Public Key Info:
    +            Public Key Algorithm: rsaEncryption
    +                RSA Public-Key: (2048 bit)
    +                Modulus:
    +                    00:bc:db:f7:17:35:17:7c:46:79:64:89:61:5f:ac:
    +                    cf:8f:6d:97:13:87:8a:d6:f1:ab:df:f6:69:4e:04:
    +                    57:c1:4d:6c:3d:77:c9:50:0d:3d:b6:89:cd:ac:00:
    +                    b5:02:45:e4:4c:78:ef:6f:18:7e:57:4e:bc:62:4d:
    +                    f6:de:6c:c8:77:ea:c5:b2:b4:65:2d:46:76:bf:5e:
    +                    5f:f8:45:78:55:f4:4d:20:ac:91:f0:4f:23:cb:5d:
    +                    40:29:44:de:9c:f7:0a:e6:48:a4:80:35:dd:cb:e8:
    +                    02:90:59:f7:31:f9:4c:50:fe:98:ef:dd:7f:60:51:
    +                    2d:44:0a:14:a2:57:96:51:36:3f:73:66:db:45:5f:
    +                    bd:9d:f4:82:3a:ce:ab:75:4f:d0:90:6d:43:d1:7b:
    +                    2f:77:31:88:db:2f:4a:a9:4e:62:39:c7:14:7f:39:
    +                    ef:e2:08:b7:18:a7:6c:f8:d9:35:d5:a3:f8:64:f5:
    +                    02:51:22:1b:8e:7a:c5:44:ae:df:b1:17:0b:71:df:
    +                    09:82:89:49:70:c5:9b:a0:f3:3c:02:48:75:e7:81:
    +                    f9:24:51:56:24:3b:ff:b8:68:d3:13:2e:a2:f4:d1:
    +                    70:33:a9:7a:d6:17:fd:ca:a5:6b:13:74:c9:ce:b6:
    +                    26:4f:01:ff:eb:ba:b5:f9:a1:70:80:da:11:df:a3:
    +                    7b:4f
    +                Exponent: 65537 (0x10001)
    +        X509v3 extensions:
    +            X509v3 Subject Key Identifier: 
    +                38:C1:E5:77:D3:01:6B:7A:A7:D8:18:6B:50:D6:FA:0E:D6:D9:B4:4F
    +            X509v3 Authority Key Identifier: 
    +                keyid:1C:27:5E:40:39:8C:EC:71:C7:ED:E9:2A:56:C9:9E:DF:48:EA:82:42
    +
    +            X509v3 Basic Constraints: critical
    +                CA:TRUE
    +    Signature Algorithm: sha256WithRSAEncryption
    +         a3:37:55:68:68:02:9f:af:d6:b1:38:b3:d8:bf:30:27:33:6f:
    +         21:4c:09:ee:cf:24:d2:eb:cf:1c:7a:15:98:6d:10:94:e0:4a:
    +         1f:88:5c:43:90:09:78:c1:a6:82:06:16:f2:8c:d1:3a:c5:3b:
    +         99:67:35:3c:00:bf:9f:a2:6a:e7:33:85:83:88:72:88:e4:d2:
    +         83:1c:6c:49:92:5f:51:80:0d:92:0f:99:4d:cb:2a:18:4d:68:
    +         b7:b6:d1:de:54:22:71:88:8d:04:45:c5:13:34:8d:52:7a:f7:
    +         2a:e7:cb:b2:41:20:7b:ef:aa:d0:58:93:b5:e6:b5:fa:8b:22:
    +         a3:ed:a7:81:9b:ca:50:f7:d0:bd:5f:f2:52:6d:8b:af:af:64:
    +         36:9d:6d:81:ce:50:29:b7:db:d0:ac:a3:1d:78:77:90:29:a3:
    +         84:10:69:13:e9:47:fc:e1:1e:c2:74:55:61:11:65:2d:77:e1:
    +         ca:9f:2d:6f:2f:76:f6:69:bc:09:50:9a:b0:48:05:a2:53:e6:
    +         93:46:81:0d:04:8b:cd:fb:a4:a7:82:08:78:f9:87:dc:0a:07:
    +         91:1f:de:09:fa:00:5a:16:1a:2b:5c:83:10:03:33:2f:ad:8c:
    +         9a:eb:94:0f:77:b1:9b:ec:e6:0e:dc:84:dd:35:3f:b5:8a:d2:
    +         06:0e:88:d7
    +-----BEGIN CERTIFICATE-----
    +MIIDrDCCApSgAwIBAgIUTJvsldEhSR1dZacaYUZn3UIYZUcwDQYJKoZIhvcNAQEL
    +BQAwWjELMAkGA1UEBhMCSFUxEDAOBgNVBAgMB0h1bmdhcnkxDzANBgNVBAoMBmNv
    +VFVSTjELMAkGA1UEAwwCQ0ExGzAZBgkqhkiG9w0BCQEWDG1pc2lAbWFqZC5ldTAe
    +Fw0yMDAzMDUwOTA1MjFaFw0zMDAzMDMwOTA1MjFaMHExCzAJBgNVBAYTAkhVMRAw
    +DgYDVQQIDAdIdW5nYXJ5MREwDwYDVQQHDAhEZWJyZWNlbjEPMA0GA1UECgwGY29U
    +VVJOMQ8wDQYDVQQDDAZTZXJ2ZXIxGzAZBgkqhkiG9w0BCQEWDG1pc2lAbWFqZC5l
    +dTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBALzb9xc1F3xGeWSJYV+s
    +z49tlxOHitbxq9/2aU4EV8FNbD13yVANPbaJzawAtQJF5Ex4728YfldOvGJN9t5s
    +yHfqxbK0ZS1Gdr9eX/hFeFX0TSCskfBPI8tdQClE3pz3CuZIpIA13cvoApBZ9zH5
    +TFD+mO/df2BRLUQKFKJXllE2P3Nm20VfvZ30gjrOq3VP0JBtQ9F7L3cxiNsvSqlO
    +YjnHFH857+IItxinbPjZNdWj+GT1AlEiG456xUSu37EXC3HfCYKJSXDFm6DzPAJI
    +deeB+SRRViQ7/7ho0xMuovTRcDOpetYX/cqlaxN0yc62Jk8B/+u6tfmhcIDaEd+j
    +e08CAwEAAaNTMFEwHQYDVR0OBBYEFDjB5XfTAWt6p9gYa1DW+g7W2bRPMB8GA1Ud
    +IwQYMBaAFBwnXkA5jOxxx+3pKlbJnt9I6oJCMA8GA1UdEwEB/wQFMAMBAf8wDQYJ
    +KoZIhvcNAQELBQADggEBAKM3VWhoAp+v1rE4s9i/MCczbyFMCe7PJNLrzxx6FZht
    +EJTgSh+IXEOQCXjBpoIGFvKM0TrFO5lnNTwAv5+iauczhYOIcojk0oMcbEmSX1GA
    +DZIPmU3LKhhNaLe20d5UInGIjQRFxRM0jVJ69yrny7JBIHvvqtBYk7XmtfqLIqPt
    +p4GbylD30L1f8lJti6+vZDadbYHOUCm329Csox14d5Apo4QQaRPpR/zhHsJ0VWER
    +ZS134cqfLW8vdvZpvAlQmrBIBaJT5pNGgQ0Ei837pKeCCHj5h9wKB5Ef3gn6AFoW
    +GitcgxADMy+tjJrrlA93sZvs5g7chN01P7WK0gYOiNc=
    +-----END CERTIFICATE-----
    
  • examples/ca/CA/newcerts/4C9BEC95D121491D5D65A71A614667DD42186548.pem+80 0 added
    @@ -0,0 +1,80 @@
    +Certificate:
    +    Data:
    +        Version: 3 (0x2)
    +        Serial Number:
    +            4c:9b:ec:95:d1:21:49:1d:5d:65:a7:1a:61:46:67:dd:42:18:65:48
    +        Signature Algorithm: sha256WithRSAEncryption
    +        Issuer: C=HU, ST=Hungary, O=coTURN, CN=CA/emailAddress=misi@majd.eu
    +        Validity
    +            Not Before: Mar  5 09:05:42 2020 GMT
    +            Not After : Mar  3 09:05:42 2030 GMT
    +        Subject: C=HU, ST=Hungary, L=Debrecen, O=coTURN, CN=Client/emailAddress=misi@majd.eu
    +        Subject Public Key Info:
    +            Public Key Algorithm: rsaEncryption
    +                RSA Public-Key: (2048 bit)
    +                Modulus:
    +                    00:af:6d:38:31:23:12:12:e7:5a:8d:ed:1c:02:7e:
    +                    bf:c2:ef:7a:d1:c0:b2:4b:b4:38:9b:a7:5d:dd:01:
    +                    2c:a0:e7:7c:5b:7a:4d:71:4b:c9:5b:77:e8:b3:4c:
    +                    92:5b:8c:43:57:b6:c9:8c:44:66:6a:9e:8c:f2:76:
    +                    58:a2:f5:38:a3:4f:ef:af:5a:c7:bf:e5:72:98:c0:
    +                    b8:2e:a1:75:cc:16:8b:bf:a3:6a:e6:fd:c9:25:35:
    +                    92:31:b2:78:2a:42:7b:a1:ce:25:be:32:45:6e:0b:
    +                    36:22:f8:6c:9c:f3:8f:bf:c8:8c:79:d5:59:02:f5:
    +                    de:1f:67:fc:ef:c7:27:88:a7:35:b1:d7:ee:dc:1c:
    +                    74:11:fc:3c:56:33:b5:e7:88:ce:f3:ce:db:b9:3c:
    +                    e0:eb:15:bc:00:5f:29:f4:9c:8e:4d:61:df:da:aa:
    +                    f4:fc:fb:e7:4b:75:dc:dc:cf:f0:4b:3b:67:cf:bf:
    +                    35:b8:0f:5b:20:94:60:dd:3b:e5:7a:ec:0e:30:2c:
    +                    c1:fb:f6:21:5b:ed:80:34:9d:59:5c:95:39:a2:61:
    +                    a4:13:fa:57:b9:f5:85:d4:a1:bf:91:cf:d7:dc:ac:
    +                    fa:32:47:ee:d2:86:9b:14:d1:35:88:1e:2d:9f:39:
    +                    74:86:de:f1:04:de:e1:39:2f:a8:91:bf:8b:f7:4f:
    +                    7c:e5
    +                Exponent: 65537 (0x10001)
    +        X509v3 extensions:
    +            X509v3 Subject Key Identifier: 
    +                32:BA:14:26:42:B6:5B:9E:3C:F1:53:1A:FD:DB:CB:FE:B1:A2:74:6C
    +            X509v3 Authority Key Identifier: 
    +                keyid:1C:27:5E:40:39:8C:EC:71:C7:ED:E9:2A:56:C9:9E:DF:48:EA:82:42
    +
    +            X509v3 Basic Constraints: critical
    +                CA:TRUE
    +    Signature Algorithm: sha256WithRSAEncryption
    +         6b:93:56:56:81:fb:34:9e:15:2e:3e:b2:2c:73:72:60:f2:1a:
    +         a8:bf:c3:f0:c7:57:00:48:37:2a:1c:63:71:1b:29:f4:2b:dc:
    +         64:07:f8:72:80:65:18:c7:74:23:c1:02:00:d8:93:1d:4f:2b:
    +         8c:46:34:1e:d2:6a:5c:ab:8d:ff:a7:fe:e5:c2:bf:33:55:ea:
    +         2b:e2:70:e9:24:4c:4d:31:d4:dd:10:55:f5:bb:2c:a5:ec:f6:
    +         8f:7a:05:1c:6c:7d:cf:85:6b:29:a7:bd:fe:a2:bc:00:45:b8:
    +         ac:70:c7:c9:67:93:0a:5c:d7:52:a3:c9:fc:6c:ef:52:b2:6b:
    +         bc:5b:f9:e1:9b:27:07:39:28:28:7f:a0:70:62:af:4f:42:82:
    +         dd:ec:23:4d:fc:8e:19:51:87:cc:d0:29:d5:27:44:9c:fa:b5:
    +         51:ea:31:eb:51:84:3f:07:5b:c0:57:5d:2a:c7:15:ed:9c:46:
    +         ac:8e:14:8b:4d:82:0e:b4:6a:47:db:37:f3:03:08:86:b6:25:
    +         0b:92:6d:99:a9:99:45:4e:38:45:e0:a2:4e:e7:34:50:51:ab:
    +         f8:c8:ef:26:3d:7f:9f:8f:45:20:cf:f5:31:27:b6:00:3a:e0:
    +         4a:d5:62:9a:29:27:9b:aa:3a:95:56:1c:d7:65:15:ce:35:10:
    +         2a:7e:cc:b6
    +-----BEGIN CERTIFICATE-----
    +MIIDrDCCApSgAwIBAgIUTJvsldEhSR1dZacaYUZn3UIYZUgwDQYJKoZIhvcNAQEL
    +BQAwWjELMAkGA1UEBhMCSFUxEDAOBgNVBAgMB0h1bmdhcnkxDzANBgNVBAoMBmNv
    +VFVSTjELMAkGA1UEAwwCQ0ExGzAZBgkqhkiG9w0BCQEWDG1pc2lAbWFqZC5ldTAe
    +Fw0yMDAzMDUwOTA1NDJaFw0zMDAzMDMwOTA1NDJaMHExCzAJBgNVBAYTAkhVMRAw
    +DgYDVQQIDAdIdW5nYXJ5MREwDwYDVQQHDAhEZWJyZWNlbjEPMA0GA1UECgwGY29U
    +VVJOMQ8wDQYDVQQDDAZDbGllbnQxGzAZBgkqhkiG9w0BCQEWDG1pc2lAbWFqZC5l
    +dTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAK9tODEjEhLnWo3tHAJ+
    +v8LvetHAsku0OJunXd0BLKDnfFt6TXFLyVt36LNMkluMQ1e2yYxEZmqejPJ2WKL1
    +OKNP769ax7/lcpjAuC6hdcwWi7+jaub9ySU1kjGyeCpCe6HOJb4yRW4LNiL4bJzz
    +j7/IjHnVWQL13h9n/O/HJ4inNbHX7twcdBH8PFYzteeIzvPO27k84OsVvABfKfSc
    +jk1h39qq9Pz750t13NzP8Es7Z8+/NbgPWyCUYN075XrsDjAswfv2IVvtgDSdWVyV
    +OaJhpBP6V7n1hdShv5HP19ys+jJH7tKGmxTRNYgeLZ85dIbe8QTe4TkvqJG/i/dP
    +fOUCAwEAAaNTMFEwHQYDVR0OBBYEFDK6FCZCtluePPFTGv3by/6xonRsMB8GA1Ud
    +IwQYMBaAFBwnXkA5jOxxx+3pKlbJnt9I6oJCMA8GA1UdEwEB/wQFMAMBAf8wDQYJ
    +KoZIhvcNAQELBQADggEBAGuTVlaB+zSeFS4+sixzcmDyGqi/w/DHVwBINyocY3Eb
    +KfQr3GQH+HKAZRjHdCPBAgDYkx1PK4xGNB7Salyrjf+n/uXCvzNV6ivicOkkTE0x
    +1N0QVfW7LKXs9o96BRxsfc+Faymnvf6ivABFuKxwx8lnkwpc11Kjyfxs71Kya7xb
    ++eGbJwc5KCh/oHBir09Cgt3sI038jhlRh8zQKdUnRJz6tVHqMetRhD8HW8BXXSrH
    +Fe2cRqyOFItNgg60akfbN/MDCIa2JQuSbZmpmUVOOEXgok7nNFBRq/jI7yY9f5+P
    +RSDP9TEntgA64ErVYpopJ5uqOpVWHNdlFc41ECp+zLY=
    +-----END CERTIFICATE-----
    
  • examples/ca/CA.pl.diff+22 0 added
    @@ -0,0 +1,22 @@
    +--- CA.pl	2019-10-12 19:56:43.000000000 +0000
    ++++ CA.pl	2020-03-05 07:58:41.112690266 +0000
    +@@ -25,8 +25,8 @@
    + my $verbose = 1;
    + 
    + my $OPENSSL_CONFIG = $ENV{"OPENSSL_CONFIG"} || "";
    +-my $DAYS = "-days 365";
    +-my $CADAYS = "-days 1095";	# 3 years
    ++my $DAYS = "-days 36500";
    ++my $CADAYS = "-days 365000";	# 1000 years
    + my $REQ = "$openssl req $OPENSSL_CONFIG";
    + my $CA = "$openssl ca $OPENSSL_CONFIG";
    + my $VERIFY = "$openssl verify";
    +@@ -34,7 +34,7 @@
    + my $PKCS12 = "$openssl pkcs12";
    + 
    + # default openssl.cnf file has setup as per the following
    +-my $CATOP = "./demoCA";
    ++my $CATOP = "./CA";
    + my $CAKEY = "cakey.pem";
    + my $CAREQ = "careq.pem";
    + my $CACERT = "cacert.pem";
    
  • examples/ca/CA/private/cakey.pem+30 0 added
    @@ -0,0 +1,30 @@
    +-----BEGIN ENCRYPTED PRIVATE KEY-----
    +MIIFHDBOBgkqhkiG9w0BBQ0wQTApBgkqhkiG9w0BBQwwHAQIeK2OY7PJbzYCAggA
    +MAwGCCqGSIb3DQIJBQAwFAYIKoZIhvcNAwcECKP+q72oc4q7BIIEyHkaZfqjSX9W
    +HIHqbQtHOMlAtqSxmAyV6C3pXLwNuEpo4cYwyPUdJwMNxm8OjsxuH708daZu5QWl
    +7EVNV4WY9ff4/4geJAp9ZrqJN5TsgFIUyss5NzHjTMPUz/yunr0Hk5OOVLusTCqF
    +Ys0Qdo2Gy33NZCK53U22pa0S/szppN4DIDujSOuUAiyxJdz12cCUyw/OlAXvDLJb
    +I9oObKWpbYBtJSLk5aWblZDUTVmFWngkTIc76wchBXu7WntLjXdMG2lv4Gy/ozUb
    +vsYvEADNRJFOpYyfWvmEFNKvEcVxfzshnms9TdzhDCmYhmYR+NfamYq5Om+81Pv3
    +h+z1Zd7x3uYs8NM+DbRKhwHS6jkQCxelWdQbeSJj/Fz9VpWSrJlkmhXI+7qkBCsv
    +DVoz017Y2zK/iM5JRPTH65tnNMeH61Zj4EOHBEzMBE6EvugJcSqPXfBKtVMwVAzV
    +Mva8gtOlMN0Ce9dmG+HZKDek6S++5AbkxuOwRb+YOVXjUrNXXf0YqglM9Nb/RCr4
    +Z+gkuTCwARJZqjebZnUw1mSZp2R89X774wNDHAlw96tSW2OZlfPmbvXBnwT7QwPm
    +YBZT6CrLL7LEIs0G5zFh1L/PCQi7EyNaE9Ixw52nqc5Ej2M6Rj6XcdCRdw5IKmh/
    +BbTzD0LxfNh+XKpAIzkuNfGkwUVtfldmfpW3xRKzI1o+rbgDGMA/eEFYWmyE9326
    +/vsv7daE4zWAG4O5OdGKMKBABCqM92X2YU7bZoNQS25dy7uZsQ8zvkcI1Q1GKMW0
    +Lg2oDTSTSrPRVgLAcb0o06Frvler5F277OBfBm1+6+7aL3hct4TZjb+0pp5SuxrS
    +7PpRXMFYzbQ+Z7YrRv6uwrrxVl99Ok/jBGLYT+CllZ+PNvRbcgsy0xUIz6KTbQQZ
    +H4qqkObdKFHQLqfP9+YUwjE2akR/prOR2Dfoq648L/eEF4qpGCADaXFoHODWfiqz
    +VQHvLP4FN4ppYn3jB4lSTIl+7s92XznK5aN5AERRdUIfjPnZB8lQkDP/qwwCI0Ki
    +SRxUtsrMef1biTKL5HI3On2wPLFQCGVEmiQoD8uEqaB/vAdJy5ZdQ3HA547TxLmy
    +TJ6je8QMFUcO3n1pJWeUHuL+WyGrcstOEkZiFQyVpAFFeS7h6u2UI7HyNXGaP1mk
    ++vWulewlMjWHw05qG9wLqEiDkpZgmx4garfWbR2rggBu1Jlg4svS2jdmytuKQ735
    +E1e5g7TCSzv6sHzdHfQ2WaVvfM5YfxqWpgPhNH2t7rScoLTvI2txyhpIIEIMn+ip
    +tBM15Ai+L92gr4wLJlsBOcKOWSN46ucqQsGla3so0PZAtU4hVPEJ+PzaR2czStUk
    +MzrKfG1qox+JW8BBiW2zV2idKy2440Sn/NSqMyvZgEFn7GDaAcTsZi2FhRLT1Fg+
    +2c5viBTaCRdh20QDQQu3skEhbFU5GjeZEqCO25hX5L3BZPnQtwQujc2RU9aGWwPm
    +o/nrp8ilBRI18qFdxfqFEV6ftdVNXlrV+cMgtuwPNX6vnmKWjN67/cDIUML3ab+e
    +9cx0rBvCBvMn7Q0AvY/RcsVP0DaLmov7ciuvih0ptCgYThov7FJ2V+q+2LbNLwSc
    +qpi/6R+l6bIjP0UITKZlug==
    +-----END ENCRYPTED PRIVATE KEY-----
    
  • examples/ca/CA/serial+1 0 added
    @@ -0,0 +1 @@
    +4C9BEC95D121491D5D65A71A614667DD42186549
    
  • examples/ca/CA/serial.old+1 0 added
    @@ -0,0 +1 @@
    +4C9BEC95D121491D5D65A71A614667DD42186548
    
  • examples/ca/openssl.conf+364 0 added
    @@ -0,0 +1,364 @@
    +#
    +# OpenSSL example configuration file.
    +# This is mostly being used for generation of certificate requests.
    +#
    +
    +# Note that you can include other files from the main configuration
    +# file using the .include directive.
    +#.include filename
    +
    +# This definition stops the following lines choking if HOME isn't
    +# defined.
    +HOME			= .
    +
    +# Extra OBJECT IDENTIFIER info:
    +#oid_file		= $ENV::HOME/.oid
    +oid_section		= new_oids
    +
    +# System default
    +openssl_conf = default_conf
    +
    +# To use this configuration file with the "-extfile" option of the
    +# "openssl x509" utility, name here the section containing the
    +# X.509v3 extensions to use:
    +# extensions		=
    +# (Alternatively, use a configuration file that has only
    +# X.509v3 extensions in its main [= default] section.)
    +
    +[ new_oids ]
    +
    +# We can add new OIDs in here for use by 'ca', 'req' and 'ts'.
    +# Add a simple OID like this:
    +# testoid1=1.2.3.4
    +# Or use config file substitution like this:
    +# testoid2=${testoid1}.5.6
    +
    +# Policies used by the TSA examples.
    +tsa_policy1 = 1.2.3.4.1
    +tsa_policy2 = 1.2.3.4.5.6
    +tsa_policy3 = 1.2.3.4.5.7
    +
    +####################################################################
    +[ ca ]
    +default_ca	= CA_default		# The default ca section
    +
    +####################################################################
    +[ CA_default ]
    +
    +dir		= ./CA		# Where everything is kept
    +certs		= $dir/certs		# Where the issued certs are kept
    +crl_dir		= $dir/crl		# Where the issued crl are kept
    +database	= $dir/index.txt	# database index file.
    +#unique_subject	= no			# Set to 'no' to allow creation of
    +					# several certs with same subject.
    +new_certs_dir	= $dir/newcerts		# default place for new certs.
    +
    +certificate	= $dir/cacert.pem 	# The CA certificate
    +serial		= $dir/serial 		# The current serial number
    +crlnumber	= $dir/crlnumber	# the current crl number
    +					# must be commented out to leave a V1 CRL
    +crl		= $dir/crl.pem 		# The current CRL
    +private_key	= $dir/private/cakey.pem# The private key
    +
    +x509_extensions	= usr_cert		# The extensions to add to the cert
    +
    +# Comment out the following two lines for the "traditional"
    +# (and highly broken) format.
    +name_opt 	= ca_default		# Subject Name options
    +cert_opt 	= ca_default		# Certificate field options
    +
    +# Extension copying option: use with caution.
    +# copy_extensions = copy
    +
    +# Extensions to add to a CRL. Note: Netscape communicator chokes on V2 CRLs
    +# so this is commented out by default to leave a V1 CRL.
    +# crlnumber must also be commented out to leave a V1 CRL.
    +# crl_extensions	= crl_ext
    +
    +default_days	= 3650			# how long to certify for
    +default_crl_days= 30			# how long before next CRL
    +default_md	= default		# use public key default MD
    +preserve	= no			# keep passed DN ordering
    +
    +# A few difference way of specifying how similar the request should look
    +# For type CA, the listed attributes must be the same, and the optional
    +# and supplied fields are just that :-)
    +policy		= policy_match
    +
    +# For the CA policy
    +[ policy_match ]
    +countryName		= match
    +stateOrProvinceName	= match
    +organizationName	= match
    +organizationalUnitName	= optional
    +commonName		= supplied
    +emailAddress		= optional
    +
    +# For the 'anything' policy
    +# At this point in time, you must list all acceptable 'object'
    +# types.
    +[ policy_anything ]
    +countryName		= optional
    +stateOrProvinceName	= optional
    +localityName		= optional
    +organizationName	= optional
    +organizationalUnitName	= optional
    +commonName		= supplied
    +emailAddress		= optional
    +
    +####################################################################
    +[ req ]
    +default_bits		= 2048
    +default_keyfile 	= privkey.pem
    +distinguished_name	= req_distinguished_name
    +attributes		= req_attributes
    +x509_extensions	= v3_ca	# The extensions to add to the self signed cert
    +
    +# Passwords for private keys if not present they will be prompted for
    +# input_password = secret
    +# output_password = secret
    +
    +# This sets a mask for permitted string types. There are several options.
    +# default: PrintableString, T61String, BMPString.
    +# pkix	 : PrintableString, BMPString (PKIX recommendation before 2004)
    +# utf8only: only UTF8Strings (PKIX recommendation after 2004).
    +# nombstr : PrintableString, T61String (no BMPStrings or UTF8Strings).
    +# MASK:XXXX a literal mask value.
    +# WARNING: ancient versions of Netscape crash on BMPStrings or UTF8Strings.
    +string_mask = utf8only
    +
    +# req_extensions = v3_req # The extensions to add to a certificate request
    +
    +[ req_distinguished_name ]
    +countryName			= Country Name (2 letter code)
    +countryName_default		= HU
    +countryName_min			= 2
    +countryName_max			= 2
    +
    +stateOrProvinceName		= State or Province Name (full name)
    +stateOrProvinceName_default	= Hungary
    +
    +localityName			= Locality Name (eg, city)
    +localityName_default		= Debrecen
    +
    +0.organizationName		= Organization Name (eg, company)
    +0.organizationName_default	= coTURN
    +
    +# we can do this but it is not needed normally :-)
    +#1.organizationName		= Second Organization Name (eg, company)
    +#1.organizationName_default	= World Wide Web Pty Ltd
    +
    +#organizationalUnitName		= Organizational Unit Name (eg, section)
    +#organizationalUnitName_default	=
    +
    +commonName			= Common Name (e.g. server FQDN or YOUR name)
    +commonName_max			= 64
    +
    +emailAddress			= Email Address
    +emailAddress_default		= misi@majd.eu
    +emailAddress_max		= 64
    +
    +# SET-ex3			= SET extension number 3
    +
    +[ req_attributes ]
    +#challengePassword		= A challenge password
    +#challengePassword_min		= 4
    +#challengePassword_max		= 20
    +
    +#unstructuredName		= An optional company name
    +
    +[ usr_cert ]
    +
    +# These extensions are added when 'ca' signs a request.
    +
    +# This goes against PKIX guidelines but some CAs do it and some software
    +# requires this to avoid interpreting an end user certificate as a CA.
    +
    +basicConstraints=CA:FALSE
    +
    +# Here are some examples of the usage of nsCertType. If it is omitted
    +# the certificate can be used for anything *except* object signing.
    +
    +# This is OK for an SSL server.
    +# nsCertType			= server
    +
    +# For an object signing certificate this would be used.
    +# nsCertType = objsign
    +
    +# For normal client use this is typical
    +# nsCertType = client, email
    +
    +# and for everything including object signing:
    +# nsCertType = client, email, objsign
    +
    +# This is typical in keyUsage for a client certificate.
    +# keyUsage = nonRepudiation, digitalSignature, keyEncipherment
    +
    +# This will be displayed in Netscape's comment listbox.
    +nsComment			= "OpenSSL Generated Certificate"
    +
    +# PKIX recommendations harmless if included in all certificates.
    +subjectKeyIdentifier=hash
    +authorityKeyIdentifier=keyid,issuer
    +
    +# This stuff is for subjectAltName and issuerAltname.
    +# Import the email address.
    +# subjectAltName=email:copy
    +# An alternative to produce certificates that aren't
    +# deprecated according to PKIX.
    +# subjectAltName=email:move
    +
    +# Copy subject details
    +# issuerAltName=issuer:copy
    +
    +#nsCaRevocationUrl		= http://www.domain.dom/ca-crl.pem
    +#nsBaseUrl
    +#nsRevocationUrl
    +#nsRenewalUrl
    +#nsCaPolicyUrl
    +#nsSslServerName
    +
    +# This is required for TSA certificates.
    +# extendedKeyUsage = critical,timeStamping
    +
    +[ v3_req ]
    +
    +# Extensions to add to a certificate request
    +
    +basicConstraints = CA:FALSE
    +keyUsage = nonRepudiation, digitalSignature, keyEncipherment
    +
    +[ v3_ca ]
    +
    +
    +# Extensions for a typical CA
    +
    +
    +# PKIX recommendation.
    +
    +subjectKeyIdentifier=hash
    +
    +authorityKeyIdentifier=keyid:always,issuer
    +
    +basicConstraints = critical,CA:true
    +
    +# Key usage: this is typical for a CA certificate. However since it will
    +# prevent it being used as an test self-signed certificate it is best
    +# left out by default.
    +# keyUsage = cRLSign, keyCertSign
    +
    +# Some might want this also
    +# nsCertType = sslCA, emailCA
    +
    +# Include email address in subject alt name: another PKIX recommendation
    +# subjectAltName=email:copy
    +# Copy issuer details
    +# issuerAltName=issuer:copy
    +
    +# DER hex encoding of an extension: beware experts only!
    +# obj=DER:02:03
    +# Where 'obj' is a standard or added object
    +# You can even override a supported extension:
    +# basicConstraints= critical, DER:30:03:01:01:FF
    +
    +[ crl_ext ]
    +
    +# CRL extensions.
    +# Only issuerAltName and authorityKeyIdentifier make any sense in a CRL.
    +
    +# issuerAltName=issuer:copy
    +authorityKeyIdentifier=keyid:always
    +
    +[ proxy_cert_ext ]
    +# These extensions should be added when creating a proxy certificate
    +
    +# This goes against PKIX guidelines but some CAs do it and some software
    +# requires this to avoid interpreting an end user certificate as a CA.
    +
    +basicConstraints=CA:FALSE
    +
    +# Here are some examples of the usage of nsCertType. If it is omitted
    +# the certificate can be used for anything *except* object signing.
    +
    +# This is OK for an SSL server.
    +# nsCertType			= server
    +
    +# For an object signing certificate this would be used.
    +# nsCertType = objsign
    +
    +# For normal client use this is typical
    +# nsCertType = client, email
    +
    +# and for everything including object signing:
    +# nsCertType = client, email, objsign
    +
    +# This is typical in keyUsage for a client certificate.
    +# keyUsage = nonRepudiation, digitalSignature, keyEncipherment
    +
    +# This will be displayed in Netscape's comment listbox.
    +nsComment			= "OpenSSL Generated Certificate"
    +
    +# PKIX recommendations harmless if included in all certificates.
    +subjectKeyIdentifier=hash
    +authorityKeyIdentifier=keyid,issuer
    +
    +# This stuff is for subjectAltName and issuerAltname.
    +# Import the email address.
    +# subjectAltName=email:copy
    +# An alternative to produce certificates that aren't
    +# deprecated according to PKIX.
    +# subjectAltName=email:move
    +
    +# Copy subject details
    +# issuerAltName=issuer:copy
    +
    +#nsCaRevocationUrl		= http://www.domain.dom/ca-crl.pem
    +#nsBaseUrl
    +#nsRevocationUrl
    +#nsRenewalUrl
    +#nsCaPolicyUrl
    +#nsSslServerName
    +
    +# This really needs to be in place for it to be a proxy certificate.
    +proxyCertInfo=critical,language:id-ppl-anyLanguage,pathlen:3,policy:foo
    +
    +####################################################################
    +[ tsa ]
    +
    +default_tsa = tsa_config1	# the default TSA section
    +
    +[ tsa_config1 ]
    +
    +# These are used by the TSA reply generation only.
    +dir		= ./CA		# TSA root directory
    +serial		= $dir/tsaserial	# The current serial number (mandatory)
    +crypto_device	= builtin		# OpenSSL engine to use for signing
    +signer_cert	= $dir/tsacert.pem 	# The TSA signing certificate
    +					# (optional)
    +certs		= $dir/cacert.pem	# Certificate chain to include in reply
    +					# (optional)
    +signer_key	= $dir/private/tsakey.pem # The TSA private key (optional)
    +signer_digest  = sha256			# Signing digest to use. (Optional)
    +default_policy	= tsa_policy1		# Policy if request did not specify it
    +					# (optional)
    +other_policies	= tsa_policy2, tsa_policy3	# acceptable policies (optional)
    +digests     = sha1, sha256, sha384, sha512  # Acceptable message digests (mandatory)
    +accuracy	= secs:1, millisecs:500, microsecs:100	# (optional)
    +clock_precision_digits  = 0	# number of digits after dot. (optional)
    +ordering		= yes	# Is ordering defined for timestamps?
    +				# (optional, default: no)
    +tsa_name		= yes	# Must the TSA name be included in the reply?
    +				# (optional, default: no)
    +ess_cert_id_chain	= no	# Must the ESS cert id chain be included?
    +				# (optional, default: no)
    +ess_cert_id_alg		= sha1	# algorithm to compute certificate
    +				# identifier (optional, default: sha1)
    +[default_conf]
    +ssl_conf = ssl_sect
    +
    +[ssl_sect]
    +system_default = system_default_sect
    +
    +[system_default_sect]
    +MinProtocol = TLSv1.2
    +CipherString = DEFAULT@SECLEVEL=2
    
  • examples/ca/run.sh+16 0 added
    @@ -0,0 +1,16 @@
    +#!/bin/bash
    +#set -x
    +# key passwd: coTURN
    +cp /usr/lib/ssl/misc/CA.pl ./CA.pl
    +patch < CA.pl.diff
    +export OPENSSL_CONFIG="-config openssl.conf"
    +./CA.pl -newca
    +
    +for i in "server" "client"; 
    +do
    +	./CA.pl -newreq-nodes
    +	./CA.pl -signCA
    +	mv newcert.pem turn_${i}_cert.pem
    +	mv newkey.pem turn_${i}_pkey.pem
    +	rm newreq.pem
    +done;
    
  • examples/ca/turn_client_cert.pem+80 0 added
    @@ -0,0 +1,80 @@
    +Certificate:
    +    Data:
    +        Version: 3 (0x2)
    +        Serial Number:
    +            4c:9b:ec:95:d1:21:49:1d:5d:65:a7:1a:61:46:67:dd:42:18:65:48
    +        Signature Algorithm: sha256WithRSAEncryption
    +        Issuer: C=HU, ST=Hungary, O=coTURN, CN=CA/emailAddress=misi@majd.eu
    +        Validity
    +            Not Before: Mar  5 09:05:42 2020 GMT
    +            Not After : Mar  3 09:05:42 2030 GMT
    +        Subject: C=HU, ST=Hungary, L=Debrecen, O=coTURN, CN=Client/emailAddress=misi@majd.eu
    +        Subject Public Key Info:
    +            Public Key Algorithm: rsaEncryption
    +                RSA Public-Key: (2048 bit)
    +                Modulus:
    +                    00:af:6d:38:31:23:12:12:e7:5a:8d:ed:1c:02:7e:
    +                    bf:c2:ef:7a:d1:c0:b2:4b:b4:38:9b:a7:5d:dd:01:
    +                    2c:a0:e7:7c:5b:7a:4d:71:4b:c9:5b:77:e8:b3:4c:
    +                    92:5b:8c:43:57:b6:c9:8c:44:66:6a:9e:8c:f2:76:
    +                    58:a2:f5:38:a3:4f:ef:af:5a:c7:bf:e5:72:98:c0:
    +                    b8:2e:a1:75:cc:16:8b:bf:a3:6a:e6:fd:c9:25:35:
    +                    92:31:b2:78:2a:42:7b:a1:ce:25:be:32:45:6e:0b:
    +                    36:22:f8:6c:9c:f3:8f:bf:c8:8c:79:d5:59:02:f5:
    +                    de:1f:67:fc:ef:c7:27:88:a7:35:b1:d7:ee:dc:1c:
    +                    74:11:fc:3c:56:33:b5:e7:88:ce:f3:ce:db:b9:3c:
    +                    e0:eb:15:bc:00:5f:29:f4:9c:8e:4d:61:df:da:aa:
    +                    f4:fc:fb:e7:4b:75:dc:dc:cf:f0:4b:3b:67:cf:bf:
    +                    35:b8:0f:5b:20:94:60:dd:3b:e5:7a:ec:0e:30:2c:
    +                    c1:fb:f6:21:5b:ed:80:34:9d:59:5c:95:39:a2:61:
    +                    a4:13:fa:57:b9:f5:85:d4:a1:bf:91:cf:d7:dc:ac:
    +                    fa:32:47:ee:d2:86:9b:14:d1:35:88:1e:2d:9f:39:
    +                    74:86:de:f1:04:de:e1:39:2f:a8:91:bf:8b:f7:4f:
    +                    7c:e5
    +                Exponent: 65537 (0x10001)
    +        X509v3 extensions:
    +            X509v3 Subject Key Identifier: 
    +                32:BA:14:26:42:B6:5B:9E:3C:F1:53:1A:FD:DB:CB:FE:B1:A2:74:6C
    +            X509v3 Authority Key Identifier: 
    +                keyid:1C:27:5E:40:39:8C:EC:71:C7:ED:E9:2A:56:C9:9E:DF:48:EA:82:42
    +
    +            X509v3 Basic Constraints: critical
    +                CA:TRUE
    +    Signature Algorithm: sha256WithRSAEncryption
    +         6b:93:56:56:81:fb:34:9e:15:2e:3e:b2:2c:73:72:60:f2:1a:
    +         a8:bf:c3:f0:c7:57:00:48:37:2a:1c:63:71:1b:29:f4:2b:dc:
    +         64:07:f8:72:80:65:18:c7:74:23:c1:02:00:d8:93:1d:4f:2b:
    +         8c:46:34:1e:d2:6a:5c:ab:8d:ff:a7:fe:e5:c2:bf:33:55:ea:
    +         2b:e2:70:e9:24:4c:4d:31:d4:dd:10:55:f5:bb:2c:a5:ec:f6:
    +         8f:7a:05:1c:6c:7d:cf:85:6b:29:a7:bd:fe:a2:bc:00:45:b8:
    +         ac:70:c7:c9:67:93:0a:5c:d7:52:a3:c9:fc:6c:ef:52:b2:6b:
    +         bc:5b:f9:e1:9b:27:07:39:28:28:7f:a0:70:62:af:4f:42:82:
    +         dd:ec:23:4d:fc:8e:19:51:87:cc:d0:29:d5:27:44:9c:fa:b5:
    +         51:ea:31:eb:51:84:3f:07:5b:c0:57:5d:2a:c7:15:ed:9c:46:
    +         ac:8e:14:8b:4d:82:0e:b4:6a:47:db:37:f3:03:08:86:b6:25:
    +         0b:92:6d:99:a9:99:45:4e:38:45:e0:a2:4e:e7:34:50:51:ab:
    +         f8:c8:ef:26:3d:7f:9f:8f:45:20:cf:f5:31:27:b6:00:3a:e0:
    +         4a:d5:62:9a:29:27:9b:aa:3a:95:56:1c:d7:65:15:ce:35:10:
    +         2a:7e:cc:b6
    +-----BEGIN CERTIFICATE-----
    +MIIDrDCCApSgAwIBAgIUTJvsldEhSR1dZacaYUZn3UIYZUgwDQYJKoZIhvcNAQEL
    +BQAwWjELMAkGA1UEBhMCSFUxEDAOBgNVBAgMB0h1bmdhcnkxDzANBgNVBAoMBmNv
    +VFVSTjELMAkGA1UEAwwCQ0ExGzAZBgkqhkiG9w0BCQEWDG1pc2lAbWFqZC5ldTAe
    +Fw0yMDAzMDUwOTA1NDJaFw0zMDAzMDMwOTA1NDJaMHExCzAJBgNVBAYTAkhVMRAw
    +DgYDVQQIDAdIdW5nYXJ5MREwDwYDVQQHDAhEZWJyZWNlbjEPMA0GA1UECgwGY29U
    +VVJOMQ8wDQYDVQQDDAZDbGllbnQxGzAZBgkqhkiG9w0BCQEWDG1pc2lAbWFqZC5l
    +dTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAK9tODEjEhLnWo3tHAJ+
    +v8LvetHAsku0OJunXd0BLKDnfFt6TXFLyVt36LNMkluMQ1e2yYxEZmqejPJ2WKL1
    +OKNP769ax7/lcpjAuC6hdcwWi7+jaub9ySU1kjGyeCpCe6HOJb4yRW4LNiL4bJzz
    +j7/IjHnVWQL13h9n/O/HJ4inNbHX7twcdBH8PFYzteeIzvPO27k84OsVvABfKfSc
    +jk1h39qq9Pz750t13NzP8Es7Z8+/NbgPWyCUYN075XrsDjAswfv2IVvtgDSdWVyV
    +OaJhpBP6V7n1hdShv5HP19ys+jJH7tKGmxTRNYgeLZ85dIbe8QTe4TkvqJG/i/dP
    +fOUCAwEAAaNTMFEwHQYDVR0OBBYEFDK6FCZCtluePPFTGv3by/6xonRsMB8GA1Ud
    +IwQYMBaAFBwnXkA5jOxxx+3pKlbJnt9I6oJCMA8GA1UdEwEB/wQFMAMBAf8wDQYJ
    +KoZIhvcNAQELBQADggEBAGuTVlaB+zSeFS4+sixzcmDyGqi/w/DHVwBINyocY3Eb
    +KfQr3GQH+HKAZRjHdCPBAgDYkx1PK4xGNB7Salyrjf+n/uXCvzNV6ivicOkkTE0x
    +1N0QVfW7LKXs9o96BRxsfc+Faymnvf6ivABFuKxwx8lnkwpc11Kjyfxs71Kya7xb
    ++eGbJwc5KCh/oHBir09Cgt3sI038jhlRh8zQKdUnRJz6tVHqMetRhD8HW8BXXSrH
    +Fe2cRqyOFItNgg60akfbN/MDCIa2JQuSbZmpmUVOOEXgok7nNFBRq/jI7yY9f5+P
    +RSDP9TEntgA64ErVYpopJ5uqOpVWHNdlFc41ECp+zLY=
    +-----END CERTIFICATE-----
    
  • examples/ca/turn_client_pkey.pem+28 0 added
    @@ -0,0 +1,28 @@
    +-----BEGIN PRIVATE KEY-----
    +MIIEvwIBADANBgkqhkiG9w0BAQEFAASCBKkwggSlAgEAAoIBAQCvbTgxIxIS51qN
    +7RwCfr/C73rRwLJLtDibp13dASyg53xbek1xS8lbd+izTJJbjENXtsmMRGZqnozy
    +dlii9TijT++vWse/5XKYwLguoXXMFou/o2rm/cklNZIxsngqQnuhziW+MkVuCzYi
    ++Gyc84+/yIx51VkC9d4fZ/zvxyeIpzWx1+7cHHQR/DxWM7XniM7zztu5PODrFbwA
    +Xyn0nI5NYd/aqvT8++dLddzcz/BLO2fPvzW4D1sglGDdO+V67A4wLMH79iFb7YA0
    +nVlclTmiYaQT+le59YXUob+Rz9fcrPoyR+7ShpsU0TWIHi2fOXSG3vEE3uE5L6iR
    +v4v3T3zlAgMBAAECggEBAINzP+vx75UirwQybA6ik2aqtEmALxnzDYf1PaxhOOPJ
    +EbIqTuVaeKOFkmToN7NJwxxy50un5WZ3L/5vF7PkNHCLcXrgd1UfxWMY5eprKi2n
    +p0gOWAiGmra7EbUTml9wOdvg8P84BDaVSBekNx7Ukx6OVFTmvTAutCascSfq/4Cx
    +K71zaW/I9hrU8oNDBDzolVW4gW8ObNLGhoDqmvkoXrlrGEBNqkuErbbYZA1k/001
    +lurEh7Zp7Kp6jjHcRm83a7bWiRYGtv1K9kR9MKKLW7au8zyjYcesTvS2QjY+k20W
    +vE2kmyAosbJShFzTmZn8kwgh6c0BPyFDEI5XleMeefECgYEA6ZhgG87wyU4RDU1N
    +PxLV9ufbSYpW91KP1iuZ5Z6QdLGWZeWKjvxtoLAa3z9ceIBVvFqCGDn4DfwIaNLe
    +tGsjeyXre1R3/B0S/oAJbmbRV4pWl/jSzgbzCTGW7x1mpqgpJdHFmTbqTxkNB6cM
    +fpzTPfM012KfRglD9D+2DTOCyEsCgYEAwECXQRIe7/657J68GHSBCaQ+rzDL3nRe
    +exe4duHyXok0yohk7OiPepKQ1hdYq2PHhGEj6b5OgFppWeA66M/ndjX4S10oCtN0
    +oEb7honFz4ZmHmqQ6UotAuBx7tq06v+KI/eTvefTVh9mujdwMW4sAowhx9Dw6PkR
    +ipFCdi458Y8CgYEAhJ//ySoYKaMKKWw/NFVkZ9fB+CH0OF2GzslYijcZuzdstZO6
    +tG37bCUwTJozzTLH+rXEcS7QeFglCibXTMYbkfq4lQAjU1/KffaB5E26A6LGgWhD
    +f7gQWqLuF/qwYmTNX+yW7ONx6tDFRhgBDw3JHb4svTEATwpJq65UlXAui7sCgYBD
    +krBXO8JKApNg+s4MHm74b5VkyFbv4qEOzOCWUIZ6+ejnQxeOOZOstnVX+q681v5a
    +pjYUQ0KeVKjw4SJzkBe/8epKuvyHCZnVd/2SZTx0271q9XPnu52khDUnihHLA3SP
    +fcadGi2q+LCHxVKW3S1028JH1EXI7TpgJPxiQ480OwKBgQDmi0BiSFaxNVcJm+pq
    +rbmK2pRPl49VOlc7px89ilZgoIeU8jwWQyqXRooarFhV1H0SA6oh52jYljiIIFVn
    +qwKfS3Sjo6iW3ytjGcRLeNS0Sk8D2XMky7Mw120ZxatTsKw3ztmYFAlSYdxRMnue
    +zkYzcxL3N2LvHeY8SOwyxayfxg==
    +-----END PRIVATE KEY-----
    
  • examples/ca/turn_server_cert.pem+80 0 added
    @@ -0,0 +1,80 @@
    +Certificate:
    +    Data:
    +        Version: 3 (0x2)
    +        Serial Number:
    +            4c:9b:ec:95:d1:21:49:1d:5d:65:a7:1a:61:46:67:dd:42:18:65:47
    +        Signature Algorithm: sha256WithRSAEncryption
    +        Issuer: C=HU, ST=Hungary, O=coTURN, CN=CA/emailAddress=misi@majd.eu
    +        Validity
    +            Not Before: Mar  5 09:05:21 2020 GMT
    +            Not After : Mar  3 09:05:21 2030 GMT
    +        Subject: C=HU, ST=Hungary, L=Debrecen, O=coTURN, CN=Server/emailAddress=misi@majd.eu
    +        Subject Public Key Info:
    +            Public Key Algorithm: rsaEncryption
    +                RSA Public-Key: (2048 bit)
    +                Modulus:
    +                    00:bc:db:f7:17:35:17:7c:46:79:64:89:61:5f:ac:
    +                    cf:8f:6d:97:13:87:8a:d6:f1:ab:df:f6:69:4e:04:
    +                    57:c1:4d:6c:3d:77:c9:50:0d:3d:b6:89:cd:ac:00:
    +                    b5:02:45:e4:4c:78:ef:6f:18:7e:57:4e:bc:62:4d:
    +                    f6:de:6c:c8:77:ea:c5:b2:b4:65:2d:46:76:bf:5e:
    +                    5f:f8:45:78:55:f4:4d:20:ac:91:f0:4f:23:cb:5d:
    +                    40:29:44:de:9c:f7:0a:e6:48:a4:80:35:dd:cb:e8:
    +                    02:90:59:f7:31:f9:4c:50:fe:98:ef:dd:7f:60:51:
    +                    2d:44:0a:14:a2:57:96:51:36:3f:73:66:db:45:5f:
    +                    bd:9d:f4:82:3a:ce:ab:75:4f:d0:90:6d:43:d1:7b:
    +                    2f:77:31:88:db:2f:4a:a9:4e:62:39:c7:14:7f:39:
    +                    ef:e2:08:b7:18:a7:6c:f8:d9:35:d5:a3:f8:64:f5:
    +                    02:51:22:1b:8e:7a:c5:44:ae:df:b1:17:0b:71:df:
    +                    09:82:89:49:70:c5:9b:a0:f3:3c:02:48:75:e7:81:
    +                    f9:24:51:56:24:3b:ff:b8:68:d3:13:2e:a2:f4:d1:
    +                    70:33:a9:7a:d6:17:fd:ca:a5:6b:13:74:c9:ce:b6:
    +                    26:4f:01:ff:eb:ba:b5:f9:a1:70:80:da:11:df:a3:
    +                    7b:4f
    +                Exponent: 65537 (0x10001)
    +        X509v3 extensions:
    +            X509v3 Subject Key Identifier: 
    +                38:C1:E5:77:D3:01:6B:7A:A7:D8:18:6B:50:D6:FA:0E:D6:D9:B4:4F
    +            X509v3 Authority Key Identifier: 
    +                keyid:1C:27:5E:40:39:8C:EC:71:C7:ED:E9:2A:56:C9:9E:DF:48:EA:82:42
    +
    +            X509v3 Basic Constraints: critical
    +                CA:TRUE
    +    Signature Algorithm: sha256WithRSAEncryption
    +         a3:37:55:68:68:02:9f:af:d6:b1:38:b3:d8:bf:30:27:33:6f:
    +         21:4c:09:ee:cf:24:d2:eb:cf:1c:7a:15:98:6d:10:94:e0:4a:
    +         1f:88:5c:43:90:09:78:c1:a6:82:06:16:f2:8c:d1:3a:c5:3b:
    +         99:67:35:3c:00:bf:9f:a2:6a:e7:33:85:83:88:72:88:e4:d2:
    +         83:1c:6c:49:92:5f:51:80:0d:92:0f:99:4d:cb:2a:18:4d:68:
    +         b7:b6:d1:de:54:22:71:88:8d:04:45:c5:13:34:8d:52:7a:f7:
    +         2a:e7:cb:b2:41:20:7b:ef:aa:d0:58:93:b5:e6:b5:fa:8b:22:
    +         a3:ed:a7:81:9b:ca:50:f7:d0:bd:5f:f2:52:6d:8b:af:af:64:
    +         36:9d:6d:81:ce:50:29:b7:db:d0:ac:a3:1d:78:77:90:29:a3:
    +         84:10:69:13:e9:47:fc:e1:1e:c2:74:55:61:11:65:2d:77:e1:
    +         ca:9f:2d:6f:2f:76:f6:69:bc:09:50:9a:b0:48:05:a2:53:e6:
    +         93:46:81:0d:04:8b:cd:fb:a4:a7:82:08:78:f9:87:dc:0a:07:
    +         91:1f:de:09:fa:00:5a:16:1a:2b:5c:83:10:03:33:2f:ad:8c:
    +         9a:eb:94:0f:77:b1:9b:ec:e6:0e:dc:84:dd:35:3f:b5:8a:d2:
    +         06:0e:88:d7
    +-----BEGIN CERTIFICATE-----
    +MIIDrDCCApSgAwIBAgIUTJvsldEhSR1dZacaYUZn3UIYZUcwDQYJKoZIhvcNAQEL
    +BQAwWjELMAkGA1UEBhMCSFUxEDAOBgNVBAgMB0h1bmdhcnkxDzANBgNVBAoMBmNv
    +VFVSTjELMAkGA1UEAwwCQ0ExGzAZBgkqhkiG9w0BCQEWDG1pc2lAbWFqZC5ldTAe
    +Fw0yMDAzMDUwOTA1MjFaFw0zMDAzMDMwOTA1MjFaMHExCzAJBgNVBAYTAkhVMRAw
    +DgYDVQQIDAdIdW5nYXJ5MREwDwYDVQQHDAhEZWJyZWNlbjEPMA0GA1UECgwGY29U
    +VVJOMQ8wDQYDVQQDDAZTZXJ2ZXIxGzAZBgkqhkiG9w0BCQEWDG1pc2lAbWFqZC5l
    +dTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBALzb9xc1F3xGeWSJYV+s
    +z49tlxOHitbxq9/2aU4EV8FNbD13yVANPbaJzawAtQJF5Ex4728YfldOvGJN9t5s
    +yHfqxbK0ZS1Gdr9eX/hFeFX0TSCskfBPI8tdQClE3pz3CuZIpIA13cvoApBZ9zH5
    +TFD+mO/df2BRLUQKFKJXllE2P3Nm20VfvZ30gjrOq3VP0JBtQ9F7L3cxiNsvSqlO
    +YjnHFH857+IItxinbPjZNdWj+GT1AlEiG456xUSu37EXC3HfCYKJSXDFm6DzPAJI
    +deeB+SRRViQ7/7ho0xMuovTRcDOpetYX/cqlaxN0yc62Jk8B/+u6tfmhcIDaEd+j
    +e08CAwEAAaNTMFEwHQYDVR0OBBYEFDjB5XfTAWt6p9gYa1DW+g7W2bRPMB8GA1Ud
    +IwQYMBaAFBwnXkA5jOxxx+3pKlbJnt9I6oJCMA8GA1UdEwEB/wQFMAMBAf8wDQYJ
    +KoZIhvcNAQELBQADggEBAKM3VWhoAp+v1rE4s9i/MCczbyFMCe7PJNLrzxx6FZht
    +EJTgSh+IXEOQCXjBpoIGFvKM0TrFO5lnNTwAv5+iauczhYOIcojk0oMcbEmSX1GA
    +DZIPmU3LKhhNaLe20d5UInGIjQRFxRM0jVJ69yrny7JBIHvvqtBYk7XmtfqLIqPt
    +p4GbylD30L1f8lJti6+vZDadbYHOUCm329Csox14d5Apo4QQaRPpR/zhHsJ0VWER
    +ZS134cqfLW8vdvZpvAlQmrBIBaJT5pNGgQ0Ei837pKeCCHj5h9wKB5Ef3gn6AFoW
    +GitcgxADMy+tjJrrlA93sZvs5g7chN01P7WK0gYOiNc=
    +-----END CERTIFICATE-----
    
  • examples/ca/turn_server_pkey.pem+28 0 added
    @@ -0,0 +1,28 @@
    +-----BEGIN PRIVATE KEY-----
    +MIIEvgIBADANBgkqhkiG9w0BAQEFAASCBKgwggSkAgEAAoIBAQC82/cXNRd8Rnlk
    +iWFfrM+PbZcTh4rW8avf9mlOBFfBTWw9d8lQDT22ic2sALUCReRMeO9vGH5XTrxi
    +TfbebMh36sWytGUtRna/Xl/4RXhV9E0grJHwTyPLXUApRN6c9wrmSKSANd3L6AKQ
    +Wfcx+UxQ/pjv3X9gUS1EChSiV5ZRNj9zZttFX72d9II6zqt1T9CQbUPRey93MYjb
    +L0qpTmI5xxR/Oe/iCLcYp2z42TXVo/hk9QJRIhuOesVErt+xFwtx3wmCiUlwxZug
    +8zwCSHXngfkkUVYkO/+4aNMTLqL00XAzqXrWF/3KpWsTdMnOtiZPAf/rurX5oXCA
    +2hHfo3tPAgMBAAECggEALGPXVBEakA9QgRz5Ui+gKaoslF6Ld7IeH+ofHkNPDRRR
    +mLELFFHIa5tASGlyIjKjUoYqYQZ0y7ip9sE0gVs4U1dPWI2mKlohlyFrlUNe4XUm
    +m8N0GfPAChDE/+48FNDMMwxn/eqrUz4ZPCypOYnLMk5lTBvX0J/D7/Yem3nSzwt1
    +qkZoijxZH5IvJAJkBWvucRuJ8XxHzOAo2V2Y+wTdilcJhfCvqGC0rkydjaN6TtRW
    +HWKvAOa7hEegNBbZhHhKfw5ovQwj9Cnr2+8gaTSw5gVaZNnhCO+TlUfQHIBH9rmt
    +82SHu1QoYSGMvkjlrrKhRYHrx+4P4TXoZ6eB1hl3QQKBgQDmwUOkh6qwL2dtcrF1
    +bVdRZjb1bw6L8qZAgUkcA1IaLVUlhjEJZGXAoPbLn6Vq+jfOvaYLmzEaLcpn3pfx
    +Hwcb1vnNW7dlXC1vpIWXPZP4IPJV4XsL1AgoEj6mgETHxvC+4cLc2gaMY5o5TzUv
    +VdV/A7SIqxAyPccXt1u/eITfNwKBgQDRhVTTJiBsGGjOetfgNqNGxpkKB6W4cET9
    +EyC1c7Lh40lioA2G8lzhFCdK9VZ+cAT51Bmkr5jq29EyMafSy3e4+PG8ZLHVL0ll
    +qBY4vSzHQNcGvUgh+15g6ISgCbM0eSsAea3LY+fmchz6mBS6DhyMkYPSbV+7YvHJ
    +PSnfTkTgqQKBgQCO+SQOJzjs3RI6UBv/4/V8K9bVjy/2Kiw0P2arAqu2KGxfSZvM
    +c/ZPuevwEkSN2ecGI59kBY4Q6FpGrTZ7YXwoFbTFNpSVKt3EFK3pHXA3B0LfT0vL
    +8l3zZgqHY2Y6WdsEiiEQcc4o4fXGmHsdjxMvFX6gR01Ls9dNrIAeTHAXVQKBgGoL
    +Q72C5JIRYKpw/mYbAVTHG5o5+KR7Hk/AqKNuJbGyqefi/jW44U2CN8j2l4pzA/G2
    +aiwyPAFStHTlMP29waC7Tw59IIy33Dw5cNXS2aEXrj1Y+/NHGKOPy+B8SFlcomkh
    +LNduf2bhhs1Gv+bTUZvL4p5UgUmEcL/b1x+Qq8fRAoGBAIpNCp4W+TsPUJcQKoWm
    +L61RVr5GaHv7/qxQvYaXIVCq8/gZAbJi3/A9ieTrF72uuOZ+ajzFHDUiiDs19y67
    +mCvCchPgqzLy9iSs6mm8fmS6kJnWn04I+7DOfe7kScUnD5WkyNaTYAeOqvdWzl/i
    +B1hQJJ9GzZG5Rztlotm5m/JY
    +-----END PRIVATE KEY-----
    
  • examples/etc/cacert.pem+1 0 added
    @@ -0,0 +1 @@
    +../ca/CA/cacert.pem
    \ No newline at end of file
    
  • examples/etc/coturn.service+24 0 added
    @@ -0,0 +1,24 @@
    +[Unit]
    +Description=Coturn STUN/TURN Server
    +Documentation=man:coturn(1) man:turnadmin(1) man:turnserver(1)
    +After=network.target
    +After=network-online.target
    +After=remote-fs.target
    +Wants=network-online.target
    +
    +[Service]
    +User=turnserver
    +Group=turnserver
    +Type=forking
    +RuntimeDirectory=turnserver
    +PIDFile=/run/turnserver/turnserver.pid
    +ExecStart=/usr/bin/turnserver --daemon -c /etc/turnserver.conf --pidfile /run/turnserver/turnserver.pid
    +#FixMe: turnserver exit faster than it is finshing the setup and ready for handling the connection.
    +ExecStartPost=/bin/sleep 2
    +Restart=on-failure
    +InaccessibleDirectories=/home
    +PrivateTmp=yes
    +
    +[Install]
    +WantedBy=multi-user.target
    +Alias=turnserver.service
    
  • examples/etc/turn_client_cert.pem+0 23 removed
    @@ -1,23 +0,0 @@
    ------BEGIN CERTIFICATE-----
    -MIIDzjCCArYCCQD3YHhln4EqhDANBgkqhkiG9w0BAQUFADCBpzELMAkGA1UEBhMC
    -VVMxCzAJBgNVBAgTAkNBMRUwEwYDVQQHEwxXYWxudXQgQ3JlZWsxKzApBgNVBAoT
    -IlJGQzU3NjYgVFVSTiBTZXJ2ZXIgcHVibGljIHByb2plY3QxFDASBgNVBAsTC2Rl
    -dmVsb3BtZW50MQ0wCwYDVQQDEwRPbGVnMSIwIAYJKoZIhvcNAQkBFhNtb20wNDAy
    -NjdAZ21haWwuY29tMCAXDTEyMTEyNzAwNDEwNVoYDzIxMTIxMTAzMDA0MTA1WjCB
    -pzELMAkGA1UEBhMCVVMxCzAJBgNVBAgTAkNBMRUwEwYDVQQHEwxXYWxudXQgQ3Jl
    -ZWsxKzApBgNVBAoTIlJGQzU3NjYgVFVSTiBTZXJ2ZXIgcHVibGljIHByb2plY3Qx
    -FDASBgNVBAsTC2RldmVsb3BtZW50MQ0wCwYDVQQDEwRPbGVnMSIwIAYJKoZIhvcN
    -AQkBFhNtb20wNDAyNjdAZ21haWwuY29tMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8A
    -MIIBCgKCAQEA3huHvPYyvNZBK91bP3O1dBdOj93YQ3812BTcRMjEYnvSyyEosxFd
    -dEnILgDiFK//pFnDtwm7FxOCtVwRQ0+8qGTH4vH0EIpKTBsaafKH3L9CYe40pwcm
    -BJHvclOa4vl2Ghi09+M0UEHdokkM77K9rpXx7aZILoICkqnoAuBe0TY8D5PBXinM
    -gtk7HlrvANxSmPHAAaGQ5t/+jfTWVH1UYCpogTgCKYPbNi+joKu6oEz+qRKAqDYd
    -FY6/Qpiv7reYiNiVhM7HGNY27FkKDJDBhsmZRmtTIEdYFfcWPZvv69L7Rf1skOXF
    -Vm5/to3HArJJF+lz6YGj0C3pE6dZt6sUmQIDAQABMA0GCSqGSIb3DQEBBQUAA4IB
    -AQAhXgGdXXf0dMPdkfl4jv4dqFNSmax6wmeNc+oJC9qIFVDLsdAaAWXZ+pZHYIMR
    -UN8mQobsIZdfPQ0gs8CgUwrKziAjA92y2Q/I7vsg83qRLhysGC5etYMD/wlySDDS
    -AJKraevDPTEdmfNstCblubNG2PIeqV1isWtPMqB2dMsCeyzJXVyfD0QcABzFv4Fs
    -MMy7JI7MsctNh1tjV/0TsddDMeMLs22rix5fS8MZ6uunFzIuJ0MshFNehXFuvz0B
    -uNmn0k7djUm3h+2Avs3YGCo/8GtqHapc/lva/9gT+iEW0e7i0Ru5Jhar66VMzJqv
    -+wEhQafC77d3vWHtXQU8dYmM
    ------END CERTIFICATE-----
    
  • examples/etc/turn_client_cert.pem+1 0 added
    @@ -0,0 +1 @@
    +../ca/turn_client_cert.pem
    \ No newline at end of file
    
  • examples/etc/turn_client_pkey.pem+0 27 removed
    @@ -1,27 +0,0 @@
    ------BEGIN RSA PRIVATE KEY-----
    -MIIEowIBAAKCAQEA3huHvPYyvNZBK91bP3O1dBdOj93YQ3812BTcRMjEYnvSyyEo
    -sxFddEnILgDiFK//pFnDtwm7FxOCtVwRQ0+8qGTH4vH0EIpKTBsaafKH3L9CYe40
    -pwcmBJHvclOa4vl2Ghi09+M0UEHdokkM77K9rpXx7aZILoICkqnoAuBe0TY8D5PB
    -XinMgtk7HlrvANxSmPHAAaGQ5t/+jfTWVH1UYCpogTgCKYPbNi+joKu6oEz+qRKA
    -qDYdFY6/Qpiv7reYiNiVhM7HGNY27FkKDJDBhsmZRmtTIEdYFfcWPZvv69L7Rf1s
    -kOXFVm5/to3HArJJF+lz6YGj0C3pE6dZt6sUmQIDAQABAoIBAH5ITN8FZEe10gws
    -qUrkcRD2h3aI/gMyetzGz45UUERmfq17xvY5M1eA884kNmbowoMhfoO9hqBSOYkA
    -Ndh9p5he5L+GLeyRlDi9WEFQ4iqCnC2uEEW/bMBAcVIhcvkGOT4ROiOPDRlsuaUh
    -v7cxe2OeYZVra7L1vJzC+eVYyNBN5CgK8w08MPEkupQS9+Jvr0QWCikRz187cG45
    -EiDMrBKyJNE9lY6u4P8gJ+/NgaASWP/D3kbsjiQ2OwSGLrwDAvWC7Bx2GK3/0goA
    -btp7YGaWvp+mE5V91cOW+PfweC5Do4MjOr4ToNkczW0AxKE5o94yo56h+II5bX6N
    -z65VvtkCgYEA/Sq/3S2yup/Oodzj003KG4skWYFrj7KXeXgm7RZcpNwkd8JaFXJ/
    -Cwl7/3bkRv6RHLmXX/2hcNWlxq3u6Efs1EjtycdArU68kO01vLdExJYIzHKmHikV
    -n+T4hukxGDzObxn3lH1KcOodh/x572Uufn79dewoZCPzH8t/jiMOWGcCgYEA4JfN
    -66Kq/oDookqenM9Ij5l6zeeNwzMjIlkU2eG0DAH0KdsBN/hTGGGRQVBk03YREQmK
    -crEhGAZxzfrX5fK11UVG3C2pqAtrVe6FuD32vFUpP1MO0ftSA889NoEwGdNZV4pV
    -Mk0+6xVCNOatj2inMXlQq5s68WfCzkiWD7uLCv8CgYBcwuYsF4tuYBGpMzNzAAS2
    -1OPLu+T6cPiZdFHm+xOVAGiITPkO9LXiCGabsydvb+UhvkrdzCP0IQQt6RsplvkK
    -y3H9RfnHxprHC3NuI0SaN1Mf/j4pvOoEfTQm0pi/hcAp6zzQ9ptpBg8t/W98LPm9
    -NbCPHamrD5UMqFajcOrXrwKBgD8D2M8IcRm/aYY/kYlFz4Ia+g3Trj7alj0I6YTI
    -gw/rbGph/FGL5ySsG2lL+T4rnlY9aw8LC9IF3OCCRRlLpCEWsu8MENIJgjA2IGa1
    -XAkzi8MstrfL4BMZjn9AeBKG7kZVldnrOoATEuRs5L2cC20iMLQ1dbBOAKaITzJS
    -2IxZAoGBAKqwr/uennxJrnMtpjLBgcphoU3aXJZvzzDqlOaqzJp6Xmbese4sDEe0
    -hvVHreigDzOnGnqL/vSjTDWaLqS/O1iE7p+UrGIkZj/Zl6Jk54OX6AHmWE2LhdlU
    -FYgIQKX7fuocpF1Dpe7xEeVwvdp+UqbDzHQg1CWGe1cBPYDYIkSH
    ------END RSA PRIVATE KEY-----
    
  • examples/etc/turn_client_pkey.pem+1 0 added
    @@ -0,0 +1 @@
    +../ca/turn_client_pkey.pem
    \ No newline at end of file
    
  • examples/etc/turn_server_cert.pem+1 0 added
    @@ -0,0 +1 @@
    +../ca/turn_server_cert.pem
    \ No newline at end of file
    
  • examples/etc/turn_server_cert.pem+0 22 removed
    @@ -1,22 +0,0 @@
    ------BEGIN CERTIFICATE-----
    -MIIDsDCCApgCCQCmgrJCiQlGOTANBgkqhkiG9w0BAQUFADCBmDELMAkGA1UEBhMC
    -VVMxCzAJBgNVBAgTAkNBMRUwEwYDVQQHEwxXYWxudXQgQ3JlZWsxHDAaBgNVBAoT
    -E1RVUk4gU2VydmVyIHByb2plY3QxFDASBgNVBAsTC0RldmVsb3BtZW50MQ0wCwYD
    -VQQDEwRPbGVnMSIwIAYJKoZIhvcNAQkBFhNtb20wNDAyNjdAZ21haWwuY29tMCAX
    -DTEyMTEyNTA4MjAxNloYDzIxMTIxMTAxMDgyMDE2WjCBmDELMAkGA1UEBhMCVVMx
    -CzAJBgNVBAgTAkNBMRUwEwYDVQQHEwxXYWxudXQgQ3JlZWsxHDAaBgNVBAoTE1RV
    -Uk4gU2VydmVyIHByb2plY3QxFDASBgNVBAsTC0RldmVsb3BtZW50MQ0wCwYDVQQD
    -EwRPbGVnMSIwIAYJKoZIhvcNAQkBFhNtb20wNDAyNjdAZ21haWwuY29tMIIBIjAN
    -BgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAv6bYkERhZ43RjW4EuqCaTq5g+D+l
    -JI/GwlVzdzQ3+F4clMQDR1kp1nX+9AvwjCXz3AYwY1H9CqjmjGM4R9uNJJseK/aJ
    -d2DUFADkF+7I674XwX8U2Fy5on9jqWq3jdbb8eg/awcTBdrNLWNPquwfS2KVdooj
    -9yPkqnO0c3ko1/OzIQCcs09O3l/MPt+aOsHk3B9l79ZRs3zWkylI+we0Fnc+7tZE
    -psCztA+KCCoiJf7NenOvVhdKg7D1AXuzJ/P/Euvc3+CIiS9HI4pWLopY1k+HydLe
    -IcopqSbg9CRIKe1HOL8YTvCm2ZoTqgijwWUlGtwEDf2xxUQX/TLYiW8JFQIDAQAB
    -MA0GCSqGSIb3DQEBBQUAA4IBAQATbrBOLV4e8Qmsby9+srxXsdbNc60PmDZ4WiZ1
    -IElfWmzM7wGXm9sJg1PX/7T24R1tbwZGLIhZnkhecG372GChULZJ9Pdjh0Ab2nK5
    -LRKHXTpjp/xOJvx0JMCIIyRnGZT1nABPOk8uEjNW8PaU6yhQ4f5nKaSOgYGRCln6
    -dcy5vylCsyD9Q7GXs0KOC38XD+Ycv6VLX4zKJ2Yum50Wt643nLjG9RlGT3FXWJ1K
    -HUbPC5TO6bcYLdiTjaYr+X8xC/x6h/Ngdo/16w7fRmQQ4uS+TVXrg8ITmI71KX/I
    -m7C9jbsubwzrhW84oZXYf+o/0ATtEAhiVLnHifKCCYikqfVj
    ------END CERTIFICATE-----
    
  • examples/etc/turnserver.conf+93 76 modified
    @@ -1,9 +1,9 @@
     # Coturn TURN SERVER configuration file
     #
    -# Boolean values note: where boolean value is supposed to be used,
    -# you can use '0', 'off', 'no', 'false', 'f' as 'false, 
    -# and you can use '1', 'on', 'yes', 'true', 't' as 'true' 
    -# If the value is missed, then it means 'true'.
    +# Boolean values note: where a boolean value is supposed to be used,
    +# you can use '0', 'off', 'no', 'false', or 'f' as 'false, 
    +# and you can use '1', 'on', 'yes', 'true', or 't' as 'true' 
    +# If the value is missing, then it means 'true' by default.
     #
     
     # Listener interface device (optional, Linux only).
    @@ -22,10 +22,10 @@
     # port(s), too - if allowed by configuration. The TURN server 
     # "automatically" recognizes the type of traffic. Actually, two listening
     # endpoints (the "plain" one and the "tls" one) are equivalent in terms of
    -# functionality; but we keep both endpoints to satisfy the RFC 5766 specs.
    -# For secure TCP connections, we currently support SSL version 3 and 
    +# functionality; but Coturn keeps both endpoints to satisfy the RFC 5766 specs.
    +# For secure TCP connections, Coturn currently supports
     # TLS version 1.0, 1.1 and 1.2.
    -# For secure UDP connections, we support DTLS version 1.
    +# For secure UDP connections, Coturn supports DTLS version 1.
     #
     #tls-listening-port=5349
     
    @@ -44,6 +44,14 @@
     # Default (or zero) value means "TLS listening port plus one".
     #
     #alt-tls-listening-port=0
    +
    +# Some network setups will require using a TCP reverse proxy in front
    +# of the STUN server. If the proxy port option is set a single listener
    +# is started on the given port that accepts connections using the
    +# haproxy proxy protocol v2.
    +# (https://www.haproxy.org/download/1.8/doc/proxy-protocol.txt)
    +#
    +#tcp-proxy-port=5555
     	
     # Listener IP address of relay server. Multiple listeners can be specified.
     # If no IP(s) specified in the config file or in the command line options, 
    @@ -133,8 +141,8 @@
     #
     # If this parameter is not set, then the default OS-dependent 
     # thread pattern algorithm will be employed. Usually the default
    -# algorithm is the most optimal, so you have to change this option
    -# only if you want to make some fine tweaks. 
    +# algorithm is optimal, so you have to change this option
    +# if you want to make some fine tweaks. 
     #
     # In the older systems (Linux kernel before 3.9),
     # the number of UDP threads is always one thread per network listening
    @@ -155,7 +163,7 @@
     	
     # Uncomment to run TURN server in 'extra' verbose mode.
     # This mode is very annoying and produces lots of output.
    -# Not recommended under any normal circumstances.
    +# Not recommended under normal circumstances.
     #	
     #Verbose
     
    @@ -169,11 +177,11 @@
     #
     #lt-cred-mech
     
    -# This option is opposite to lt-cred-mech. 
    +# This option is the opposite of lt-cred-mech. 
     # (TURN Server with no-auth option allows anonymous access).
     # If neither option is defined, and no users are defined,
     # then no-auth is default. If at least one user is defined, 
    -# in this file or in command line or in usersdb file, then
    +# in this file, in command line or in usersdb file, then
     # lt-cred-mech is default.
     #
     #no-auth
    @@ -193,34 +201,33 @@
     # turn password -> base64(hmac(secret key, usercombo))
     #
     # This allows TURN credentials to be accounted for a specific user id.
    -# If you don't have a suitable id, the timestamp alone can be used.
    -# This option is just turning on secret-based authentication.
    -# The actual value of the secret is defined either by option static-auth-secret,
    +# If you don't have a suitable id, then the timestamp alone can be used.
    +# This option is enabled by turning on secret-based authentication.
    +# The actual value of the secret is defined either by the option static-auth-secret,
     # or can be found in the turn_secret table in the database (see below).
     # 
     # Read more about it:
     #  - https://tools.ietf.org/html/draft-uberti-behave-turn-rest-00
     #  - https://www.ietf.org/proceedings/87/slides/slides-87-behave-10.pdf
     #
    -# Be aware that use-auth-secret overrides some part of lt-cred-mech.
    -# Notice that this feature depends internally on lt-cred-mech, so if you set
    -# use-auth-secret then it enables internally automatically lt-cred-mech option
    -# like if you enable both.
    -#
    -# You can use only one of the to auth mechanisms in the same time because,
    -# both mechanism use the username and password validation in different way.
    +# Be aware that use-auth-secret overrides some parts of lt-cred-mech.
    +# The use-auth-secret feature depends internally on lt-cred-mech, so if you set
    +# this option then it automatically enables lt-cred-mech internally
    +# as if you had enabled both.
     #
    -# This way be aware that you can't use both auth mechnaism in the same time!
    -# Use in config either the lt-cred-mech or the use-auth-secret
    +# Note that you can use only one auth mechanism at the same time! This is because,
    +# both mechanisms conduct username and password validation in different ways.
    +# 
    +# Use either lt-cred-mech or use-auth-secret in the conf
     # to avoid any confusion.
     #
     #use-auth-secret
     
     # 'Static' authentication secret value (a string) for TURN REST API only. 
     # If not set, then the turn server
    -# will try to use the 'dynamic' value in turn_secret table
    -# in user database (if present). The database-stored  value can be changed on-the-fly
    -# by a separate program, so this is why that other mode is 'dynamic'.
    +# will try to use the 'dynamic' value in the turn_secret table
    +# in the user database (if present). The database-stored  value can be changed on-the-fly
    +# by a separate program, so this is why that mode is considered 'dynamic'.
     #
     #static-auth-secret=north
     
    @@ -234,10 +241,10 @@
     #
     #oauth
     
    -# 'Static' user accounts for long term credentials mechanism, only.
    +# 'Static' user accounts for the long term credentials mechanism, only.
     # This option cannot be used with TURN REST API.
     # 'Static' user accounts are NOT dynamically checked by the turnserver process, 
    -# so that they can NOT be changed while the turnserver is running.
    +# so they can NOT be changed while the turnserver is running.
     #
     #user=username1:key1
     #user=username2:key2
    @@ -263,83 +270,83 @@
     
     # SQLite database file name.
     #
    -# Default file name is /var/db/turndb or /usr/local/var/db/turndb or
    +# The default file name is /var/db/turndb or /usr/local/var/db/turndb or
     # /var/lib/turn/turndb.
     # 
     #userdb=/var/db/turndb
     
    -# PostgreSQL database connection string in the case that we are using PostgreSQL
    +# PostgreSQL database connection string in the case that you are using PostgreSQL
     # as the user database.
    -# This database can be used for long-term credential mechanism
    -# and it can store the secret value for secret-based timed authentication in TURN RESP API. 
    +# This database can be used for the long-term credential mechanism
    +# and it can store the secret value for secret-based timed authentication in TURN REST API. 
     # See http://www.postgresql.org/docs/8.4/static/libpq-connect.html for 8.x PostgreSQL
     # versions connection string format, see 
     # http://www.postgresql.org/docs/9.2/static/libpq-connect.html#LIBPQ-CONNSTRING
     # for 9.x and newer connection string formats.
     #
     #psql-userdb="host=<host> dbname=<database-name> user=<database-user> password=<database-user-password> connect_timeout=30"
     
    -# MySQL database connection string in the case that we are using MySQL
    +# MySQL database connection string in the case that you are using MySQL
     # as the user database.
    -# This database can be used for long-term credential mechanism
    -# and it can store the secret value for secret-based timed authentication in TURN RESP API.
    +# This database can be used for the long-term credential mechanism
    +# and it can store the secret value for secret-based timed authentication in TURN REST API.
     #
     # Optional connection string parameters for the secure communications (SSL): 
     # ca, capath, cert, key, cipher 
     # (see http://dev.mysql.com/doc/refman/5.1/en/ssl-options.html for the 
     # command options description).
     #
    -# Use string format as below (space separated parameters, all optional):
    +# Use the string format below (space separated parameters, all optional):
     #
     #mysql-userdb="host=<host> dbname=<database-name> user=<database-user> password=<database-user-password> port=<port> connect_timeout=<seconds> read_timeout=<seconds>"
     
    -# If you want to use in the MySQL connection string the password in encrypted format,
    -# then set in this option the MySQL password encryption secret key file.
    +# If you want to use an encrypted password in the MySQL connection string,
    +# then set the MySQL password encryption secret key file with this option.
     #
    -# Warning: If this option is set, then mysql password must be set in "mysql-userdb" in encrypted format! 
    -# If you want to use cleartext password then do not set this option!
    +# Warning: If this option is set, then the mysql password must be set in "mysql-userdb" in an encrypted format! 
    +# If you want to use a cleartext password then do not set this option!
     #
    -# This is the file path which contain secret key of aes encryption while using password encryption.
    +# This is the file path for the aes encrypted secret key used for password encryption.
     #
     #secret-key-file=/path/
     
    -# MongoDB database connection string in the case that we are using MongoDB
    +# MongoDB database connection string in the case that you are using MongoDB
     # as the user database.
     # This database can be used for long-term credential mechanism
    -# and it can store the secret value for secret-based timed authentication in TURN RESP API. 
    -# Use string format is described at http://hergert.me/docs/mongo-c-driver/mongoc_uri.html
    +# and it can store the secret value for secret-based timed authentication in TURN REST API. 
    +# Use the string format described at http://hergert.me/docs/mongo-c-driver/mongoc_uri.html
     #
     #mongo-userdb="mongodb://[username:password@]host1[:port1][,host2[:port2],...[,hostN[:portN]]][/[database][?options]]"
     
    -# Redis database connection string in the case that we are using Redis
    +# Redis database connection string in the case that you are using Redis
     # as the user database.
     # This database can be used for long-term credential mechanism
    -# and it can store the secret value for secret-based timed authentication in TURN RESP API. 
    -# Use string format as below (space separated parameters, all optional):
    +# and it can store the secret value for secret-based timed authentication in TURN REST API. 
    +# Use the string format below (space separated parameters, all optional):
     #
     #redis-userdb="ip=<ip-address> dbname=<database-number> password=<database-user-password> port=<port> connect_timeout=<seconds>"
     
     # Redis status and statistics database connection string, if used (default - empty, no Redis stats DB used).
     # This database keeps allocations status information, and it can be also used for publishing
     # and delivering traffic and allocation event notifications.
     # The connection string has the same parameters as redis-userdb connection string. 
    -# Use string format as below (space separated parameters, all optional):
    +# Use the string format below (space separated parameters, all optional):
     #
     #redis-statsdb="ip=<ip-address> dbname=<database-number> password=<database-user-password> port=<port> connect_timeout=<seconds>"
     
     # The default realm to be used for the users when no explicit 
    -# origin/realm relationship was found in the database, or if the TURN
    +# origin/realm relationship is found in the database, or if the TURN
     # server is not using any database (just the commands-line settings
     # and the userdb file). Must be used with long-term credentials 
     # mechanism or with TURN REST API.
     #
    -# Note: If default realm is not specified at all, then realm falls back to the host domain name.
    -#       If domain name is empty string, or '(None)', then it is initialized to am empty string.
    +# Note: If the default realm is not specified, then realm falls back to the host domain name.
    +#       If the domain name string is empty, or set to '(None)', then it is initialized as an empty string.
     #
     #realm=mycompany.org
     
    -# The flag that sets the origin consistency 
    -# check: across the session, all requests must have the same
    +# This flag sets the origin consistency 
    +# check. Across the session, all requests must have the same
     # main ORIGIN attribute value (if the ORIGIN was
     # initially used by the session).
     #
    @@ -359,7 +366,7 @@
     
     # Max bytes-per-second bandwidth a TURN session is allowed to handle
     # (input and output network streams are treated separately). Anything above
    -# that limit will be dropped or temporary suppressed (within
    +# that limit will be dropped or temporarily suppressed (within
     # the available buffer limits).
     # This option can also be set through the database, for a particular realm.
     #
    @@ -403,9 +410,9 @@
     #no-tcp-relay
     
     # Uncomment if extra security is desired,
    -# with nonce value having limited lifetime.
    +# with nonce value having a limited lifetime.
     # By default, the nonce value is unique for a session,
    -# and has unlimited lifetime. 
    +# and has an unlimited lifetime. 
     # Set this option to limit the nonce lifetime. 
     # It defaults to 600 secs (10 min) if no value is provided. After that delay, 
     # the client will get 438 error and will have to re-authenticate itself.
    @@ -435,6 +442,7 @@
     # Certificate file.
     # Use an absolute path or path relative to the 
     # configuration file.
    +# Use PEM file format.
     #
     #cert=/usr/local/etc/turn_server_cert.pem
     
    @@ -457,7 +465,7 @@
     
     # CA file in OpenSSL format. 
     # Forces TURN server to verify the client SSL certificates.
    -# By default it is not set: there is no default value and the client
    +# By default this is not set: there is no default value and the client
     # certificate is not checked.
     #
     # Example:
    @@ -471,30 +479,30 @@
     #
     #ec-curve-name=prime256v1
     
    -# Use 566 bits predefined DH TLS key. Default size of the key is 1066.
    +# Use 566 bits predefined DH TLS key. Default size of the key is 2066.
     #
     #dh566
     
    -# Use 2066 bits predefined DH TLS key. Default size of the key is 1066.
    +# Use 1066 bits predefined DH TLS key. Default size of the key is 2066.
     #
    -#dh2066
    +#dh1066
     
     # Use custom DH TLS key, stored in PEM format in the file.
     # Flags --dh566 and --dh2066 are ignored when the DH key is taken from a file.
     #
     #dh-file=<DH-PEM-file-name>
     
     # Flag to prevent stdout log messages.
    -# By default, all log messages are going to both stdout and to 
    -# the configured log file. With this option everything will be 
    -# going to the configured log only (unless the log file itself is stdout).
    +# By default, all log messages go to both stdout and to 
    +# the configured log file. With this option everything will 
    +# go to the configured log only (unless the log file itself is stdout).
     #
     #no-stdout-log
     
     # Option to set the log file name.
     # By default, the turnserver tries to open a log file in 
    -# /var/log, /var/tmp, /tmp and current directories directories
    -# (which open operation succeeds first that file will be used).
    +# /var/log, /var/tmp, /tmp and the current directory
    +# (Whichever file open operation succeeds first will be used).
     # With this option you can set the definite log file name.
     # The special names are "stdout" and "-" - they will force everything 
     # to the stdout. Also, the "syslog" name will force everything to
    @@ -515,14 +523,14 @@
     #simple-log
     
     # Option to set the "redirection" mode. The value of this option
    -# will be the address of the alternate server for UDP & TCP service in form of 
    +# will be the address of the alternate server for UDP & TCP service in the form of 
     # <ip>[:<port>]. The server will send this value in the attribute
     # ALTERNATE-SERVER, with error 300, on ALLOCATE request, to the client.
     # Client will receive only values with the same address family
     # as the client network endpoint address family. 
    -# See RFC 5389 and RFC 5766 for ALTERNATE-SERVER functionality description. 
    +# See RFC 5389 and RFC 5766 for the description of ALTERNATE-SERVER functionality. 
     # The client must use the obtained value for subsequent TURN communications.
    -# If more than one --alternate-server options are provided, then the functionality
    +# If more than one --alternate-server option is provided, then the functionality
     # can be more accurately described as "load-balancing" than a mere "redirection". 
     # If the port number is omitted, then the default port 
     # number 3478 for the UDP/TCP protocols will be used.
    @@ -532,7 +540,7 @@
     # [2001:db8:85a3:8d3:1319:8a2e:370:7348]:3478 . 
     # Multiple alternate servers can be set. They will be used in the
     # round-robin manner. All servers in the pool are considered of equal weight and 
    -# the load will be distributed equally. For example, if we have 4 alternate servers, 
    +# the load will be distributed equally. For example, if you have 4 alternate servers, 
     # then each server will receive 25% of ALLOCATE requests. A alternate TURN server 
     # address can be used more than one time with the alternate-server option, so this 
     # can emulate "weighting" of the servers.
    @@ -559,6 +567,15 @@
     #
     #stun-only
     
    +# Option to hide software version. Enhance security when used in production.
    +# Revealing the specific software version of the agent through the
    +# SOFTWARE attribute might allow them to become more vulnerable to
    +# attacks against software that is known to contain security holes.
    +# Implementers SHOULD make usage of the SOFTWARE attribute a
    +# configurable option (https://tools.ietf.org/html/rfc5389#section-16.1.2)
    +#
    +#no-software-attribute
    +
     # Option to suppress STUN functionality, only TURN requests will be processed.
     # Run as TURN server only, all STUN requests will be ignored.
     # By default, this option is NOT set.
    @@ -622,19 +639,19 @@
     # Allocate Address Family according 
     # If enabled then TURN server allocates address family according  the TURN 
     # Client <=> Server communication address family.
    -# (By default coTURN works according RFC 6156.)
    +# (By default Coturn works according RFC 6156.)
     # !!Warning: Enabling this option breaks RFC6156 section-4.2 (violates use default IPv4)!!
     #
     #keep-address-family
     
     
     # User name to run the process. After the initialization, the turnserver process
    -# will make an attempt to change the current user ID to that user.
    +# will attempt to change the current user ID to that user.
     #
     #proc-user=<user-name>
     
     # Group name to run the process. After the initialization, the turnserver process
    -# will make an attempt to change the current group ID to that group.
    +# will attempt to change the current group ID to that group.
     #
     #proc-group=<group-name>
     
    @@ -654,8 +671,8 @@
     #cli-port=5766
     
     # CLI access password. Default is empty (no password).
    -# For the security reasons, it is recommended to use the encrypted
    -# for of the password (see the -P command in the turnadmin utility).
    +# For the security reasons, it is recommended that you use the encrypted
    +# form of the password (see the -P command in the turnadmin utility).
     #
     # Secure form for password 'qwerty':
     #
    @@ -685,7 +702,7 @@
     #web-admin-listen-on-workers
     
     # Server relay. NON-STANDARD AND DANGEROUS OPTION. 
    -# Only for those applications when we want to run 
    +# Only for those applications when you want to run 
     # server applications on the relay endpoints.
     # This option eliminates the IP permissions check on 
     # the packets incoming to the relay endpoints.
    
  • examples/etc/turn_server_pkey.pem+1 0 added
    @@ -0,0 +1 @@
    +../ca/turn_server_pkey.pem
    \ No newline at end of file
    
  • examples/etc/turn_server_pkey.pem+0 27 removed
    @@ -1,27 +0,0 @@
    ------BEGIN RSA PRIVATE KEY-----
    -MIIEpAIBAAKCAQEAv6bYkERhZ43RjW4EuqCaTq5g+D+lJI/GwlVzdzQ3+F4clMQD
    -R1kp1nX+9AvwjCXz3AYwY1H9CqjmjGM4R9uNJJseK/aJd2DUFADkF+7I674XwX8U
    -2Fy5on9jqWq3jdbb8eg/awcTBdrNLWNPquwfS2KVdooj9yPkqnO0c3ko1/OzIQCc
    -s09O3l/MPt+aOsHk3B9l79ZRs3zWkylI+we0Fnc+7tZEpsCztA+KCCoiJf7NenOv
    -VhdKg7D1AXuzJ/P/Euvc3+CIiS9HI4pWLopY1k+HydLeIcopqSbg9CRIKe1HOL8Y
    -TvCm2ZoTqgijwWUlGtwEDf2xxUQX/TLYiW8JFQIDAQABAoIBADUPHCXUyKLCwKFH
    -NEf27sGZxX71H+NfaseioLT/3/8DDyagncfDB7I4OL2YEKC8YScpD3xv1n59BFcZ
    -oRtDzW+1AkVpm+VRCWYAWSXHFhkuJ6WKaVr9UOeMHStqQCcktP/kLKqU6s9UJDnM
    -pOHNPVzBjl+jHxHs/gGyxuKxSH2Anwkrzpiv5j0obKFnw3QtAqeZRs1NlvPtYt2S
    -eihZWr8r8LqylPk9ga9MYmO79Yr+EPVaqd6bmz4MpZJ4/7LEjx03Q6azdMCPhFNY
    -cYzPIDZFEj81Zj/tqA2MU/uTTUUrcXint4dHRJs34m5N68PV1Y1XhhH6FG0+X711
    -ZymudoECgYEA/ChS5zmmOoLoaq2441+PzQbDP45qR6+G4slHwC8RDZhsYw0hQnp9
    -n44Qagpt74J4FjxT20BdE714DZP32IqagUwatWRQ+z3UoGafkJSNc5JSEogwZ65C
    -nC8RI1pPHLEvE8IzBJiqUA1kbMOMfTYW694wdN9JVZang05/AXaJzm8CgYEAwpJ8
    -nJRR9JFweHRrRgnrVk0Qi+ABbN9T/nhPXYab2vjBfeBOTA1Mob0M3zMJDCnL2i+D
    -K1GzE6WaYHElr45j2Wfphd/rRTk74WR4BaPpTCGaAhBQNn0ufqUkKsCPEAlTU+nG
    -iyXP4OvdMPjEBckjbKm/mlX7m0njSHAY6SWNorsCgYEAi8Yubk3efwChpMC3hBIs
    -vBHLmSdwclwyAPRh+X4djdO4AQ/+J8OObytond86IVHJD0pRkW+UKKUWLzCeakIq
    -cxGknHgHC72yZ1d7i8FMx4uMQwmLC23lLn5ImbgtslHlLqavcRTPE6DY0hFzhtS8
    -z/JSGfbLx83C/V49uKnkqbECgYA6h1oYt70XdpCAi3ShcuZp5XCuwslq+JsJlyM4
    -nP9RFTcPKGQlGHMOzBGNKor0L7Z0gYpRg5f8tvoDPMX7UzfR9CIY9UyOXDMZD+HS
    -wIWzMwBi0olueqV7zy1b9uSSDFwWh+IDhXJM1GaLDqnYm7KeQ0mxoV+4TLej2KSF
    -rZg3dQKBgQCVrVxFV8jHBsRsH5PzMx6pUSAollmuyte9mGU1MIE7EZf+LEQIAjGZ
    -9jvtAILYVJXwVZv1/zNxldUfBNuWc95ft+Gg7FEN0p0uLpdYNXQUcXuJaJ9tJ1td
    -ZfvRcrUXdFNKYt9/yaGeHVaIQfp4W1faZD7OnII7EOVkUKyv/qNGAA==
    ------END RSA PRIVATE KEY-----
    
  • examples/scripts/longtermsecure/secure_dtls_client_cert.sh+1 1 modified
    @@ -32,5 +32,5 @@ fi
     
     export LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:/usr/local/lib/
     
    -PATH=examples/bin/:../bin:./bin/:${PATH} turnutils_uclient -S -i turn_server_cert.pem -k turn_server_pkey.pem -E turn_server_cert.pem -n 1000 -m 10 -l 170 -e 127.0.0.1 -g -u bolt -w kwyjibo -s -X $@ 127.0.0.1
    +PATH=examples/bin/:../bin:./bin/:${PATH} turnutils_uclient -S -i turn_server_cert.pem -k turn_server_pkey.pem -E cacert.pem -n 1000 -m 10 -l 170 -e 127.0.0.1 -g -u bolt -w kwyjibo -s -X $@ 127.0.0.1
     
    
  • examples/scripts/longtermsecure/secure_relay_cert.sh+1 1 modified
    @@ -36,4 +36,4 @@ fi
     export LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:/usr/local/lib/:/usr/local/mysql/lib/
     export DYLD_LIBRARY_PATH=${DYLD_LIBRARY_PATH}:/usr/local/lib/:/usr/local/mysql/lib/
     
    -PATH="./bin/:../bin/:../../bin/:${PATH}" turnserver --syslog -a -L 127.0.0.1 -L ::1 -E 127.0.0.1 -E ::1 --allow-loopback-peers --max-bps=3000000 -f -m 10 --min-port=32355 --max-port=65535 --user=ninefingers:youhavetoberealistic --user=bolt:kwyjibo -r bolt.co --cert=turn_server_cert.pem --pkey=turn_server_pkey.pem --CA-file=turn_server_cert.pem --log-file=stdout -v --cipher-list="ALL:!eNULL:!aNULL:!NULL" --cli-password=secret --db=var/db/turndb $@
    +PATH="./bin/:../bin/:../../bin/:${PATH}" turnserver --syslog -a -L 127.0.0.1 -L ::1 -E 127.0.0.1 -E ::1 --allow-loopback-peers --max-bps=3000000 -f -m 10 --min-port=32355 --max-port=65535 --user=ninefingers:youhavetoberealistic --user=bolt:kwyjibo -r bolt.co --cert=turn_server_cert.pem --pkey=turn_server_pkey.pem --CA-file=cacert.pem --log-file=stdout -v --cipher-list="ALL:!eNULL:!aNULL:!NULL" --cli-password=secret --db=var/db/turndb $@
    
  • examples/scripts/longtermsecure/secure_tls_client_cert.sh+1 1 modified
    @@ -32,5 +32,5 @@ fi
     
     export LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:/usr/local/lib/
     
    -PATH=examples/bin/:../bin:./bin/:${PATH} turnutils_uclient -t -S -i turn_server_cert.pem -k turn_server_pkey.pem -E turn_server_cert.pem -n 1000 -m 10 -l 170 -e 127.0.0.1 -X -g -u bolt -w kwyjibo -s $@ 127.0.0.1
    +PATH=examples/bin/:../bin:./bin/:${PATH} turnutils_uclient -t -S -i turn_server_cert.pem -k turn_server_pkey.pem -E cacert.pem -n 1000 -m 10 -l 170 -e 127.0.0.1 -X -g -u bolt -w kwyjibo -s $@ 127.0.0.1
     
    
  • examples/scripts/pack.sh+3 2 modified
    @@ -2,7 +2,7 @@
     
     # Run it from the root of the coturn source tree
     
    -V=4.5.1.0
    +V=4.5.1.3
     
     PACKDIR=`pwd`/../coturn-releases/
     SRCDIR=`pwd`
    @@ -16,7 +16,8 @@ mkdir tmp
     cd tmp
     mkdir ${DDIR}
     cp -R ${SRCDIR}/* ${DDIR}/
    -tar cvfz ../${DDIR}.tar.gz ${DDIR}
    +#tell tar to not include the metadata
    +COPYFILE_DISABLE=1 tar cvfz ../${DDIR}.tar.gz ${DDIR}
     cd ..
     rm -rf tmp
     
    
  • INSTALL+1 1 modified
    @@ -15,7 +15,7 @@ Unpack the archive:
     
      $ tar xvfz turnserver-<...>.tar.gz
      
    -Read the INSTALl file:
    +Read the INSTALL file:
     
      $ cat INSTALL
      
    
  • man/man1/turnadmin.1+27 26 modified
    @@ -1,17 +1,17 @@
     .\" Text automatically generated by txt2man
    -.TH TURN 1 "29 January 2019" "" ""
    +.TH TURN 1 "29 April 2020" "" ""
     .SH GENERAL INFORMATION
     
    -\fIturnadmin\fP is a TURN administration tool. This tool can be used to manage 
    -the user accounts (add/remove users, generate 
    -TURN keys for the users). For security reasons, we do not recommend 
    -storing passwords openly. The better option is to use pre\-processed "keys" 
    -which are then used for authentication. These keys are generated by \fIturnadmin\fP. 
    -Turnadmin is a link to \fIturnserver\fP binary, but \fIturnadmin\fP performs different 
    +\fIturnadmin\fP is a TURN administration tool. This tool can be used to manage
    +the user accounts (add/remove users, generate
    +TURN keys for the users). For security reasons, we do not recommend
    +storing passwords openly. The better option is to use pre\-processed "keys"
    +which are then used for authentication. These keys are generated by \fIturnadmin\fP.
    +Turnadmin is a link to \fIturnserver\fP binary, but \fIturnadmin\fP performs different
     functions.
     .PP
     Options note: \fIturnadmin\fP has long and short option names, for most options.
    -Some options have only long form, some options have only short form. Their syntax 
    +Some options have only long form, some options have only short form. Their syntax
     somewhat different, if an argument is required:
     .PP
     The short form must be used as this (for example):
    @@ -46,23 +46,28 @@ is equivalent to:
     
     .fam T
     .fi
    -You have always the use the \fB\-r\fP <realm> option with commands for long term credentials \- 
    +You have always the use the \fB\-r\fP <realm> option with commands for long term credentials \-
     because data for multiple realms can be stored in the same database.
     .PP
     =====================================
     .SS  NAME
     \fB
     \fBturnadmin \fP\- a TURN relay administration tool.
     \fB
    -.SS  SYNOPSIS  
    +.SS  SYNOPSIS
    +.nf
    +.fam C
    +
    +$ \fIturnadmin\fP [\fIcommand\fP] [\fIoptions\fP]
     
    -$ \fIturnadmin\fP [command] [options]
    -.PP
     $ \fIturnadmin\fP [ \fB\-h\fP | \fB\-\-help\fP]
    +
    +.fam T
    +.fi
    +.fam T
    +.fi
     .SS  DESCRIPTION
     
    -.TP
    -.B
     Commands:
     .TP
     .B
    @@ -71,7 +76,7 @@ Generate and print to the standard
     output an encrypted form of a password (for web admin user or CLI).
     The value then can be used as a safe key for the password
     storage on disk or in the database. Every invocation for the same password
    -produces a different result. The for mat of the encrypted password is:
    +produces a different result. The format of the encrypted password is:
     $5$<\.\.\.salt\.\.\.>$<\.\.\.sha256(salt+password)\.\.\.>. Salt is 16 characters,
     the sha256 output is 64 characters. Character 5 is the algorithm id (sha256).
     Only sha256 is supported as the hash function.
    @@ -104,7 +109,7 @@ List long\-term users in the database.
     \fB\-L\fP, \fB\-\-list\-admin\fP
     List admin users in the database.
     .PP
    -\fB\-s\fP, \fB\-\-set\-secret\fP=<value> Add shared secret for TURN RESP API
    +\fB\-s\fP, \fB\-\-set\-secret\fP=<value> Add shared secret for TURN REST API
     .TP
     .B
     \fB\-S\fP, \fB\-\-show\-secret\fP
    @@ -135,15 +140,14 @@ List origin\-to\-realm relations.
     Set realm params: max\-bps, total\-quota, user\-quota.
     .TP
     .B
    -\fB\-G\fP, \fB\-\-list\-realm\-options\fP
    +\fB\-G\fP, \fB\-\-list\-realm\fP\-\fIoptions\fP
     List realm params.
     .TP
     .B
     \fB\-E\fP, \fB\-\-generate\-encrypted\-password\-aes\fP
    -Generate and print to the standard output 
    +Generate and print to the standard output
     an encrypted form of password with AES\-128
    -.TP
    -.B
    +.PP
     Options with required values:
     .TP
     .B
    @@ -210,13 +214,12 @@ Set value of realm's total\-quota parameter.
     .TP
     .B
     \fB\-\-user\-quota\fP
    -Set value of realm's user\-quota parameter. 
    +Set value of realm's user\-quota parameter.
     .TP
     .B
     \fB\-h\fP, \fB\-\-help\fP
     Help.
    -.TP
    -.B
    +.PP
     Command examples:
     .PP
     Generate an encrypted form of a password:
    @@ -282,16 +285,14 @@ $ \fIturnadmin\fP \fB\-\-file\-key\-path\fP <key\-file> \fB\-v\fP <encrypted>
     .PP
     
     .RS
    -.TP
    -.B
     Help:
     .PP
     $ \fIturnadmin\fP \fB\-h\fP
     .PP
     =======================================
     .SS  DOCS
     
    -After installation, run the command:
    +After installation, run the \fIcommand\fP:
     .PP
     $ man \fIturnadmin\fP
     .PP
    
  • man/man1/turnserver.1+233 220 modified
    @@ -1,18 +1,18 @@
     .\" Text automatically generated by txt2man
    -.TH TURN 1 "29 January 2019" "" ""
    +.TH TURN 1 "29 April 2020" "" ""
     .SH GENERAL INFORMATION
     
    -The \fBTURN Server\fP project contains the source code of a TURN server and TURN client 
    -messaging library. Also, some extra programs provided, for testing\-only 
    -purposes. 
    +The \fBTURN Server\fP project contains the source code of a TURN server and TURN client
    +messaging library. Also, some extra programs provided, for testing\-only
    +purposes.
     .PP
     See the INSTALL file for the building instructions.
     .PP
     After the build, you will have the following binary images:
     .TP
     .B
     1.
    -\fIturnserver\fP: \fBTURN Server\fP relay. 
    +\fIturnserver\fP: \fBTURN Server\fP relay.
     The compiled binary image of the \fBTURN Server\fP program is located in bin/ sub\-directory.
     .TP
     .B
    @@ -35,15 +35,15 @@ turnutils_stunclient. See README.turnutils and \fIturnutils\fP man page.
     6.
     turnutils_rfc5769check. See README.turnutils and \fIturnutils\fP man page.
     .PP
    -In the "examples/scripts" sub\-directory, you will find the examples of command lines to be used 
    +In the "examples/scripts" sub\-directory, you will find the examples of command lines to be used
     to run the programs. The scripts are meant to be run from examples/ sub\-directory, for example:
     .PP
     $ cd examples
     $ ./scripts/secure_relay.sh
     .SH RUNNING THE TURN SERVER
     
     Options note: \fIturnserver\fP has long and short option names, for most options.
    -Some options have only long form, some options have only short form. Their syntax 
    +Some options have only long form, some options have only short form. Their syntax
     somewhat different, if an argument is required:
     .PP
     The short form must be used as this (for example):
    @@ -94,10 +94,8 @@ $ \fIturnserver\fP \fB\-h\fP
     .fi
     .fam T
     .fi
    -.SS  DESCRIPTION                                           
    +.SS  DESCRIPTION
     
    -.TP
    -.B
     Config file settings:
     .TP
     .B
    @@ -108,10 +106,10 @@ Do not use configuration file, use only command line parameters.
     \fB\-c\fP
     Configuration file name (default \- turnserver.conf).
     The format of config file can be seen in
    -the supplied examples/etc/turnserver.conf example file. Long 
    -names of the \fIoptions\fP are used as the configuration 
    -items names in the file. If not an absolute path is supplied, 
    -then the file is searched in the following directories: 
    +the supplied examples/etc/turnserver.conf example file. Long
    +names of the \fIoptions\fP are used as the configuration
    +items names in the file. If not an absolute path is supplied,
    +then the file is searched in the following directories:
     .RS
     .IP \(bu 3
     current directory
    @@ -126,8 +124,7 @@ upper directory level etc/
     .IP \(bu 3
     installation directory /etc
     .RE
    -.TP
    -.B
    +.PP
     User database settings:
     .TP
     .B
    @@ -139,18 +136,18 @@ SQLite user database file name (default \- /var/db/turndb or
     \fB\-e\fP, \fB\-\-psql\-userdb\fP
     User database connection string for PostgreSQL.
     This database can be used for long\-term credentials mechanism,
    -and it can store the secret value 
    -for secret\-based timed authentication in TURN RESP API.
    +and it can store the secret value
    +for secret\-based timed authentication in TURN REST API.
     The connection string format is like that:
     .RS
     .PP
    -"host=<host> dbname=<dbname> user=<db\-user> password=<db\-user\-password> connect_timeout=<seconds>" 
    +"host=<host> dbname=<dbname> user=<db\-user> password=<db\-user\-password> connect_timeout=<seconds>"
     (for 8.x or newer Postgres).
     .PP
     Or:
     .PP
    -"postgresql://username:password@hostname:port/databasename" 
    -(for 9.x or newer Postgres). 
    +"postgresql://username:password@hostname:port/databasename"
    +(for 9.x or newer Postgres).
     .PP
     See the INSTALL file for more explanations and examples.
     .PP
    @@ -159,23 +156,23 @@ Also, see http://www.PostgreSQL.org for full PostgreSQL documentation.
     .TP
     .B
     \fB\-M\fP, \fB\-\-mysql\-userdb\fP
    -User database connection string for MySQL or MariaDB. 
    +User database connection string for MySQL or MariaDB.
     This database can be used for long\-term credentials mechanism,
    -and it can store the secret value for 
    -secret\-based timed authentication in TURN RESP API.
    +and it can store the secret value for
    +secret\-based timed authentication in TURN REST API.
     The connection string format is like that:
     .RS
     .PP
     "host=<host> dbname=<dbname> user=<db\-user> password=<db\-user\-password> connect_timeout=<seconds> read_timeout=<seconds>"
     .PP
     See the INSTALL file for more explanations and examples.
     .PP
    -Also, see http://www.mysql.org or http://mariadb.org 
    +Also, see http://www.mysql.org or http://mariadb.org
     for full MySQL documentation.
     .PP
    -Optional connection string parameters for the secure communications (SSL): 
    -ca, capath, cert, key, cipher 
    -(see http://dev.mysql.com/doc/refman/5.1/en/ssl\-options.html for the 
    +Optional connection string parameters for the secure communications (SSL):
    +ca, capath, cert, key, cipher
    +(see http://dev.mysql.com/doc/refman/5.1/en/ssl\-options.html for the
     command \fIoptions\fP description).
     .RE
     .TP
    @@ -184,15 +181,15 @@ command \fIoptions\fP description).
     This is the file path which contain secret key of aes encryption while using MySQL password encryption.
     If you want to use in the MySQL connection string the password in encrypted format,
     then set in this option the file path of the secret key. The key which is used to encrypt MySQL password.
    -Warning: If this option is set, then MySQL password must be set in "mysql\-userdb" option in encrypted format! 
    +Warning: If this option is set, then MySQL password must be set in "mysql\-userdb" option in encrypted format!
     If you want to use cleartext password then do not set this option!
     .TP
     .B
     \fB\-J\fP, \fB\-\-mongo\-userdb\fP
    -User database connection string for MongoDB. 
    +User database connection string for MongoDB.
     This database can be used for long\-term credentials mechanism,
    -and it can store the secret value 
    -for secret\-based timed authentication in TURN RESP API.
    +and it can store the secret value
    +for secret\-based timed authentication in TURN REST API.
     The connection string format is like that:
     .RS
     .PP
    @@ -206,10 +203,10 @@ for full MongoDB documentation.
     .TP
     .B
     \fB\-N\fP, \fB\-\-redis\-userdb\fP
    -User database connection string for Redis. 
    +User database connection string for Redis.
     This database can be used for long\-term credentials mechanism,
    -and it can store the secret 
    -value for secret\-based timed authentication in TURN RESP API.
    +and it can store the secret
    +value for secret\-based timed authentication in TURN REST API.
     The connection string format is like that:
     .RS
     .PP
    @@ -219,8 +216,7 @@ See the INSTALL file for more explanations and examples.
     .PP
     Also, see http://redis.io for full Redis documentation.
     .RE
    -.TP
    -.B
    +.PP
     Flags:
     .TP
     .B
    @@ -234,15 +230,13 @@ Extra verbose mode, very annoying and not recommended.
     .B
     \fB\-o\fP, \fB\-\-daemon\fP
     Run server as daemon.
    -.TP
    -.B
    -\fB\-\-prod\fP
    -Production mode: hide the software version.
    +.PP
    +\fB\-\-no\-software\-attribute\fP Production mode: hide the software version.
     .TP
     .B
     \fB\-f\fP, \fB\-\-fingerprint\fP
     Use fingerprints in the TURN messages. If an incoming request
    -contains a fingerprint, then TURN server will always add 
    +contains a fingerprint, then TURN server will always add
     fingerprints to the messages in this session, regardless of the
     per\-server setting.
     .TP
    @@ -252,17 +246,17 @@ Use long\-term credentials mechanism (this one you need for WebRTC usage).
     .TP
     .B
     \fB\-z\fP, \fB\-\-no\-auth\fP
    -Do not use any credentials mechanism, allow anonymous access. 
    -Opposite to \fB\-a\fP and \fB\-A\fP \fIoptions\fP. This is default option when no 
    +Do not use any credentials mechanism, allow anonymous access.
    +Opposite to \fB\-a\fP and \fB\-A\fP \fIoptions\fP. This is default option when no
     authentication\-related \fIoptions\fP are set.
     By default, no credential mechanism is used \-
     any user is allowed.
     .TP
     .B
     \fB\-\-use\-auth\-secret\fP
     TURN REST API flag.
    -Flag that sets a special WebRTC authorization option 
    -that is based upon authentication secret. The feature purpose 
    +Flag that sets a special WebRTC authorization option
    +that is based upon authentication secret. The feature purpose
     is to support "\fBTURN Server\fP REST API" as described in
     the TURN REST API section below.
     This option uses timestamp as part of combined username:
    @@ -281,11 +275,11 @@ Support oAuth authentication, as in the third\-party STUN/TURN RFC 7635.
     .TP
     .B
     \fB\-\-dh566\fP
    -Use 566 bits predefined DH TLS key. Default size of the key is 1066.
    +Use 566 bits predefined DH TLS key. Default size of the key is 2066.
     .TP
     .B
    -\fB\-\-dh2066\fP
    -Use 2066 bits predefined DH TLS key. Default size of the key is 1066.
    +\fB\-\-dh1066\fP
    +Use 1066 bits predefined DH TLS key. Default size of the key is 2066.
     .TP
     .B
     \fB\-\-no\-tlsv1\fP
    @@ -317,19 +311,19 @@ Do not start DTLS client listeners.
     .TP
     .B
     \fB\-\-no\-udp\-relay\fP
    -Do not allow UDP relay endpoints defined in RFC 5766, 
    +Do not allow UDP relay endpoints defined in RFC 5766,
     use only TCP relay endpoints as defined in RFC 6062.
     .TP
     .B
     \fB\-\-no\-tcp\-relay\fP
    -Do not allow TCP relay endpoints defined in RFC 6062, 
    -use only UDP relay endpoints as defined in RFC 5766. 
    +Do not allow TCP relay endpoints defined in RFC 6062,
    +use only UDP relay endpoints as defined in RFC 5766.
     .TP
     .B
     \fB\-\-no\-stdout\-log\fP
     Flag to prevent stdout log messages.
     By default, all log messages are going to both stdout and to
    -the configured log file. With this option everything will be going to 
    +the configured log file. With this option everything will be going to
     the log file only (unless the log file itself is stdout).
     .TP
     .B
    @@ -349,25 +343,25 @@ By default, the clients are allowed anonymous access to the STUN Binding functio
     .TP
     .B
     \fB\-S\fP, \fB\-\-stun\-only\fP
    -Run as STUN server only, all TURN requests will be ignored. 
    +Run as STUN server only, all TURN requests will be ignored.
     Option to suppress TURN functionality, only STUN requests will be processed.
     .TP
     .B
     \fB\-\-no\-stun\fP
    -Run as TURN server only, all STUN requests will be ignored. 
    +Run as TURN server only, all STUN requests will be ignored.
     Option to suppress STUN functionality, only TURN requests will be processed.
     .TP
     .B
     \fB\-\-allow\-loopback\-peers\fP
     Allow peers on the loopback addresses (127.x.x.x and ::1).
    -Allow it only for testing in a development environment! 
    -In production it adds a possible security vulnerability, 
    -and so due to security reasons, it is not allowed 
    +Allow it only for testing in a development environment!
    +In production it adds a possible security vulnerability,
    +and so due to security reasons, it is not allowed
     using it together with empty cli\-password.
     .TP
     .B
     \fB\-\-no\-multicast\-peers\fP
    -Disallow peers on well\-known broadcast addresses 
    +Disallow peers on well\-known broadcast addresses
     (224.0.0.0 and above, and FFXX:*).
     .TP
     .B
    @@ -381,33 +375,32 @@ See also \fIoptions\fP \fB\-\-cli\-ip\fP and \fB\-\-cli\-port\fP.
     .TP
     .B
     \fB\-\-server\-relay\fP
    -Server relay. NON\-STANDARD AND DANGEROUS OPTION. 
    -Only for those applications when we want to run 
    +Server relay. NON\-STANDARD AND DANGEROUS OPTION.
    +Only for those applications when we want to run
     server applications on the relay endpoints.
    -This option eliminates the IP permissions check 
    +This option eliminates the IP permissions check
     on the packets incoming to the relay endpoints.
     See http://tools.ietf.org/search/rfc5766#section\-17.2.3 .
     .TP
     .B
     \fB\-\-udp\-self\-balance\fP
     (recommended for older Linuxes only)
     Automatically balance UDP traffic over auxiliary servers
    -(if configured). The load balancing is using the 
    -ALTERNATE\-SERVER mechanism. The TURN client must support 
    +(if configured). The load balancing is using the
    +ALTERNATE\-SERVER mechanism. The TURN client must support
     300 ALTERNATE\-SERVER response for this functionality.
     .TP
     .B
     \fB\-\-check\-origin\-consistency\fP
    -The flag that sets the origin consistency 
    +The flag that sets the origin consistency
     check: across the session, all requests must have the same
     main ORIGIN attribute value (if the ORIGIN was
     initially used by the session).
     .TP
     .B
     \fB\-h\fP
     Help.
    -.TP
    -.B
    +.PP
     Options with values:
     .TP
     .B
    @@ -434,17 +427,17 @@ This MUST not be changed for production purposes.
     .B
     \fB\-d\fP, \fB\-\-listening\-device\fP
     Listener interface device.
    -(NOT RECOMMENDED. Optional functionality, Linux only). 
    -The \fIturnserver\fP process must have root privileges to bind the 
    -listening endpoint to a device. If \fIturnserver\fP must run as a 
    +(NOT RECOMMENDED. Optional functionality, Linux only).
    +The \fIturnserver\fP process must have root privileges to bind the
    +listening endpoint to a device. If \fIturnserver\fP must run as a
     process without root privileges, then just do not use this setting.
     .TP
     .B
     \fB\-L\fP, \fB\-\-listening\-ip\fP
    -Listener IP address of relay server. 
    +Listener IP address of relay server.
     Multiple listeners can be specified, for example:
     \fB\-L\fP ip1 \fB\-L\fP ip2 \fB\-L\fP ip3
    -If no \fBIP\fP(s) specified, then all IPv4 and 
    +If no \fBIP\fP(s) specified, then all IPv4 and
     IPv6 system IPs will be used for listening.
     The same \fBip\fP(s) can be used as both listening and relay \fBip\fP(s).
     .TP
    @@ -458,11 +451,11 @@ Note: actually, TLS & DTLS sessions can connect to the "plain" TCP & UDP
     \fB\-\-tls\-listening\-port\fP
     TURN listener port for TLS and DTLS listeners (Default: 5349).
     Note: actually, "plain" TCP & UDP sessions can connect to the TLS & DTLS
    -\fBport\fP(s), too \- if allowed by configuration. The TURN server 
    +\fBport\fP(s), too \- if allowed by configuration. The TURN server
     "automatically" recognizes the type of traffic. Actually, two listening
     endpoints (the "plain" one and the "tls" one) are equivalent in terms of
     functionality; but we keep both endpoints to satisfy the RFC 5766 specs.
    -For secure TCP connections, we currently support SSL version 3 and 
    +For secure TCP connections, we currently support SSL version 3 and
     TLS versions 1.0, 1.1, 1.2.
     For secure UDP connections, we support DTLS version 1.
     .TP
    @@ -483,6 +476,12 @@ Alternative listening port for TLS and DTLS protocols.
     Default (or zero) value means "TLS listening port plus one".
     .TP
     .B
    +\fB\-\-tcp\-proxy\-port\fP
    +Support connections from TCP loadbalancer on this port. The loadbalancer
    +should use the binary proxy protocol.
    +(https://www.haproxy.org/download/1.8/doc/proxy\-protocol.txt)
    +.TP
    +.B
     \fB\-\-aux\-server\fP
     Auxiliary STUN/TURN server listening endpoint.
     Aux servers have almost full TURN and STUN functionality.
    @@ -501,37 +500,37 @@ to client requests.
     .TP
     .B
     \fB\-i\fP, \fB\-\-relay\-device\fP
    -Relay interface device for relay sockets 
    +Relay interface device for relay sockets
     (NOT RECOMMENDED. Optional, Linux only).
     .TP
     .B
     \fB\-E\fP, \fB\-\-relay\-ip\fP
    -Relay address (the local IP address that 
    -will be used to relay the packets to the 
    +Relay address (the local IP address that
    +will be used to relay the packets to the
     peer). Multiple relay addresses may be used:
     \fB\-E\fP ip1 \fB\-E\fP ip2 \fB\-E\fP ip3
     The same \fBIP\fP(s) can be used as both listening \fBIP\fP(s) and relay \fBIP\fP(s).
    -If no relay \fBIP\fP(s) specified, then the \fIturnserver\fP will apply the 
    -default policy: it will decide itself which relay addresses to be 
    -used, and it will always be using the client socket IP address as 
    -the relay IP address of the TURN session (if the requested relay 
    +If no relay \fBIP\fP(s) specified, then the \fIturnserver\fP will apply the
    +default policy: it will decide itself which relay addresses to be
    +used, and it will always be using the client socket IP address as
    +the relay IP address of the TURN session (if the requested relay
     address family is the same as the family of the client socket).
     .TP
     .B
     \fB\-X\fP, \fB\-\-external\-ip\fP
     \fBTURN Server\fP public/private address mapping, if the server is behind NAT.
     In that situation, if a \fB\-X\fP is used in form "\fB\-X\fP <ip>" then that ip will be reported
     as relay IP address of all allocations. This scenario works only in a simple case
    -when one single relay address is be used, and no CHANGE_REQUEST functionality is 
    +when one single relay address is be used, and no CHANGE_REQUEST functionality is
     required. That single relay address must be mapped by NAT to the 'external' IP.
     The "external\-ip" value, if not empty, is returned in XOR\-RELAYED\-ADDRESS field.
     For that 'external' IP, NAT must forward ports directly (relayed port 12345
     must be always mapped to the same 'external' port 12345).
     In more complex case when more than one IP address is involved,
     that option must be used several times, each entry must
     have form "\fB\-X\fP <public\-ip/private\-ip>", to map all involved addresses.
    -CHANGE_REQUEST (RFC5780 or RFC3489) NAT discovery STUN functionality will work 
    -correctly, if the addresses are mapped properly, even when the TURN server itself 
    +CHANGE_REQUEST (RFC5780 or RFC3489) NAT discovery STUN functionality will work
    +correctly, if the addresses are mapped properly, even when the TURN server itself
     is behind A NAT.
     By default, this value is empty, and no address mapping is used.
     .TP
    @@ -540,54 +539,54 @@ By default, this value is empty, and no address mapping is used.
     Number of the relay threads to handle the established connections
     (in addition to authentication thread and the listener thread).
     If explicitly set to 0 then application runs relay process in a single thread,
    -in the same thread with the listener process (the authentication thread will 
    -still be a separate thread). If not set, then a default optimal algorithm 
    +in the same thread with the listener process (the authentication thread will
    +still be a separate thread). If not set, then a default optimal algorithm
     will be employed (OS\-dependent). In the older Linux systems
    -(before Linux kernel 3.9), the number of UDP threads is always one threads 
    +(before Linux kernel 3.9), the number of UDP threads is always one threads
     per network listening endpoint \- unless "\fB\-m\fP 0" or "\fB\-m\fP 1" is set.
     .TP
     .B
     \fB\-\-min\-port\fP
    -Lower bound of the UDP port range for relay 
    +Lower bound of the UDP port range for relay
     endpoints allocation.
     Default value is 49152, according to RFC 5766.
     .TP
     .B
     \fB\-\-max\-port\fP
    -Upper bound of the UDP port range for relay 
    +Upper bound of the UDP port range for relay
     endpoints allocation.
     Default value is 65535, according to RFC 5766.
     .TP
     .B
     \fB\-u\fP, \fB\-\-user\fP
    -Long\-term security mechanism credentials user account, 
    -in the column\-separated form username:key. 
    +Long\-term security mechanism credentials user account,
    +in the column\-separated form username:key.
     Multiple user accounts may be used in the command line.
     The key is either the user password, or
     the key is generated
     by \fIturnadmin\fP command. In the second case,
     the key must be prepended with 0x symbols.
    -The key is calculated over the user name, 
    +The key is calculated over the user name,
     the user realm, and the user password.
     This setting may not be used with TURN REST API.
     .TP
     .B
     \fB\-r\fP, \fB\-\-realm\fP
    -The default realm to be used for the users when no explicit 
    +The default realm to be used for the users when no explicit
     origin/realm relationship was found in the database, or if the TURN
     server is not using any database (just the commands\-line settings
    -and the userdb file). Must be used with long\-term credentials 
    +and the userdb file). Must be used with long\-term credentials
     mechanism or with TURN REST API.
     .TP
     .B
     \fB\-C\fP, \fB\-\-rest\-api\-separator\fP
    -This is the timestamp/username separator symbol 
    +This is the timestamp/username separator symbol
     (character) in TURN REST API. The default value is :.
     .TP
     .B
     \fB\-q\fP, \fB\-\-user\-quota\fP
    -Per\-user allocations quota: how many concurrent 
    -allocations a user can create. This option can also be set 
    +Per\-user allocations quota: how many concurrent
    +allocations a user can create. This option can also be set
     through the database, for a particular realm.
     .TP
     .B
    @@ -598,9 +597,9 @@ This option can also be set through the database, for a particular realm.
     .B
     \fB\-s\fP, \fB\-\-max\-bps\fP
     Max bytes\-per\-second bandwidth a TURN session is allowed to handle
    -(input and output network streams are treated separately). Anything above 
    +(input and output network streams are treated separately). Anything above
     that limit will be dropped or temporary suppressed (within the
    -available buffer limits). This option can also be set through the 
    +available buffer limits). This option can also be set through the
     database, for a particular realm.
     .TP
     .B
    @@ -613,11 +612,25 @@ separately).
     .B
     \fB\-\-static\-auth\-secret\fP
     Static authentication secret value (a string) for TURN REST API only.
    -If not set, then the turn server will try to use the dynamic value 
    +If not set, then the turn server will try to use the dynamic value
     in turn_secret table in user database (if present). The database\-stored
     value can be changed on\-the\-fly by a separate program, so this is why
     that other mode is dynamic. Multiple shared secrets can be used
     (both in the database and in the "static" fashion).
    +.RS
    +.TP
    +.B
    +\fB\-\-no\-auth\-pings\fP
    +Disable periodic health checks to 'dynamic' auth secret tables.
    +.TP
    +.B
    +\fB\-\-no\-dynamic\-ip\-list\fP
    +Do not use dynamic allowed/denied peer ip list.
    +.TP
    +.B
    +\fB\-\-no\-dynamic\-realms\fP
    +Do not use dynamic realm assignment and \fIoptions\fP.
    +.RE
     .TP
     .B
     \fB\-\-server\-name\fP
    @@ -627,17 +640,17 @@ The default value is the realm name.
     .TP
     .B
     \fB\-\-cert\fP
    -Certificate file, PEM format. Same file 
    -search rules applied as for the configuration 
    -file. If both \fB\-\-no\-tls\fP and \fB\-\-no\-dtls\fP \fIoptions\fP 
    +Certificate file, PEM format. Same file
    +search rules applied as for the configuration
    +file. If both \fB\-\-no\-tls\fP and \fB\-\-no\-dtls\fP \fIoptions\fP
     are specified, then this parameter is not needed.
     Default value is turn_server_cert.pem.
     .TP
     .B
     \fB\-\-pkey\fP
    -Private key file, PEM format. Same file 
    -search rules applied as for the configuration 
    -file. If both \fB\-\-no\-tls\fP and \fB\-\-no\-dtls\fP \fIoptions\fP 
    +Private key file, PEM format. Same file
    +search rules applied as for the configuration
    +file. If both \fB\-\-no\-tls\fP and \fB\-\-no\-dtls\fP \fIoptions\fP
     are specified, then this parameter is not needed.
     Default value is turn_server_pkey.pem.
     .TP
    @@ -652,94 +665,94 @@ Default value is "DEFAULT".
     .TP
     .B
     \fB\-\-CA\-file\fP
    -CA file in OpenSSL format. 
    +CA file in OpenSSL format.
     Forces TURN server to verify the client SSL certificates.
     By default, no CA is set and no client certificate check is performed.
     .TP
     .B
     \fB\-\-ec\-curve\-name\fP
    -Curve name for EC ciphers, if supported by OpenSSL 
    -library (TLS and DTLS). The default value is prime256v1, 
    +Curve name for EC ciphers, if supported by OpenSSL
    +library (TLS and DTLS). The default value is prime256v1,
     if pre\-OpenSSL 1.0.2 is used. With OpenSSL 1.0.2+,
     an optimal curve will be automatically calculated, if not defined
     by this option.
     .TP
     .B
     \fB\-\-dh\-file\fP
     Use custom DH TLS key, stored in PEM format in the file.
    -Flags \fB\-\-dh566\fP and \fB\-\-dh2066\fP are ignored when the DH key is taken from a file.
    +Flags \fB\-\-dh566\fP and \fB\-\-dh1066\fP are ignored when the DH key is taken from a file.
     .TP
     .B
     \fB\-l\fP, \fB\-\-log\-file\fP
     Option to set the full path name of the log file.
    -By default, the \fIturnserver\fP tries to open a log file in 
    -/var/log/\fIturnserver\fP, /var/log, /var/tmp, /tmp and . (current) 
    -directories (which file open operation succeeds 
    -first that file will be used). With this option you can set the 
    +By default, the \fIturnserver\fP tries to open a log file in
    +/var/log/\fIturnserver\fP, /var/log, /var/tmp, /tmp and . (current)
    +directories (which file open operation succeeds
    +first that file will be used). With this option you can set the
     definite log file name.
    -The special names are "stdout" and "\-" \- they will force everything 
    +The special names are "stdout" and "\-" \- they will force everything
     to the stdout. Also, "syslog" name will redirect everything into
    -the system log (syslog), as if the option "\fB\-\-syslog\fP" was set. 
    -In the runtime, the logfile can be reset with the SIGHUP signal 
    +the system log (syslog), as if the option "\fB\-\-syslog\fP" was set.
    +In the runtime, the logfile can be reset with the SIGHUP signal
     to the \fIturnserver\fP process.
     .TP
     .B
     \fB\-\-alternate\-server\fP
     Option to set the "redirection" mode. The value of this option
    -will be the address of the alternate server for UDP & TCP service in form of 
    +will be the address of the alternate server for UDP & TCP service in form of
     <ip>[:<port>]. The server will send this value in the attribute
     ALTERNATE\-SERVER, with error 300, on ALLOCATE request, to the client.
     Client will receive only values with the same address family
    -as the client network endpoint address family. 
    -See RFC 5389 and RFC 5766 for ALTERNATE\-SERVER functionality description. 
    +as the client network endpoint address family.
    +See RFC 5389 and RFC 5766 for ALTERNATE\-SERVER functionality description.
     The client must use the obtained value for subsequent TURN communications.
     If more than one \fB\-\-alternate\-server\fP \fIoptions\fP are provided, then the functionality
    -can be more accurately described as "load\-balancing" than a mere "redirection". 
    -If the port number is omitted, then the default port 
    +can be more accurately described as "load\-balancing" than a mere "redirection".
    +If the port number is omitted, then the default port
     number 3478 for the UDP/TCP protocols will be used.
    -Colon (:) characters in IPv6 addresses may conflict with the syntax of 
    -the option. To alleviate this conflict, literal IPv6 addresses are enclosed 
    -in square brackets in such resource identifiers, for example: 
    -[2001:db8:85a3:8d3:1319:8a2e:370:7348]:3478 . 
    +Colon (:) characters in IPv6 addresses may conflict with the syntax of
    +the option. To alleviate this conflict, literal IPv6 addresses are enclosed
    +in square brackets in such resource identifiers, for example:
    +[2001:db8:85a3:8d3:1319:8a2e:370:7348]:3478 .
     Multiple alternate servers can be set. They will be used in the
    -round\-robin manner. All servers in the pool are considered of equal weight and 
    -the load will be distributed equally. For example, if we have 4 alternate servers, 
    -then each server will receive 25% of ALLOCATE requests. An alternate TURN server 
    -address can be used more than one time with the alternate\-server option, so this 
    -can emulate "weighting" of the servers. 
    +round\-robin manner. All servers in the pool are considered of equal weight and
    +the load will be distributed equally. For example, if we have 4 alternate servers,
    +then each server will receive 25% of ALLOCATE requests. An alternate TURN server
    +address can be used more than one time with the alternate\-server option, so this
    +can emulate "weighting" of the servers.
     .TP
     .B
     \fB\-\-tls\-alternate\-server\fP
    -Option to set alternative server for TLS & DTLS services in form of 
    -<ip>:<port>. If the port number is omitted, then the default port 
    -number 5349 for the TLS/DTLS protocols will be used. See the 
    +Option to set alternative server for TLS & DTLS services in form of
    +<ip>:<port>. If the port number is omitted, then the default port
    +number 5349 for the TLS/DTLS protocols will be used. See the
     previous option for the functionality description.
     .TP
     .B
     \fB\-O\fP, \fB\-\-redis\-statsdb\fP
    -Redis status and statistics database connection string, if used (default \- empty, 
    -no Redis stats DB used). This database keeps allocations status information, and it can 
    +Redis status and statistics database connection string, if used (default \- empty,
    +no Redis stats DB used). This database keeps allocations status information, and it can
     be also used for publishing and delivering traffic and allocation event notifications.
     This database option can be used independently of \fB\-\-redis\-userdb\fP option,
    -and actually Redis can be used for status/statistics and SQLite or MySQL or MongoDB or 
    +and actually Redis can be used for status/statistics and SQLite or MySQL or MongoDB or
     PostgreSQL can be used for the user database.
     The connection string has the same parameters as redis\-userdb connection string.
     .TP
     .B
     \fB\-\-max\-allocate\-timeout\fP
    -Max time, in seconds, allowed for full allocation establishment. 
    +Max time, in seconds, allowed for full allocation establishment.
     Default is 60 seconds.
     .PP
     \fB\-\-denied\-peer\-ip\fP=<IPaddr[\fB\-IPaddr\fP]>
     .PP
    -\fB\-\-allowed\-peer\-ip\fP=<IPaddr[\fB\-IPaddr\fP]> Options to ban or allow specific ip addresses or ranges 
    -of ip addresses. If an ip address is specified as both allowed and denied, then 
    +\fB\-\-allowed\-peer\-ip\fP=<IPaddr[\fB\-IPaddr\fP]> Options to ban or allow specific ip addresses or ranges
    +of ip addresses. If an ip address is specified as both allowed and denied, then
     the ip address is considered to be allowed. This is useful when you wish to ban
     a range of ip addresses, except for a few specific ips within that range.
     This can be used when you do not want users of the turn server to be able to access
    -machines reachable by the turn server, but would otherwise be unreachable from the 
    -internet (e.g. when the turn server is sitting behind a NAT). The 'white" and "black" peer 
    -IP ranges can also be dynamically changed in the database. 
    +machines reachable by the turn server, but would otherwise be unreachable from the
    +internet (e.g. when the turn server is sitting behind a NAT). The 'white" and "black" peer
    +IP ranges can also be dynamically changed in the database.
     The allowed/denied addresses (white/black lists) rules are very simple:
     .RS
     .IP 1) 4
    @@ -777,9 +790,9 @@ Client <=> Server communication address family.
     \fB\-\-cli\-ip\fP
     Local system IP address to be used for CLI management interface.
     The \fIturnserver\fP process can be accessed for management with telnet,
    -at this IP address and on the CLI port (see the next parameter). 
    +at this IP address and on the CLI port (see the next parameter).
     Default value is 127.0.0.1. You can use telnet or putty (in telnet mode)
    -to access the CLI management interface. 
    +to access the CLI management interface.
     .TP
     .B
     \fB\-\-cli\-port\fP
    @@ -833,24 +846,24 @@ This is a set of notes for the WebRTC users:
     .IP 1) 4
     WebRTC uses long\-term authentication mechanism, so you have to use \fB\-a\fP
     option (or \fB\-\-lt\-cred\-mech\fP). WebRTC relaying will not work with anonymous
    -access. With \fB\-a\fP option, do not forget to set the 
    -default realm (\fB\-r\fP option). You will also have to set up the user accounts, 
    +access. With \fB\-a\fP option, do not forget to set the
    +default realm (\fB\-r\fP option). You will also have to set up the user accounts,
     for that you have a number of \fIoptions\fP:
     .PP
     .nf
     .fam C
             a) command\-line options (\-u).
     
    -        b) a database table (SQLite or PostgreSQL or MySQL or MongoDB). You will have to 
    -        set keys with turnadmin utility (see docs and wiki for turnadmin). 
    +        b) a database table (SQLite or PostgreSQL or MySQL or MongoDB). You will have to
    +        set keys with turnadmin utility (see docs and wiki for turnadmin).
             You cannot use open passwords in the database.
     
    -        c) Redis key/value pair(s), if Redis is used. You key use either keys or 
    -        open passwords with Redis; see turndb/testredisdbsetup.sh file.  
    +        c) Redis key/value pair(s), if Redis is used. You key use either keys or
    +        open passwords with Redis; see turndb/testredisdbsetup.sh file.
     
             d) You also can use the TURN REST API. You will need shared secret(s) set
             either  through the command line option, or through the config file, or through
    -        the database table or Redis key/value pairs.  
    +        the database table or Redis key/value pairs.
     
     .fam T
     .fi
    @@ -868,19 +881,19 @@ number range.
     .SH TURN REST API
     
     In WebRTC, the browser obtains the TURN connection information from the web
    -server. This information is a secure information \- because it contains the 
    -necessary TURN credentials. As these credentials are transmitted over the 
    +server. This information is a secure information \- because it contains the
    +necessary TURN credentials. As these credentials are transmitted over the
     public networks, we have a potential security breach.
     .PP
    -If we have to transmit a valuable information over the public network, 
    -then this information has to have a limited lifetime. Then the guy who 
    -obtains this information without permission will be able to perform 
    +If we have to transmit a valuable information over the public network,
    +then this information has to have a limited lifetime. Then the guy who
    +obtains this information without permission will be able to perform
     only limited damage.
     .PP
    -This is how the idea of TURN REST API \- time\-limited TURN credentials \- 
    -appeared. This security mechanism is based upon the long\-term credentials 
    -mechanism. The main idea of the REST API is that the web server provides 
    -the credentials to the client, but those credentials can be used only 
    +This is how the idea of TURN REST API \- time\-limited TURN credentials \-
    +appeared. This security mechanism is based upon the long\-term credentials
    +mechanism. The main idea of the REST API is that the web server provides
    +the credentials to the client, but those credentials can be used only
     limited time by an application that has to create a TURN server connection.
     .PP
     The "classic" long\-term credentials mechanism (LTCM) is described here:
    @@ -891,23 +904,23 @@ http://tools.ietf.org/html/rfc5389#section\-15.4
     .PP
     For authentication, each user must know two things: the username and the
     password. Optionally, the user must supply the ORIGIN value, so that the
    -server can figure out the realm to be used for the user. The nonce and 
    -the realm values are supplied by the TURN server. But LTCM is not saying 
    -anything about the nature and about the persistence of the username and 
    +server can figure out the realm to be used for the user. The nonce and
    +the realm values are supplied by the TURN server. But LTCM is not saying
    +anything about the nature and about the persistence of the username and
     of the password; and this is used by the REST API.
     .PP
    -In the TURN REST API, there is no persistent passwords for users. A user has 
    -just the username. The password is always temporary, and it is generated by 
    -the web server on\-demand, when the user accesses the WebRTC page. And, 
    -actually, a temporary one\-time session only, username is provided to the user, 
    -too. 
    +In the TURN REST API, there is no persistent passwords for users. A user has
    +just the username. The password is always temporary, and it is generated by
    +the web server on\-demand, when the user accesses the WebRTC page. And,
    +actually, a temporary one\-time session only, username is provided to the user,
    +too.
     .PP
     The temporary user is generated as:
     .PP
     temporary\-username="timestamp" + ":" + "username"
     .PP
    -where username is the persistent user name, and the timestamp format is just 
    -seconds sinse 1970 \- the same value as \fBtime\fP(NULL) function returns.
    +where username is the persistent user name, and the timestamp format is just
    +seconds since 1970 \- the same value as \fBtime\fP(NULL) function returns.
     .PP
     The temporary password is obtained as HMAC\-SHA1 function over the temporary
     username, with shared secret as the HMAC key, and then the result is encoded:
    @@ -918,7 +931,7 @@ Both the TURN server and the web server know the same shared secret. How the
     shared secret is distributed among the involved entities is left to the WebRTC
     deployment details \- this is beyond the scope of the TURN REST API.
     .PP
    -So, a timestamp is used for the temporary password calculation, and this 
    +So, a timestamp is used for the temporary password calculation, and this
     timestamp can be retrieved from the temporary username. This information
     is valuable, but only temporary, while the timestamp is not expired. Without
     knowledge of the shared secret, a new temporary password cannot be generated.
    @@ -933,7 +946,7 @@ For developers, we are going to describe it step\-by\-step below:
     .RS
     .IP \(bu 3
     a new TURN client sends a request command to the TURN server. Optionally,
    -it adds the ORIGIN field to it. 
    +it adds the ORIGIN field to it.
     .IP \(bu 3
     TURN server sees that this is a new client and the message is not
     authenticated.
    @@ -956,13 +969,13 @@ the client uses username, realm and password to produce a key:
     (SASLprep is described here: http://tools.ietf.org/html/rfc4013)
     .IP \(bu 3
     the client forms a new request, adds username, realm and nonce to the
    -request. Then, the client calculates and adds the integrity field to 
    +request. Then, the client calculates and adds the integrity field to
     the request. This is the trickiest part of the process, and it is
    -described in the end of section 15.4: 
    +described in the end of section 15.4:
     http://tools.ietf.org/html/rfc5389#section\-15.4
     .IP \(bu 3
     the client, optionally, adds the fingerprint field. This may be also
    -a tricky procedure, described in section 15.5 of the same document. 
    +a tricky procedure, described in section 15.5 of the same document.
     WebRTC usually uses fingerprinted TURN messages.
     .IP \(bu 3
     the TURN server receives the request, reads the username.
    @@ -975,65 +988,65 @@ then the TURN server calculates the key.
     then the TURN server calculates the integrity field.
     .IP \(bu 3
     then the TURN server compares the calculated integrity field with the
    -received one \- they must be the same. If the integrity fields differ, 
    +received one \- they must be the same. If the integrity fields differ,
     then the request is rejected.
     .RE
     .PP
    -In subsequent communications, the client may go with exactly the same 
    -sequence, but for optimization usually the client, having already 
    -information about realm and nonce, pre\-calculates the integrity string 
    -for each request, so that the 401 error response becomes unnecessary. 
    -The TURN server may use "\fB\-\-stale\-nonce\fP" option for extra security: in 
    +In subsequent communications, the client may go with exactly the same
    +sequence, but for optimization usually the client, having already
    +information about realm and nonce, pre\-calculates the integrity string
    +for each request, so that the 401 error response becomes unnecessary.
    +The TURN server may use "\fB\-\-stale\-nonce\fP" option for extra security: in
     some time, the nonce expires and the client will obtain 438 error response
     with the new nonce, and the client will have to start using the new nonce.
     .PP
    -In subsequent communications, the sever and the client will always assume 
    -the same password \- the original password becomes the session parameter and 
    +In subsequent communications, the server and the client will always assume
    +the same password \- the original password becomes the session parameter and
     is never expiring. So the password is not changing while the session is valid
    -and unexpired. So, if the session is properly maintained, it may go forever, 
    -even if the user password has been already changed (in the database). The 
    -session simply is using the old password. Once the session got disconnected, 
    -the client will have to use the new password to re\-connect (if the password 
    +and unexpired. So, if the session is properly maintained, it may go forever,
    +even if the user password has been already changed (in the database). The
    +session simply is using the old password. Once the session got disconnected,
    +the client will have to use the new password to re\-connect (if the password
     has been changed).
     .PP
     An example when a new shared secret is generated every hour by the TURN server
     box and then supplied to the web server, remotely, is provided in the script
     examples/scripts/restapi/shared_secret_maintainer.pl .
     .PP
    -A very important thing is that the nonce must be totally random and it must be 
    -different for different clients and different sessions. 
    +A very important thing is that the nonce must be totally random and it must be
    +different for different clients and different sessions.
     .PP
     ===================================
     .SH DATABASES
     
     For the user database, the \fIturnserver\fP has the following \fIoptions\fP:
     .IP 1) 4
     Users can be set in the command line, with multiple \fB\-u\fP or \fB\-\-user\fP \fIoptions\fP.
    -Obviously, only a few users can be set that way, and their credentials are fixed 
    +Obviously, only a few users can be set that way, and their credentials are fixed
     for the \fIturnserver\fP process lifetime.
     .IP 2) 4
     Users can be stored in SQLite DB. The default SQLite database file is /var/db/turndb
     or /usr/local/var/db/turndb or /var/lib/turn/turndb.
     .IP 3) 4
     Users can be stored in PostgreSQL database, if the \fIturnserver\fP was compiled with PostgreSQL
     support. Each time \fIturnserver\fP checks user credentials, it reads the database (asynchronously,
    -of course, so that the current flow of packets is not delayed in any way), so any change in the 
    -database content is immediately visible by the \fIturnserver\fP. This is the way if you need the 
    +of course, so that the current flow of packets is not delayed in any way), so any change in the
    +database content is immediately visible by the \fIturnserver\fP. This is the way if you need the
     best scalability. The schema for the database can be found in schema.sql file.
    -For long\-term credentials, you have to set the "keys" for the users; the "keys" are generated 
    -by the \fIturnadmin\fP utility. For the key generation, you need username, password and the realm. 
    -All users in the database must use the same realm value; if down the road you will decide 
    -to change the realm name, then you will have to re\-generate all user keys (that can be done 
    +For long\-term credentials, you have to set the "keys" for the users; the "keys" are generated
    +by the \fIturnadmin\fP utility. For the key generation, you need username, password and the realm.
    +All users in the database must use the same realm value; if down the road you will decide
    +to change the realm name, then you will have to re\-generate all user keys (that can be done
     in a batch script). See the file turndb/testsqldbsetup.sql as an example.
     .IP 4) 4
     The same is true for MySQL database. The same schema file is applicable.
    -The same considerations are applicable. 
    +The same considerations are applicable.
     .IP 5) 4
     The same is true for the Redis database, but the Redis database has aa different schema \-
    -it can be found (in the form of explanation) in schema.userdb.redis. 
    -Also, in Redis you can store both "keys" and open passwords (for long term credentials) \- 
    -the "open password" option is less secure but more convenient for low\-security environments. 
    -See the file turndb/testredisdbsetup.sh as an example. 
    +it can be found (in the form of explanation) in schema.userdb.redis.
    +Also, in Redis you can store both "keys" and open passwords (for long term credentials) \-
    +the "open password" option is less secure but more convenient for low\-security environments.
    +See the file turndb/testredisdbsetup.sh as an example.
     .IP 6) 4
     If a database is used, then users can be divided into multiple independent realms. Each realm
     can be administered separately, and each realm can have its own set of users and its own
    @@ -1050,21 +1063,21 @@ The simplest choice is not to use it. Do not set \fB\-\-redis\-statsdb\fP option
     will be simply ignored.
     .IP 2) 4
     If you choose to use it, then set the \fB\-\-redis\-statsdb\fP option. This may be the same database
    -as in \fB\-\-redis\-userdb\fP option, or it may be a different database. You may want to use different 
    +as in \fB\-\-redis\-userdb\fP option, or it may be a different database. You may want to use different
     database for security or convenience reasons. Also, you can use different database management
    -systems for the user database and for the ststus and statistics database. For example, you can use 
    +systems for the user database and for the ststus and statistics database. For example, you can use
     MySQL as the user database, and you can use redis for the statistics. Or you can use Redis for both.
     .PP
     So, we have 6 choices for the user management, and 2 choices for the statistics management. These
    -two are totally independent. So, you have overall 6*2=12 ways to handle persistent information, 
    +two are totally independent. So, you have overall 6*2=12 ways to handle persistent information,
     choose any for your convenience.
     .PP
    -You do not have to handle the database information "manually" \- the \fIturnadmin\fP program can handle 
    +You do not have to handle the database information "manually" \- the \fIturnadmin\fP program can handle
     everything for you. For PostgreSQL and MySQL you will just have to create an empty database
    -with schema.sql SQL script. With Redis, you do not have to do even that \- just run \fIturnadmin\fP and 
    -it will set the users for you (see the \fIturnadmin\fP manuals). If you are using SQLite, then the 
    -\fIturnserver\fP or \fIturnadmin\fP will initialize the empty database, for you, when started. The 
    -TURN server installation process creates an empty initialized SQLite database in the default 
    +with schema.sql SQL script. With Redis, you do not have to do even that \- just run \fIturnadmin\fP and
    +it will set the users for you (see the \fIturnadmin\fP manuals). If you are using SQLite, then the
    +\fIturnserver\fP or \fIturnadmin\fP will initialize the empty database, for you, when started. The
    +TURN server installation process creates an empty initialized SQLite database in the default
     location (/var/db/turndb or /usr/local/var/db/turndb or /var/lib/turn/turndb, depending on the system).
     .PP
     =================================
    @@ -1083,7 +1096,7 @@ does not include the ALPN information into the ServerHello.
     In the lib/ sub\-directory the build process will create TURN client messaging library.
     In the include/ sub\-directory, the necessary include files will be placed.
     The C++ wrapper for the messaging functionality is located in TurnMsgLib.h header.
    -An example of C++ code can be found in stunclient.c file. 
    +An example of C++ code can be found in stunclient.c file.
     .PP
     =================================
     .SH DOCS
    @@ -1098,13 +1111,13 @@ $ man \fB\-M\fP man \fIturnserver\fP
     .PP
     to see the man page.
     .PP
    -In the docs/html subdirectory of the original archive tree, you will find the client library 
    +In the docs/html subdirectory of the original archive tree, you will find the client library
     reference. After the installation, it will be placed in PREFIX/share/doc/\fIturnserver\fP/html.
     .PP
     =================================
     .SH LOGS
     
    -When the \fBTURN Server\fP starts, it makes efforts to create a log file turn_<pid>.log 
    +When the \fBTURN Server\fP starts, it makes efforts to create a log file turn_<pid>.log
     in the following directories:
     .RS
     .IP \(bu 3
    @@ -1119,7 +1132,7 @@ in the following directories:
     current directory
     .RE
     .PP
    -If all efforts failed (due to the system permission settings) then all 
    +If all efforts failed (due to the system permission settings) then all
     log messages are sent only to the standard output of the process.
     .PP
     This behavior can be controlled by \fB\-\-log\-file\fP, \fB\-\-syslog\fP and \fB\-\-no\-stdout\-log\fP
    @@ -1129,7 +1142,7 @@ This behavior can be controlled by \fB\-\-log\-file\fP, \fB\-\-syslog\fP and \fB
     .SH HTTPS MANAGEMENT INTERFACE
     
     The \fIturnserver\fP process provides an HTTPS Web access as statistics and basic
    -management interface. The \fIturnserver\fP listens to incoming HTTPS admin 
    +management interface. The \fIturnserver\fP listens to incoming HTTPS admin
     connections on the same ports as the main TURN/STUN listener. The Web admin
     pages are basic and self\-explanatory.
     .PP
    @@ -1151,11 +1164,11 @@ in "help" command output in the telnet CLI.
     =================================
     .SH CLUSTERS
     
    -\fBTURN Server\fP can be a part of the cluster installation. But, to support the "even port" functionality 
    -(RTP/RTCP streams pairs) the client requests from a particular IP must be delivered to the same 
    -\fBTURN Server\fP instance, so it requires some networking setup massaging for the cluster. The reason is that 
    -the RTP and RTCP relaying endpoints must be allocated on the same relay IP. It would be possible 
    -to design a scheme with the application\-level requests forwarding (and we may do that later) but 
    +\fBTURN Server\fP can be a part of the cluster installation. But, to support the "even port" functionality
    +(RTP/RTCP streams pairs) the client requests from a particular IP must be delivered to the same
    +\fBTURN Server\fP instance, so it requires some networking setup massaging for the cluster. The reason is that
    +the RTP and RTCP relaying endpoints must be allocated on the same relay IP. It would be possible
    +to design a scheme with the application\-level requests forwarding (and we may do that later) but
     it would affect the performance.
     .PP
     =================================
    
  • man/man1/turnutils.1+16 16 modified
    @@ -1,5 +1,5 @@
     .\" Text automatically generated by txt2man
    -.TH TURN 1 "29 January 2019" "" ""
    +.TH TURN 1 "29 April 2020" "" ""
     .SH GENERAL INFORMATION
     
     A set of turnutils_* programs provides some utility functionality to be used
    @@ -51,12 +51,12 @@ addresses should be configured to be able to work properly!
     .TP
     .B
     6.
    -\fIturnutils_oauth\fP: a utility that provides OAuth access_token 
    -\fBgeneration\fP(AEAD encryption), validation and decryption. This utility inputs 
    -all the keys and lifetimes and any related information that needed for 
    -creation and validationi of an access_token. It outputs a JSON with all OAuth 
    -PoP parameters that need to pass to the client. Output is generated accoriding 
    -RFC7635 Appendix B, Figure 8. 
    +\fIturnutils_oauth\fP: a utility that provides OAuth access_token
    +\fBgeneration\fP(AEAD encryption), validation and decryption. This utility inputs
    +all the keys and lifetimes and any related information that needed for
    +creation and validationi of an access_token. It outputs a JSON with all OAuth
    +PoP parameters that need to pass to the client. Output is generated accoriding
    +RFC7635 Appendix B, Figure 8.
     .PP
     For more details, and for the access_token structure, read rfc7635, and see
     script in examples/scripts/oauth.sh.
    @@ -480,15 +480,15 @@ $ \fIturnutils_oauth\fP [\fIoptions\fP]
     .fi
     .SS  DESCRIPTION
     
    -\fIturnutils_oauth\fP utilitiy provides help in OAuth access_token encryption and/or 
    -decryption with AEAD (Atuthenticated Encryption with Associated Data). It helps 
    -for an Auth Server in access_token creation, and also for debugging purposes it 
    -helps the access_token validation and decryption. This utility inputs all the 
    -keys and lifetimes and any related information that are needed for encryption 
    -or decryption of an access_token. It outputs a JSON with all OAuth PoP 
    -parameters that need to pass to the client. Output is generated accoriding 
    -RFC7635 Appendix B, Figure 8. This utility could help to build an Auth Server 
    -service, but be awere that this utility does not generate "session key" / 
    +\fIturnutils_oauth\fP utilitiy provides help in OAuth access_token encryption and/or
    +decryption with AEAD (Atuthenticated Encryption with Associated Data). It helps
    +for an Auth Server in access_token creation, and also for debugging purposes it
    +helps the access_token validation and decryption. This utility inputs all the
    +keys and lifetimes and any related information that are needed for encryption
    +or decryption of an access_token. It outputs a JSON with all OAuth PoP
    +parameters that need to pass to the client. Output is generated accoriding
    +RFC7635 Appendix B, Figure 8. This utility could help to build an Auth Server
    +service, but be awere that this utility does not generate "session key" /
     "mac_key" and not verifies lifetime of "session key" / "mac_key" or "Auth key".
     For more details, and for the access_token structure, read rfc7635, and see
     the example in examples/scripts/oauth.sh.
    
  • README.turnadmin+34 34 modified
    @@ -1,57 +1,57 @@
     GENERAL INFORMATION
     
    -turnadmin is a TURN administration tool. This tool can be used to manage 
    -the user accounts (add/remove users, generate 
    -TURN keys for the users). For security reasons, we do not recommend 
    -storing passwords openly. The better option is to use pre-processed "keys" 
    -which are then used for authentication. These keys are generated by turnadmin. 
    -Turnadmin is a link to turnserver binary, but turnadmin performs different 
    +turnadmin is a TURN administration tool. This tool can be used to manage
    +the user accounts (add/remove users, generate
    +TURN keys for the users). For security reasons, we do not recommend
    +storing passwords openly. The better option is to use pre-processed "keys"
    +which are then used for authentication. These keys are generated by turnadmin.
    +Turnadmin is a link to turnserver binary, but turnadmin performs different
     functions.
     
     Options note: turnadmin has long and short option names, for most options.
    -Some options have only long form, some options have only short form. Their syntax 
    +Some options have only long form, some options have only short form. Their syntax
     somewhat different, if an argument is required:
     
     The short form must be used as this (for example):
     
       $ turnadmin -u <username> ...
    -  
    +
     The long form equivalent must use the "=" character:
     
       $ turnadmin --user=<username> ...
    -  
    +
     If this is a flag option (no argument required) then their usage are the same, for example:
     
      $ turnadmin -k ...
    - 
    +
     is equivalent to:
     
      $ turnadmin --key ...
     
    -You have always the use the -r <realm> option with commands for long term credentials - 
    +You have always the use the -r <realm> option with commands for long term credentials -
     because data for multiple realms can be stored in the same database.
    - 
    +
     =====================================
     
       NAME
     
    -turnadmin - a TURN relay administration tool. 
    -  
    -  SYNOPSIS  
    +turnadmin - a TURN relay administration tool.
    +
    +  SYNOPSIS
     
     $ turnadmin [command] [options]
     
     $ turnadmin [ -h | --help]
     
       DESCRIPTION
    -  
    -Commands:  
    +
    +Commands:
     
     -P, --generate-encrypted-password	Generate and print to the standard
     output an encrypted form of a password (for web admin user or CLI).
     The value then can be used as a safe key for the password
     storage on disk or in the database. Every invocation for the same password
    -produces a different result. The for mat of the encrypted password is:
    +produces a different result. The format of the encrypted password is:
     $5$<...salt...>$<...sha256(salt+password)...>. Salt is 16 characters,
     the sha256 output is 64 characters. Character 5 is the algorithm id (sha256).
     Only sha256 is supported as the hash function.
    @@ -70,13 +70,13 @@ Only sha256 is supported as the hash function.
     
     -L, --list-admin		List admin users in the database.
     
    --s, --set-secret=<value> Add shared secret for TURN RESP API
    +-s, --set-secret=<value> Add shared secret for TURN REST API
     
     -S, --show-secret	Show stored shared secrets for TURN REST API
     
     -X, --delete-secret=<value> Delete a shared secret.
     	--delete-all_secrets	Delete all shared secrets for REST API.
    -	
    +
     -O, --add-origin		Add origin-to-realm relation.
     
     -R, --del-origin		Delete origin-to-realm relation.
    @@ -86,10 +86,10 @@ Only sha256 is supported as the hash function.
     -g, --set-realm-option		Set realm params: max-bps, total-quota, user-quota.
     
     -G, --list-realm-options	List realm params.
    --E, --generate-encrypted-password-aes	Generate and print to the standard output 
    +-E, --generate-encrypted-password-aes	Generate and print to the standard output
     					an encrypted form of password with AES-128
    -  
    -Options with required values:  
    +
    +Options with required values:
     
     -b, --db, --userdb	SQLite user database file name (default - /var/db/turndb or
     			/usr/local/var/db/turndb or /var/lib/turn/turndb).
    @@ -111,10 +111,10 @@ Options with required values:
     -o, --origin		Origin
     --max-bps		Set value of realm's max-bps parameter.
     --total-quota	Set value of realm's total-quota parameter.
    ---user-quota	Set value of realm's user-quota parameter. 
    +--user-quota	Set value of realm's user-quota parameter.
     -h, --help		Help.
     
    -Command examples:  
    +Command examples:
     
     Generate an encrypted form of a password:
     
    @@ -123,11 +123,11 @@ $ turnadmin -P -p <password>
     Generate a key:
     
     $ turnadmin -k -u <username> -r <realm> -p <password>
    -  
    +
     Add/update a user in the in the database:
     
     $ turnadmin -a [-b <userdb-file> | -e <db-connection-string> | -M <db-connection-string> | -N <db-connection-string> ] -u <username> -r <realm> -p <password>
    -  
    +
     Delete a user from the database:
     
     $ turnadmin -d [-b <userdb-file> | -e <db-connection-string> | -M <db-connection-string> | -N <db-connection-string> ] -u <username> -r <realm>
    @@ -176,13 +176,13 @@ Verify/decrypt encrypted password:
     
     $ turnadmin --file-key-path <key-file> -v <encrypted>
     
    -   
    -Help:  
    +
    +Help:
     
     $ turnadmin -h
     
     =======================================
    - 
    +
       DOCS
     
     After installation, run the command:
    @@ -258,13 +258,13 @@ to see the man page.
     	Erik Johnston <erikj@openmarket.com>
     
     	Roman Lisagor <roman@demonware.net>
    -	
    +
     	Vladimir Tsanev <tsachev@gmail.com>
    -	
    +
     	Po-sheng Lin <personlin118@gmail.com>
    -	
    +
     	Peter Dunkley <peter.dunkley@acision.com>
    -	
    +
     	Mutsutoshi Yoshimoto <mutsutoshi.yoshimoto@mixi.co.jp>
     
     	Federico Pinna <fpinna@vivocha.com>
    
  • README.turnserver+292 282 modified
    @@ -1,181 +1,181 @@
     GENERAL INFORMATION
     
    -The TURN Server project contains the source code of a TURN server and TURN client 
    -messaging library. Also, some extra programs provided, for testing-only 
    -purposes. 
    +The TURN Server project contains the source code of a TURN server and TURN client
    +messaging library. Also, some extra programs provided, for testing-only
    +purposes.
     
     See the INSTALL file for the building instructions.
     
     After the build, you will have the following binary images:
     
    -1.	turnserver: TURN Server relay. 
    +1.	turnserver: TURN Server relay.
     The compiled binary image of the TURN Server program is located in bin/ sub-directory.
     
     2.	turnadmin: TURN administration tool. See README.turnadmin and turnadmin man page.
    -  
    +
     3.	turnutils_uclient. See README.turnutils and turnutils man page.
     
     4.	turnutils_peer. See README.turnutils and turnutils man page.
    -   
    +
     5.	turnutils_stunclient. See README.turnutils and turnutils man page.
    -  
    +
     6.	turnutils_rfc5769check. See README.turnutils and turnutils man page.
     
    -In the "examples/scripts" sub-directory, you will find the examples of command lines to be used 
    +In the "examples/scripts" sub-directory, you will find the examples of command lines to be used
     to run the programs. The scripts are meant to be run from examples/ sub-directory, for example:
     
     $ cd examples
     $ ./scripts/secure_relay.sh
    -  
    +
     RUNNING THE TURN SERVER
     
     Options note: turnserver has long and short option names, for most options.
    -Some options have only long form, some options have only short form. Their syntax 
    +Some options have only long form, some options have only short form. Their syntax
     somewhat different, if an argument is required:
     
     The short form must be used as this (for example):
     
       $ turnserver -L 12.34.56.78
    -  
    +
     The long form equivalent must use the "=" character:
     
       $ turnserver --listening-ip=12.34.56.78
    -  
    +
     If this is a flag option (no argument required) then their usage are the same, for example:
     
      $ turnserver -a
    - 
    +
     is equivalent to:
     
      $ turnserver --lt-cred-mech
    -  
    +
     =====================================
     
       NAME
    -  
    +
     turnserver - a TURN relay server implementation.
    -  
    +
       SYNOPSIS
    -  
    +
     $ turnserver [-n | -c <config-file> ] [flags] [ --userdb=<userdb-file> | --psql-userdb=<db-conn-string> | --mysql-userdb=<db-conn-string>  | --mongo-userdb=<db-conn-string>  | --redis-userdb=<db-conn-string> ] [-z | --no-auth | -a | --lt-cred-mech ] [options]
     $ turnserver -h
    -  
    -  DESCRIPTION						
    -  
    -Config file settings:  
    +
    +  DESCRIPTION
    +
    +Config file settings:
     
     -n		Do not use configuration file, use only command line parameters.
     
     -c		Configuration file name (default - turnserver.conf).
     		The format of config file can be seen in
    -		the supplied examples/etc/turnserver.conf example file. Long 
    -		names of the options are used as the configuration 
    -		items names in the file. If not an absolute path is supplied, 
    -		then the file is searched in the following directories: 
    +		the supplied examples/etc/turnserver.conf example file. Long
    +		names of the options are used as the configuration
    +		items names in the file. If not an absolute path is supplied,
    +		then the file is searched in the following directories:
     		  * current directory
     		  * current directory etc/ sub-directory
     		  * upper directory level etc/
    -		  * /etc/ 
    +		  * /etc/
     		  * /usr/local/etc/
     		  * installation directory /etc
     
    -User database settings:  
    +User database settings:
     
     -b, --db, --userdb	SQLite user database file name (default - /var/db/turndb or
     		/usr/local/var/db/turndb or /var/lib/turn/turndb).
    -				  
    +
     -e, --psql-userdb	User database connection string for PostgreSQL.
     		This database can be used for long-term credentials mechanism,
    -		and it can store the secret value 
    -		for secret-based timed authentication in TURN RESP API.
    +		and it can store the secret value
    +		for secret-based timed authentication in TURN REST API.
     		The connection string format is like that:
    -		 
    -		"host=<host> dbname=<dbname> user=<db-user> password=<db-user-password> connect_timeout=<seconds>" 
    +
    +		"host=<host> dbname=<dbname> user=<db-user> password=<db-user-password> connect_timeout=<seconds>"
     		(for 8.x or newer Postgres).
    -		
    +
     		Or:
    -		
    -		"postgresql://username:password@hostname:port/databasename" 
    -		(for 9.x or newer Postgres). 
    +
    +		"postgresql://username:password@hostname:port/databasename"
    +		(for 9.x or newer Postgres).
     
     		See the INSTALL file for more explanations and examples.
    -		
    +
     		Also, see http://www.PostgreSQL.org for full PostgreSQL documentation.
    -				  
    --M, --mysql-userdb	User database connection string for MySQL or MariaDB. 
    +
    +-M, --mysql-userdb	User database connection string for MySQL or MariaDB.
     		This database can be used for long-term credentials mechanism,
    -		and it can store the secret value for 
    -		secret-based timed authentication in TURN RESP API.
    +		and it can store the secret value for
    +		secret-based timed authentication in TURN REST API.
     		The connection string format is like that:
    -		 
    +
     		"host=<host> dbname=<dbname> user=<db-user> password=<db-user-password> connect_timeout=<seconds> read_timeout=<seconds>"
     
     		See the INSTALL file for more explanations and examples.
    -		
    -		Also, see http://www.mysql.org or http://mariadb.org 
    +
    +		Also, see http://www.mysql.org or http://mariadb.org
     		for full MySQL documentation.
    -		
    -		Optional connection string parameters for the secure communications (SSL): 
    -		ca, capath, cert, key, cipher 
    -		(see http://dev.mysql.com/doc/refman/5.1/en/ssl-options.html for the 
    +
    +		Optional connection string parameters for the secure communications (SSL):
    +		ca, capath, cert, key, cipher
    +		(see http://dev.mysql.com/doc/refman/5.1/en/ssl-options.html for the
     		command options description).
    -		
    +
     --secret-key-file 	This is the file path which contain secret key of aes encryption while using MySQL password encryption.
     			If you want to use in the MySQL connection string the password in encrypted format,
     			then set in this option the file path of the secret key. The key which is used to encrypt MySQL password.
    -			Warning: If this option is set, then MySQL password must be set in "mysql-userdb" option in encrypted format! 
    +			Warning: If this option is set, then MySQL password must be set in "mysql-userdb" option in encrypted format!
     			If you want to use cleartext password then do not set this option!
    --J, --mongo-userdb	User database connection string for MongoDB. 
    +-J, --mongo-userdb	User database connection string for MongoDB.
     		This database can be used for long-term credentials mechanism,
    -		and it can store the secret value 
    -		for secret-based timed authentication in TURN RESP API.
    +		and it can store the secret value
    +		for secret-based timed authentication in TURN REST API.
     		The connection string format is like that:
    -		 
    +
     		"mongodb://username:password@host:port/database?options"
     
     		See the INSTALL file for more explanations and examples.
    -		
    +
     		Also, see http://docs.mongodb.org/manual/
     		for full MongoDB documentation.
    -		
    --N, --redis-userdb	User database connection string for Redis. 
    +
    +-N, --redis-userdb	User database connection string for Redis.
     		This database can be used for long-term	credentials mechanism,
    -		and it can store the secret 
    -		value for secret-based timed authentication in TURN RESP API.
    +		and it can store the secret
    +		value for secret-based timed authentication in TURN REST API.
     		The connection string format is like that:
    -		 
    +
     		"ip=<ip-addr> dbname=<db-number> password=<db-password> connect_timeout=<seconds>"
     
     		See the INSTALL file for more explanations and examples.
    -		
    +
     		Also, see http://redis.io for full Redis documentation.
     
    -Flags:   
    +Flags:
     
     -v, --verbose		Moderate verbose mode.
     
     -V, --Verbose		Extra verbose mode, very annoying and not recommended.
     
     -o, --daemon		Run server as daemon.
     
    ---prod       	 	Production mode: hide the software version.
    +--no-software-attribute	Production mode: hide the software version.
     
     -f, --fingerprint	Use fingerprints in the TURN messages. If an incoming request
    -			contains a fingerprint, then TURN server will always add 
    +			contains a fingerprint, then TURN server will always add
     			fingerprints to the messages in this session, regardless of the
     			per-server setting.
     
     -a, --lt-cred-mech	Use long-term credentials mechanism (this one you need for WebRTC usage).
     
    --z, --no-auth		Do not use any credentials mechanism, allow anonymous access. 
    -			Opposite to -a and -A options. This is default option when no 
    +-z, --no-auth		Do not use any credentials mechanism, allow anonymous access.
    +			Opposite to -a and -A options. This is default option when no
     			authentication-related options are set.
     			By default, no credential mechanism is used -
     			any user is allowed.
     
     --use-auth-secret	TURN REST API flag.
    -			Flag that sets a special WebRTC authorization option 
    -			that is based upon authentication secret. The feature purpose 
    +			Flag that sets a special WebRTC authorization option
    +			that is based upon authentication secret. The feature purpose
     			is to support "TURN Server REST API" as described in
     			the TURN REST API section below.
     			This option uses timestamp as part of combined username:
    @@ -187,12 +187,12 @@ Flags:
     			This option is just turns on secret-based authentication.
     			The actual value of the secret is defined either by option static-auth-secret,
     			or can be found in the turn_secret table in the database.
    -			
    +
     --oauth			Support oAuth authentication, as in the third-party STUN/TURN RFC 7635.
    -			
    ---dh566			Use 566 bits predefined DH TLS key. Default size of the key is 1066.
     
    ---dh2066		Use 2066 bits predefined DH TLS key. Default size of the key is 1066.
    +--dh566			Use 566 bits predefined DH TLS key. Default size of the key is 2066.
    +
    +--dh1066		Use 1066 bits predefined DH TLS key. Default size of the key is 2066.
     
     --no-tlsv1		Do not allow TLSv1/DTLSv1 protocol.
     
    @@ -208,67 +208,67 @@ Flags:
     
     --no-dtls		Do not start DTLS client listeners.
     
    ---no-udp-relay		Do not allow UDP relay endpoints defined in RFC 5766, 
    +--no-udp-relay		Do not allow UDP relay endpoints defined in RFC 5766,
     			use only TCP relay endpoints as defined in RFC 6062.
     
    ---no-tcp-relay		Do not allow TCP relay endpoints defined in RFC 6062, 
    -			use only UDP relay endpoints as defined in RFC 5766. 
    +--no-tcp-relay		Do not allow TCP relay endpoints defined in RFC 6062,
    +			use only UDP relay endpoints as defined in RFC 5766.
     
     --no-stdout-log		Flag to prevent stdout log messages.
     			By default, all log messages are going to both stdout and to
    -			the configured log file. With this option everything will be going to 
    +			the configured log file. With this option everything will be going to
     			the log file only (unless the log file itself is stdout).
    -			
    +
     --syslog		With this flag, all log will be redirected to the system log (syslog).
     
     --simple-log		This flag means that no log file rollover will be used, and the log file
     			name will be constructed as-is, without PID and date appendage.
     			This option can be used, for example, together with the logrotate tool.
    -				
    +
     --secure-stun		Require authentication of the STUN Binding request.
     			By default, the clients are allowed anonymous access to the STUN Binding functionality.
     
    --S, --stun-only		Run as STUN server only, all TURN requests will be ignored. 
    +-S, --stun-only		Run as STUN server only, all TURN requests will be ignored.
     			Option to suppress TURN functionality, only STUN requests will be processed.
     
    ---no-stun		Run as TURN server only, all STUN requests will be ignored. 
    +--no-stun		Run as TURN server only, all STUN requests will be ignored.
     			Option to suppress STUN functionality, only TURN requests will be processed.
     
     --allow-loopback-peers	Allow peers on the loopback addresses (127.x.x.x and ::1).
    -             Allow it only for testing in a development environment! 
    -             In production it adds a possible security vulnerability, 
    -             and so due to security reasons, it is not allowed 
    +             Allow it only for testing in a development environment!
    +             In production it adds a possible security vulnerability,
    +             and so due to security reasons, it is not allowed
                  using it together with empty cli-password.
     
    ---no-multicast-peers	Disallow peers on well-known broadcast addresses 
    +--no-multicast-peers	Disallow peers on well-known broadcast addresses
     			(224.0.0.0 and above, and FFXX:*).
     
     --mobility		Mobility with ICE (MICE) specs support.
     
     --no-cli		Turn OFF the CLI support. By default it is always ON.
     			See also options --cli-ip and --cli-port.
    -				
    ---server-relay		Server relay. NON-STANDARD AND DANGEROUS OPTION. 
    -			Only for those applications when we want to run 
    +
    +--server-relay		Server relay. NON-STANDARD AND DANGEROUS OPTION.
    +			Only for those applications when we want to run
     			server applications on the relay endpoints.
    -			This option eliminates the IP permissions check 
    +			This option eliminates the IP permissions check
     			on the packets incoming to the relay endpoints.
     			See http://tools.ietf.org/search/rfc5766#section-17.2.3 .
    -				
    +
     --udp-self-balance	(recommended for older Linuxes only)
     			Automatically balance UDP traffic over auxiliary servers
    -			(if configured). The load balancing is using the 
    -			ALTERNATE-SERVER mechanism. The TURN client must support 
    +			(if configured). The load balancing is using the
    +			ALTERNATE-SERVER mechanism. The TURN client must support
     			300 ALTERNATE-SERVER response for this functionality.
    -			
    ---check-origin-consistency	The flag that sets the origin consistency 
    +
    +--check-origin-consistency	The flag that sets the origin consistency
     			check: across the session, all requests must have the same
     			main ORIGIN attribute value (if the ORIGIN was
     			initially used by the session).
     
     -h			Help.
    -    
    -Options with values:  
    +
    +Options with values:
     
     --stale-nonce[=<value>]		Use extra security with nonce value having
     							limited lifetime, in seconds (default 600 secs).
    @@ -284,15 +284,15 @@ Options with values:
     					This MUST not be changed for production purposes.
     
     -d, --listening-device	Listener interface device.
    -			(NOT RECOMMENDED. Optional functionality, Linux only). 
    -			The turnserver process must have root privileges to bind the 
    -			listening endpoint to a device. If turnserver must run as a 
    +			(NOT RECOMMENDED. Optional functionality, Linux only).
    +			The turnserver process must have root privileges to bind the
    +			listening endpoint to a device. If turnserver must run as a
     			process without root privileges, then just do not use this setting.
     
    --L, --listening-ip	Listener IP address of relay server. 
    +-L, --listening-ip	Listener IP address of relay server.
     			Multiple listeners can be specified, for example:
     			-L ip1 -L ip2 -L ip3
    -			If no IP(s) specified, then all IPv4 and 
    +			If no IP(s) specified, then all IPv4 and
     			IPv6 system IPs will be used for listening.
     			The same ip(s) can be used as both listening and relay ip(s).
     
    @@ -302,11 +302,11 @@ Options with values:
     
     --tls-listening-port	TURN listener port for TLS and DTLS listeners (Default: 5349).
     			Note: actually, "plain" TCP & UDP sessions can connect to the TLS & DTLS
    -			port(s), too - if allowed by configuration. The TURN server 
    +			port(s), too - if allowed by configuration. The TURN server
     			"automatically" recognizes the type of traffic. Actually, two listening
     			endpoints (the "plain" one and the "tls" one) are equivalent in terms of
     			functionality; but we keep both endpoints to satisfy the RFC 5766 specs.
    -			For secure TCP connections, we currently support SSL version 3 and 
    +			For secure TCP connections, we currently support SSL version 3 and
     			TLS versions 1.0, 1.1, 1.2.
     			For secure UDP connections, we support DTLS version 1.
     
    @@ -321,218 +321,228 @@ Options with values:
     
     --alt-tls-listening-port	Alternative listening port for TLS and DTLS protocols.
     			Default (or zero) value means "TLS listening port plus one".
    +
    +--tcp-proxy-port	Support connections from TCP loadbalancer on this port. The loadbalancer
    +			should use the binary proxy protocol.
    +			(https://www.haproxy.org/download/1.8/doc/proxy-protocol.txt)
     				
     --aux-server		Auxiliary STUN/TURN server listening endpoint.
     			Aux servers have almost full TURN and STUN functionality.
     			The (minor) limitations are:
     				1) Auxiliary servers do not have alternative ports and
     				they do not support STUN RFC 5780 functionality (CHANGE REQUEST).
     				2) Auxiliary servers also are never returning ALTERNATIVE-SERVER reply.
    -					
    +
     			Valid formats are 1.2.3.4:5555 for IPv4 and [1:2::3:4]:5555 for IPv6.
     			There may be multiple aux-server options, each will be used for listening
     			to client requests.
     
    --i, --relay-device	Relay interface device for relay sockets 
    +-i, --relay-device	Relay interface device for relay sockets
     			(NOT RECOMMENDED. Optional, Linux only).
     
    --E, --relay-ip		Relay address (the local IP address that 
    -			will be used to relay the packets to the 
    +-E, --relay-ip		Relay address (the local IP address that
    +			will be used to relay the packets to the
     			peer). Multiple relay addresses may be used:
     			-E ip1 -E ip2 -E ip3
     			The same IP(s) can be used as both listening IP(s) and relay IP(s).
    -			If no relay IP(s) specified, then the turnserver will apply the 
    -			default policy: it will decide itself which relay addresses to be 
    -			used, and it will always be using the client socket IP address as 
    -			the relay IP address of the TURN session (if the requested relay 
    +			If no relay IP(s) specified, then the turnserver will apply the
    +			default policy: it will decide itself which relay addresses to be
    +			used, and it will always be using the client socket IP address as
    +			the relay IP address of the TURN session (if the requested relay
     			address family is the same as the family of the client socket).
     
     -X, --external-ip	TURN Server public/private address mapping, if the server is behind NAT.
     			In that situation, if a -X is used in form "-X <ip>" then that ip will be reported
     			as relay IP address of all allocations. This scenario works only in a simple case
    -			when one single relay address is be used, and no CHANGE_REQUEST functionality is 
    +			when one single relay address is be used, and no CHANGE_REQUEST functionality is
     			required. That single relay address must be mapped by NAT to the 'external' IP.
     			The "external-ip" value, if not empty, is returned in XOR-RELAYED-ADDRESS field.
     			For that 'external' IP, NAT must forward ports directly (relayed port 12345
     			must be always mapped to the same 'external' port 12345).
     			In more complex case when more than one IP address is involved,
     			that option must be used several times, each entry must
     			have form "-X <public-ip/private-ip>", to map all involved addresses.
    -			CHANGE_REQUEST (RFC5780 or RFC3489) NAT discovery STUN functionality will work 
    -			correctly, if the addresses are mapped properly, even when the TURN server itself 
    +			CHANGE_REQUEST (RFC5780 or RFC3489) NAT discovery STUN functionality will work
    +			correctly, if the addresses are mapped properly, even when the TURN server itself
     			is behind A NAT.
     			By default, this value is empty, and no address mapping is used.
    -				
    +
     -m, --relay-threads	Number of the relay threads to handle the established connections
     			(in addition to authentication thread and the listener thread).
     			If explicitly set to 0 then application runs relay process in a single thread,
    -			in the same thread with the listener process (the authentication thread will 
    -			still be a separate thread). If not set, then a default optimal algorithm 
    +			in the same thread with the listener process (the authentication thread will
    +			still be a separate thread). If not set, then a default optimal algorithm
     			will be employed (OS-dependent). In the older Linux systems
    -			(before Linux kernel 3.9), the number of UDP threads is always one threads 
    +			(before Linux kernel 3.9), the number of UDP threads is always one threads
     			per network listening endpoint - unless "-m 0" or "-m 1" is set.
     
    ---min-port		Lower bound of the UDP port range for relay 
    +--min-port		Lower bound of the UDP port range for relay
     			endpoints allocation.
     			Default value is 49152, according to RFC 5766.
     
    ---max-port		Upper bound of the UDP port range for relay 
    +--max-port		Upper bound of the UDP port range for relay
     			endpoints allocation.
     			Default value is 65535, according to RFC 5766.
     
    --u, --user		Long-term security mechanism credentials user account, 
    -			in the column-separated form username:key. 
    +-u, --user		Long-term security mechanism credentials user account,
    +			in the column-separated form username:key.
     			Multiple user accounts may be used in the command line.
     			The key is either the user password, or
     			the key is generated
     			by turnadmin command. In the second case,
     			the key must be prepended with 0x symbols.
    -			The key is calculated over the user name, 
    +			The key is calculated over the user name,
     			the user realm, and the user password.
     			This setting may not be used with TURN REST API.
     
    --r, --realm		The default realm to be used for the users when no explicit 
    +-r, --realm		The default realm to be used for the users when no explicit
     			origin/realm relationship was found in the database, or if the TURN
     			server is not using any database (just the commands-line settings
    -			and the userdb file). Must be used with long-term credentials 
    +			and the userdb file). Must be used with long-term credentials
     			mechanism or with TURN REST API.
     
    --C, --rest-api-separator	This is the timestamp/username separator symbol 
    +-C, --rest-api-separator	This is the timestamp/username separator symbol
     			(character) in TURN REST API. The default value is :.
     
    --q, --user-quota	Per-user allocations quota: how many concurrent 
    -			allocations a user can create. This option can also be set 
    +-q, --user-quota	Per-user allocations quota: how many concurrent
    +			allocations a user can create. This option can also be set
     			through the database, for a particular realm.
     
     -Q, --total-quota	Total allocations quota: global limit on concurrent allocations.
     			This option can also be set through the database, for a particular realm.
     
     -s, --max-bps		Max bytes-per-second bandwidth a TURN session is allowed to handle
    -			(input and output network streams are treated separately). Anything above 
    +			(input and output network streams are treated separately). Anything above
     			that limit will be dropped or temporary suppressed (within the
    -			available buffer limits). This option can also be set through the 
    +			available buffer limits). This option can also be set through the
     			database, for a particular realm.
    -			
    +
     -B, --bps-capacity	Maximum server capacity.
     			Total bytes-per-second bandwidth the TURN server is allowed to allocate
     			for the sessions, combined (input and output network streams are treated
     			separately).
     
     --static-auth-secret	Static authentication secret value (a string) for TURN REST API only.
    -			If not set, then the turn server will try to use the dynamic value 
    +			If not set, then the turn server will try to use the dynamic value
     			in turn_secret table in user database (if present). The database-stored
     			value can be changed on-the-fly by a separate program, so this is why
     			that other mode is dynamic. Multiple shared secrets can be used
     			(both in the database and in the "static" fashion).
    +
    + --no-auth-pings			Disable periodic health checks to 'dynamic' auth secret tables.
    +
    + --no-dynamic-ip-list	Do not use dynamic allowed/denied peer ip list.
    +
    + --no-dynamic-realms	Do not use dynamic realm assignment and options.
     			
     --server-name		Server name used for
     			the oAuth authentication purposes.
     			The default value is the realm name.
     
    ---cert			Certificate file, PEM format. Same file 
    -			search rules applied as for the configuration 
    -			file. If both --no-tls and --no-dtls options 
    +--cert			Certificate file, PEM format. Same file
    +			search rules applied as for the configuration
    +			file. If both --no-tls and --no-dtls options
     			are specified, then this parameter is not needed.
     			Default value is turn_server_cert.pem.
     
    ---pkey		     	Private key file, PEM format. Same file 
    -			search rules applied as for the configuration 
    -			file. If both --no-tls and --no-dtls options 
    +--pkey		     	Private key file, PEM format. Same file
    +			search rules applied as for the configuration
    +			file. If both --no-tls and --no-dtls options
     			are specified, then this parameter is not needed.
     			Default value is turn_server_pkey.pem.
    -			
    +
     --pkey-pwd		If the private key file is encrypted, then this password to be used.
     
     --cipher-list		Allowed OpenSSL cipher list for TLS/DTLS connections.
     			Default value is "DEFAULT".
    -				
    ---CA-file		CA file in OpenSSL format. 
    +
    +--CA-file		CA file in OpenSSL format.
     			Forces TURN server to verify the client SSL certificates.
     			By default, no CA is set and no client certificate check is performed.
     
    ---ec-curve-name		Curve name for EC ciphers, if supported by OpenSSL 
    -			library (TLS and DTLS). The default value is prime256v1, 
    +--ec-curve-name		Curve name for EC ciphers, if supported by OpenSSL
    +			library (TLS and DTLS). The default value is prime256v1,
     			if pre-OpenSSL 1.0.2 is used. With OpenSSL 1.0.2+,
     			an optimal curve will be automatically calculated, if not defined
     			by this option.
     
     --dh-file		Use custom DH TLS key, stored in PEM format in the file.
    -			Flags --dh566 and --dh2066 are ignored when the DH key is taken from a file.
    +			Flags --dh566 and --dh1066 are ignored when the DH key is taken from a file.
     
     -l, --log-file		Option to set the full path name of the log file.
    -			By default, the turnserver tries to open a log file in 
    -			/var/log/turnserver, /var/log, /var/tmp, /tmp and . (current) 
    -			directories (which file open operation succeeds 
    -			first that file will be used). With this option you can set the 
    +			By default, the turnserver tries to open a log file in
    +			/var/log/turnserver, /var/log, /var/tmp, /tmp and . (current)
    +			directories (which file open operation succeeds
    +			first that file will be used). With this option you can set the
     			definite log file name.
    -			The special names are "stdout" and "-" - they will force everything 
    +			The special names are "stdout" and "-" - they will force everything
     			to the stdout. Also, "syslog" name will redirect everything into
    -			the system log (syslog), as if the option "--syslog" was set. 
    -			In the runtime, the logfile can be reset with the SIGHUP signal 
    +			the system log (syslog), as if the option "--syslog" was set.
    +			In the runtime, the logfile can be reset with the SIGHUP signal
     			to the turnserver process.
    -				
    +
     --alternate-server	Option to set the "redirection" mode. The value of this option
    -			will be the address of the alternate server for UDP & TCP service in form of 
    +			will be the address of the alternate server for UDP & TCP service in form of
     			<ip>[:<port>]. The server will send this value in the attribute
     			ALTERNATE-SERVER, with error 300, on ALLOCATE request, to the client.
     			Client will receive only values with the same address family
    -			as the client network endpoint address family. 
    -			See RFC 5389 and RFC 5766 for ALTERNATE-SERVER functionality description. 
    +			as the client network endpoint address family.
    +			See RFC 5389 and RFC 5766 for ALTERNATE-SERVER functionality description.
     			The client must use the obtained value for subsequent TURN communications.
     			If more than one --alternate-server options are provided, then the functionality
    -			can be more accurately described as "load-balancing" than a mere "redirection". 
    -			If the port number is omitted, then the default port 
    +			can be more accurately described as "load-balancing" than a mere "redirection".
    +			If the port number is omitted, then the default port
     			number 3478 for the UDP/TCP protocols will be used.
    -			Colon (:) characters in IPv6 addresses may conflict with the syntax of 
    -			the option. To alleviate this conflict, literal IPv6 addresses are enclosed 
    -			in square brackets in such resource identifiers, for example: 
    -			[2001:db8:85a3:8d3:1319:8a2e:370:7348]:3478 . 
    +			Colon (:) characters in IPv6 addresses may conflict with the syntax of
    +			the option. To alleviate this conflict, literal IPv6 addresses are enclosed
    +			in square brackets in such resource identifiers, for example:
    +			[2001:db8:85a3:8d3:1319:8a2e:370:7348]:3478 .
     			Multiple alternate servers can be set. They will be used in the
    -			round-robin manner. All servers in the pool are considered of equal weight and 
    -			the load will be distributed equally. For example, if we have 4 alternate servers, 
    -			then each server will receive 25% of ALLOCATE requests. An alternate TURN server 
    -			address can be used more than one time with the alternate-server option, so this 
    -			can emulate "weighting" of the servers. 
    -
    ---tls-alternate-server	Option to set alternative server for TLS & DTLS services in form of 
    -			<ip>:<port>. If the port number is omitted, then the default port 
    -			number 5349 for the TLS/DTLS protocols will be used. See the 
    +			round-robin manner. All servers in the pool are considered of equal weight and
    +			the load will be distributed equally. For example, if we have 4 alternate servers,
    +			then each server will receive 25% of ALLOCATE requests. An alternate TURN server
    +			address can be used more than one time with the alternate-server option, so this
    +			can emulate "weighting" of the servers.
    +
    +--tls-alternate-server	Option to set alternative server for TLS & DTLS services in form of
    +			<ip>:<port>. If the port number is omitted, then the default port
    +			number 5349 for the TLS/DTLS protocols will be used. See the
     			previous option for the functionality description.
     
    --O, --redis-statsdb	Redis status and statistics database connection string, if used (default - empty, 
    -			no Redis stats DB used). This database keeps allocations status information, and it can 
    +-O, --redis-statsdb	Redis status and statistics database connection string, if used (default - empty,
    +			no Redis stats DB used). This database keeps allocations status information, and it can
     			be also used for publishing and delivering traffic and allocation event notifications.
     			This database option can be used independently of --redis-userdb option,
    -			and actually Redis can be used for status/statistics and SQLite or MySQL or MongoDB or 
    +			and actually Redis can be used for status/statistics and SQLite or MySQL or MongoDB or
     			PostgreSQL can be used for the user database.
     			The connection string has the same parameters as redis-userdb connection string.
     
    ---max-allocate-timeout	Max time, in seconds, allowed for full allocation establishment. 
    +--max-allocate-timeout	Max time, in seconds, allowed for full allocation establishment.
     			Default is 60 seconds.
     
     --denied-peer-ip=<IPaddr[-IPaddr]>
     
    ---allowed-peer-ip=<IPaddr[-IPaddr]> Options to ban or allow specific ip addresses or ranges 
    -			of ip addresses. If an ip address is specified as both allowed and denied, then 
    +--allowed-peer-ip=<IPaddr[-IPaddr]> Options to ban or allow specific ip addresses or ranges
    +			of ip addresses. If an ip address is specified as both allowed and denied, then
     			the ip address is considered to be allowed. This is useful when you wish to ban
     			a range of ip addresses, except for a few specific ips within that range.
     			This can be used when you do not want users of the turn server to be able to access
    -			machines reachable by the turn server, but would otherwise be unreachable from the 
    -			internet (e.g. when the turn server is sitting behind a NAT). The 'white" and "black" peer 
    -			IP ranges can also be dynamically changed in the database. 
    +			machines reachable by the turn server, but would otherwise be unreachable from the
    +			internet (e.g. when the turn server is sitting behind a NAT). The 'white" and "black" peer
    +			IP ranges can also be dynamically changed in the database.
     			The allowed/denied addresses (white/black lists) rules are very simple:
    -			1) If there is no rule for an address, then it is allowed; 
    +			1) If there is no rule for an address, then it is allowed;
     			2) If there is an "allowed" rule that fits the address then it is allowed - no matter what;
     			3) If there is no "allowed" rule that fits the address, and if there is a "denied" rule that
     			fits the address, then it is denied.
     
     --pidfile 		File name to store the pid of the process.
     			Default is /var/run/turnserver.pid (if superuser account is used) or
     			/var/tmp/turnserver.pid .
    -				
    +
     --proc-user		User name to run the process. After the initialization, the turnserver process
     			will make an attempt to change the current user ID to that user.
    -	
    +
     --proc-group		Group name to run the process. After the initialization, the turnserver process
     			will make an attempt to change the current group ID to that group.
     
    @@ -542,10 +552,10 @@ Options with values:
     
     --cli-ip		Local system IP address to be used for CLI management interface.
     			The turnserver process can be accessed for management with telnet,
    -			at this IP address and on the CLI port (see the next parameter). 
    +			at this IP address and on the CLI port (see the next parameter).
     			Default value is 127.0.0.1. You can use telnet or putty (in telnet mode)
    -			to access the CLI management interface. 
    -					
    +			to access the CLI management interface.
    +
     --cli-port		CLI management interface listening port. Default is 5766.
     
     --cli-password		CLI access password. Default is empty (no password).
    @@ -574,59 +584,59 @@ LOAD BALANCE AND PERFORMANCE TUNING
     This topic is covered in the wiki page:
     
     https://github.com/coturn/coturn/wiki/turn_performance_and_load_balance
    -	 
    +
     ===================================
     
     WEBRTC USAGE
     
     This is a set of notes for the WebRTC users:
     
    -1) WebRTC uses long-term authentication mechanism, so you have to use -a 
    +1) WebRTC uses long-term authentication mechanism, so you have to use -a
     option (or --lt-cred-mech). WebRTC relaying will not work with anonymous
    -access. With -a option, do not forget to set the 
    -default realm (-r option). You will also have to set up the user accounts, 
    +access. With -a option, do not forget to set the
    +default realm (-r option). You will also have to set up the user accounts,
     for that you have a number of options:
     
     	a) command-line options (-u).
    -	
    -	b) a database table (SQLite or PostgreSQL or MySQL or MongoDB). You will have to 
    -	set keys with turnadmin utility (see docs and wiki for turnadmin). 
    +
    +	b) a database table (SQLite or PostgreSQL or MySQL or MongoDB). You will have to
    +	set keys with turnadmin utility (see docs and wiki for turnadmin).
     	You cannot use open passwords in the database.
     
    -	c) Redis key/value pair(s), if Redis is used. You key use either keys or 
    -	open passwords with Redis; see turndb/testredisdbsetup.sh file.  
    -	
    +	c) Redis key/value pair(s), if Redis is used. You key use either keys or
    +	open passwords with Redis; see turndb/testredisdbsetup.sh file.
    +
     	d) You also can use the TURN REST API. You will need shared secret(s) set
     	either	through the command line option, or through the config file, or through
    -	the database table or Redis key/value pairs.  
    +	the database table or Redis key/value pairs.
     
     2) Usually WebRTC uses fingerprinting (-f).
     
     3) -v option may be nice to see the connected clients.
     
     4) -X is needed if you are running your TURN server behind a NAT.
     
    -5) --min-port and --max-port may be needed if you want to limit the relay endpoints ports 
    +5) --min-port and --max-port may be needed if you want to limit the relay endpoints ports
     number range.
     
     ===================================
     
     TURN REST API
     
     In WebRTC, the browser obtains the TURN connection information from the web
    -server. This information is a secure information - because it contains the 
    -necessary TURN credentials. As these credentials are transmitted over the 
    +server. This information is a secure information - because it contains the
    +necessary TURN credentials. As these credentials are transmitted over the
     public networks, we have a potential security breach.
     
    -If we have to transmit a valuable information over the public network, 
    -then this information has to have a limited lifetime. Then the guy who 
    -obtains this information without permission will be able to perform 
    +If we have to transmit a valuable information over the public network,
    +then this information has to have a limited lifetime. Then the guy who
    +obtains this information without permission will be able to perform
     only limited damage.
     
    -This is how the idea of TURN REST API - time-limited TURN credentials - 
    -appeared. This security mechanism is based upon the long-term credentials 
    -mechanism. The main idea of the REST API is that the web server provides 
    -the credentials to the client, but those credentials can be used only 
    +This is how the idea of TURN REST API - time-limited TURN credentials -
    +appeared. This security mechanism is based upon the long-term credentials
    +mechanism. The main idea of the REST API is that the web server provides
    +the credentials to the client, but those credentials can be used only
     limited time by an application that has to create a TURN server connection.
     
     The "classic" long-term credentials mechanism (LTCM) is described here:
    @@ -637,23 +647,23 @@ http://tools.ietf.org/html/rfc5389#section-15.4
     
     For authentication, each user must know two things: the username and the
     password. Optionally, the user must supply the ORIGIN value, so that the
    -server can figure out the realm to be used for the user. The nonce and 
    -the realm values are supplied by the TURN server. But LTCM is not saying 
    -anything about the nature and about the persistence of the username and 
    +server can figure out the realm to be used for the user. The nonce and
    +the realm values are supplied by the TURN server. But LTCM is not saying
    +anything about the nature and about the persistence of the username and
     of the password; and this is used by the REST API.
     
    -In the TURN REST API, there is no persistent passwords for users. A user has 
    -just the username. The password is always temporary, and it is generated by 
    -the web server on-demand, when the user accesses the WebRTC page. And, 
    -actually, a temporary one-time session only, username is provided to the user, 
    -too. 
    +In the TURN REST API, there is no persistent passwords for users. A user has
    +just the username. The password is always temporary, and it is generated by
    +the web server on-demand, when the user accesses the WebRTC page. And,
    +actually, a temporary one-time session only, username is provided to the user,
    +too.
     
     The temporary user is generated as:
     
     temporary-username="timestamp" + ":" + "username"
     
    -where username is the persistent user name, and the timestamp format is just 
    -seconds sinse 1970 - the same value as time(NULL) function returns.
    +where username is the persistent user name, and the timestamp format is just
    +seconds since 1970 - the same value as time(NULL) function returns.
     
     The temporary password is obtained as HMAC-SHA1 function over the temporary
     username, with shared secret as the HMAC key, and then the result is encoded:
    @@ -664,7 +674,7 @@ Both the TURN server and the web server know the same shared secret. How the
     shared secret is distributed among the involved entities is left to the WebRTC
     deployment details - this is beyond the scope of the TURN REST API.
     
    -So, a timestamp is used for the temporary password calculation, and this 
    +So, a timestamp is used for the temporary password calculation, and this
     timestamp can be retrieved from the temporary username. This information
     is valuable, but only temporary, while the timestamp is not expired. Without
     knowledge of the shared secret, a new temporary password cannot be generated.
    @@ -677,94 +687,94 @@ Once the temporary username and password are obtained by the client (browser)
     application, then the rest is just 'classic" long-term credentials mechanism.
     For developers, we are going to describe it step-by-step below:
     
    -  - a new TURN client sends a request command to the TURN server. Optionally, 
    -  it adds the ORIGIN field to it. 
    -  - TURN server sees that this is a new client and the message is not 
    +  - a new TURN client sends a request command to the TURN server. Optionally,
    +  it adds the ORIGIN field to it.
    +  - TURN server sees that this is a new client and the message is not
       	authenticated.
    -  - the TURN server generates a random nonce string, and return the 
    +  - the TURN server generates a random nonce string, and return the
       	error 401 to the client, with nonce and realm included. If the ORIGIN
       	field was present in the client request, it may affect the realm value
       	that the server chooses for the client.
    -  - the client sees the 401 error and it extracts two values from 
    +  - the client sees the 401 error and it extracts two values from
       	the error response: the nonce and the realm.
       - the client uses username, realm and password to produce a key:
     
              key = MD5(username ":" realm ":" SASLprep(password))
      (SASLprep is described here: http://tools.ietf.org/html/rfc4013)
    - 
    -  - the client forms a new request, adds username, realm and nonce to the 
    -  	request. Then, the client calculates and adds the integrity field to 
    +
    +  - the client forms a new request, adds username, realm and nonce to the
    +  	request. Then, the client calculates and adds the integrity field to
       	the request. This is the trickiest part of the process, and it is
    -  	 described in the end of section 15.4: 
    +  	 described in the end of section 15.4:
       	http://tools.ietf.org/html/rfc5389#section-15.4
    -  - the client, optionally, adds the fingerprint field. This may be also 
    -  	a tricky procedure, described in section 15.5 of the same document. 
    +  - the client, optionally, adds the fingerprint field. This may be also
    +  	a tricky procedure, described in section 15.5 of the same document.
       	WebRTC usually uses fingerprinted TURN messages.
       - the TURN server receives the request, reads the username.
    -  - then the TURN server checks that the nonce and the realm in the request 
    +  - then the TURN server checks that the nonce and the realm in the request
       	are the valid ones.
       - then the TURN server calculates the key.
       - then the TURN server calculates the integrity field.
    -  - then the TURN server compares the calculated integrity field with the 
    -  	received one - they must be the same. If the integrity fields differ, 
    +  - then the TURN server compares the calculated integrity field with the
    +  	received one - they must be the same. If the integrity fields differ,
       	then the request is rejected.
     
    -In subsequent communications, the client may go with exactly the same 
    -sequence, but for optimization usually the client, having already 
    -information about realm and nonce, pre-calculates the integrity string 
    -for each request, so that the 401 error response becomes unnecessary. 
    -The TURN server may use "--stale-nonce" option for extra security: in 
    +In subsequent communications, the client may go with exactly the same
    +sequence, but for optimization usually the client, having already
    +information about realm and nonce, pre-calculates the integrity string
    +for each request, so that the 401 error response becomes unnecessary.
    +The TURN server may use "--stale-nonce" option for extra security: in
     some time, the nonce expires and the client will obtain 438 error response
     with the new nonce, and the client will have to start using the new nonce.
     
    -In subsequent communications, the sever and the client will always assume 
    -the same password - the original password becomes the session parameter and 
    +In subsequent communications, the server and the client will always assume
    +the same password - the original password becomes the session parameter and
     is never expiring. So the password is not changing while the session is valid
    -and unexpired. So, if the session is properly maintained, it may go forever, 
    -even if the user password has been already changed (in the database). The 
    -session simply is using the old password. Once the session got disconnected, 
    -the client will have to use the new password to re-connect (if the password 
    +and unexpired. So, if the session is properly maintained, it may go forever,
    +even if the user password has been already changed (in the database). The
    +session simply is using the old password. Once the session got disconnected,
    +the client will have to use the new password to re-connect (if the password
     has been changed).
     
     An example when a new shared secret is generated every hour by the TURN server
     box and then supplied to the web server, remotely, is provided in the script
     examples/scripts/restapi/shared_secret_maintainer.pl .
     
    -A very important thing is that the nonce must be totally random and it must be 
    -different for different clients and different sessions. 
    -	 
    +A very important thing is that the nonce must be totally random and it must be
    +different for different clients and different sessions.
    +
     ===================================
     
     DATABASES
     
     For the user database, the turnserver has the following options:
     
    -1) Users can be set in the command line, with multiple -u or --user options. 
    -Obviously, only a few users can be set that way, and their credentials are fixed 
    +1) Users can be set in the command line, with multiple -u or --user options.
    +Obviously, only a few users can be set that way, and their credentials are fixed
     for the turnserver process lifetime.
     
     2) Users can be stored in SQLite DB. The default SQLite database file is /var/db/turndb
     or /usr/local/var/db/turndb or /var/lib/turn/turndb.
     
     3) Users can be stored in PostgreSQL database, if the turnserver was compiled with PostgreSQL
     support. Each time turnserver checks user credentials, it reads the database (asynchronously,
    -of course, so that the current flow of packets is not delayed in any way), so any change in the 
    -database content is immediately visible by the turnserver. This is the way if you need the 
    +of course, so that the current flow of packets is not delayed in any way), so any change in the
    +database content is immediately visible by the turnserver. This is the way if you need the
     best scalability. The schema for the database can be found in schema.sql file.
    -For long-term credentials, you have to set the "keys" for the users; the "keys" are generated 
    -by the turnadmin utility. For the key generation, you need username, password and the realm. 
    -All users in the database must use the same realm value; if down the road you will decide 
    -to change the realm name, then you will have to re-generate all user keys (that can be done 
    +For long-term credentials, you have to set the "keys" for the users; the "keys" are generated
    +by the turnadmin utility. For the key generation, you need username, password and the realm.
    +All users in the database must use the same realm value; if down the road you will decide
    +to change the realm name, then you will have to re-generate all user keys (that can be done
     in a batch script). See the file turndb/testsqldbsetup.sql as an example.
     
    -4) The same is true for MySQL database. The same schema file is applicable. 
    -The same considerations are applicable. 
    +4) The same is true for MySQL database. The same schema file is applicable.
    +The same considerations are applicable.
     
     5) The same is true for the Redis database, but the Redis database has aa different schema -
    -it can be found (in the form of explanation) in schema.userdb.redis. 
    -Also, in Redis you can store both "keys" and open passwords (for long term credentials) - 
    -the "open password" option is less secure but more convenient for low-security environments. 
    -See the file turndb/testredisdbsetup.sh as an example. 
    +it can be found (in the form of explanation) in schema.userdb.redis.
    +Also, in Redis you can store both "keys" and open passwords (for long term credentials) -
    +the "open password" option is less secure but more convenient for low-security environments.
    +See the file turndb/testredisdbsetup.sh as an example.
     
     6) If a database is used, then users can be divided into multiple independent realms. Each realm
     can be administered separately, and each realm can have its own set of users and its own
    @@ -777,25 +787,25 @@ sessions anonymously. But in most cases (like WebRTC) that will not work.
     
     For the status and statistics database, there are two choices:
     
    -1) The simplest choice is not to use it. Do not set --redis-statsdb option, and this functionality 
    +1) The simplest choice is not to use it. Do not set --redis-statsdb option, and this functionality
     will be simply ignored.
     
     2) If you choose to use it, then set the --redis-statsdb option. This may be the same database
    -as in --redis-userdb option, or it may be a different database. You may want to use different 
    +as in --redis-userdb option, or it may be a different database. You may want to use different
     database for security or convenience reasons. Also, you can use different database management
    -systems for the user database and for the ststus and statistics database. For example, you can use 
    +systems for the user database and for the ststus and statistics database. For example, you can use
     MySQL as the user database, and you can use redis for the statistics. Or you can use Redis for both.
     
     So, we have 6 choices for the user management, and 2 choices for the statistics management. These
    -two are totally independent. So, you have overall 6*2=12 ways to handle persistent information, 
    +two are totally independent. So, you have overall 6*2=12 ways to handle persistent information,
     choose any for your convenience.
     
    -You do not have to handle the database information "manually" - the turnadmin program can handle 
    +You do not have to handle the database information "manually" - the turnadmin program can handle
     everything for you. For PostgreSQL and MySQL you will just have to create an empty database
    -with schema.sql SQL script. With Redis, you do not have to do even that - just run turnadmin and 
    -it will set the users for you (see the turnadmin manuals). If you are using SQLite, then the 
    -turnserver or turnadmin will initialize the empty database, for you, when started. The 
    -TURN server installation process creates an empty initialized SQLite database in the default 
    +with schema.sql SQL script. With Redis, you do not have to do even that - just run turnadmin and
    +it will set the users for you (see the turnadmin manuals). If you are using SQLite, then the
    +turnserver or turnadmin will initialize the empty database, for you, when started. The
    +TURN server installation process creates an empty initialized SQLite database in the default
     location (/var/db/turndb or /usr/local/var/db/turndb or /var/lib/turn/turndb, depending on the system).
     
     =================================
    @@ -816,7 +826,7 @@ LIBRARIES
     In the lib/ sub-directory the build process will create TURN client messaging library.
     In the include/ sub-directory, the necessary include files will be placed.
     The C++ wrapper for the messaging functionality is located in TurnMsgLib.h header.
    -An example of C++ code can be found in stunclient.c file. 
    +An example of C++ code can be found in stunclient.c file.
     
     =================================
     
    @@ -832,14 +842,14 @@ $ man -M man turnserver
     
     to see the man page.
     
    -In the docs/html subdirectory of the original archive tree, you will find the client library 
    +In the docs/html subdirectory of the original archive tree, you will find the client library
     reference. After the installation, it will be placed in PREFIX/share/doc/turnserver/html.
     
     =================================
     
     LOGS
     
    -When the TURN Server starts, it makes efforts to create a log file turn_<pid>.log 
    +When the TURN Server starts, it makes efforts to create a log file turn_<pid>.log
     in the following directories:
     
     	* /var/log
    @@ -848,7 +858,7 @@ in the following directories:
     	* /tmp
     	* current directory
     
    -If all efforts failed (due to the system permission settings) then all 
    +If all efforts failed (due to the system permission settings) then all
     log messages are sent only to the standard output of the process.
     
     This behavior can be controlled by --log-file, --syslog and --no-stdout-log
    @@ -859,7 +869,7 @@ options.
     HTTPS MANAGEMENT INTERFACE
     
     The turnserver process provides an HTTPS Web access as statistics and basic
    -management interface. The turnserver listens to incoming HTTPS admin 
    +management interface. The turnserver listens to incoming HTTPS admin
     connections on the same ports as the main TURN/STUN listener. The Web admin
     pages are basic and self-explanatory.
     
    @@ -883,11 +893,11 @@ in "help" command output in the telnet CLI.
     
     CLUSTERS
     
    -TURN Server can be a part of the cluster installation. But, to support the "even port" functionality 
    -(RTP/RTCP streams pairs) the client requests from a particular IP must be delivered to the same 
    -TURN Server instance, so it requires some networking setup massaging for the cluster. The reason is that 
    -the RTP and RTCP relaying endpoints must be allocated on the same relay IP. It would be possible 
    -to design a scheme with the application-level requests forwarding (and we may do that later) but 
    +TURN Server can be a part of the cluster installation. But, to support the "even port" functionality
    +(RTP/RTCP streams pairs) the client requests from a particular IP must be delivered to the same
    +TURN Server instance, so it requires some networking setup massaging for the cluster. The reason is that
    +the RTP and RTCP relaying endpoints must be allocated on the same relay IP. It would be possible
    +to design a scheme with the application-level requests forwarding (and we may do that later) but
     it would affect the performance.
     
     =================================
    @@ -925,7 +935,7 @@ new STUN RFC 5389
     TURN RFC 5766
     
     TURN-TCP extension RFC 6062
    - 
    +
     TURN IPv6 extension RFC 6156
     
     STUN/TURN test vectors RFC 5769
    @@ -971,13 +981,13 @@ https://groups.google.com/forum/?fromgroups=#!forum/turn-server-project-rfc5766-
     	Erik Johnston <erikj@openmarket.com>
     
     	Roman Lisagor <roman@demonware.net>
    -	
    +
     	Vladimir Tsanev <tsachev@gmail.com>
    -	
    +
     	Po-sheng Lin <personlin118@gmail.com>
    -	
    +
     	Peter Dunkley <peter.dunkley@acision.com>
    -	
    +
     	Mutsutoshi Yoshimoto <mutsutoshi.yoshimoto@mixi.co.jp>
     
     	Federico Pinna <fpinna@vivocha.com>
    
  • README.turnutils+15 15 modified
    @@ -37,12 +37,12 @@ according RFC5780. This utility discovers the actual NAT Mapping and Filtering
     behavior, etc. Be aware that on TURN server side two different listening IP
     addresses should be configured to be able to work properly!
     
    -6.	turnutils_oauth: a utility that provides OAuth access_token 
    -generation(AEAD encryption), validation and decryption. This utility inputs 
    -all the keys and lifetimes and any related information that needed for 
    -creation and validationi of an access_token. It outputs a JSON with all OAuth 
    -PoP parameters that need to pass to the client. Output is generated accoriding 
    -RFC7635 Appendix B, Figure 8. 
    +6.	turnutils_oauth: a utility that provides OAuth access_token
    +generation(AEAD encryption), validation and decryption. This utility inputs
    +all the keys and lifetimes and any related information that needed for
    +creation and validationi of an access_token. It outputs a JSON with all OAuth
    +PoP parameters that need to pass to the client. Output is generated accoriding
    +RFC7635 Appendix B, Figure 8.
     
     For more details, and for the access_token structure, read rfc7635, and see
     script in examples/scripts/oauth.sh.
    @@ -312,15 +312,15 @@ $ turnutils_oauth [options]
     
       DESCRIPTION
     
    -turnutils_oauth utilitiy provides help in OAuth access_token encryption and/or 
    -decryption with AEAD (Atuthenticated Encryption with Associated Data). It helps 
    -for an Auth Server in access_token creation, and also for debugging purposes it 
    -helps the access_token validation and decryption. This utility inputs all the 
    -keys and lifetimes and any related information that are needed for encryption 
    -or decryption of an access_token. It outputs a JSON with all OAuth PoP 
    -parameters that need to pass to the client. Output is generated accoriding 
    -RFC7635 Appendix B, Figure 8. This utility could help to build an Auth Server 
    -service, but be awere that this utility does not generate "session key" / 
    +turnutils_oauth utilitiy provides help in OAuth access_token encryption and/or
    +decryption with AEAD (Atuthenticated Encryption with Associated Data). It helps
    +for an Auth Server in access_token creation, and also for debugging purposes it
    +helps the access_token validation and decryption. This utility inputs all the
    +keys and lifetimes and any related information that are needed for encryption
    +or decryption of an access_token. It outputs a JSON with all OAuth PoP
    +parameters that need to pass to the client. Output is generated accoriding
    +RFC7635 Appendix B, Figure 8. This utility could help to build an Auth Server
    +service, but be awere that this utility does not generate "session key" /
     "mac_key" and not verifies lifetime of "session key" / "mac_key" or "Auth key".
     For more details, and for the access_token structure, read rfc7635, and see
     the example in examples/scripts/oauth.sh.
    
  • rpm/build.settings.sh+1 2 modified
    @@ -2,10 +2,9 @@
     
     # Common settings script.
     
    -TURNVERSION=4.5.1.1
    +TURNVERSION=4.5.1.3
     BUILDDIR=~/rpmbuild
     ARCH=`uname -p`
    -TURNSERVER_GIT_URL=https://github.com/coturn/coturn.git
     
     WGETOPTIONS="--no-check-certificate"
     RPMOPTIONS="-ivh --force"
    
  • rpm/build.sh+4 10 modified
    @@ -18,18 +18,11 @@ fi
     
     # TURN
     
    +#create archive from local folder
     cd ${BUILDDIR}/tmp
     rm -rf turnserver-${TURNVERSION}
    -git clone ${TURNSERVER_GIT_URL} --branch ${TURNVERSION} turnserver-${TURNVERSION}
    -ER=$?
    -if ! [ ${ER} -eq 0 ] ; then
    -	git clone ${TURNSERVER_GIT_URL} turnserver-${TURNVERSION}
    -	ER=$?
    -	if ! [ ${ER} -eq 0 ] ; then
    -    	cd ${CPWD}
    -    	exit -1
    -    fi
    -fi
    +mkdir -p ${BUILDDIR}/tmp/turnserver-${TURNVERSION}
    +cp -R ${CPWD}/.. ${BUILDDIR}/tmp/turnserver-${TURNVERSION}
     
     tar zcf ${BUILDDIR}/SOURCES/turnserver-${TURNVERSION}.tar.gz turnserver-${TURNVERSION}
     ER=$?
    @@ -38,6 +31,7 @@ if ! [ ${ER} -eq 0 ] ; then
         exit -1
     fi
     
    +#build package from archive
     rpmbuild -ta ${BUILDDIR}/SOURCES/turnserver-${TURNVERSION}.tar.gz
     ER=$?
     if ! [ ${ER} -eq 0 ] ; then
    
  • rpm/turnserver.spec+3 1 modified
    @@ -1,5 +1,5 @@
     Name:		turnserver
    -Version:	4.5.1.1
    +Version:	4.5.1.3
     Release:	0%{dist}
     Summary:	Coturn TURN Server
     
    @@ -197,6 +197,8 @@ fi
     %{_datadir}/%{name}/testmongosetup.sh
     %{_datadir}/%{name}/testsqldbsetup.sql
     %dir %{_datadir}/%{name}/etc
    +%{_datadir}/%{name}/etc/cacert.pem
    +%{_datadir}/%{name}/etc/coturn.service
     %{_datadir}/%{name}/etc/turn_server_cert.pem
     %{_datadir}/%{name}/etc/turn_server_pkey.pem
     %{_datadir}/%{name}/etc/turnserver.conf
    
  • src/apps/common/apputils.c+29 82 modified
    @@ -279,7 +279,7 @@ int addr_bind(evutil_socket_t fd, const ioa_addr* addr, int reusable, int debug,
     				int err = errno;
     				perror("bind");
     				char str[129];
    -				addr_to_string(addr,(u08bits*)str);
    +				addr_to_string(addr,(uint8_t*)str);
     				TURN_LOG_FUNC(TURN_LOG_LEVEL_WARNING, "Trying to bind fd %d to <%s>: errno=%d\n", fd, str, err);
     			}
     		}
    @@ -439,6 +439,7 @@ int set_raw_socket_tos(evutil_socket_t fd, int family, int tos)
     int is_stream_socket(int st) {
     	switch(st) {
     	case TCP_SOCKET:
    +	case TCP_SOCKET_PROXY:
     	case TLS_SOCKET:
     	case TENTATIVE_TCP_SOCKET:
     	case SCTP_SOCKET:
    @@ -760,7 +761,7 @@ void set_execdir(void)
       /* On some systems, this may give us the execution path */
       char *_var = getenv("_");
       if(_var && *_var) {
    -    _var = turn_strdup(_var);
    +    _var = strdup(_var);
         char *edir=_var;
         if(edir[0]!='.') 
           edir = strstr(edir,"/");
    @@ -769,9 +770,9 @@ void set_execdir(void)
         else
           edir = dirname(_var);
         if(c_execdir)
    -      turn_free(c_execdir,strlen(c_execdir)+1);
    -    c_execdir = turn_strdup(edir);
    -    turn_free(_var,strlen(_var)+1);
    +      free(c_execdir);
    +    c_execdir = strdup(edir);
    +    free(_var);
       }
     }
     
    @@ -786,7 +787,7 @@ void print_abs_file_name(const char *msg1, const char *msg2, const char *fn)
           if(fn[0]=='/') {
     	STRCPY(absfn,fn);
           } else {
    -	if(fn[0]=='.' && fn[1]=='/')
    +	if(fn[0]=='.' && fn[1] && fn[1]=='/')
     	  fn+=2;
     	if(!getcwd(absfn,sizeof(absfn)-1))
     	  absfn[0]=0;
    @@ -815,7 +816,7 @@ char* find_config_file(const char *config_file, int print_file_name)
     			FILE *f = fopen(config_file, "r");
     			if (f) {
     				fclose(f);
    -				full_path_to_config_file = turn_strdup(config_file);
    +				full_path_to_config_file = strdup(config_file);
     			}
     		} else {
     			int i = 0;
    @@ -824,7 +825,7 @@ char* find_config_file(const char *config_file, int print_file_name)
     			while (config_file_search_dirs[i]) {
     				size_t dirlen = strlen(config_file_search_dirs[i]);
     				size_t fnsz = sizeof(char) * (dirlen + cflen + 10);
    -				char *fn = (char*)turn_malloc(fnsz+1);
    +				char *fn = (char*)malloc(fnsz+1);
     				strncpy(fn, config_file_search_dirs[i], fnsz);
     				strncpy(fn + dirlen, config_file, fnsz-dirlen);
     				fn[fnsz]=0;
    @@ -836,13 +837,13 @@ char* find_config_file(const char *config_file, int print_file_name)
     					full_path_to_config_file = fn;
     					break;
     				}
    -				turn_free(fn,fnsz+1);
    +				free(fn);
     				if(config_file_search_dirs[i][0]!='/' && 
     				   config_file_search_dirs[i][0]!='.' &&
     				   c_execdir && c_execdir[0]) {
     					size_t celen = strlen(c_execdir);
     					fnsz = sizeof(char) * (dirlen + cflen + celen + 10);
    -					fn = (char*)turn_malloc(fnsz+1);
    +					fn = (char*)malloc(fnsz+1);
     					strncpy(fn,c_execdir,fnsz);
     					size_t fnlen=strlen(fn);
     					if(fnlen<fnsz) {
    @@ -867,7 +868,7 @@ char* find_config_file(const char *config_file, int print_file_name)
     					    break;
     					  }
     					}
    -					turn_free(fn,fnsz+1);
    +					free(fn);
     				}
     				++i;
     			}
    @@ -893,15 +894,15 @@ void ignore_sigpipe(void)
     	}
     }
     
    -static u64bits turn_getRandTime(void) {
    +static uint64_t turn_getRandTime(void) {
       struct timespec tp={0,0};
     #if defined(CLOCK_REALTIME)
       clock_gettime(CLOCK_REALTIME, &tp);
     #else
       tp.tv_sec = time(NULL);
     #endif
    -  u64bits current_time = (u64bits)(tp.tv_sec);
    -  u64bits current_mstime = (u64bits)(current_time + (tp.tv_nsec));
    +  uint64_t current_time = (uint64_t)(tp.tv_sec);
    +  uint64_t current_mstime = (uint64_t)(current_time + (tp.tv_nsec));
     
       return current_mstime;
     }
    @@ -950,17 +951,17 @@ char *base64_encode(const unsigned char *data,
     
         *output_length = 4 * ((input_length + 2) / 3);
     
    -    char *encoded_data = (char*)turn_malloc(*output_length+1);
    +    char *encoded_data = (char*)malloc(*output_length+1);
         if (encoded_data == NULL) return NULL;
     
         size_t i,j;
         for (i = 0, j = 0; i < input_length;) {
     
    -        u32bits octet_a = i < input_length ? data[i++] : 0;
    -        u32bits octet_b = i < input_length ? data[i++] : 0;
    -        u32bits octet_c = i < input_length ? data[i++] : 0;
    +        uint32_t octet_a = i < input_length ? data[i++] : 0;
    +        uint32_t octet_b = i < input_length ? data[i++] : 0;
    +        uint32_t octet_c = i < input_length ? data[i++] : 0;
     
    -        u32bits triple = (octet_a << 0x10) + (octet_b << 0x08) + octet_c;
    +        uint32_t triple = (octet_a << 0x10) + (octet_b << 0x08) + octet_c;
     
             encoded_data[j++] = encoding_table[(triple >> 3 * 6) & 0x3F];
             encoded_data[j++] = encoding_table[(triple >> 2 * 6) & 0x3F];
    @@ -978,8 +979,8 @@ char *base64_encode(const unsigned char *data,
     
     void build_base64_decoding_table() {
     
    -    decoding_table = (char*)turn_malloc(256);
    -    ns_bzero(decoding_table,256);
    +    decoding_table = (char*)malloc(256);
    +    bzero(decoding_table,256);
     
         int i;
         for (i = 0; i < 64; i++)
    @@ -998,7 +999,7 @@ unsigned char *base64_decode(const char *data,
         if (data[input_length - 1] == '=') (*output_length)--;
         if (data[input_length - 2] == '=') (*output_length)--;
     
    -    unsigned char *decoded_data = (unsigned char*)turn_malloc(*output_length);
    +    unsigned char *decoded_data = (unsigned char*)malloc(*output_length);
         if (decoded_data == NULL) return NULL;
     
         int i;
    @@ -1031,67 +1032,13 @@ unsigned char *base64_decode(const char *data,
     
     ////////////////// SSL /////////////////////
     
    -static const char* turn_get_method(const SSL_METHOD *method, const char* mdefault)
    -{
    -	{
    -		if(!method)
    -			return mdefault;
    -		else {
    -			if(method == SSLv23_server_method()) {
    -					return "SSLv23";
    -			} else if(method == SSLv23_client_method()) {
    -					return "SSLv23";
    -			} else if(method == TLSv1_server_method()) {
    -					return "TLSv1.0";
    -			} else if(method == TLSv1_client_method()) {
    -				return "TLSv1.0";
    -#if TLSv1_1_SUPPORTED
    -			} else if(method == TLSv1_1_server_method()) {
    -					return "TLSv1.1";
    -			} else if(method == TLSv1_1_client_method()) {
    -				return "TLSv1.1";
    -#if TLSv1_2_SUPPORTED
    -			} else if(method == TLSv1_2_server_method()) {
    -					return "TLSv1.2";
    -			} else if(method == TLSv1_2_client_method()) {
    -				return "TLSv1.2";
    -#endif
    -#endif
    -#if DTLS_SUPPORTED
    -
    -			} else if(method == DTLSv1_server_method()) {
    -				return "DTLSv1.0";
    -			} else if(method == DTLSv1_client_method()) {
    -				return "DTLSv1.0";
    -
    -#if DTLSv1_2_SUPPORTED
    -			} else if(method == DTLSv1_2_server_method()) {
    -				return "DTLSv1.2";
    -			} else if(method == DTLSv1_2_client_method()) {
    -				return "DTLSv1.2";
    -#endif
    -#endif
    -			} else {
    -				if(mdefault)
    -					return mdefault;
    -				return "UNKNOWN";
    -			}
    -		}
    -	}
    -}
    -
     const char* turn_get_ssl_method(SSL *ssl, const char* mdefault)
     {
     	const char* ret = "unknown";
     	if(!ssl) {
     		ret = mdefault;
     	} else {
    -		const SSL_METHOD *method = SSL_get_ssl_method(ssl);
    -		if(!method) {
    -			ret = mdefault;
    -		} else {
    -			ret = turn_get_method(method, mdefault);
    -		}
    +		ret = SSL_get_version(ssl);
     	}
     
     	return ret;
    @@ -1114,21 +1061,21 @@ void convert_oauth_key_data_raw(const oauth_key_data_raw *raw, oauth_key_data *o
     {
     	if(raw && oakd) {
     
    -		ns_bzero(oakd,sizeof(oauth_key_data));
    +		bzero(oakd,sizeof(oauth_key_data));
     
     		oakd->timestamp = (turn_time_t)raw->timestamp;
     		oakd->lifetime = raw->lifetime;
     
    -		ns_bcopy(raw->as_rs_alg,oakd->as_rs_alg,sizeof(oakd->as_rs_alg));
    -		ns_bcopy(raw->kid,oakd->kid,sizeof(oakd->kid));
    +		bcopy(raw->as_rs_alg,oakd->as_rs_alg,sizeof(oakd->as_rs_alg));
    +		bcopy(raw->kid,oakd->kid,sizeof(oakd->kid));
     
     		if(raw->ikm_key[0]) {
     			size_t ikm_key_size = 0;
     			char *ikm_key = (char*)base64_decode(raw->ikm_key,strlen(raw->ikm_key),&ikm_key_size);
     			if(ikm_key) {
    -				ns_bcopy(ikm_key,oakd->ikm_key,ikm_key_size);
    +				bcopy(ikm_key,oakd->ikm_key,ikm_key_size);
     				oakd->ikm_key_size = ikm_key_size;
    -				turn_free(ikm_key,ikm_key_size);
    +				free(ikm_key);
     			}
     		}
     	}
    
  • src/apps/common/apputils.h+2 2 modified
    @@ -135,8 +135,8 @@ typedef enum _TURN_TLS_TYPE TURN_TLS_TYPE;
     struct _oauth_key_data_raw {
     	char kid[OAUTH_KID_SIZE+1];
     	char ikm_key[OAUTH_KEY_SIZE+1];
    -	u64bits timestamp;
    -	u32bits lifetime;
    +	uint64_t timestamp;
    +	uint32_t lifetime;
     	char as_rs_alg[OAUTH_ALG_SIZE+1];
     	char realm[STUN_MAX_REALM_SIZE+1];
     };
    
  • src/apps/common/hiredis_libevent2.c+5 5 modified
    @@ -246,16 +246,16 @@ redis_context_handle redisLibeventAttach(struct event_base *base, char *ip0, int
       }
     
       /* Create container for context and r/w events */
    -  e = (struct redisLibeventEvents*)turn_malloc(sizeof(struct redisLibeventEvents));
    -  ns_bzero(e,sizeof(struct redisLibeventEvents));
    +  e = (struct redisLibeventEvents*)malloc(sizeof(struct redisLibeventEvents));
    +  bzero(e,sizeof(struct redisLibeventEvents));
     
       e->allocated = 1;
       e->context = ac;
       e->base = base;
    -  e->ip = turn_strdup(ip);
    +  e->ip = strdup(ip);
       e->port = port;
       if(pwd)
    -	  e->pwd = turn_strdup(pwd);
    +	  e->pwd = strdup(pwd);
       e->db = db;
     
       /* Register functions to start/stop listening for events */
    @@ -277,7 +277,7 @@ redis_context_handle redisLibeventAttach(struct event_base *base, char *ip0, int
       		     e);
     
       if (e->rev == NULL || e->wev == NULL) {
    -	  turn_free(e, sizeof(struct redisLibeventEvents));
    +	  free(e);
     	  return NULL;
       }
       
    
  • src/apps/common/ns_turn_utils.c+36 235 modified
    @@ -98,7 +98,7 @@ int turn_mutex_unlock(const turn_mutex *mutex) {
     int turn_mutex_init(turn_mutex* mutex) {
       if(mutex) {
         mutex->data=MAGIC_CODE;
    -    mutex->mutex=turn_malloc(sizeof(pthread_mutex_t));
    +    mutex->mutex=malloc(sizeof(pthread_mutex_t));
         pthread_mutex_init((pthread_mutex_t*)mutex->mutex,NULL);
         return 0;
       } else {
    @@ -116,13 +116,13 @@ int turn_mutex_init_recursive(turn_mutex* mutex) {
     			if (pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_RECURSIVE) < 0) {
     				perror("Cannot set type on mutex attr");
     			} else {
    -				mutex->mutex = turn_malloc(sizeof(pthread_mutex_t));
    +				mutex->mutex = malloc(sizeof(pthread_mutex_t));
     				mutex->data = MAGIC_CODE;
     				if ((ret = pthread_mutex_init((pthread_mutex_t*) mutex->mutex,
     						&attr)) < 0) {
     					perror("Cannot init mutex");
     					mutex->data = 0;
    -					turn_free(mutex->mutex,sizeof(pthread_mutex_t));
    +					free(mutex->mutex);
     					mutex->mutex = NULL;
     				}
     			}
    @@ -136,7 +136,7 @@ int turn_mutex_destroy(turn_mutex* mutex) {
       if(mutex && mutex->mutex && mutex->data == MAGIC_CODE) {
         int ret = 0;
         ret = pthread_mutex_destroy((pthread_mutex_t*)(mutex->mutex));
    -    turn_free(mutex->mutex, sizeof(pthread_mutex_t));
    +    free(mutex->mutex);
         mutex->mutex=NULL;
         mutex->data=0;
         return ret;
    @@ -148,7 +148,7 @@ int turn_mutex_destroy(turn_mutex* mutex) {
     ///////////////////////// LOG ///////////////////////////////////
     
     #if defined(TURN_LOG_FUNC_IMPL)
    -extern void TURN_LOG_FUNC_IMPL(TURN_LOG_LEVEL level, const s08bits* format, va_list args);
    +extern void TURN_LOG_FUNC_IMPL(TURN_LOG_LEVEL level, const char* format, va_list args);
     #endif
     
     static int no_stdout_log = 0;
    @@ -158,7 +158,7 @@ void set_no_stdout_log(int val)
     	no_stdout_log = val;
     }
     
    -void turn_log_func_default(TURN_LOG_LEVEL level, const s08bits* format, ...)
    +void turn_log_func_default(TURN_LOG_LEVEL level, const char* format, ...)
     {
     #if !defined(TURN_LOG_FUNC_IMPL)
     	{
    @@ -194,13 +194,13 @@ void turn_log_func_default(TURN_LOG_LEVEL level, const s08bits* format, ...)
     	}
     }
     
    -void addr_debug_print(int verbose, const ioa_addr *addr, const s08bits* s)
    +void addr_debug_print(int verbose, const ioa_addr *addr, const char* s)
     {
     	if (verbose) {
     		if (!addr) {
     			TURN_LOG_FUNC(TURN_LOG_LEVEL_INFO, "%s: EMPTY\n", s);
     		} else {
    -			s08bits addrbuf[INET6_ADDRSTRLEN];
    +			char addrbuf[INET6_ADDRSTRLEN];
     			if (!s)
     				s = "";
     			if (addr->ss.sa_family == AF_INET) {
    @@ -296,11 +296,11 @@ static void set_log_file_name_func(char *base, char *f, size_t fsz)
     	}
     
     	char logdate[125];
    -	char *tail=turn_strdup(".log");
    +	char *tail=strdup(".log");
     
     	get_date(logdate,sizeof(logdate));
     
    -	char *base1=turn_strdup(base);
    +	char *base1=strdup(base);
     
     	int len=(int)strlen(base1);
     
    @@ -319,12 +319,12 @@ static void set_log_file_name_func(char *base, char *f, size_t fsz)
     		if(base1[len]=='/')
     			break;
     		else if(base1[len]=='.') {
    -			turn_free(tail,strlen(tail)+1);
    -			tail=turn_strdup(base1+len);
    +			free(tail);
    +			tail=strdup(base1+len);
     			base1[len]=0;
     			if(strlen(tail)<2) {
    -				turn_free(tail,strlen(tail)+1);
    -				tail = turn_strdup(".log");
    +				free(tail);
    +				tail = strdup(".log");
     			}
     			break;
     		}
    @@ -338,8 +338,8 @@ static void set_log_file_name_func(char *base, char *f, size_t fsz)
     	  snprintf(f, FILE_STR_LEN, "%s%s%s", base1,logdate,tail);
     	}
     
    -	turn_free(base1,strlen(base1)+1);
    -	turn_free(tail,strlen(tail)+1);
    +	free(base1);
    +	free(tail);
     }
     
     static void sighup_callback_handler(int signum)
    @@ -370,7 +370,7 @@ static void set_rtpfile(void)
     				no_stdout_log = 1;
     			} else {
     				set_log_file_name(log_fn_base,log_fn);
    -				_rtpfile = fopen(log_fn, "w");
    +				_rtpfile = fopen(log_fn, "a");
     				if(_rtpfile)
     					TURN_LOG_FUNC(TURN_LOG_LEVEL_INFO, "log file opened: %s\n", log_fn);
     			}
    @@ -393,36 +393,41 @@ static void set_rtpfile(void)
     		else
     			snprintf(logtail, FILE_STR_LEN, "turn_%d_", (int)getpid());
     
    -		snprintf(logbase, FILE_STR_LEN, "/var/log/turnserver/%s", logtail);
    +		if (snprintf(logbase, FILE_STR_LEN, "/var/log/turnserver/%s", logtail)<0)
    +			TURN_LOG_FUNC(TURN_LOG_LEVEL_INFO, "String truncation occured.\n");
     
     		set_log_file_name(logbase, logf);
     
    -		_rtpfile = fopen(logf, "w");
    +		_rtpfile = fopen(logf, "a");
     		if(_rtpfile)
     			TURN_LOG_FUNC(TURN_LOG_LEVEL_INFO, "log file opened: %s\n", logf);
     		else {
    -			snprintf(logbase, FILE_STR_LEN, "/var/log/%s", logtail);
    +			if (snprintf(logbase, FILE_STR_LEN, "/var/log/%s", logtail)<0)
    +				TURN_LOG_FUNC(TURN_LOG_LEVEL_INFO, "String truncation occured.\n");
     
     			set_log_file_name(logbase, logf);
    -			_rtpfile = fopen(logf, "w");
    +			_rtpfile = fopen(logf, "a");
     			if(_rtpfile)
     				TURN_LOG_FUNC(TURN_LOG_LEVEL_INFO, "log file opened: %s\n", logf);
     			else {
    -				snprintf(logbase, FILE_STR_LEN, "/var/tmp/%s", logtail);
    +				if (snprintf(logbase, FILE_STR_LEN, "/var/tmp/%s", logtail)<0)
    +					TURN_LOG_FUNC(TURN_LOG_LEVEL_INFO, "String truncation occured.\n");
    +
     				set_log_file_name(logbase, logf);
    -				_rtpfile = fopen(logf, "w");
    +				_rtpfile = fopen(logf, "a");
     				if(_rtpfile)
     					TURN_LOG_FUNC(TURN_LOG_LEVEL_INFO, "log file opened: %s\n", logf);
     				else {
    -					snprintf(logbase, FILE_STR_LEN, "/tmp/%s", logtail);
    +					if (snprintf(logbase, FILE_STR_LEN, "/tmp/%s", logtail)<0)
    +						TURN_LOG_FUNC(TURN_LOG_LEVEL_INFO, "String truncation occured.\n");
     					set_log_file_name(logbase, logf);
    -					_rtpfile = fopen(logf, "w");
    +					_rtpfile = fopen(logf, "a");
     					if(_rtpfile)
     						TURN_LOG_FUNC(TURN_LOG_LEVEL_INFO, "log file opened: %s\n", logf);
     					else {
     						snprintf(logbase, FILE_STR_LEN, "%s", logtail);
     						set_log_file_name(logbase, logf);
    -						_rtpfile = fopen(logf, "w");
    +						_rtpfile = fopen(logf, "a");
     						if(_rtpfile)
     							TURN_LOG_FUNC(TURN_LOG_LEVEL_INFO, "log file opened: %s\n", logf);
     						else {
    @@ -556,7 +561,7 @@ int get_default_protocol_port(const char* scheme, size_t slen)
     				return 21;
     			if(!memcmp("svn",scheme,3))
     				return 3690;
    -			if(!memcmp("ssh",scheme,4))
    +			if(!memcmp("ssh",scheme,3))
     				return 22;
     			if(!memcmp("sip",scheme,3))
     				return 5060;
    @@ -615,7 +620,7 @@ int get_canonic_origin(const char* o, char *co, int sz)
     					const char *host = evhttp_uri_get_host(uri);
     					if(host && host[0]) {
     						char otmp[STUN_MAX_ORIGIN_SIZE+STUN_MAX_ORIGIN_SIZE];
    -						ns_bcopy(scheme,otmp,schlen);
    +						bcopy(scheme,otmp,schlen);
     						otmp[schlen]=0;
     
     						{
    @@ -663,215 +668,11 @@ int get_canonic_origin(const char* o, char *co, int sz)
     
     //////////////////////////////////////////////////////////////////
     
    -#ifdef __cplusplus
    -#if defined(TURN_MEMORY_DEBUG)
    -
    -#include <map>
    -#include <set>
    -#include <string>
    -
    -static volatile int tmm_init = 0;
    -static pthread_mutex_t tm;
    -
    -typedef void* ptrtype;
    -typedef std::set<ptrtype> ptrs_t;
    -typedef std::map<std::string,ptrs_t> str_to_ptrs_t;
    -typedef std::map<ptrtype,std::string> ptr_to_str_t;
    -
    -static str_to_ptrs_t str_to_ptrs;
    -static ptr_to_str_t ptr_to_str;
    -
    -static void tm_init(void) {
    -  if(!tmm_init) {
    -    pthread_mutex_init(&tm,NULL);
    -    tmm_init = 1;
    -  }
    -}
    -
    -static void add_tm_ptr(void *ptr, const char *id) {
    -
    -  UNUSED_ARG(ptr);
    -  UNUSED_ARG(id);
    -
    -  if(!ptr)
    -    return;
    -
    -  std::string sid(id);
    -
    -  str_to_ptrs_t::iterator iter;
    -
    -  pthread_mutex_lock(&tm);
    -
    -  iter = str_to_ptrs.find(sid);
    -
    -  if(iter == str_to_ptrs.end()) {
    -    std::set<ptrtype> sp;
    -    sp.insert(ptr);
    -    str_to_ptrs[sid]=sp;
    -  } else {
    -	iter->second.insert(ptr);
    -  }
    -
    -  ptr_to_str[ptr]=sid;
    -
    -  pthread_mutex_unlock(&tm);
    -}
    -
    -static void del_tm_ptr(void *ptr, const char *id) {
    -
    -  UNUSED_ARG(ptr);
    -  UNUSED_ARG(id);
    -
    -  if(!ptr)
    -    return;
    -
    -  pthread_mutex_lock(&tm);
    -
    -  ptr_to_str_t::iterator pts_iter = ptr_to_str.find(ptr);
    -  if(pts_iter == ptr_to_str.end()) {
    -
    -	  printf("Tring to free unknown pointer (1): %s\n",id);
    -
    -  } else {
    -
    -    std::string sid = pts_iter->second;
    -    ptr_to_str.erase(pts_iter);
    -
    -    str_to_ptrs_t::iterator iter = str_to_ptrs.find(sid);
    -
    -    if(iter == str_to_ptrs.end()) {
    -
    -    	printf("Tring to free unknown pointer (2): %s\n",id);
    -
    -    } else {
    -
    -      iter->second.erase(ptr);
    -
    -    }
    -  }
    -
    -  pthread_mutex_unlock(&tm);
    -}
    -
    -static void tm_id(char *id, const char* function, int line) {
    -  sprintf(id,"%s:%d",function,line);
    -}
    -
    -#define TM_START() char id[128];tm_id(id,function,line);tm_init()
    -
    -extern "C" void* debug_ptr_add_func(void *ptr, const char* function, int line) {
    -
    -	TM_START();
    -
    -	add_tm_ptr(ptr,id);
    -
    -	return ptr;
    -}
    -
    -extern "C" void debug_ptr_del_func(void *ptr, const char* function, int line) {
    -
    -	TM_START();
    -
    -	del_tm_ptr(ptr,id);
    -}
    -
    -extern "C" void tm_print_func(void);
    -void tm_print_func(void) {
    -  pthread_mutex_lock(&tm);
    -  printf("=============================================\n");
    -  for(str_to_ptrs_t::const_iterator iter=str_to_ptrs.begin();iter != str_to_ptrs.end();++iter) {
    -	  if(iter->second.size())
    -		  printf("%s: %s: %d\n",__FUNCTION__,iter->first.c_str(),(int)(iter->second.size()));
    -  }
    -  printf("=============================================\n");
    -  pthread_mutex_unlock(&tm);
    -} 
    -
    -extern "C" void *turn_malloc_func(size_t sz, const char* function, int line);
    -void *turn_malloc_func(size_t sz, const char* function, int line) {
    -
    -  TM_START();
    -
    -  void *ptr = malloc(sz);
    -  
    -  add_tm_ptr(ptr,id);
    -
    -  return ptr;
    -}
    -
    -extern "C" void *turn_realloc_func(void *ptr, size_t old_sz, size_t new_sz, const char* function, int line);
    -void *turn_realloc_func(void *ptr, size_t old_sz, size_t new_sz, const char* function, int line) {
    -
    -  UNUSED_ARG(old_sz);
    -
    -  TM_START();
    -
    -  if(ptr)
    -	  del_tm_ptr(ptr,id);
    -
    -  ptr = realloc(ptr,new_sz);
    -
    -  add_tm_ptr(ptr,id);
    -
    -  return ptr;
    -}
    -
    -extern "C" void turn_free_func(void *ptr, size_t sz, const char* function, int line);
    -void turn_free_func(void *ptr, size_t sz, const char* function, int line) {
    -
    -  UNUSED_ARG(sz);
    -
    -  TM_START();
    -
    -  del_tm_ptr(ptr,id);
    -
    -  free(ptr);
    -}
    -
    -extern "C" void turn_free_simple(void *ptr);
    -void turn_free_simple(void *ptr) {
    -
    -  tm_init();
    -
    -  del_tm_ptr(ptr,__FUNCTION__);
    -
    -  free(ptr);
    -}
    -
    -extern "C" void *turn_calloc_func(size_t number, size_t size, const char* function, int line);
    -void *turn_calloc_func(size_t number, size_t size, const char* function, int line) {
    -  
    -  TM_START();
    -
    -  void *ptr = calloc(number,size);
    -
    -  add_tm_ptr(ptr,id);
    -
    -  return ptr;
    -}
    -
    -extern "C" char *turn_strdup_func(const char* s, const char* function, int line);
    -char *turn_strdup_func(const char* s, const char* function, int line) {
    -
    -  TM_START();
    -
    -  char *ptr = strdup(s);
    -
    -  add_tm_ptr(ptr,id);
    -
    -  return ptr;
    -}
    -
    -#endif
    -#endif
    -
    -////////////////////////////////
    -
    -int is_secure_string(const u08bits *string, int sanitizesql)
    +int is_secure_string(const uint8_t *string, int sanitizesql)
     {
     	int ret = 0;
     	if(string) {
    -		unsigned char *s0 = (unsigned char*)turn_strdup((const char*)string);
    +		unsigned char *s0 = (unsigned char*)strdup((const char*)string);
     		unsigned char *s = s0;
     		while(*s) {
     			*s = (unsigned char)tolower((int)*s);
    @@ -885,7 +686,7 @@ int is_secure_string(const u08bits *string, int sanitizesql)
     		} else {
     			ret = 1;
     		}
    -		turn_free(s,strlen((char*)s));
    +		free(s);
     	}
     	return ret;
     }
    
  • src/apps/common/ns_turn_utils.h+3 3 modified
    @@ -61,9 +61,9 @@ void set_no_stdout_log(int val);
     void set_log_to_syslog(int val);
     void set_simple_log(int val);
     
    -void turn_log_func_default(TURN_LOG_LEVEL level, const s08bits* format, ...);
    +void turn_log_func_default(TURN_LOG_LEVEL level, const char* format, ...);
     
    -void addr_debug_print(int verbose, const ioa_addr *addr, const s08bits* s);
    +void addr_debug_print(int verbose, const ioa_addr *addr, const char* s);
     
     /* Log */
     
    @@ -78,7 +78,7 @@ void rollover_logfile(void);
     
     ///////////////////////////////////////////////////////
     
    -int is_secure_string(const u08bits *string, int sanitizesql);
    +int is_secure_string(const uint8_t *string, int sanitizesql);
     
     ///////////////////////////////////////////////////////
     
    
  • src/apps/common/stun_buffer.c+27 27 modified
    @@ -34,7 +34,7 @@
     
     int stun_init_buffer(stun_buffer *buf) {
       if(!buf) return -1;
    -  ns_bzero(buf->buf,sizeof(buf->buf));
    +  bzero(buf->buf,sizeof(buf->buf));
       buf->len=0;
       buf->offset=0;
       buf->coffset=0;
    @@ -82,7 +82,7 @@ int stun_is_success_response(const stun_buffer* buf) {
       return stun_is_success_response_str(buf->buf, (size_t)(buf->len));
     }
     
    -int stun_is_error_response(const stun_buffer* buf, int *err_code, u08bits *err_msg, size_t err_msg_size) {
    +int stun_is_error_response(const stun_buffer* buf, int *err_code, uint8_t *err_msg, size_t err_msg_size) {
       return stun_is_error_response_str(buf->buf, (size_t)(buf->len), err_code, err_msg, err_msg_size);
     }
     
    @@ -95,36 +95,36 @@ int stun_is_indication(const stun_buffer* buf) {
       return IS_STUN_INDICATION(stun_get_msg_type(buf));
     }
     
    -u16bits stun_get_method(const stun_buffer* buf) {
    +uint16_t stun_get_method(const stun_buffer* buf) {
     	return stun_get_method_str(buf->buf, (size_t)(buf->len));
     }
     
    -u16bits stun_get_msg_type(const stun_buffer* buf) {
    -  if(!buf) return (u16bits)-1;
    +uint16_t stun_get_msg_type(const stun_buffer* buf) {
    +  if(!buf) return (uint16_t)-1;
       return stun_get_msg_type_str(buf->buf,(size_t)buf->len);
     }
     
     ////////////////////////////////////////////////////////////
     
    -static void stun_init_command(u16bits message_type, stun_buffer* buf) {
    +static void stun_init_command(uint16_t message_type, stun_buffer* buf) {
       buf->len=stun_get_size(buf);
       stun_init_command_str(message_type, buf->buf, (size_t*)(&(buf->len)));
     }
     
    -void stun_init_request(u16bits method, stun_buffer* buf) {
    +void stun_init_request(uint16_t method, stun_buffer* buf) {
       stun_init_command(stun_make_request(method), buf);
     }
     
    -void stun_init_indication(u16bits method, stun_buffer* buf) {
    +void stun_init_indication(uint16_t method, stun_buffer* buf) {
       stun_init_command(stun_make_indication(method), buf);
     }
     
    -void stun_init_success_response(u16bits method, stun_buffer* buf, stun_tid* id) {
    +void stun_init_success_response(uint16_t method, stun_buffer* buf, stun_tid* id) {
       buf->len=stun_get_size(buf);
       stun_init_success_response_str(method, buf->buf, (size_t*)(&(buf->len)), id);
     }
     
    -void stun_init_error_response(u16bits method, stun_buffer* buf, u16bits error_code, const u08bits *reason, stun_tid* id) {
    +void stun_init_error_response(uint16_t method, stun_buffer* buf, uint16_t error_code, const uint8_t *reason, stun_tid* id) {
       buf->len=stun_get_size(buf);
       stun_init_error_response_str(method, buf->buf, (size_t*)(&(buf->len)), error_code, reason, id);
     }
    @@ -137,11 +137,11 @@ int stun_get_command_message_len(const stun_buffer* buf) {
     
     ///////////////////////////////////////////////////////////////////////////////
     
    -int stun_init_channel_message(u16bits chnumber, stun_buffer* buf, int length, int do_padding) {
    +int stun_init_channel_message(uint16_t chnumber, stun_buffer* buf, int length, int do_padding) {
       return stun_init_channel_message_str(chnumber, buf->buf, (size_t*)(&(buf->len)), length, do_padding);
     }
     
    -int stun_is_channel_message(stun_buffer* buf, u16bits* chnumber, int is_padding_mandatory) {
    +int stun_is_channel_message(stun_buffer* buf, uint16_t* chnumber, int is_padding_mandatory) {
       if(!buf) return 0;
       size_t blen = (size_t)buf->len;
       int ret = stun_is_channel_message_str(buf->buf, &blen, chnumber, is_padding_mandatory);
    @@ -153,15 +153,15 @@ int stun_is_channel_message(stun_buffer* buf, u16bits* chnumber, int is_padding_
     
     ///////////////////////////////////////////////////////////////////////////////
     
    -int stun_set_allocate_request(stun_buffer* buf, u32bits lifetime, int af4, int af6, u08bits transport, int mobile, const char *rt, int ep) {
    +int stun_set_allocate_request(stun_buffer* buf, uint32_t lifetime, int af4, int af6, uint8_t transport, int mobile, const char *rt, int ep) {
       return stun_set_allocate_request_str(buf->buf, (size_t*)(&(buf->len)), lifetime, af4, af6, transport, mobile, rt, ep);
     }
     
     int stun_set_allocate_response(stun_buffer* buf, stun_tid* tid, 
     			       const ioa_addr *relayed_addr1, const ioa_addr *relayed_addr2,
     			       const ioa_addr *reflexive_addr,
    -			       u32bits lifetime, u32bits max_lifetime, int error_code, const u08bits *reason,
    -			       u64bits reservation_token, char *mobile_id) {
    +			       uint32_t lifetime, uint32_t max_lifetime, int error_code, const uint8_t *reason,
    +			       uint64_t reservation_token, char *mobile_id) {
     
       return stun_set_allocate_response_str(buf->buf, (size_t*)(&(buf->len)), tid, 
     					relayed_addr1, relayed_addr2, reflexive_addr,
    @@ -172,13 +172,13 @@ int stun_set_allocate_response(stun_buffer* buf, stun_tid* tid,
     
     ///////////////////////////////////////////////////////////////////////////////
     
    -u16bits stun_set_channel_bind_request(stun_buffer* buf, 
    -				       const ioa_addr* peer_addr, u16bits channel_number) {
    +uint16_t stun_set_channel_bind_request(stun_buffer* buf, 
    +				       const ioa_addr* peer_addr, uint16_t channel_number) {
     
       return stun_set_channel_bind_request_str(buf->buf,(size_t*)(&(buf->len)), peer_addr, channel_number);
     }
     
    -void stun_set_channel_bind_response(stun_buffer* buf, stun_tid* tid, int error_code, const u08bits *reason) {
    +void stun_set_channel_bind_response(stun_buffer* buf, stun_tid* tid, int error_code, const uint8_t *reason) {
       stun_set_channel_bind_response_str(buf->buf, (size_t*)(&(buf->len)), tid, error_code, reason);
     }
     
    @@ -192,15 +192,15 @@ stun_attr_ref stun_attr_get_next(const stun_buffer* buf, stun_attr_ref prev) {
       return stun_attr_get_next_str(buf->buf, (size_t)(buf->len), prev);
     }
     
    -int stun_attr_add(stun_buffer* buf, u16bits attr, const s08bits* avalue, int alen) {
    -  return stun_attr_add_str(buf->buf, (size_t*)(&(buf->len)), attr, (const u08bits *)avalue, alen);
    +int stun_attr_add(stun_buffer* buf, uint16_t attr, const char* avalue, int alen) {
    +  return stun_attr_add_str(buf->buf, (size_t*)(&(buf->len)), attr, (const uint8_t *)avalue, alen);
     }
     
    -int stun_attr_add_channel_number(stun_buffer* buf, u16bits chnumber) {
    +int stun_attr_add_channel_number(stun_buffer* buf, uint16_t chnumber) {
       return stun_attr_add_channel_number_str(buf->buf, (size_t *)(&(buf->len)), chnumber);
     }
     
    -int stun_attr_add_addr(stun_buffer *buf,u16bits attr_type, const ioa_addr* ca) {
    +int stun_attr_add_addr(stun_buffer *buf,uint16_t attr_type, const ioa_addr* ca) {
       return stun_attr_add_addr_str(buf->buf,(size_t*)(&(buf->len)), attr_type, ca);
     }
     
    @@ -210,22 +210,22 @@ int stun_attr_get_addr(const stun_buffer *buf, stun_attr_ref attr, ioa_addr* ca,
       return stun_attr_get_addr_str(buf->buf, (size_t)(buf->len), attr, ca, default_addr);
     }
     
    -int stun_attr_get_first_addr(const stun_buffer *buf, u16bits attr_type, ioa_addr* ca, 
    +int stun_attr_get_first_addr(const stun_buffer *buf, uint16_t attr_type, ioa_addr* ca, 
     			     const ioa_addr *default_addr) {
     
       return stun_attr_get_first_addr_str(buf->buf, (size_t)(buf->len), attr_type, ca, default_addr);
     }
     
     int stun_attr_add_even_port(stun_buffer* buf, uint8_t value) {
       if(value) value=0x80;
    -  return stun_attr_add(buf,STUN_ATTRIBUTE_EVEN_PORT,(const s08bits*)&value,1);
    +  return stun_attr_add(buf,STUN_ATTRIBUTE_EVEN_PORT,(const char*)&value,1);
     }
     
    -u16bits stun_attr_get_first_channel_number(const stun_buffer *buf) {
    +uint16_t stun_attr_get_first_channel_number(const stun_buffer *buf) {
       return stun_attr_get_first_channel_number_str(buf->buf, (size_t)(buf->len));
     }
     
    -stun_attr_ref stun_attr_get_first_by_type(const stun_buffer* buf, u16bits attr_type) {
    +stun_attr_ref stun_attr_get_first_by_type(const stun_buffer* buf, uint16_t attr_type) {
       return stun_attr_get_first_by_type_str(buf->buf, (size_t)(buf->len), attr_type);
     }
     
    @@ -236,7 +236,7 @@ void stun_set_binding_request(stun_buffer* buf) {
     }
     
     int stun_set_binding_response(stun_buffer* buf, stun_tid* tid, 
    -			      const ioa_addr *reflexive_addr, int error_code, const u08bits *reason) {
    +			      const ioa_addr *reflexive_addr, int error_code, const uint8_t *reason) {
       return stun_set_binding_response_str(buf->buf, (size_t*)(&(buf->len)), tid, 
     				       reflexive_addr, error_code, reason,
     				       0,0);
    
  • src/apps/common/stun_buffer.h+26 26 modified
    @@ -40,11 +40,11 @@ extern "C" {
     ///////////////////////////////////////////////////////////////
     
     typedef struct _stun_buffer {
    -  u08bits	channel[STUN_CHANNEL_HEADER_LENGTH];
    -  u08bits	buf[STUN_BUFFER_SIZE];
    +  uint8_t	channel[STUN_CHANNEL_HEADER_LENGTH];
    +  uint8_t	buf[STUN_BUFFER_SIZE];
       size_t	len;
    -  u16bits	offset;
    -  u08bits	coffset;
    +  uint16_t	offset;
    +  uint8_t	coffset;
     } stun_buffer;
     
     //////////////////////////////////////////////////////////////
    @@ -63,65 +63,65 @@ int stun_is_command_message(const stun_buffer* buf);
     int stun_is_request(const stun_buffer* buf);
     int stun_is_response(const stun_buffer* buf);
     int stun_is_success_response(const stun_buffer* buf);
    -int stun_is_error_response(const stun_buffer* buf, int *err_code, u08bits *err_msg, size_t err_msg_size);
    +int stun_is_error_response(const stun_buffer* buf, int *err_code, uint8_t *err_msg, size_t err_msg_size);
     int stun_is_indication(const stun_buffer* buf);
    -u16bits stun_get_method(const stun_buffer* buf);
    -u16bits stun_get_msg_type(const stun_buffer* buf);
    +uint16_t stun_get_method(const stun_buffer* buf);
    +uint16_t stun_get_msg_type(const stun_buffer* buf);
     
     ///////////////////////////////////////////////////////////////
     
    -void stun_init_request(u16bits method, stun_buffer* buf);
    -void stun_init_indication(u16bits method, stun_buffer* buf);
    -void stun_init_success_response(u16bits method, stun_buffer* buf, stun_tid* id);
    -void stun_init_error_response(u16bits method, stun_buffer* buf, u16bits error_code, const u08bits *reason, stun_tid* id);
    +void stun_init_request(uint16_t method, stun_buffer* buf);
    +void stun_init_indication(uint16_t method, stun_buffer* buf);
    +void stun_init_success_response(uint16_t method, stun_buffer* buf, stun_tid* id);
    +void stun_init_error_response(uint16_t method, stun_buffer* buf, uint16_t error_code, const uint8_t *reason, stun_tid* id);
     
     ///////////////////////////////////////////////////////////////
     
    -int stun_attr_add(stun_buffer* buf, u16bits attr, const s08bits* avalue, int alen);
    -int stun_attr_add_channel_number(stun_buffer* buf, u16bits chnumber);
    -int stun_attr_add_addr(stun_buffer *buf,u16bits attr_type, const ioa_addr* ca);
    +int stun_attr_add(stun_buffer* buf, uint16_t attr, const char* avalue, int alen);
    +int stun_attr_add_channel_number(stun_buffer* buf, uint16_t chnumber);
    +int stun_attr_add_addr(stun_buffer *buf,uint16_t attr_type, const ioa_addr* ca);
     
     stun_attr_ref stun_attr_get_first(const stun_buffer* buf);
    -stun_attr_ref stun_attr_get_first_by_type(const stun_buffer* buf, u16bits attr_type);
    +stun_attr_ref stun_attr_get_first_by_type(const stun_buffer* buf, uint16_t attr_type);
     stun_attr_ref stun_attr_get_next(const stun_buffer* buf, stun_attr_ref prev);
     int stun_attr_get_addr(const stun_buffer *buf, stun_attr_ref attr, ioa_addr* ca, const ioa_addr *default_addr);
     int stun_attr_add_even_port(stun_buffer* buf, uint8_t value);
     
    -int stun_attr_get_first_addr(const stun_buffer *buf, u16bits attr_type, ioa_addr* ca, const ioa_addr *default_addr);
    -u16bits stun_attr_get_first_channel_number(const stun_buffer *buf);
    +int stun_attr_get_first_addr(const stun_buffer *buf, uint16_t attr_type, ioa_addr* ca, const ioa_addr *default_addr);
    +uint16_t stun_attr_get_first_channel_number(const stun_buffer *buf);
     
     ///////////////////////////////////////////////////////////////
     
     int stun_get_command_message_len(const stun_buffer* buf);
     
     ///////////////////////////////////////////////////////////////
     
    -int stun_init_channel_message(u16bits chnumber, stun_buffer* buf, int length, int do_padding);
    -int stun_is_channel_message(stun_buffer* buf, u16bits* chnumber, int is_padding_madatory);
    +int stun_init_channel_message(uint16_t chnumber, stun_buffer* buf, int length, int do_padding);
    +int stun_is_channel_message(stun_buffer* buf, uint16_t* chnumber, int is_padding_madatory);
     
     ///////////////////////////////////////////////////////////////
     
    -int stun_set_allocate_request(stun_buffer* buf, u32bits lifetime, int af4, int af6, u08bits transport, int mobile, const char* rt, int ep);
    +int stun_set_allocate_request(stun_buffer* buf, uint32_t lifetime, int af4, int af6, uint8_t transport, int mobile, const char* rt, int ep);
     int stun_set_allocate_response(stun_buffer* buf, stun_tid* tid, 
     			       const ioa_addr *relayed_addr1, const ioa_addr *relayed_addr2,
     			       const ioa_addr *reflexive_addr,
    -			       u32bits lifetime, u32bits max_lifetime,
    -			       int error_code, const u08bits *reason,
    -			       u64bits reservation_token, char *mobile_id);
    +			       uint32_t lifetime, uint32_t max_lifetime,
    +			       int error_code, const uint8_t *reason,
    +			       uint64_t reservation_token, char *mobile_id);
     
     ///////////////////////////////////////////////////////////////
     
     void stun_set_binding_request(stun_buffer* buf);
     int stun_set_binding_response(stun_buffer* buf, stun_tid* tid, 
    -			      const ioa_addr *reflexive_addr, int error_code, const u08bits *reason);
    +			      const ioa_addr *reflexive_addr, int error_code, const uint8_t *reason);
     
     void stun_prepare_binding_request(stun_buffer* buf);
     int stun_is_binding_response(const stun_buffer* buf);
     
     ///////////////////////////////////////////////////////////////
     
    -u16bits stun_set_channel_bind_request(stun_buffer* buf, const ioa_addr* peer_addr, u16bits channel_number);
    -void stun_set_channel_bind_response(stun_buffer* buf, stun_tid* tid, int error_code, const u08bits *reason);
    +uint16_t stun_set_channel_bind_request(stun_buffer* buf, const ioa_addr* peer_addr, uint16_t channel_number);
    +void stun_set_channel_bind_response(stun_buffer* buf, stun_tid* tid, int error_code, const uint8_t *reason);
     
     ///////////////////////////////////////////////////////////////
     
    
  • src/apps/natdiscovery/natdiscovery.c+14 14 modified
    @@ -81,7 +81,7 @@ static int stunclient_send(int sockfd, ioa_addr *local_addr, int *local_port, io
     
     	if (response_port >= 0) {
     		turn::StunAttrResponsePort rpa;
    -		rpa.setResponsePort((u16bits)response_port);
    +		rpa.setResponsePort((uint16_t)response_port);
     		try {
     			req.addAttr(rpa);
     		} catch(turn::WrongStunAttrFormatException &ex1) {
    @@ -159,7 +159,7 @@ static int stunclient_receive(int sockfd, ioa_addr *local_addr, ioa_addr *reflex
     	{
     		int len = 0;
     		stun_buffer buf;
    -		u08bits *ptr = buf.buf;
    +		uint8_t *ptr = buf.buf;
     		int recvd = 0;
     		const int to_recv = sizeof(buf.buf);
     		struct timeval tv;
    @@ -353,13 +353,13 @@ static int stunclient_send(stun_buffer *buf, int sockfd, ioa_addr *local_addr, i
     	stun_prepare_binding_request(buf);
     
     	if (response_port >= 0) {
    -		stun_attr_add_response_port_str((u08bits*) (buf->buf), (size_t*) &(buf->len), (u16bits) response_port);
    +		stun_attr_add_response_port_str((uint8_t*) (buf->buf), (size_t*) &(buf->len), (uint16_t) response_port);
     	}
     	if (change_ip || change_port) {
    -		stun_attr_add_change_request_str((u08bits*) buf->buf, (size_t*) &(buf->len), change_ip, change_port);
    +		stun_attr_add_change_request_str((uint8_t*) buf->buf, (size_t*) &(buf->len), change_ip, change_port);
     	}
     	if (padding) {
    -		if(stun_attr_add_padding_str((u08bits*) buf->buf, (size_t*) &(buf->len), 1500)<0) {
    +		if(stun_attr_add_padding_str((uint8_t*) buf->buf, (size_t*) &(buf->len), 1500)<0) {
     			printf("%s: ERROR: Cannot add padding\n",__FUNCTION__);
     		}
     	}
    @@ -393,7 +393,7 @@ static int stunclient_receive(stun_buffer *buf, int sockfd, ioa_addr *local_addr
     
     	{
     		int len = 0;
    -		u08bits *ptr = buf->buf;
    +		uint8_t *ptr = buf->buf;
     		int recvd = 0;
     		const int to_recv = sizeof(buf->buf);
     		struct timeval tv;
    @@ -444,11 +444,11 @@ static int stunclient_receive(stun_buffer *buf, int sockfd, ioa_addr *local_addr
     								} else {
     									printf("Not received mapped address attribute.\n");
     								}
    -								stun_attr_get_addr_str((u08bits *) buf->buf, (size_t) buf->len, sar, other_addr, NULL);
    +								stun_attr_get_addr_str((uint8_t *) buf->buf, (size_t) buf->len, sar, other_addr, NULL);
     								sar = stun_attr_get_first_by_type_str(buf->buf, buf->len, STUN_ATTRIBUTE_RESPONSE_ORIGIN);
     								if (sar) {
     									ioa_addr response_origin;
    -									stun_attr_get_addr_str((u08bits *) buf->buf, (size_t) buf->len, sar, &response_origin, NULL);
    +									stun_attr_get_addr_str((uint8_t *) buf->buf, (size_t) buf->len, sar, &response_origin, NULL);
     									addr_debug_print(1, &response_origin, "Response origin: ");
     								}
     								addr_debug_print(1, other_addr, "Other addr: ");
    @@ -463,7 +463,7 @@ static int stunclient_receive(stun_buffer *buf, int sockfd, ioa_addr *local_addr
     					}
     				} else {
     					int err_code = 0;
    -					u08bits err_msg[1025] = "\0";
    +					uint8_t err_msg[1025] = "\0";
     					size_t err_msg_size = sizeof(err_msg);
     					if (stun_is_error_response(buf, &err_code, err_msg, err_msg_size)) {
     						printf("The response is an error %d (%s)\n", err_code, (char*) err_msg);
    @@ -592,14 +592,14 @@ static void init(int first, ioa_addr *local_addr, ioa_addr *remote_addr, int *lo
     	addr_set_any(local_addr);
     
     	if(local_addr_string[0]) {
    -		if(make_ioa_addr((const u08bits*)local_addr_string, 0, local_addr)<0) {
    +		if(make_ioa_addr((const uint8_t*)local_addr_string, 0, local_addr)<0) {
     			err(-1,NULL);
     		}
     	}
     	if (!first) *local_port=-1;
     	*rfc5780 = 0;
     
    -	if (make_ioa_addr((const u08bits*)remote_param, port, remote_addr) < 0)
    +	if (make_ioa_addr((const uint8_t*)remote_param, port, remote_addr) < 0)
     	err(-1, NULL);
     }
     
    @@ -631,8 +631,8 @@ int main(int argc, char **argv)
     	set_logfile("stdout");
     	set_system_parameters(0);
     
    -	ns_bzero(local_addr_string, sizeof(local_addr_string));
    -	ns_bzero(local2_addr_string, sizeof(local2_addr_string));
    +	bzero(local_addr_string, sizeof(local_addr_string));
    +	bzero(local2_addr_string, sizeof(local2_addr_string));
     	addr_set_any(&remote_addr);
     	addr_set_any(&other_addr);
     	addr_set_any(&reflexive_addr);
    @@ -791,7 +791,7 @@ int main(int argc, char **argv)
     		addr_set_any(&local2_addr);
     
     		if(local2_addr_string[0]) {
    -			if(make_ioa_addr((const u08bits*)local2_addr_string, 0, &local2_addr)<0) {
    +			if(make_ioa_addr((const uint8_t*)local2_addr_string, 0, &local2_addr)<0) {
     				err(-1,NULL);
     			}
     		}
    
  • src/apps/oauth/oauth.c+9 9 modified
    @@ -62,14 +62,14 @@ static int setup_ikm_key(const char *kid,
                             const char *as_rs_alg, 
                             oauth_key *key) { 
     
    -        ns_bzero(key,sizeof(*key));
    +        bzero(key,sizeof(*key));
     
             oauth_key_data okd;
    -        ns_bzero(&okd,sizeof(okd));
    +        bzero(&okd,sizeof(okd));
     
             {
                     oauth_key_data_raw okdr;
    -                ns_bzero(&okdr,sizeof(okdr));
    +                bzero(&okdr,sizeof(okdr));
     
                     STRCPY(okdr.kid,kid);
                     STRCPY(okdr.ikm_key,ikm_key);
    @@ -103,7 +103,7 @@ static int encode_token(const char* server_name,
     
     
             oauth_token ot;
    -        ns_bzero(&ot,sizeof(ot));
    +        bzero(&ot,sizeof(ot));
     
             const size_t mac_key_length=strlen(mac_key);
             ot.enc_block.key_length = (uint16_t)mac_key_length;
    @@ -112,12 +112,12 @@ static int encode_token(const char* server_name,
             ot.enc_block.lifetime = token_lifetime;
     
             encoded_oauth_token etoken;
    -        ns_bzero(&etoken,sizeof(etoken));
    +        bzero(&etoken,sizeof(etoken));
     
             // TODO: avoid this hack
             if (!*gcm_nonce) gcm_nonce=NULL;
     
    -        if (encode_oauth_token((const u08bits *) server_name, &etoken, &key, &ot,(const u08bits *) gcm_nonce) < 0) {
    +        if (encode_oauth_token((const uint8_t *) server_name, &etoken, &key, &ot,(const uint8_t *) gcm_nonce) < 0) {
                     fprintf(stderr, "%s: cannot encode oauth token\n",
                                     __FUNCTION__);
                     return -1;
    @@ -135,16 +135,16 @@ static int validate_decode_token(const char* server_name,
                             const char* base64encoded_etoken, oauth_token* dot) {
     
             
    -        ns_bzero((dot),sizeof(*dot));
    +        bzero((dot),sizeof(*dot));
     
             encoded_oauth_token etoken;
    -        ns_bzero(&etoken,sizeof(etoken));
    +        bzero(&etoken,sizeof(etoken));
     
             const size_t base64encoded_etoken_length=strlen(base64encoded_etoken);
             const unsigned char *tmp = base64_decode(base64encoded_etoken,base64encoded_etoken_length,&etoken.size);
             memcpy(etoken.token,tmp,etoken.size);
                             
    -        if (decode_oauth_token((const u08bits *) server_name, &etoken, &key, dot) < 0) {
    +        if (decode_oauth_token((const uint8_t *) server_name, &etoken, &key, dot) < 0) {
                     fprintf(stderr, "%s: cannot decode oauth token\n",
                                     __FUNCTION__);
                     return -1;
    
  • src/apps/peer/udpserver.c+5 5 modified
    @@ -68,11 +68,11 @@ static int udp_create_server_socket(server_type* server,
       if(!server) return -1;
     
       evutil_socket_t udp_fd = -1;
    -  ioa_addr *server_addr = (ioa_addr*)turn_malloc(sizeof(ioa_addr));
    +  ioa_addr *server_addr = (ioa_addr*)malloc(sizeof(ioa_addr));
     
       STRCPY(server->ifname,ifname);
     
    -  if(make_ioa_addr((const u08bits*)local_address, port, server_addr)<0) return -1;
    +  if(make_ioa_addr((const uint8_t*)local_address, port, server_addr)<0) return -1;
       
       udp_fd = socket(server_addr->ss.sa_family, RELAY_DGRAM_SOCKET_TYPE, RELAY_DGRAM_SOCKET_PROTOCOL);
       if (udp_fd < 0) {
    @@ -102,11 +102,11 @@ static int udp_create_server_socket(server_type* server,
     
     static server_type* init_server(int verbose, const char* ifname, char **local_addresses, size_t las, int port) {
     
    -  server_type* server=(server_type*)turn_malloc(sizeof(server_type));
    +  server_type* server=(server_type*)malloc(sizeof(server_type));
     
       if(!server) return server;
     
    -  ns_bzero(server,sizeof(server_type));
    +  bzero(server,sizeof(server_type));
     
       server->verbose=verbose;
     
    @@ -123,7 +123,7 @@ static server_type* init_server(int verbose, const char* ifname, char **local_ad
     static int clean_server(server_type* server) {
       if(server) {
         if(server->event_base) event_base_free(server->event_base);
    -    turn_free(server,sizeof(server_type));
    +    free(server);
       }
       return 0;
     }
    
  • src/apps/relay/dbdrivers/dbd_mongo.c+54 42 modified
    @@ -74,7 +74,7 @@ static void MongoFree(MONGO * info) {
     	if(info) {
     		if(info->uri) mongoc_uri_destroy(info->uri);
     		if(info->client) mongoc_client_destroy(info->client);
    -		turn_free(info, sizeof(MONGO));
    +		free(info);
     	}
     }
     
    @@ -88,7 +88,9 @@ static MONGO * get_mongodb_connection(void) {
     		mongoc_init();
     		mongoc_log_set_handler(&mongo_logger, NULL);
     
    -		mydbconnection = (MONGO *) turn_malloc(sizeof(MONGO));
    +		mydbconnection = (MONGO *) malloc(sizeof(MONGO));
    +		bzero(mydbconnection, sizeof(MONGO));
    +
     		mydbconnection->uri = mongoc_uri_new(pud->userdb);
     
     		if (!mydbconnection->uri) {
    @@ -144,7 +146,7 @@ static mongoc_collection_t * mongo_get_collection(const char * name) {
     
     ///////////////////////////////////////////////////////////////////////////////////////////////////////////
     
    -static int mongo_get_auth_secrets(secrets_list_t *sl, u08bits *realm) {
    +static int mongo_get_auth_secrets(secrets_list_t *sl, uint8_t *realm) {
       mongoc_collection_t * collection = mongo_get_collection("turn_secret"); 
     
     	if(!collection)
    @@ -186,7 +188,7 @@ static int mongo_get_auth_secrets(secrets_list_t *sl, u08bits *realm) {
       return ret;
     }
       
    -static int mongo_get_user_key(u08bits *usname, u08bits *realm, hmackey_t key) {
    +static int mongo_get_user_key(uint8_t *usname, uint8_t *realm, hmackey_t key) {
       mongoc_collection_t * collection = mongo_get_collection("turnusers_lt"); 
     
     	if(!collection)
    @@ -221,7 +223,7 @@ static int mongo_get_user_key(u08bits *usname, u08bits *realm, hmackey_t key) {
     					TURN_LOG_FUNC(TURN_LOG_LEVEL_ERROR, "Wrong key format: string length=%d (must be %d): user %s\n", (int)length, (int)sz, usname);
     				} else {
     					char kval[sizeof(hmackey_t) + sizeof(hmackey_t) + 1];
    -					ns_bcopy(value, kval, sz);
    +					bcopy(value, kval, sz);
     					kval[sz] = 0;
     					if(convert_string_key_to_binary(kval, key, sz / 2) < 0) {
     						TURN_LOG_FUNC(TURN_LOG_LEVEL_ERROR, "Wrong key: %s, user %s\n", kval, usname);
    @@ -239,7 +241,7 @@ static int mongo_get_user_key(u08bits *usname, u08bits *realm, hmackey_t key) {
       return ret;
     }
     
    -static int mongo_get_oauth_key(const u08bits *kid, oauth_key_data_raw *key) {
    +static int mongo_get_oauth_key(const uint8_t *kid, oauth_key_data_raw *key) {
     
     	mongoc_collection_t * collection = mongo_get_collection("oauth_key");
     
    @@ -264,7 +266,7 @@ static int mongo_get_oauth_key(const u08bits *kid, oauth_key_data_raw *key) {
     
     	int ret = -1;
     
    -	ns_bzero(key,sizeof(oauth_key_data_raw));
    +	bzero(key,sizeof(oauth_key_data_raw));
     	STRCPY(key->kid,kid);
     
     	if (!cursor) {
    @@ -285,10 +287,10 @@ static int mongo_get_oauth_key(const u08bits *kid, oauth_key_data_raw *key) {
     				STRCPY(key->ikm_key,bson_iter_utf8(&iter, &length));
     			}
     			if (bson_iter_init(&iter, item) && bson_iter_find(&iter, "timestamp") && BSON_ITER_HOLDS_INT64(&iter)) {
    -				key->timestamp = (u64bits)bson_iter_int64(&iter);
    +				key->timestamp = (uint64_t)bson_iter_int64(&iter);
     			}
     			if (bson_iter_init(&iter, item) && bson_iter_find(&iter, "lifetime") && BSON_ITER_HOLDS_INT32(&iter)) {
    -				key->lifetime = (u32bits)bson_iter_int32(&iter);
    +				key->lifetime = (uint32_t)bson_iter_int32(&iter);
     			}
     			ret = 0;
     		}
    @@ -300,7 +302,7 @@ static int mongo_get_oauth_key(const u08bits *kid, oauth_key_data_raw *key) {
     	return ret;
     }
       
    -static int mongo_set_user_key(u08bits *usname, u08bits *realm, const char *key) {
    +static int mongo_set_user_key(uint8_t *usname, uint8_t *realm, const char *key) {
       mongoc_collection_t * collection = mongo_get_collection("turnusers_lt"); 
     
     	if(!collection)
    @@ -363,7 +365,7 @@ static int mongo_set_oauth_key(oauth_key_data_raw *key) {
       return ret;
     }
       
    -static int mongo_del_user(u08bits *usname, u08bits *realm) {
    +static int mongo_del_user(uint8_t *usname, uint8_t *realm) {
       mongoc_collection_t * collection = mongo_get_collection("turnusers_lt");
     
     	if(!collection)
    @@ -386,7 +388,7 @@ static int mongo_del_user(u08bits *usname, u08bits *realm) {
       return ret;
     }
     
    -static int mongo_del_oauth_key(const u08bits *kid) {
    +static int mongo_del_oauth_key(const uint8_t *kid) {
     
       mongoc_collection_t * collection = mongo_get_collection("oauth_key");
     
    @@ -409,12 +411,12 @@ static int mongo_del_oauth_key(const u08bits *kid) {
       return ret;
     }
       
    -static int mongo_list_users(u08bits *realm, secrets_list_t *users, secrets_list_t *realms)
    +static int mongo_list_users(uint8_t *realm, secrets_list_t *users, secrets_list_t *realms)
     {
       const char * collection_name = "turnusers_lt";
       mongoc_collection_t * collection = mongo_get_collection(collection_name);
     
    -  u08bits realm0[STUN_MAX_REALM_SIZE+1] = "\0";
    +  uint8_t realm0[STUN_MAX_REALM_SIZE+1] = "\0";
       if(!realm) realm=realm0;
     
       if(!collection)
    @@ -524,7 +526,7 @@ static int mongo_list_oauth_keys(secrets_list_t *kids,secrets_list_t *teas,secre
         bson_iter_t iter;
         while (mongoc_cursor_next(cursor, &item)) {
     
    -    	ns_bzero(key,sizeof(oauth_key_data_raw));
    +    	bzero(key,sizeof(oauth_key_data_raw));
         	if (bson_iter_init(&iter, item) && bson_iter_find(&iter, "kid") && BSON_ITER_HOLDS_UTF8(&iter)) {
         		STRCPY(key->kid,bson_iter_utf8(&iter, &length));
         	}
    @@ -538,10 +540,10 @@ static int mongo_list_oauth_keys(secrets_list_t *kids,secrets_list_t *teas,secre
         		STRCPY(key->ikm_key,bson_iter_utf8(&iter, &length));
         	}
         	if (bson_iter_init(&iter, item) && bson_iter_find(&iter, "timestamp") && BSON_ITER_HOLDS_INT64(&iter)) {
    -    		key->timestamp = (u64bits)bson_iter_int64(&iter);
    +    		key->timestamp = (uint64_t)bson_iter_int64(&iter);
         	}
         	if (bson_iter_init(&iter, item) && bson_iter_find(&iter, "lifetime") && BSON_ITER_HOLDS_INT32(&iter)) {
    -    		key->lifetime = (u32bits)bson_iter_int32(&iter);
    +    		key->lifetime = (uint32_t)bson_iter_int32(&iter);
         	}
         	if(kids) {
         		add_to_secrets_list(kids,key->kid);
    @@ -572,11 +574,11 @@ static int mongo_list_oauth_keys(secrets_list_t *kids,secrets_list_t *teas,secre
       return ret;
     }
       
    -static int mongo_list_secrets(u08bits *realm, secrets_list_t *secrets, secrets_list_t *realms)
    +static int mongo_list_secrets(uint8_t *realm, secrets_list_t *secrets, secrets_list_t *realms)
     {
     	mongoc_collection_t * collection = mongo_get_collection("turn_secret");
     
    -	u08bits realm0[STUN_MAX_REALM_SIZE+1] = "\0";
    +	uint8_t realm0[STUN_MAX_REALM_SIZE+1] = "\0";
     	if(!realm) realm=realm0;
     
     	if(!collection)
    @@ -644,7 +646,7 @@ static int mongo_list_secrets(u08bits *realm, secrets_list_t *secrets, secrets_l
     	return ret;
     }
       
    -static int mongo_del_secret(u08bits *secret, u08bits *realm) {
    +static int mongo_del_secret(uint8_t *secret, uint8_t *realm) {
       mongoc_collection_t * collection = mongo_get_collection("turn_secret"); 
     
     	if(!collection)
    @@ -663,7 +665,7 @@ static int mongo_del_secret(u08bits *secret, u08bits *realm) {
       return 0;
     }
       
    -static int mongo_set_secret(u08bits *secret, u08bits *realm) {
    +static int mongo_set_secret(uint8_t *secret, uint8_t *realm) {
       mongoc_collection_t * collection = mongo_get_collection("turn_secret"); 
     
     	if(!collection)
    @@ -686,7 +688,7 @@ static int mongo_set_secret(u08bits *secret, u08bits *realm) {
       }
     }
     
    -static int mongo_set_permission_ip(const char *kind, u08bits *realm, const char* ip, int del)
    +static int mongo_set_permission_ip(const char *kind, uint8_t *realm, const char* ip, int del)
     {
     	char sub_collection_name[129];
     	snprintf(sub_collection_name,sizeof(sub_collection_name)-1,"%s_peer_ip",kind);
    @@ -698,7 +700,7 @@ static int mongo_set_permission_ip(const char *kind, u08bits *realm, const char*
     
     	int ret = -1;
     
    -	u08bits realm0[STUN_MAX_REALM_SIZE+1] = "\0";
    +	uint8_t realm0[STUN_MAX_REALM_SIZE+1] = "\0";
     	if(!realm) realm=realm0;
     
     	bson_t query, doc, child;
    @@ -732,7 +734,7 @@ static int mongo_set_permission_ip(const char *kind, u08bits *realm, const char*
     	return ret;
     }
       
    -static int mongo_add_origin(u08bits *origin, u08bits *realm)
    +static int mongo_add_origin(uint8_t *origin, uint8_t *realm)
     {
     	mongoc_collection_t * collection = mongo_get_collection("realm");
     
    @@ -741,7 +743,7 @@ static int mongo_add_origin(u08bits *origin, u08bits *realm)
         
     	int ret = -1;
     
    -	u08bits realm0[STUN_MAX_REALM_SIZE+1] = "\0";
    +	uint8_t realm0[STUN_MAX_REALM_SIZE+1] = "\0";
     	if(!realm) realm=realm0;
       
     	bson_t query, doc, child;
    @@ -763,7 +765,7 @@ static int mongo_add_origin(u08bits *origin, u08bits *realm)
     	return ret;
     }
       
    -static int mongo_del_origin(u08bits *origin)
    +static int mongo_del_origin(uint8_t *origin)
     {
       mongoc_collection_t * collection = mongo_get_collection("realm"); 
     
    @@ -790,14 +792,14 @@ static int mongo_del_origin(u08bits *origin)
       return ret;
     }
       
    -static int mongo_list_origins(u08bits *realm, secrets_list_t *origins, secrets_list_t *realms)
    +static int mongo_list_origins(uint8_t *realm, secrets_list_t *origins, secrets_list_t *realms)
     {
     	mongoc_collection_t * collection = mongo_get_collection("realm");
     
     	if(!collection)
     		return -1;
     
    -	u08bits realm0[STUN_MAX_REALM_SIZE+1] = "\0";
    +	uint8_t realm0[STUN_MAX_REALM_SIZE+1] = "\0";
     	if(!realm) realm=realm0;
     
     	bson_t query, child;
    @@ -868,7 +870,7 @@ static int mongo_list_origins(u08bits *realm, secrets_list_t *origins, secrets_l
     	return ret;
     }
       
    -static int mongo_set_realm_option_one(u08bits *realm, unsigned long value, const char* opt) {
    +static int mongo_set_realm_option_one(uint8_t *realm, unsigned long value, const char* opt) {
       mongoc_collection_t * collection = mongo_get_collection("realm"); 
     
     	if(!collection)
    @@ -880,7 +882,7 @@ static int mongo_set_realm_option_one(u08bits *realm, unsigned long value, const
       bson_init(&doc);
       
       size_t klen = 9 + strlen(opt);
    -  char * _k = (char *)turn_malloc(klen);
    +  char * _k = (char *)malloc(klen);
       strcpy(_k, "options.");
       strcat(_k, opt);
       
    @@ -893,7 +895,7 @@ static int mongo_set_realm_option_one(u08bits *realm, unsigned long value, const
         BSON_APPEND_INT32(&child, _k, 1);
         bson_append_document_end(&doc, &child);
       }
    -  turn_free(_k,klen);
    +  free(_k);
       
       int ret = -1;
       
    @@ -908,7 +910,7 @@ static int mongo_set_realm_option_one(u08bits *realm, unsigned long value, const
       return ret;
     }
       
    -static int mongo_list_realm_options(u08bits *realm) {
    +static int mongo_list_realm_options(uint8_t *realm) {
       mongoc_collection_t * collection = mongo_get_collection("realm"); 
     
     	if(!collection)
    @@ -1089,7 +1091,7 @@ static void mongo_reread_realms(secrets_list_t * realms_list) {
     		TURN_LOG_FUNC(TURN_LOG_LEVEL_ERROR,
     				"Error querying MongoDB collection 'realm'\n");
     	} else {
    -		ur_string_map *o_to_realm_new = ur_string_map_create(turn_free_simple);
    +		ur_string_map *o_to_realm_new = ur_string_map_create(free);
     
     		const bson_t * item;
     		uint32_t length;
    @@ -1100,7 +1102,7 @@ static void mongo_reread_realms(secrets_list_t * realms_list) {
     			if (bson_iter_init(&iter, item) && bson_iter_find(&iter, "realm")
     					&& BSON_ITER_HOLDS_UTF8(&iter)) {
     
    -				char * _realm = turn_strdup(bson_iter_utf8(&iter, &length));
    +				char * _realm = strdup(bson_iter_utf8(&iter, &length));
     
     				get_realm(_realm);
     
    @@ -1117,14 +1119,14 @@ static void mongo_reread_realms(secrets_list_t * realms_list) {
     					if (bson_iter_init(&origin_iter, &origin_array)) {
     						while (bson_iter_next(&origin_iter)) {
     							if (BSON_ITER_HOLDS_UTF8(&origin_iter)) {
    -								char* _origin =	turn_strdup(bson_iter_utf8(&origin_iter, &length));
    -								char *rval = turn_strdup(_realm);
    +								char* _origin =	strdup(bson_iter_utf8(&origin_iter, &length));
    +								char *rval = strdup(_realm);
     								ur_string_map_value_type value =
     										(ur_string_map_value_type) (rval);
     								ur_string_map_put(o_to_realm_new,
     										(const ur_string_map_key_type) _origin,
     										value);
    -								turn_free(_origin,strlen(_origin)+1);
    +								free(_origin);
     							}
     						}
     					}
    @@ -1173,7 +1175,7 @@ static void mongo_reread_realms(secrets_list_t * realms_list) {
     						}
     					}
     				}
    -				turn_free(_realm,strlen(_realm)+1);
    +				free(_realm);
     			}
     		}
     		update_o_to_realm(o_to_realm_new);
    @@ -1186,7 +1188,7 @@ static void mongo_reread_realms(secrets_list_t * realms_list) {
     
     /////////////////////////////////////////////////
     
    -static int mongo_get_admin_user(const u08bits *usname, u08bits *realm, password_t pwd)
    +static int mongo_get_admin_user(const uint8_t *usname, uint8_t *realm, password_t pwd)
     {
     	mongoc_collection_t * collection = mongo_get_collection("admin_user");
     
    @@ -1234,7 +1236,7 @@ static int mongo_get_admin_user(const u08bits *usname, u08bits *realm, password_
     	return ret;
     }
     
    -static int mongo_set_admin_user(const u08bits *usname, const u08bits *realm, const password_t pwd)
    +static int mongo_set_admin_user(const uint8_t *usname, const uint8_t *realm, const password_t pwd)
     {
     	mongoc_collection_t * collection = mongo_get_collection("admin_user");
     
    @@ -1264,7 +1266,7 @@ static int mongo_set_admin_user(const u08bits *usname, const u08bits *realm, con
     	return ret;
     }
     
    -static int mongo_del_admin_user(const u08bits *usname)
    +static int mongo_del_admin_user(const uint8_t *usname)
     {
     	mongoc_collection_t * collection = mongo_get_collection("admin_user");
     
    @@ -1349,6 +1351,15 @@ static int mongo_list_admin_users(int no_print)
     	return ret;
     }
     
    +static void mongo_disconnect(void) {
    +	MONGO * mongoconnection = (MONGO *) pthread_getspecific(connection_key);
    +	if (mongoconnection) {
    +		MongoFree(mongoconnection);
    +		mongoconnection = NULL;
    +	}
    +	TURN_LOG_FUNC(TURN_LOG_LEVEL_INFO, "MongoDB connection was closed.\n");
    +}
    +
     //////////////////////////////////////////////////////////
     
     static const turn_dbdriver_t driver = {
    @@ -1376,7 +1387,8 @@ static const turn_dbdriver_t driver = {
       &mongo_get_admin_user,
       &mongo_set_admin_user,
       &mongo_del_admin_user,
    -  &mongo_list_admin_users
    +  &mongo_list_admin_users,
    +  &mongo_disconnect
     };
     
     const turn_dbdriver_t * get_mongo_dbdriver(void) {
    
  • src/apps/relay/dbdrivers/dbd_mysql.c+107 97 modified
    @@ -61,16 +61,16 @@ typedef struct _Myconninfo Myconninfo;
     
     static void MyconninfoFree(Myconninfo *co) {
     	if(co) {
    -		if(co->host) turn_free(co->host,strlen(co->host)+1);
    -		if(co->dbname) turn_free(co->dbname, strlen(co->dbname)+1);
    -		if(co->user) turn_free(co->user, strlen(co->user)+1);
    -		if(co->password) turn_free(co->password, strlen(co->password)+1);
    -		if(co->key) turn_free(co->key, strlen(co->key)+1);
    -		if(co->ca) turn_free(co->ca, strlen(co->ca)+1);
    -		if(co->cert) turn_free(co->cert, strlen(co->cert)+1);
    -		if(co->capath) turn_free(co->capath, strlen(co->capath)+1);
    -		if(co->cipher) turn_free(co->cipher, strlen(co->cipher)+1);
    -		ns_bzero(co,sizeof(Myconninfo));
    +		if(co->host) free(co->host);
    +		if(co->dbname) free(co->dbname);
    +		if(co->user) free(co->user);
    +		if(co->password) free(co->password);
    +		if(co->key) free(co->key);
    +		if(co->ca) free(co->ca);
    +		if(co->cert) free(co->cert);
    +		if(co->capath) free(co->capath);
    +		if(co->cipher) free(co->cipher);
    +		bzero(co,sizeof(Myconninfo));
     	}
     }
     
    @@ -103,10 +103,10 @@ char* decryptPassword(char* in, const unsigned char* mykey){
     
     
     static Myconninfo *MyconninfoParse(char *userdb, char **errmsg) {
    -	Myconninfo *co = (Myconninfo*)turn_malloc(sizeof(Myconninfo));
    -	ns_bzero(co,sizeof(Myconninfo));
    +	Myconninfo *co = (Myconninfo*)malloc(sizeof(Myconninfo));
    +	bzero(co,sizeof(Myconninfo));
     	if(userdb) {
    -		char *s0=turn_strdup(userdb);
    +		char *s0=strdup(userdb);
     		char *s = s0;
     
     		while(s && *s) {
    @@ -123,44 +123,44 @@ static Myconninfo *MyconninfoParse(char *userdb, char **errmsg) {
     				MyconninfoFree(co);
     				co = NULL;
     				if(errmsg) {
    -					*errmsg = turn_strdup(s);
    +					*errmsg = strdup(s);
     				}
     				break;
     			}
     
     			*seq = 0;
     			if(!strcmp(s,"host"))
    -				co->host = turn_strdup(seq+1);
    +				co->host = strdup(seq+1);
     			else if(!strcmp(s,"ip"))
    -				co->host = turn_strdup(seq+1);
    +				co->host = strdup(seq+1);
     			else if(!strcmp(s,"addr"))
    -				co->host = turn_strdup(seq+1);
    +				co->host = strdup(seq+1);
     			else if(!strcmp(s,"ipaddr"))
    -				co->host = turn_strdup(seq+1);
    +				co->host = strdup(seq+1);
     			else if(!strcmp(s,"hostaddr"))
    -				co->host = turn_strdup(seq+1);
    +				co->host = strdup(seq+1);
     			else if(!strcmp(s,"dbname"))
    -				co->dbname = turn_strdup(seq+1);
    +				co->dbname = strdup(seq+1);
     			else if(!strcmp(s,"db"))
    -				co->dbname = turn_strdup(seq+1);
    +				co->dbname = strdup(seq+1);
     			else if(!strcmp(s,"database"))
    -				co->dbname = turn_strdup(seq+1);
    +				co->dbname = strdup(seq+1);
     			else if(!strcmp(s,"user"))
    -				co->user = turn_strdup(seq+1);
    +				co->user = strdup(seq+1);
     			else if(!strcmp(s,"uname"))
    -				co->user = turn_strdup(seq+1);
    +				co->user = strdup(seq+1);
     			else if(!strcmp(s,"name"))
    -				co->user = turn_strdup(seq+1);
    +				co->user = strdup(seq+1);
     			else if(!strcmp(s,"username"))
    -				co->user = turn_strdup(seq+1);
    +				co->user = strdup(seq+1);
     			else if(!strcmp(s,"password"))
    -				co->password = turn_strdup(seq+1);
    +				co->password = strdup(seq+1);
     			else if(!strcmp(s,"pwd"))
    -				co->password = turn_strdup(seq+1);
    +				co->password = strdup(seq+1);
     			else if(!strcmp(s,"passwd"))
    -				co->password = turn_strdup(seq+1);
    +				co->password = strdup(seq+1);
     			else if(!strcmp(s,"secret"))
    -				co->password = turn_strdup(seq+1);
    +				co->password = strdup(seq+1);
     			else if(!strcmp(s,"port"))
     				co->port = (unsigned int)atoi(seq+1);
     			else if(!strcmp(s,"p"))
    @@ -172,49 +172,49 @@ static Myconninfo *MyconninfoParse(char *userdb, char **errmsg) {
     			else if(!strcmp(s,"read_timeout"))
     				co->read_timeout = (unsigned int)atoi(seq+1);
     			else if(!strcmp(s,"key"))
    -				co->key = turn_strdup(seq+1);
    +				co->key = strdup(seq+1);
     			else if(!strcmp(s,"ssl-key"))
    -				co->key = turn_strdup(seq+1);
    +				co->key = strdup(seq+1);
     			else if(!strcmp(s,"ca"))
    -				co->ca = turn_strdup(seq+1);
    +				co->ca = strdup(seq+1);
     			else if(!strcmp(s,"ssl-ca"))
    -				co->ca = turn_strdup(seq+1);
    +				co->ca = strdup(seq+1);
     			else if(!strcmp(s,"capath"))
    -				co->capath = turn_strdup(seq+1);
    +				co->capath = strdup(seq+1);
     			else if(!strcmp(s,"ssl-capath"))
    -				co->capath = turn_strdup(seq+1);
    +				co->capath = strdup(seq+1);
     			else if(!strcmp(s,"cert"))
    -				co->cert = turn_strdup(seq+1);
    +				co->cert = strdup(seq+1);
     			else if(!strcmp(s,"ssl-cert"))
    -				co->cert = turn_strdup(seq+1);
    +				co->cert = strdup(seq+1);
     			else if(!strcmp(s,"cipher"))
    -				co->cipher = turn_strdup(seq+1);
    +				co->cipher = strdup(seq+1);
     			else if(!strcmp(s,"ssl-cipher"))
    -				co->cipher = turn_strdup(seq+1);
    +				co->cipher = strdup(seq+1);
     			else {
     				MyconninfoFree(co);
     				co = NULL;
     				if(errmsg) {
    -					*errmsg = turn_strdup(s);
    +					*errmsg = strdup(s);
     				}
     				break;
     			}
     
     			s = snext;
     		}
     
    -		turn_free(s0, strlen(s0)+1);
    +		free(s0);
     	}
     
     	if(co) {
     		if(!(co->dbname))
    -			co->dbname=turn_strdup("0");
    +			co->dbname=strdup("0");
     		if(!(co->host))
    -			co->host=turn_strdup("127.0.0.1");
    +			co->host=strdup("127.0.0.1");
     		if(!(co->user))
    -			co->user=turn_strdup("");
    +			co->user=strdup("");
     		if(!(co->password))
    -			co->password=turn_strdup("");
    +			co->password=strdup("");
     	}
     
     	return co;
    @@ -240,13 +240,13 @@ static MYSQL *get_mydb_connection(void) {
     		if(!co) {
     			if(errmsg) {
     				TURN_LOG_FUNC(TURN_LOG_LEVEL_ERROR, "Cannot open MySQL DB connection <%s>, connection string format error: %s\n",pud->userdb,errmsg);
    -				turn_free(errmsg,strlen(errmsg)+1);
    +				free(errmsg);
     			} else {
     				TURN_LOG_FUNC(TURN_LOG_LEVEL_ERROR, "Cannot open MySQL DB connection <%s>, connection string format error\n",pud->userdb);
     			}
     		} else if(errmsg) {
     			TURN_LOG_FUNC(TURN_LOG_LEVEL_ERROR, "Cannot open MySQL DB connection <%s>, connection string format error: %s\n",pud->userdb,errmsg);
    -			turn_free(errmsg,strlen(errmsg)+1);
    +			free(errmsg);
     			MyconninfoFree(co);
     		} else if(!(co->dbname)) {
     			TURN_LOG_FUNC(TURN_LOG_LEVEL_ERROR, "MySQL Database name is not provided: <%s>\n",pud->userdb);
    @@ -299,7 +299,7 @@ static MYSQL *get_mydb_connection(void) {
     
     ///////////////////////////////////////////////////////////////////////////////////////////////////////////
     
    -static int mysql_get_auth_secrets(secrets_list_t *sl, u08bits *realm) {
    +static int mysql_get_auth_secrets(secrets_list_t *sl, uint8_t *realm) {
       int ret = -1;
     	MYSQL * myc = get_mydb_connection();
     	if(myc) {
    @@ -323,7 +323,7 @@ static int mysql_get_auth_secrets(secrets_list_t *sl, u08bits *realm) {
     							if(lengths) {
     								size_t sz = lengths[0];
     								char auth_secret[TURN_LONG_STRING_SIZE];
    -								ns_bcopy(row[0],auth_secret,sz);
    +								bcopy(row[0],auth_secret,sz);
     								auth_secret[sz]=0;
     								add_to_secrets_list(sl,auth_secret);
     							}
    @@ -340,7 +340,7 @@ static int mysql_get_auth_secrets(secrets_list_t *sl, u08bits *realm) {
       return ret;
     }
       
    -static int mysql_get_user_key(u08bits *usname, u08bits *realm, hmackey_t key) {
    +static int mysql_get_user_key(uint8_t *usname, uint8_t *realm, hmackey_t key) {
       int ret = -1;
     	MYSQL * myc = get_mydb_connection();
     	if(myc) {
    @@ -366,7 +366,7 @@ static int mysql_get_user_key(u08bits *usname, u08bits *realm, hmackey_t key) {
     							TURN_LOG_FUNC(TURN_LOG_LEVEL_ERROR, "Wrong key format: string length=%d (must be %d): user %s\n",(int)lengths[0],(int)sz,usname);
     						} else {
     							char kval[sizeof(hmackey_t)+sizeof(hmackey_t)+1];
    -							ns_bcopy(row[0],kval,sz);
    +							bcopy(row[0],kval,sz);
     							kval[sz]=0;
     							if(convert_string_key_to_binary(kval, key, sz/2)<0) {
     								TURN_LOG_FUNC(TURN_LOG_LEVEL_ERROR, "Wrong key: %s, user %s\n",kval,usname);
    @@ -385,7 +385,7 @@ static int mysql_get_user_key(u08bits *usname, u08bits *realm, hmackey_t key) {
       return ret;
     }
     
    -static int mysql_get_oauth_key(const u08bits *kid, oauth_key_data_raw *key) {
    +static int mysql_get_oauth_key(const uint8_t *kid, oauth_key_data_raw *key) {
     
     	int ret = -1;
     	char statement[TURN_LONG_STRING_SIZE];
    @@ -409,23 +409,23 @@ static int mysql_get_oauth_key(const u08bits *kid, oauth_key_data_raw *key) {
     					unsigned long *lengths = mysql_fetch_lengths(mres);
     					if(lengths) {
     						STRCPY(key->kid,kid);
    -						ns_bcopy(row[0],key->ikm_key,lengths[0]);
    +						bcopy(row[0],key->ikm_key,lengths[0]);
     						key->ikm_key[lengths[0]]=0;
     
     						char stimestamp[128];
    -						ns_bcopy(row[1],stimestamp,lengths[1]);
    +						bcopy(row[1],stimestamp,lengths[1]);
     						stimestamp[lengths[1]]=0;
    -						key->timestamp = (u64bits)strtoull(stimestamp,NULL,10);
    +						key->timestamp = (uint64_t)strtoull(stimestamp,NULL,10);
     
     						char slifetime[128];
    -						ns_bcopy(row[2],slifetime,lengths[2]);
    +						bcopy(row[2],slifetime,lengths[2]);
     						slifetime[lengths[2]]=0;
    -						key->lifetime = (u32bits)strtoul(slifetime,NULL,10);
    +						key->lifetime = (uint32_t)strtoul(slifetime,NULL,10);
     
    -						ns_bcopy(row[3],key->as_rs_alg,lengths[3]);
    +						bcopy(row[3],key->as_rs_alg,lengths[3]);
     						key->as_rs_alg[lengths[3]]=0;
     
    -						ns_bcopy(row[4],key->realm,lengths[4]);
    +						bcopy(row[4],key->realm,lengths[4]);
     						key->realm[lengths[4]]=0;
     
     						ret = 0;
    @@ -465,26 +465,26 @@ static int mysql_list_oauth_keys(secrets_list_t *kids,secrets_list_t *teas,secre
     					unsigned long *lengths = mysql_fetch_lengths(mres);
     					if(lengths) {
     
    -						ns_bcopy(row[0],key->ikm_key,lengths[0]);
    +						bcopy(row[0],key->ikm_key,lengths[0]);
     						key->ikm_key[lengths[0]]=0;
     
     						char stimestamp[128];
    -						ns_bcopy(row[1],stimestamp,lengths[1]);
    +						bcopy(row[1],stimestamp,lengths[1]);
     						stimestamp[lengths[1]]=0;
    -						key->timestamp = (u64bits)strtoull(stimestamp,NULL,10);
    +						key->timestamp = (uint64_t)strtoull(stimestamp,NULL,10);
     
     						char slifetime[128];
    -						ns_bcopy(row[2],slifetime,lengths[2]);
    +						bcopy(row[2],slifetime,lengths[2]);
     						slifetime[lengths[2]]=0;
    -						key->lifetime = (u32bits)strtoul(slifetime,NULL,10);
    +						key->lifetime = (uint32_t)strtoul(slifetime,NULL,10);
     
    -						ns_bcopy(row[3],key->as_rs_alg,lengths[3]);
    +						bcopy(row[3],key->as_rs_alg,lengths[3]);
     						key->as_rs_alg[lengths[3]]=0;
     
    -						ns_bcopy(row[4],key->realm,lengths[4]);
    +						bcopy(row[4],key->realm,lengths[4]);
     						key->realm[lengths[4]]=0;
     
    -						ns_bcopy(row[5],key->kid,lengths[5]);
    +						bcopy(row[5],key->kid,lengths[5]);
     						key->kid[lengths[5]]=0;
     
     						if(kids) {
    @@ -519,7 +519,7 @@ static int mysql_list_oauth_keys(secrets_list_t *kids,secrets_list_t *teas,secre
     	return ret;
     }
       
    -static int mysql_set_user_key(u08bits *usname, u08bits *realm, const char *key)
    +static int mysql_set_user_key(uint8_t *usname, uint8_t *realm, const char *key)
     {
       int ret = -1;
       char statement[TURN_LONG_STRING_SIZE];
    @@ -568,7 +568,7 @@ static int mysql_set_oauth_key(oauth_key_data_raw *key)
     	return ret;
     }
       
    -static int mysql_del_user(u08bits *usname, u08bits *realm) {
    +static int mysql_del_user(uint8_t *usname, uint8_t *realm) {
       int ret = -1;
     	char statement[TURN_LONG_STRING_SIZE];
     	MYSQL * myc = get_mydb_connection();
    @@ -584,7 +584,7 @@ static int mysql_del_user(u08bits *usname, u08bits *realm) {
       return ret;
     }
     
    -static int mysql_del_oauth_key(const u08bits *kid) {
    +static int mysql_del_oauth_key(const uint8_t *kid) {
     	int ret = -1;
     	char statement[TURN_LONG_STRING_SIZE];
     	MYSQL * myc = get_mydb_connection();
    @@ -600,12 +600,12 @@ static int mysql_del_oauth_key(const u08bits *kid) {
     	return ret;
     }
       
    -static int mysql_list_users(u08bits *realm, secrets_list_t *users, secrets_list_t *realms)
    +static int mysql_list_users(uint8_t *realm, secrets_list_t *users, secrets_list_t *realms)
     {
     	int ret = -1;
     	char statement[TURN_LONG_STRING_SIZE];
     
    -	u08bits realm0[STUN_MAX_REALM_SIZE+1] = "\0";
    +	uint8_t realm0[STUN_MAX_REALM_SIZE+1] = "\0";
     	if(!realm) realm=realm0;
     
     	MYSQL * myc = get_mydb_connection();
    @@ -656,11 +656,11 @@ static int mysql_list_users(u08bits *realm, secrets_list_t *users, secrets_list_
       return ret;
     }
       
    -static int mysql_list_secrets(u08bits *realm, secrets_list_t *secrets, secrets_list_t *realms)
    +static int mysql_list_secrets(uint8_t *realm, secrets_list_t *secrets, secrets_list_t *realms)
     {
     	int ret = -1;
     
    -	u08bits realm0[STUN_MAX_REALM_SIZE+1] = "\0";
    +	uint8_t realm0[STUN_MAX_REALM_SIZE+1] = "\0";
     	if(!realm) realm=realm0;
     
     	char statement[TURN_LONG_STRING_SIZE];
    @@ -717,7 +717,7 @@ static int mysql_list_secrets(u08bits *realm, secrets_list_t *secrets, secrets_l
     	return ret;
     }
       
    -static int mysql_del_secret(u08bits *secret, u08bits *realm) {
    +static int mysql_del_secret(uint8_t *secret, uint8_t *realm) {
       int ret = -1;
     	donot_print_connection_success=1;
     	char statement[TURN_LONG_STRING_SIZE];
    @@ -733,7 +733,7 @@ static int mysql_del_secret(u08bits *secret, u08bits *realm) {
       return ret;
     }
       
    -static int mysql_set_secret(u08bits *secret, u08bits *realm) {
    +static int mysql_set_secret(uint8_t *secret, uint8_t *realm) {
       int ret = -1;
     	donot_print_connection_success = 1;
     	char statement[TURN_LONG_STRING_SIZE];
    @@ -753,11 +753,11 @@ static int mysql_set_secret(u08bits *secret, u08bits *realm) {
       return ret;
     }
     
    -static int mysql_set_permission_ip(const char *kind, u08bits *realm, const char* ip, int del)
    +static int mysql_set_permission_ip(const char *kind, uint8_t *realm, const char* ip, int del)
     {
     	int ret = -1;
     
    -	u08bits realm0[STUN_MAX_REALM_SIZE+1] = "\0";
    +	uint8_t realm0[STUN_MAX_REALM_SIZE+1] = "\0";
     	if(!realm) realm=realm0;
     
     	donot_print_connection_success = 1;
    @@ -784,7 +784,7 @@ static int mysql_set_permission_ip(const char *kind, u08bits *realm, const char*
     	return ret;
     }
       
    -static int mysql_add_origin(u08bits *origin, u08bits *realm) {
    +static int mysql_add_origin(uint8_t *origin, uint8_t *realm) {
       int ret = -1;
     	char statement[TURN_LONG_STRING_SIZE];
     	MYSQL * myc = get_mydb_connection();
    @@ -803,7 +803,7 @@ static int mysql_add_origin(u08bits *origin, u08bits *realm) {
       return ret;
     }
       
    -static int mysql_del_origin(u08bits *origin) {
    +static int mysql_del_origin(uint8_t *origin) {
       int ret = -1;
     	char statement[TURN_LONG_STRING_SIZE];
     	MYSQL * myc = get_mydb_connection();
    @@ -822,11 +822,11 @@ static int mysql_del_origin(u08bits *origin) {
       return ret;
     }
       
    -static int mysql_list_origins(u08bits *realm, secrets_list_t *origins, secrets_list_t *realms)
    +static int mysql_list_origins(uint8_t *realm, secrets_list_t *origins, secrets_list_t *realms)
     {
     	int ret = -1;
     
    -	u08bits realm0[STUN_MAX_REALM_SIZE+1] = "\0";
    +	uint8_t realm0[STUN_MAX_REALM_SIZE+1] = "\0";
     	if(!realm) realm=realm0;
     
     	donot_print_connection_success = 1;
    @@ -882,7 +882,7 @@ static int mysql_list_origins(u08bits *realm, secrets_list_t *origins, secrets_l
       return ret;
     }
       
    -static int mysql_set_realm_option_one(u08bits *realm, unsigned long value, const char* opt) {
    +static int mysql_set_realm_option_one(uint8_t *realm, unsigned long value, const char* opt) {
       int ret = -1;
     	char statement[TURN_LONG_STRING_SIZE];
     	MYSQL * myc = get_mydb_connection();
    @@ -907,7 +907,7 @@ static int mysql_set_realm_option_one(u08bits *realm, unsigned long value, const
       return ret;
     }
       
    -static int mysql_list_realm_options(u08bits *realm) {
    +static int mysql_list_realm_options(uint8_t *realm) {
       int ret = -1;
     	donot_print_connection_success = 1;
     	char statement[TURN_LONG_STRING_SIZE];
    @@ -999,11 +999,11 @@ static int mysql_get_ip_list(const char *kind, ip_range_list_t * list) {
     							if(lengths) {
     								size_t sz = lengths[0];
     								char kval[TURN_LONG_STRING_SIZE];
    -								ns_bcopy(row[0],kval,sz);
    +								bcopy(row[0],kval,sz);
     								kval[sz]=0;
     								sz = lengths[1];
     								char rval[TURN_LONG_STRING_SIZE];
    -								ns_bcopy(row[1],rval,sz);
    +								bcopy(row[1],rval,sz);
     								rval[sz]=0;
     								add_ip_list_range(kval,rval,list);
     							}
    @@ -1031,7 +1031,7 @@ static void mysql_reread_realms(secrets_list_t * realms_list) {
     				MYSQL_RES *mres = mysql_store_result(myc);
     				if(mres && mysql_field_count(myc)==2) {
     
    -					ur_string_map *o_to_realm_new = ur_string_map_create(turn_free_simple);
    +					ur_string_map *o_to_realm_new = ur_string_map_create(free);
     
     					for(;;) {
     						MYSQL_ROW row = mysql_fetch_row(mres);
    @@ -1043,9 +1043,9 @@ static void mysql_reread_realms(secrets_list_t * realms_list) {
     								if(lengths) {
     									size_t sz = lengths[0];
     									char oval[513];
    -									ns_bcopy(row[0],oval,sz);
    +									bcopy(row[0],oval,sz);
     									oval[sz]=0;
    -									char *rval=turn_strdup(row[1]);
    +									char *rval=strdup(row[1]);
     									get_realm(rval);
     									ur_string_map_value_type value = (ur_string_map_value_type)rval;
     									ur_string_map_put(o_to_realm_new, (const ur_string_map_key_type) oval, value);
    @@ -1106,15 +1106,15 @@ static void mysql_reread_realms(secrets_list_t * realms_list) {
     							if(lengths) {
     								char rval[513];
     								size_t sz = lengths[0];
    -								ns_bcopy(row[0],rval,sz);
    +								bcopy(row[0],rval,sz);
     								rval[sz]=0;
     								char oval[513];
     								sz = lengths[1];
    -								ns_bcopy(row[1],oval,sz);
    +								bcopy(row[1],oval,sz);
     								oval[sz]=0;
     								char vval[513];
     								sz = lengths[2];
    -								ns_bcopy(row[2],vval,sz);
    +								bcopy(row[2],vval,sz);
     								vval[sz]=0;
     								realm_params_t* rp = get_realm(rval);
     								if(!strcmp(oval,"max-bps"))
    @@ -1140,7 +1140,7 @@ static void mysql_reread_realms(secrets_list_t * realms_list) {
     
     /////////////////////////////////////////////////////
     
    -static int mysql_get_admin_user(const u08bits *usname, u08bits *realm, password_t pwd)
    +static int mysql_get_admin_user(const uint8_t *usname, uint8_t *realm, password_t pwd)
     {
       int ret = -1;
     
    @@ -1176,7 +1176,7 @@ static int mysql_get_admin_user(const u08bits *usname, u08bits *realm, password_
       return ret;
     }
     
    -static int mysql_set_admin_user(const u08bits *usname, const u08bits *realm, const password_t pwd)
    +static int mysql_set_admin_user(const uint8_t *usname, const uint8_t *realm, const password_t pwd)
     {
       int ret = -1;
       char statement[TURN_LONG_STRING_SIZE];
    @@ -1200,7 +1200,7 @@ static int mysql_set_admin_user(const u08bits *usname, const u08bits *realm, con
       return ret;
     }
     
    -static int mysql_del_admin_user(const u08bits *usname)
    +static int mysql_del_admin_user(const uint8_t *usname)
     {
     	int ret = -1;
     	char statement[TURN_LONG_STRING_SIZE];
    @@ -1261,6 +1261,15 @@ static int mysql_list_admin_users(int no_print)
     	return ret;
     }
     
    +static void mysql_disconnect(void) {
    +	MYSQL *mydbconnection = (MYSQL*)pthread_getspecific(connection_key);
    +	if (mydbconnection) {
    +		mysql_close(mydbconnection);
    +		mydbconnection=NULL;
    +	}
    +	TURN_LOG_FUNC(TURN_LOG_LEVEL_INFO, "MySQL connection was closed.\n");
    +}
    +
     //////////////////////////////////////////////////////
     
     static const turn_dbdriver_t driver = {
    @@ -1288,7 +1297,8 @@ static const turn_dbdriver_t driver = {
       &mysql_get_admin_user,
       &mysql_set_admin_user,
       &mysql_del_admin_user,
    -  &mysql_list_admin_users
    +  &mysql_list_admin_users,
    +  &mysql_disconnect
     };
     
     const turn_dbdriver_t * get_mysql_dbdriver(void) {
    
  • src/apps/relay/dbdrivers/dbd_pgsql.c+42 32 modified
    @@ -58,14 +58,14 @@ static PGconn *get_pqdb_connection(void) {
     		if(!co) {
     			if(errmsg) {
     				TURN_LOG_FUNC(TURN_LOG_LEVEL_ERROR, "Cannot open PostgreSQL DB connection <%s>, connection string format error: %s\n",pud->userdb,errmsg);
    -				turn_free(errmsg,strlen(errmsg)+1);
    +				free(errmsg);
     			} else {
     				TURN_LOG_FUNC(TURN_LOG_LEVEL_ERROR, "Cannot open PostgreSQL DB connection: <%s>, unknown connection string format error\n",pud->userdb);
     			}
     		} else {
     			PQconninfoFree(co);
     			if(errmsg)
    -				turn_free(errmsg,strlen(errmsg)+1);
    +				free(errmsg);
     			pqdbconnection = PQconnectdb(pud->userdb);
     			if(!pqdbconnection) {
     				TURN_LOG_FUNC(TURN_LOG_LEVEL_ERROR, "Cannot open PostgreSQL DB connection: <%s>, runtime error\n",pud->userdb);
    @@ -91,7 +91,7 @@ static PGconn *get_pqdb_connection(void) {
     
     ///////////////////////////////////////////////////////////////////////////////////////////////////////////
     
    -static int pgsql_get_auth_secrets(secrets_list_t *sl, u08bits *realm) {
    +static int pgsql_get_auth_secrets(secrets_list_t *sl, uint8_t *realm) {
       int ret = -1;
     	PGconn * pqc = get_pqdb_connection();
     	if(pqc) {
    @@ -119,7 +119,7 @@ static int pgsql_get_auth_secrets(secrets_list_t *sl, u08bits *realm) {
       return ret;
     }
       
    -static int pgsql_get_user_key(u08bits *usname, u08bits *realm, hmackey_t key) {
    +static int pgsql_get_user_key(uint8_t *usname, uint8_t *realm, hmackey_t key) {
       int ret = -1;
     	PGconn * pqc = get_pqdb_connection();
     	if(pqc) {
    @@ -154,7 +154,7 @@ static int pgsql_get_user_key(u08bits *usname, u08bits *realm, hmackey_t key) {
       return ret;
     }
     
    -static int pgsql_get_oauth_key(const u08bits *kid, oauth_key_data_raw *key) {
    +static int pgsql_get_oauth_key(const uint8_t *kid, oauth_key_data_raw *key) {
     
     	int ret = -1;
     
    @@ -170,8 +170,8 @@ static int pgsql_get_oauth_key(const u08bits *kid, oauth_key_data_raw *key) {
     			TURN_LOG_FUNC(TURN_LOG_LEVEL_ERROR, "Error retrieving PostgreSQL DB information: %s\n",PQerrorMessage(pqc));
     		} else {
     			STRCPY(key->ikm_key,PQgetvalue(res,0,0));
    -			key->timestamp = (u64bits)strtoll(PQgetvalue(res,0,1),NULL,10);
    -			key->lifetime = (u32bits)strtol(PQgetvalue(res,0,2),NULL,10);
    +			key->timestamp = (uint64_t)strtoll(PQgetvalue(res,0,1),NULL,10);
    +			key->lifetime = (uint32_t)strtol(PQgetvalue(res,0,2),NULL,10);
     			STRCPY(key->as_rs_alg,PQgetvalue(res,0,3));
     			STRCPY(key->realm,PQgetvalue(res,0,4));
     			STRCPY(key->kid,kid);
    @@ -207,8 +207,8 @@ static int pgsql_list_oauth_keys(secrets_list_t *kids,secrets_list_t *teas,secre
     			for(i=0;i<PQntuples(res);i++) {
     
     				STRCPY(key->ikm_key,PQgetvalue(res,i,0));
    -				key->timestamp = (u64bits)strtoll(PQgetvalue(res,i,1),NULL,10);
    -				key->lifetime = (u32bits)strtol(PQgetvalue(res,i,2),NULL,10);
    +				key->timestamp = (uint64_t)strtoll(PQgetvalue(res,i,1),NULL,10);
    +				key->lifetime = (uint32_t)strtol(PQgetvalue(res,i,2),NULL,10);
     				STRCPY(key->as_rs_alg,PQgetvalue(res,i,3));
     				STRCPY(key->realm,PQgetvalue(res,i,4));
     				STRCPY(key->kid,PQgetvalue(res,i,5));
    @@ -245,7 +245,7 @@ static int pgsql_list_oauth_keys(secrets_list_t *kids,secrets_list_t *teas,secre
     	return ret;
     }
       
    -static int pgsql_set_user_key(u08bits *usname, u08bits *realm, const char *key) {
    +static int pgsql_set_user_key(uint8_t *usname, uint8_t *realm, const char *key) {
       int ret = -1;
     	char statement[TURN_LONG_STRING_SIZE];
     	PGconn *pqc = get_pqdb_connection();
    @@ -306,7 +306,7 @@ static int pgsql_set_oauth_key(oauth_key_data_raw *key) {
       return ret;
     }
       
    -static int pgsql_del_user(u08bits *usname, u08bits *realm) {
    +static int pgsql_del_user(uint8_t *usname, uint8_t *realm) {
       int ret = -1;
     	char statement[TURN_LONG_STRING_SIZE];
     	PGconn *pqc = get_pqdb_connection();
    @@ -321,7 +321,7 @@ static int pgsql_del_user(u08bits *usname, u08bits *realm) {
       return ret;
     }
     
    -static int pgsql_del_oauth_key(const u08bits *kid) {
    +static int pgsql_del_oauth_key(const uint8_t *kid) {
     
       int ret = -1;
       char statement[TURN_LONG_STRING_SIZE];
    @@ -342,12 +342,12 @@ static int pgsql_del_oauth_key(const u08bits *kid) {
       return ret;
     }
       
    -static int pgsql_list_users(u08bits *realm, secrets_list_t *users, secrets_list_t *realms)
    +static int pgsql_list_users(uint8_t *realm, secrets_list_t *users, secrets_list_t *realms)
     {
     	int ret = -1;
     	char statement[TURN_LONG_STRING_SIZE];
     
    -	u08bits realm0[STUN_MAX_REALM_SIZE+1] = "\0";
    +	uint8_t realm0[STUN_MAX_REALM_SIZE+1] = "\0";
     	if(!realm) realm=realm0;
     
     	PGconn *pqc = get_pqdb_connection();
    @@ -391,11 +391,11 @@ static int pgsql_list_users(u08bits *realm, secrets_list_t *users, secrets_list_
       return ret;
     }
       
    -static int pgsql_list_secrets(u08bits *realm, secrets_list_t *secrets, secrets_list_t *realms)
    +static int pgsql_list_secrets(uint8_t *realm, secrets_list_t *secrets, secrets_list_t *realms)
     {
     	int ret = -1;
     
    -	u08bits realm0[STUN_MAX_REALM_SIZE+1] = "\0";
    +	uint8_t realm0[STUN_MAX_REALM_SIZE+1] = "\0";
     	if(!realm) realm=realm0;
     
     	char statement[TURN_LONG_STRING_SIZE];
    @@ -441,7 +441,7 @@ static int pgsql_list_secrets(u08bits *realm, secrets_list_t *secrets, secrets_l
     	return ret;
     }
       
    -static int pgsql_del_secret(u08bits *secret, u08bits *realm) {
    +static int pgsql_del_secret(uint8_t *secret, uint8_t *realm) {
       int ret = -1;
     	donot_print_connection_success=1;
     	char statement[TURN_LONG_STRING_SIZE];
    @@ -461,7 +461,7 @@ static int pgsql_del_secret(u08bits *secret, u08bits *realm) {
       return ret;
     }
       
    -static int pgsql_set_secret(u08bits *secret, u08bits *realm) {
    +static int pgsql_set_secret(uint8_t *secret, uint8_t *realm) {
       int ret = -1;
     	donot_print_connection_success = 1;
     	char statement[TURN_LONG_STRING_SIZE];
    @@ -485,11 +485,11 @@ static int pgsql_set_secret(u08bits *secret, u08bits *realm) {
     	return ret;
     }
     
    -static int pgsql_set_permission_ip(const char *kind, u08bits *realm, const char* ip, int del)
    +static int pgsql_set_permission_ip(const char *kind, uint8_t *realm, const char* ip, int del)
     {
     	int ret = -1;
     
    -	u08bits realm0[STUN_MAX_REALM_SIZE+1] = "\0";
    +	uint8_t realm0[STUN_MAX_REALM_SIZE+1] = "\0";
     	if(!realm) realm=realm0;
     
     	donot_print_connection_success = 1;
    @@ -523,7 +523,7 @@ static int pgsql_set_permission_ip(const char *kind, u08bits *realm, const char*
     	return ret;
     }
       
    -static int pgsql_add_origin(u08bits *origin, u08bits *realm) {
    +static int pgsql_add_origin(uint8_t *origin, uint8_t *realm) {
       int ret = -1;
     	char statement[TURN_LONG_STRING_SIZE];
     	PGconn *pqc = get_pqdb_connection();
    @@ -542,7 +542,7 @@ static int pgsql_add_origin(u08bits *origin, u08bits *realm) {
       return ret;
     }
       
    -static int pgsql_del_origin(u08bits *origin) {
    +static int pgsql_del_origin(uint8_t *origin) {
       int ret = -1;
     	char statement[TURN_LONG_STRING_SIZE];
     	PGconn *pqc = get_pqdb_connection();
    @@ -561,11 +561,11 @@ static int pgsql_del_origin(u08bits *origin) {
       return ret;
     }
       
    -static int pgsql_list_origins(u08bits *realm, secrets_list_t *origins, secrets_list_t *realms)
    +static int pgsql_list_origins(uint8_t *realm, secrets_list_t *origins, secrets_list_t *realms)
     {
     	int ret = -1;
     
    -	u08bits realm0[STUN_MAX_REALM_SIZE+1] = "\0";
    +	uint8_t realm0[STUN_MAX_REALM_SIZE+1] = "\0";
     	if(!realm) realm=realm0;
     
     	donot_print_connection_success = 1;
    @@ -615,7 +615,7 @@ static int pgsql_list_origins(u08bits *realm, secrets_list_t *origins, secrets_l
     	return ret;
     }
       
    -static int pgsql_set_realm_option_one(u08bits *realm, unsigned long value, const char* opt) {
    +static int pgsql_set_realm_option_one(uint8_t *realm, unsigned long value, const char* opt) {
       int ret = -1;
     	char statement[TURN_LONG_STRING_SIZE];
     	PGconn *pqc = get_pqdb_connection();
    @@ -643,7 +643,7 @@ static int pgsql_set_realm_option_one(u08bits *realm, unsigned long value, const
       return ret;
     }
       
    -static int pgsql_list_realm_options(u08bits *realm) {
    +static int pgsql_list_realm_options(uint8_t *realm) {
       int ret = -1;
     	donot_print_connection_success = 1;
     	char statement[TURN_LONG_STRING_SIZE];
    @@ -748,7 +748,7 @@ static void pgsql_reread_realms(secrets_list_t * realms_list) {
     
     			if(res && (PQresultStatus(res) == PGRES_TUPLES_OK)) {
     
    -				ur_string_map *o_to_realm_new = ur_string_map_create(turn_free_simple);
    +				ur_string_map *o_to_realm_new = ur_string_map_create(free);
     
     				int i = 0;
     				for(i=0;i<PQntuples(res);i++) {
    @@ -757,7 +757,7 @@ static void pgsql_reread_realms(secrets_list_t * realms_list) {
     						char *rval = PQgetvalue(res,i,1);
     						if(rval) {
     							get_realm(rval);
    -							ur_string_map_value_type value = turn_strdup(rval);
    +							ur_string_map_value_type value = strdup(rval);
     							ur_string_map_put(o_to_realm_new, (const ur_string_map_key_type) oval, value);
     						}
     					}
    @@ -835,7 +835,7 @@ static void pgsql_reread_realms(secrets_list_t * realms_list) {
     
     //////////////////////////////////////////////
     
    -static int pgsql_get_admin_user(const u08bits *usname, u08bits *realm, password_t pwd)
    +static int pgsql_get_admin_user(const uint8_t *usname, uint8_t *realm, password_t pwd)
     {
     	int ret = -1;
     
    @@ -869,7 +869,7 @@ static int pgsql_get_admin_user(const u08bits *usname, u08bits *realm, password_
     	return ret;
     }
     
    -static int pgsql_set_admin_user(const u08bits *usname, const u08bits *realm, const password_t pwd)
    +static int pgsql_set_admin_user(const uint8_t *usname, const uint8_t *realm, const password_t pwd)
     {
     	int ret = -1;
     	char statement[TURN_LONG_STRING_SIZE];
    @@ -898,7 +898,7 @@ static int pgsql_set_admin_user(const u08bits *usname, const u08bits *realm, con
     	return ret;
     }
     
    -static int pgsql_del_admin_user(const u08bits *usname)
    +static int pgsql_del_admin_user(const uint8_t *usname)
     {
     	int ret = -1;
     	char statement[TURN_LONG_STRING_SIZE];
    @@ -949,6 +949,15 @@ static int pgsql_list_admin_users(int no_print)
     	return ret;
     }
     
    +static void pgsql_disconnect(void) {
    +	PGconn *pqdbconnection = (PGconn*)pthread_getspecific(connection_key);
    +	if (pqdbconnection) {
    +		PQfinish(pqdbconnection);
    +		pqdbconnection=NULL;
    +	}
    +	TURN_LOG_FUNC(TURN_LOG_LEVEL_INFO, "PostgreSQL connection was closed.\n");
    +}
    +
     /////////////////////////////////////////////////////////////
     
     static const turn_dbdriver_t driver = {
    @@ -976,7 +985,8 @@ static const turn_dbdriver_t driver = {
       &pgsql_get_admin_user,
       &pgsql_set_admin_user,
       &pgsql_del_admin_user,
    -  &pgsql_list_admin_users
    +  &pgsql_list_admin_users,
    +  &pgsql_disconnect
     };
     
     const turn_dbdriver_t * get_pgsql_dbdriver(void) {
    
  • src/apps/relay/dbdrivers/dbd_redis.c+71 61 modified
    @@ -58,18 +58,18 @@ typedef struct _Ryconninfo Ryconninfo;
     
     static void RyconninfoFree(Ryconninfo *co) {
     	if(co) {
    -		if(co->host) turn_free(co->host, strlen(co->host)+1);
    -		if(co->dbname) turn_free(co->dbname, strlen(co->dbname)+1);
    -		if(co->password) turn_free(co->password, strlen(co->password)+1);
    -		ns_bzero(co,sizeof(Ryconninfo));
    +		if(co->host) free(co->host);
    +		if(co->dbname) free(co->dbname);
    +		if(co->password) free(co->password);
    +		bzero(co,sizeof(Ryconninfo));
     	}
     }
     
     static Ryconninfo *RyconninfoParse(const char *userdb, char **errmsg) {
    -	Ryconninfo *co = (Ryconninfo*) turn_malloc(sizeof(Ryconninfo));
    -	ns_bzero(co,sizeof(Ryconninfo));
    +	Ryconninfo *co = (Ryconninfo*) malloc(sizeof(Ryconninfo));
    +	bzero(co,sizeof(Ryconninfo));
     	if (userdb) {
    -		char *s0 = turn_strdup(userdb);
    +		char *s0 = strdup(userdb);
     		char *s = s0;
     
     		while (s && *s) {
    @@ -87,28 +87,28 @@ static Ryconninfo *RyconninfoParse(const char *userdb, char **errmsg) {
     				RyconninfoFree(co);
     				co = NULL;
     				if (errmsg) {
    -					*errmsg = turn_strdup(s);
    +					*errmsg = strdup(s);
     				}
     				break;
     			}
     
     			*seq = 0;
     			if (!strcmp(s, "host"))
    -				co->host = turn_strdup(seq + 1);
    +				co->host = strdup(seq + 1);
     			else if (!strcmp(s, "ip"))
    -				co->host = turn_strdup(seq + 1);
    +				co->host = strdup(seq + 1);
     			else if (!strcmp(s, "addr"))
    -				co->host = turn_strdup(seq + 1);
    +				co->host = strdup(seq + 1);
     			else if (!strcmp(s, "ipaddr"))
    -				co->host = turn_strdup(seq + 1);
    +				co->host = strdup(seq + 1);
     			else if (!strcmp(s, "hostaddr"))
    -				co->host = turn_strdup(seq + 1);
    +				co->host = strdup(seq + 1);
     			else if (!strcmp(s, "dbname"))
    -				co->dbname = turn_strdup(seq + 1);
    +				co->dbname = strdup(seq + 1);
     			else if (!strcmp(s, "db"))
    -				co->dbname = turn_strdup(seq + 1);
    +				co->dbname = strdup(seq + 1);
     			else if (!strcmp(s, "database"))
    -				co->dbname = turn_strdup(seq + 1);
    +				co->dbname = strdup(seq + 1);
     			else if (!strcmp(s, "user"))
     				;
     			else if (!strcmp(s, "uname"))
    @@ -118,13 +118,13 @@ static Ryconninfo *RyconninfoParse(const char *userdb, char **errmsg) {
     			else if (!strcmp(s, "username"))
     				;
     			else if (!strcmp(s, "password"))
    -				co->password = turn_strdup(seq + 1);
    +				co->password = strdup(seq + 1);
     			else if (!strcmp(s, "pwd"))
    -				co->password = turn_strdup(seq + 1);
    +				co->password = strdup(seq + 1);
     			else if (!strcmp(s, "passwd"))
    -				co->password = turn_strdup(seq + 1);
    +				co->password = strdup(seq + 1);
     			else if (!strcmp(s, "secret"))
    -				co->password = turn_strdup(seq + 1);
    +				co->password = strdup(seq + 1);
     			else if (!strcmp(s, "port"))
     				co->port = (unsigned int) atoi(seq + 1);
     			else if (!strcmp(s, "p"))
    @@ -137,24 +137,24 @@ static Ryconninfo *RyconninfoParse(const char *userdb, char **errmsg) {
     				RyconninfoFree(co);
     				co = NULL;
     				if (errmsg) {
    -					*errmsg = turn_strdup(s);
    +					*errmsg = strdup(s);
     				}
     				break;
     			}
     
     			s = snext;
     		}
     
    -		turn_free(s0, strlen(s0)+1);
    +		free(s0);
     	}
     
     	if(co) {
     		if(!(co->dbname))
    -			co->dbname=turn_strdup("0");
    +			co->dbname=strdup("0");
     		if(!(co->host))
    -			co->host=turn_strdup("127.0.0.1");
    +			co->host=strdup("127.0.0.1");
     		if(!(co->password))
    -			co->password=turn_strdup("");
    +			co->password=strdup("");
     	}
     
     	return co;
    @@ -170,13 +170,13 @@ redis_context_handle get_redis_async_connection(struct event_base *base, const c
     		if (!co) {
     			if (errmsg) {
     				TURN_LOG_FUNC(TURN_LOG_LEVEL_ERROR, "Cannot open Redis DB connection <%s>, connection string format error: %s\n", connection_string, errmsg);
    -				turn_free(errmsg,strlen(errmsg)+1);
    +				free(errmsg);
     			} else {
     				TURN_LOG_FUNC(TURN_LOG_LEVEL_ERROR, "Cannot open Redis DB connection <%s>, connection string format error\n", connection_string);
     			}
     		} else if (errmsg) {
     			TURN_LOG_FUNC(TURN_LOG_LEVEL_ERROR, "Cannot open Redis DB connection <%s>, connection string format error: %s\n", connection_string, errmsg);
    -			turn_free(errmsg,strlen(errmsg)+1);
    +			free(errmsg);
     			RyconninfoFree(co);
     		} else {
     
    @@ -284,13 +284,13 @@ static redisContext *get_redis_connection(void) {
     		if (!co) {
     			if (errmsg) {
     				TURN_LOG_FUNC(TURN_LOG_LEVEL_ERROR, "Cannot open Redis DB connection <%s>, connection string format error: %s\n", pud->userdb, errmsg);
    -				turn_free(errmsg,strlen(errmsg)+1);
    +				free(errmsg);
     			} else {
     				TURN_LOG_FUNC(TURN_LOG_LEVEL_ERROR, "Cannot open Redis DB connection <%s>, connection string format error\n", pud->userdb);
     			}
     		} else if (errmsg) {
     			TURN_LOG_FUNC(TURN_LOG_LEVEL_ERROR, "Cannot open Redis DB connection <%s>, connection string format error: %s\n", pud->userdb, errmsg);
    -			turn_free(errmsg,strlen(errmsg)+1);
    +			free(errmsg);
     			RyconninfoFree(co);
     		} else {
     			char ip[256] = "\0";
    @@ -397,7 +397,7 @@ static int set_redis_realm_opt(char *realm, const char* key, unsigned long *valu
     
     ///////////////////////////////////////////////////////////////////////////////////////////////////////////
     
    -static int redis_get_auth_secrets(secrets_list_t *sl, u08bits *realm)
    +static int redis_get_auth_secrets(secrets_list_t *sl, uint8_t *realm)
     {
     	int ret = -1;
     	redisContext *rc = get_redis_connection();
    @@ -425,7 +425,7 @@ static int redis_get_auth_secrets(secrets_list_t *sl, u08bits *realm)
     	return ret;
     }
       
    -static int redis_get_user_key(u08bits *usname, u08bits *realm, hmackey_t key) {
    +static int redis_get_user_key(uint8_t *usname, uint8_t *realm, hmackey_t key) {
       int ret = -1;
     	redisContext * rc = get_redis_connection();
     	if(rc) {
    @@ -454,12 +454,12 @@ static int redis_get_user_key(u08bits *usname, u08bits *realm, hmackey_t key) {
       return ret;
     }
     
    -static int redis_get_oauth_key(const u08bits *kid, oauth_key_data_raw *key) {
    +static int redis_get_oauth_key(const uint8_t *kid, oauth_key_data_raw *key) {
       int ret = -1;
       redisContext * rc = get_redis_connection();
       if(rc) {
     	char s[TURN_LONG_STRING_SIZE];
    -	ns_bzero(key,sizeof(oauth_key_data_raw));
    +	bzero(key,sizeof(oauth_key_data_raw));
     	STRCPY(key->kid,kid);
     	snprintf(s,sizeof(s),"hgetall turn/oauth/kid/%s", (const char*)kid);
     	redisReply *reply = (redisReply *)redisCommand(rc, s);
    @@ -482,9 +482,9 @@ static int redis_get_oauth_key(const u08bits *kid, oauth_key_data_raw *key) {
     					} else if(!strcmp(kw,"ikm_key")) {
     						STRCPY(key->ikm_key,val);
     					} else if(!strcmp(kw,"timestamp")) {
    -						key->timestamp = (u64bits)strtoull(val,NULL,10);
    +						key->timestamp = (uint64_t)strtoull(val,NULL,10);
     					} else if(!strcmp(kw,"lifetime")) {
    -						key->lifetime = (u32bits)strtoul(val,NULL,10);
    +						key->lifetime = (uint32_t)strtoul(val,NULL,10);
     					}
     				}
     			}
    @@ -496,7 +496,7 @@ static int redis_get_oauth_key(const u08bits *kid, oauth_key_data_raw *key) {
       return ret;
     }
       
    -static int redis_set_user_key(u08bits *usname, u08bits *realm, const char *key) {
    +static int redis_set_user_key(uint8_t *usname, uint8_t *realm, const char *key) {
       int ret = -1;
     	redisContext *rc = get_redis_connection();
     	if(rc) {
    @@ -523,7 +523,7 @@ static int redis_set_oauth_key(oauth_key_data_raw *key) {
       return ret;
     }
       
    -static int redis_del_user(u08bits *usname, u08bits *realm) {
    +static int redis_del_user(uint8_t *usname, uint8_t *realm) {
       int ret = -1;
     	redisContext *rc = get_redis_connection();
     	if(rc) {
    @@ -539,7 +539,7 @@ static int redis_del_user(u08bits *usname, u08bits *realm) {
       return ret;
     }
     
    -static int redis_del_oauth_key(const u08bits *kid) {
    +static int redis_del_oauth_key(const uint8_t *kid) {
       int ret = -1;
       redisContext *rc = get_redis_connection();
       if(rc) {
    @@ -552,12 +552,12 @@ static int redis_del_oauth_key(const u08bits *kid) {
       return ret;
     }
       
    -static int redis_list_users(u08bits *realm, secrets_list_t *users, secrets_list_t *realms)
    +static int redis_list_users(uint8_t *realm, secrets_list_t *users, secrets_list_t *realms)
     {
     	int ret = -1;
     	redisContext *rc = get_redis_connection();
     
    -	u08bits realm0[STUN_MAX_REALM_SIZE+1] = "\0";
    +	uint8_t realm0[STUN_MAX_REALM_SIZE+1] = "\0";
     	if(!realm) realm=realm0;
     
     	if(rc) {
    @@ -666,7 +666,7 @@ static int redis_list_oauth_keys(secrets_list_t *kids,secrets_list_t *teas,secre
     	s += strlen("turn/oauth/kid/");
     	oauth_key_data_raw key_;
     	oauth_key_data_raw *key=&key_;
    -	if(redis_get_oauth_key((const u08bits*)s,key) == 0) {
    +	if(redis_get_oauth_key((const uint8_t*)s,key) == 0) {
     		if(kids) {
     			add_to_secrets_list(kids,key->kid);
     			add_to_secrets_list(teas,key->as_rs_alg);
    @@ -696,11 +696,11 @@ static int redis_list_oauth_keys(secrets_list_t *kids,secrets_list_t *teas,secre
     }
       
     
    -static int redis_list_secrets(u08bits *realm, secrets_list_t *secrets, secrets_list_t *realms)
    +static int redis_list_secrets(uint8_t *realm, secrets_list_t *secrets, secrets_list_t *realms)
     {
     	int ret = -1;
     
    -	u08bits realm0[STUN_MAX_REALM_SIZE+1] = "\0";
    +	uint8_t realm0[STUN_MAX_REALM_SIZE+1] = "\0";
     	if(!realm) realm=realm0;
     
     	donot_print_connection_success = 1;
    @@ -787,7 +787,7 @@ static int redis_list_secrets(u08bits *realm, secrets_list_t *secrets, secrets_l
     }
       
     
    -static int redis_del_secret(u08bits *secret, u08bits *realm)
    +static int redis_del_secret(uint8_t *secret, uint8_t *realm)
     {
     	int ret = -1;
     	donot_print_connection_success = 1;
    @@ -801,7 +801,7 @@ static int redis_del_secret(u08bits *secret, u08bits *realm)
     }
       
     
    -static int redis_set_secret(u08bits *secret, u08bits *realm)
    +static int redis_set_secret(uint8_t *secret, uint8_t *realm)
     {
     	int ret = -1;
     	donot_print_connection_success = 1;
    @@ -820,11 +820,11 @@ static int redis_set_secret(u08bits *secret, u08bits *realm)
     	return ret;
     }
     
    -static int redis_set_permission_ip(const char *kind, u08bits *realm, const char* ip, int del)
    +static int redis_set_permission_ip(const char *kind, uint8_t *realm, const char* ip, int del)
     {
     	int ret = -1;
     
    -	u08bits realm0[STUN_MAX_REALM_SIZE+1] = "\0";
    +	uint8_t realm0[STUN_MAX_REALM_SIZE+1] = "\0";
     	if(!realm) realm=realm0;
     
     	donot_print_connection_success = 1;
    @@ -846,7 +846,7 @@ static int redis_set_permission_ip(const char *kind, u08bits *realm, const char*
     	return ret;
     }
       
    -static int redis_add_origin(u08bits *origin, u08bits *realm) {
    +static int redis_add_origin(uint8_t *origin, uint8_t *realm) {
       int ret = -1;
     	redisContext *rc = get_redis_connection();
     	if(rc) {
    @@ -861,7 +861,7 @@ static int redis_add_origin(u08bits *origin, u08bits *realm) {
       return ret;
     }
       
    -static int redis_del_origin(u08bits *origin) {
    +static int redis_del_origin(uint8_t *origin) {
       int ret = -1;
     	redisContext *rc = get_redis_connection();
     	if(rc) {
    @@ -876,11 +876,11 @@ static int redis_del_origin(u08bits *origin) {
       return ret;
     }
       
    -static int redis_list_origins(u08bits *realm, secrets_list_t *origins, secrets_list_t *realms)
    +static int redis_list_origins(uint8_t *realm, secrets_list_t *origins, secrets_list_t *realms)
     {
     	int ret = -1;
     
    -	u08bits realm0[STUN_MAX_REALM_SIZE+1] = "\0";
    +	uint8_t realm0[STUN_MAX_REALM_SIZE+1] = "\0";
     	if(!realm) realm=realm0;
     
     	donot_print_connection_success = 1;
    @@ -948,7 +948,7 @@ static int redis_list_origins(u08bits *realm, secrets_list_t *origins, secrets_l
     	return ret;
     }
       
    -static int redis_set_realm_option_one(u08bits *realm, unsigned long value, const char* opt) {
    +static int redis_set_realm_option_one(uint8_t *realm, unsigned long value, const char* opt) {
       int ret = -1;
     	redisContext *rc = get_redis_connection();
     	if(rc) {
    @@ -966,7 +966,7 @@ static int redis_set_realm_option_one(u08bits *realm, unsigned long value, const
       return ret;
     }
       
    -static int redis_list_realm_options(u08bits *realm) {
    +static int redis_list_realm_options(uint8_t *realm) {
       int ret = -1;
     	donot_print_connection_success = 1;
     	redisContext *rc = get_redis_connection();
    @@ -1124,7 +1124,7 @@ static void redis_reread_realms(secrets_list_t * realms_list) {
     		redisReply *reply = (redisReply*) redisCommand(rc, "keys turn/origin/*");
     		if (reply) {
     
    -			ur_string_map *o_to_realm_new = ur_string_map_create(turn_free_simple);
    +			ur_string_map *o_to_realm_new = ur_string_map_create(free);
     
     			secrets_list_t keys;
     
    @@ -1160,7 +1160,7 @@ static void redis_reread_realms(secrets_list_t * realms_list) {
     							TURN_LOG_FUNC(TURN_LOG_LEVEL_ERROR, "Unexpected type: %d\n", rget->type);
     					} else {
     						get_realm(rget->str);
    -						ur_string_map_value_type value = turn_strdup(rget->str);
    +						ur_string_map_value_type value = strdup(rget->str);
     						ur_string_map_put(o_to_realm_new, (const ur_string_map_key_type) origin, value);
     					}
     					turnFreeRedisReply(rget);
    @@ -1222,7 +1222,7 @@ static void redis_reread_realms(secrets_list_t * realms_list) {
     
     /////////////////////////////////////////////////////
     
    -static int redis_get_admin_user(const u08bits *usname, u08bits *realm, password_t pwd)
    +static int redis_get_admin_user(const uint8_t *usname, uint8_t *realm, password_t pwd)
     {
     	int ret = -1;
     	redisContext * rc = get_redis_connection();
    @@ -1259,7 +1259,7 @@ static int redis_get_admin_user(const u08bits *usname, u08bits *realm, password_
     	  return ret;
     }
     
    -static int redis_set_admin_user(const u08bits *usname, const u08bits *realm, const password_t pwd)
    +static int redis_set_admin_user(const uint8_t *usname, const uint8_t *realm, const password_t pwd)
     {
       int ret = -1;
       donot_print_connection_success = 1;
    @@ -1278,7 +1278,7 @@ static int redis_set_admin_user(const u08bits *usname, const u08bits *realm, con
       return ret;
     }
     
    -static int redis_del_admin_user(const u08bits *usname) {
    +static int redis_del_admin_user(const uint8_t *usname) {
       int ret = -1;
       donot_print_connection_success = 1;
       redisContext *rc = get_redis_connection();
    @@ -1328,9 +1328,9 @@ static int redis_list_admin_users(int no_print)
       for(isz=0;isz<keys.sz;++isz) {
     	char *s = keys.secrets[isz];
     	s += strlen("turn/admin_user/");
    -	u08bits realm[STUN_MAX_REALM_SIZE];
    +	uint8_t realm[STUN_MAX_REALM_SIZE];
     	password_t pwd;
    -	if(redis_get_admin_user((const u08bits*)s,realm,pwd) == 0) {
    +	if(redis_get_admin_user((const uint8_t*)s,realm,pwd) == 0) {
     		++ret;
     		if(!no_print) {
     			if(realm[0]) {
    @@ -1347,6 +1347,15 @@ static int redis_list_admin_users(int no_print)
       return ret;
     }
     
    +static void redis_disconnect(void) {
    +	redisContext *redisconnection = (redisContext*)pthread_getspecific(connection_key);
    +	if (redisconnection) {
    +		redisFree(redisconnection);
    +		redisconnection = NULL;
    +	}
    +	TURN_LOG_FUNC(TURN_LOG_LEVEL_INFO, "Redis connection was closed.\n");
    +}
    +
     //////////////////////////////////////////////////////
     
     static const turn_dbdriver_t driver = {
    @@ -1374,7 +1383,8 @@ static const turn_dbdriver_t driver = {
       &redis_get_admin_user,
       &redis_set_admin_user,
       &redis_del_admin_user,
    -  &redis_list_admin_users
    +  &redis_list_admin_users,
    +  &redis_disconnect
     };
     
     const turn_dbdriver_t * get_redis_dbdriver(void) {
    
  • src/apps/relay/dbdrivers/dbdriver.h+20 19 modified
    @@ -48,31 +48,32 @@ extern pthread_key_t connection_key;
     extern pthread_once_t connection_key_once;
     
     typedef struct _turn_dbdriver_t {
    -  int (*get_auth_secrets)(secrets_list_t *sl, u08bits *realm);
    -  int (*get_user_key)(u08bits *usname, u08bits *realm, hmackey_t key);
    -  int (*set_user_key)(u08bits *usname, u08bits *realm, const char *key);
    -  int (*del_user)(u08bits *usname, u08bits *realm);
    -  int (*list_users)(u08bits *realm, secrets_list_t *users, secrets_list_t *realms);
    -  int (*list_secrets)(u08bits *realm, secrets_list_t *secrets, secrets_list_t *realms);
    -  int (*del_secret)(u08bits *secret, u08bits *realm);
    -  int (*set_secret)(u08bits *secret, u08bits *realm);
    -  int (*add_origin)(u08bits *origin, u08bits *realm);
    -  int (*del_origin)(u08bits *origin);
    -  int (*list_origins)(u08bits *realm, secrets_list_t *origins, secrets_list_t *realms);
    -  int (*set_realm_option_one)(u08bits *realm, unsigned long value, const char* opt);
    -  int (*list_realm_options)(u08bits *realm);
    +  int (*get_auth_secrets)(secrets_list_t *sl, uint8_t *realm);
    +  int (*get_user_key)(uint8_t *usname, uint8_t *realm, hmackey_t key);
    +  int (*set_user_key)(uint8_t *usname, uint8_t *realm, const char *key);
    +  int (*del_user)(uint8_t *usname, uint8_t *realm);
    +  int (*list_users)(uint8_t *realm, secrets_list_t *users, secrets_list_t *realms);
    +  int (*list_secrets)(uint8_t *realm, secrets_list_t *secrets, secrets_list_t *realms);
    +  int (*del_secret)(uint8_t *secret, uint8_t *realm);
    +  int (*set_secret)(uint8_t *secret, uint8_t *realm);
    +  int (*add_origin)(uint8_t *origin, uint8_t *realm);
    +  int (*del_origin)(uint8_t *origin);
    +  int (*list_origins)(uint8_t *realm, secrets_list_t *origins, secrets_list_t *realms);
    +  int (*set_realm_option_one)(uint8_t *realm, unsigned long value, const char* opt);
    +  int (*list_realm_options)(uint8_t *realm);
       void (*auth_ping)(void * rch);
       int (*get_ip_list)(const char *kind, ip_range_list_t * list);
    -  int (*set_permission_ip)(const char *kind, u08bits *realm, const char* ip, int del);
    +  int (*set_permission_ip)(const char *kind, uint8_t *realm, const char* ip, int del);
       void (*reread_realms)(secrets_list_t * realms_list);
       int (*set_oauth_key)(oauth_key_data_raw *key);
    -  int (*get_oauth_key)(const u08bits *kid, oauth_key_data_raw *key);
    -  int (*del_oauth_key)(const u08bits *kid);
    +  int (*get_oauth_key)(const uint8_t *kid, oauth_key_data_raw *key);
    +  int (*del_oauth_key)(const uint8_t *kid);
       int (*list_oauth_keys)(secrets_list_t *kids,secrets_list_t *teas,secrets_list_t *tss,secrets_list_t *lts,secrets_list_t *realms);
    -  int (*get_admin_user)(const u08bits *usname, u08bits *realm, password_t pwd);
    -  int (*set_admin_user)(const u08bits *usname, const u08bits *realm, const password_t pwd);
    -  int (*del_admin_user)(const u08bits *usname);
    +  int (*get_admin_user)(const uint8_t *usname, uint8_t *realm, password_t pwd);
    +  int (*set_admin_user)(const uint8_t *usname, const uint8_t *realm, const password_t pwd);
    +  int (*del_admin_user)(const uint8_t *usname);
       int (*list_admin_users)(int no_print);
    +  void (*disconnect)(void);
     } turn_dbdriver_t;
     
     /////////// USER DB CHECK //////////////////
    
  • src/apps/relay/dbdrivers/dbd_sqlite.c+48 38 modified
    @@ -140,11 +140,11 @@ static void fix_user_directory(char *dir0) {
     		}
     		size_t szh = strlen(home);
     		size_t sz = strlen(dir0)+1+szh;
    -		char* dir_fixed = (char*)turn_malloc(sz);
    +		char* dir_fixed = (char*)malloc(sz);
     		strncpy(dir_fixed,home,szh);
     		strncpy(dir_fixed+szh,dir+1,(sz-szh-1));
     		strncpy(dir0,dir_fixed,sz);
    -		turn_free(dir_fixed,sz);
    +		free(dir_fixed);
     	}
     }
     
    @@ -207,7 +207,7 @@ static sqlite3 * get_sqlite_connection(void) {
     
     ///////////////////////////////////////////////////////////////////////////////////////////////////////////
     
    -static int sqlite_get_auth_secrets(secrets_list_t *sl, u08bits *realm)
    +static int sqlite_get_auth_secrets(secrets_list_t *sl, uint8_t *realm)
     {
     	int ret = -1;
     	sqlite3 *sqliteconnection = get_sqlite_connection();
    @@ -253,7 +253,7 @@ static int sqlite_get_auth_secrets(secrets_list_t *sl, u08bits *realm)
     	return ret;
     }
     
    -static int sqlite_get_user_key(u08bits *usname, u08bits *realm, hmackey_t key)
    +static int sqlite_get_user_key(uint8_t *usname, uint8_t *realm, hmackey_t key)
     {
     	int ret = -1;
     	sqlite3 *sqliteconnection = get_sqlite_connection();
    @@ -269,14 +269,14 @@ static int sqlite_get_user_key(u08bits *usname, u08bits *realm, hmackey_t key)
     		if ((rc = sqlite3_prepare(sqliteconnection, statement, -1, &st, 0)) == SQLITE_OK) {
     			int res = sqlite3_step(st);
     			if (res == SQLITE_ROW) {
    -				char *kval = turn_strdup((const char*) sqlite3_column_text(st, 0));
    +				char *kval = strdup((const char*) sqlite3_column_text(st, 0));
     				size_t sz = get_hmackey_size(SHATYPE_DEFAULT);
     				if (convert_string_key_to_binary(kval, key, sz) < 0) {
     					TURN_LOG_FUNC(TURN_LOG_LEVEL_ERROR, "Wrong key: %s, user %s\n", kval, usname);
     				} else {
     					ret = 0;
     				}
    -				turn_free(kval,strlen(kval)+1);
    +				free(kval);
     			}
     		} else {
     			const char* errmsg = sqlite3_errmsg(sqliteconnection);
    @@ -290,7 +290,7 @@ static int sqlite_get_user_key(u08bits *usname, u08bits *realm, hmackey_t key)
     	return ret;
     }
     
    -static int sqlite_get_oauth_key(const u08bits *kid, oauth_key_data_raw *key) {
    +static int sqlite_get_oauth_key(const uint8_t *kid, oauth_key_data_raw *key) {
     
     	int ret = -1;
     
    @@ -312,8 +312,8 @@ static int sqlite_get_oauth_key(const u08bits *kid, oauth_key_data_raw *key) {
     			if (res == SQLITE_ROW) {
     
     				STRCPY(key->ikm_key,sqlite3_column_text(st, 0));
    -				key->timestamp = (u64bits)strtoll((const char*)sqlite3_column_text(st, 1),NULL,10);
    -				key->lifetime = (u32bits)strtol((const char*)sqlite3_column_text(st, 2),NULL,10);
    +				key->timestamp = (uint64_t)strtoll((const char*)sqlite3_column_text(st, 1),NULL,10);
    +				key->lifetime = (uint32_t)strtol((const char*)sqlite3_column_text(st, 2),NULL,10);
     				STRCPY(key->as_rs_alg,sqlite3_column_text(st, 3));
     				STRCPY(key->realm,sqlite3_column_text(st, 4));
     				STRCPY(key->kid,kid);
    @@ -359,8 +359,8 @@ static int sqlite_list_oauth_keys(secrets_list_t *kids,secrets_list_t *teas,secr
     				if (res == SQLITE_ROW) {
     
     					STRCPY(key->ikm_key,sqlite3_column_text(st, 0));
    -					key->timestamp = (u64bits)strtoll((const char*)sqlite3_column_text(st, 1),NULL,10);
    -					key->lifetime = (u32bits)strtol((const char*)sqlite3_column_text(st, 2),NULL,10);
    +					key->timestamp = (uint64_t)strtoll((const char*)sqlite3_column_text(st, 1),NULL,10);
    +					key->lifetime = (uint32_t)strtol((const char*)sqlite3_column_text(st, 2),NULL,10);
     					STRCPY(key->as_rs_alg,sqlite3_column_text(st, 3));
     					STRCPY(key->realm,sqlite3_column_text(st, 4));
     					STRCPY(key->kid,sqlite3_column_text(st, 5));
    @@ -407,7 +407,7 @@ static int sqlite_list_oauth_keys(secrets_list_t *kids,secrets_list_t *teas,secr
     	return ret;
     }
     
    -static int sqlite_set_user_key(u08bits *usname, u08bits *realm, const char *key)
    +static int sqlite_set_user_key(uint8_t *usname, uint8_t *realm, const char *key)
     {
     	int ret = -1;
     	char statement[TURN_LONG_STRING_SIZE];
    @@ -471,7 +471,7 @@ static int sqlite_set_oauth_key(oauth_key_data_raw *key)
     	return ret;
     }
     
    -static int sqlite_del_user(u08bits *usname, u08bits *realm)
    +static int sqlite_del_user(uint8_t *usname, uint8_t *realm)
     {
     	int ret = -1;
     	char statement[TURN_LONG_STRING_SIZE];
    @@ -500,7 +500,7 @@ static int sqlite_del_user(u08bits *usname, u08bits *realm)
     	return ret;
     }
     
    -static int sqlite_del_oauth_key(const u08bits *kid)
    +static int sqlite_del_oauth_key(const uint8_t *kid)
     {
     	int ret = -1;
     	char statement[TURN_LONG_STRING_SIZE];
    @@ -531,14 +531,14 @@ static int sqlite_del_oauth_key(const u08bits *kid)
     }
     
     
    -static int sqlite_list_users(u08bits *realm, secrets_list_t *users, secrets_list_t *realms)
    +static int sqlite_list_users(uint8_t *realm, secrets_list_t *users, secrets_list_t *realms)
     {
     	int ret = -1;
     	char statement[TURN_LONG_STRING_SIZE];
     	sqlite3_stmt *st = NULL;
     	int rc = 0;
     
    -	u08bits realm0[STUN_MAX_REALM_SIZE+1] = "\0";
    +	uint8_t realm0[STUN_MAX_REALM_SIZE+1] = "\0";
     	if(!realm) realm=realm0;
     
     	donot_print_connection_success=1;
    @@ -596,12 +596,12 @@ static int sqlite_list_users(u08bits *realm, secrets_list_t *users, secrets_list
     	return ret;
     }
     
    -static int sqlite_list_secrets(u08bits *realm, secrets_list_t *secrets, secrets_list_t *realms)
    +static int sqlite_list_secrets(uint8_t *realm, secrets_list_t *secrets, secrets_list_t *realms)
     {
     	int ret = -1;
     	char statement[TURN_LONG_STRING_SIZE];
     
    -	u08bits realm0[STUN_MAX_REALM_SIZE+1] = "\0";
    +	uint8_t realm0[STUN_MAX_REALM_SIZE+1] = "\0";
     	if(!realm) realm=realm0;
     
     	sqlite3_stmt *st = NULL;
    @@ -660,7 +660,7 @@ static int sqlite_list_secrets(u08bits *realm, secrets_list_t *secrets, secrets_
     	return ret;
     }
       
    -static int sqlite_del_secret(u08bits *secret, u08bits *realm)
    +static int sqlite_del_secret(uint8_t *secret, uint8_t *realm)
     {
     	int ret = -1;
     	donot_print_connection_success=1;
    @@ -691,7 +691,7 @@ static int sqlite_del_secret(u08bits *secret, u08bits *realm)
     	return ret;
     }
       
    -static int sqlite_set_secret(u08bits *secret, u08bits *realm)
    +static int sqlite_set_secret(uint8_t *secret, uint8_t *realm)
     {
     	int ret = -1;
     	donot_print_connection_success = 1;
    @@ -720,7 +720,7 @@ static int sqlite_set_secret(u08bits *secret, u08bits *realm)
     	return ret;
     }
       
    -static int sqlite_add_origin(u08bits *origin, u08bits *realm)
    +static int sqlite_add_origin(uint8_t *origin, uint8_t *realm)
     {
     	int ret = -1;
     	char statement[TURN_LONG_STRING_SIZE];
    @@ -748,7 +748,7 @@ static int sqlite_add_origin(u08bits *origin, u08bits *realm)
     	return ret;
     }
       
    -static int sqlite_del_origin(u08bits *origin)
    +static int sqlite_del_origin(uint8_t *origin)
     {
     	int ret = -1;
     	char statement[TURN_LONG_STRING_SIZE];
    @@ -776,11 +776,11 @@ static int sqlite_del_origin(u08bits *origin)
     	return ret;
     }
     
    -static int sqlite_list_origins(u08bits *realm, secrets_list_t *origins, secrets_list_t *realms)
    +static int sqlite_list_origins(uint8_t *realm, secrets_list_t *origins, secrets_list_t *realms)
     {
     	int ret = -1;
     
    -	u08bits realm0[STUN_MAX_REALM_SIZE+1] = "\0";
    +	uint8_t realm0[STUN_MAX_REALM_SIZE+1] = "\0";
     	if(!realm) realm=realm0;
     
     	donot_print_connection_success = 1;
    @@ -841,7 +841,7 @@ static int sqlite_list_origins(u08bits *realm, secrets_list_t *origins, secrets_
     	return ret;
     }
       
    -static int sqlite_set_realm_option_one(u08bits *realm, unsigned long value, const char* opt)
    +static int sqlite_set_realm_option_one(uint8_t *realm, unsigned long value, const char* opt)
     {
     	int ret = -1;
     	char statement[TURN_LONG_STRING_SIZE];
    @@ -871,7 +871,7 @@ static int sqlite_set_realm_option_one(u08bits *realm, unsigned long value, cons
     	return ret;
     }
       
    -static int sqlite_list_realm_options(u08bits *realm)
    +static int sqlite_list_realm_options(uint8_t *realm)
     {
     	int ret = -1;
     	donot_print_connection_success = 1;
    @@ -974,11 +974,11 @@ static int sqlite_get_ip_list(const char *kind, ip_range_list_t * list)
     	return ret;
     }
     
    -static int sqlite_set_permission_ip(const char *kind, u08bits *realm, const char* ip, int del)
    +static int sqlite_set_permission_ip(const char *kind, uint8_t *realm, const char* ip, int del)
     {
     	int ret = -1;
     
    -	u08bits realm0[STUN_MAX_REALM_SIZE+1] = "\0";
    +	uint8_t realm0[STUN_MAX_REALM_SIZE+1] = "\0";
     	if(!realm) realm=realm0;
     
     	char statement[TURN_LONG_STRING_SIZE];
    @@ -1027,20 +1027,20 @@ static void sqlite_reread_realms(secrets_list_t * realms_list)
     
     			if ((rc = sqlite3_prepare(sqliteconnection, statement, -1, &st, 0)) == SQLITE_OK) {
     
    -				ur_string_map *o_to_realm_new = ur_string_map_create(turn_free_simple);
    +				ur_string_map *o_to_realm_new = ur_string_map_create(free);
     
     				while (1) {
     					int res = sqlite3_step(st);
     					if (res == SQLITE_ROW) {
     
    -						char* oval = turn_strdup((const char*) sqlite3_column_text(st, 0));
    -						char* rval = turn_strdup((const char*) sqlite3_column_text(st, 1));
    +						char* oval = strdup((const char*) sqlite3_column_text(st, 0));
    +						char* rval = strdup((const char*) sqlite3_column_text(st, 1));
     
     						get_realm(rval);
     						ur_string_map_value_type value = rval;
     						ur_string_map_put(o_to_realm_new, (const ur_string_map_key_type) oval, value);
     
    -						turn_free(oval,strlen(oval)+1);
    +						free(oval);
     
     					} else if (res == SQLITE_DONE) {
     						break;
    @@ -1101,7 +1101,7 @@ static void sqlite_reread_realms(secrets_list_t * realms_list)
     					int res = sqlite3_step(st);
     					if (res == SQLITE_ROW) {
     
    -						char* rval = turn_strdup((const char*) sqlite3_column_text(st, 0));
    +						char* rval = strdup((const char*) sqlite3_column_text(st, 0));
     						const char* oval = (const char*) sqlite3_column_text(st, 1);
     						const char* vval = (const char*) sqlite3_column_text(st, 2);
     
    @@ -1116,7 +1116,7 @@ static void sqlite_reread_realms(secrets_list_t * realms_list)
     							TURN_LOG_FUNC(TURN_LOG_LEVEL_ERROR, "Unknown realm option: %s\n", oval);
     						}
     
    -						turn_free(rval,strlen(rval)+1);
    +						free(rval);
     
     					} else if (res == SQLITE_DONE) {
     						break;
    @@ -1139,7 +1139,7 @@ static void sqlite_reread_realms(secrets_list_t * realms_list)
     
     ////////////////////////////////////////////////////
     
    -static int sqlite_get_admin_user(const u08bits *usname, u08bits *realm, password_t pwd)
    +static int sqlite_get_admin_user(const uint8_t *usname, uint8_t *realm, password_t pwd)
     {
     	int ret = -1;
     
    @@ -1180,7 +1180,7 @@ static int sqlite_get_admin_user(const u08bits *usname, u08bits *realm, password
     	return ret;
     }
     
    -static int sqlite_set_admin_user(const u08bits *usname, const u08bits *realm, const password_t pwd)
    +static int sqlite_set_admin_user(const uint8_t *usname, const uint8_t *realm, const password_t pwd)
     {
     	int ret = -1;
     	char statement[TURN_LONG_STRING_SIZE];
    @@ -1210,7 +1210,7 @@ static int sqlite_set_admin_user(const u08bits *usname, const u08bits *realm, co
     	return ret;
     }
     
    -static int sqlite_del_admin_user(const u08bits *usname)
    +static int sqlite_del_admin_user(const uint8_t *usname)
     {
     	int ret = -1;
     	char statement[TURN_LONG_STRING_SIZE];
    @@ -1294,6 +1294,15 @@ static int sqlite_list_admin_users(int no_print)
     	return ret;
     }
     
    +static void sqlite_disconnect(void) {
    +	sqlite3 *sqliteconnection = (sqlite3 *)pthread_getspecific(connection_key);
    +	if (sqliteconnection) {
    +		sqlite3_close(sqliteconnection);
    +		sqliteconnection=NULL;
    +	}
    +	TURN_LOG_FUNC(TURN_LOG_LEVEL_INFO, "SQLite connection was closed.\n");
    +}
    +
     ///////////////////////////////////////////////////////
     
     static const turn_dbdriver_t driver = {
    @@ -1321,7 +1330,8 @@ static const turn_dbdriver_t driver = {
       &sqlite_get_admin_user,
       &sqlite_set_admin_user,
       &sqlite_del_admin_user,
    -  &sqlite_list_admin_users
    +  &sqlite_list_admin_users,
    +  &sqlite_disconnect
     };
     
     //////////////////////////////////////////////////
    
  • src/apps/relay/dtls_listener.c+25 25 modified
    @@ -288,13 +288,13 @@ static ioa_socket_handle dtls_server_input_handler(dtls_listener_relay_server_ty
     #if DTLSv1_2_SUPPORTED
     	if(get_dtls_version(ioa_network_buffer_data(nbh),
     							(int)ioa_network_buffer_get_size(nbh)) == 1) {
    -		connecting_ssl = SSL_NEW(server->dtls_ctx_v1_2);
    +		connecting_ssl = SSL_new(server->dtls_ctx_v1_2);
     	} else {
    -		connecting_ssl = SSL_NEW(server->dtls_ctx);
    +		connecting_ssl = SSL_new(server->dtls_ctx);
     	}
     #else
     	{
    -		connecting_ssl = SSL_NEW(server->dtls_ctx);
    +		connecting_ssl = SSL_new(server->dtls_ctx);
     	}
     #endif
     
    @@ -315,7 +315,7 @@ static ioa_socket_handle dtls_server_input_handler(dtls_listener_relay_server_ty
     			SSL_set_shutdown(connecting_ssl, SSL_RECEIVED_SHUTDOWN);
     			SSL_shutdown(connecting_ssl);
     		}
    -		SSL_FREE(connecting_ssl);
    +		SSL_free(connecting_ssl);
     	}
     
     	return rc;
    @@ -396,8 +396,8 @@ static int handle_udp_packet(dtls_listener_relay_server_type *server,
     			TURN_LOG_FUNC(TURN_LOG_LEVEL_ERROR,
     					"%s: socket to be closed\n", __FUNCTION__);
     			{
    -				u08bits saddr[129];
    -				u08bits rsaddr[129];
    +				uint8_t saddr[129];
    +				uint8_t rsaddr[129];
     				long thrid = (long) pthread_self();
     				addr_to_string(get_local_addr_from_ioa_socket(chs),saddr);
     				addr_to_string(get_remote_addr_from_ioa_socket(chs),rsaddr);
    @@ -419,8 +419,8 @@ static int handle_udp_packet(dtls_listener_relay_server_type *server,
     			TURN_LOG_FUNC(TURN_LOG_LEVEL_ERROR,
     					"%s: wrong socket container\n", __FUNCTION__);
     			{
    -				u08bits saddr[129];
    -				u08bits rsaddr[129];
    +				uint8_t saddr[129];
    +				uint8_t rsaddr[129];
     				long thrid = (long) pthread_self();
     				addr_to_string(get_local_addr_from_ioa_socket(chs),saddr);
     				addr_to_string(get_remote_addr_from_ioa_socket(chs),rsaddr);
    @@ -457,8 +457,8 @@ static int handle_udp_packet(dtls_listener_relay_server_type *server,
     
     		if (s) {
     			if(verbose) {
    -				u08bits saddr[129];
    -				u08bits rsaddr[129];
    +				uint8_t saddr[129];
    +				uint8_t rsaddr[129];
     				addr_to_string(get_local_addr_from_ioa_socket(s),saddr);
     				addr_to_string(get_remote_addr_from_ioa_socket(s),rsaddr);
     				TURN_LOG_FUNC(TURN_LOG_LEVEL_INFO,
    @@ -495,15 +495,15 @@ static int create_new_connected_udp_socket(
     				(char*) (s->e->relay_ifname));
     	}
     
    -	ioa_socket_handle ret = (ioa_socket*) turn_malloc(sizeof(ioa_socket));
    +	ioa_socket_handle ret = (ioa_socket*) malloc(sizeof(ioa_socket));
     	if (!ret) {
     		TURN_LOG_FUNC(TURN_LOG_LEVEL_ERROR,
     				"%s: Cannot allocate new socket structure\n", __FUNCTION__);
     		close(udp_fd);
     		return -1;
     	}
     
    -	ns_bzero(ret, sizeof(ioa_socket));
    +	bzero(ret, sizeof(ioa_socket));
     
     	ret->magic = SOCKET_MAGIC;
     
    @@ -528,8 +528,8 @@ static int create_new_connected_udp_socket(
     		if (addr_connect(udp_fd, &(server->sm.m.sm.nd.src_addr), &connect_err) < 0) {
     			char sl[129];
     			char sr[129];
    -			addr_to_string(&(ret->local_addr),(u08bits*)sl);
    -			addr_to_string(&(server->sm.m.sm.nd.src_addr),(u08bits*)sr);
    +			addr_to_string(&(ret->local_addr),(uint8_t*)sl);
    +			addr_to_string(&(server->sm.m.sm.nd.src_addr),(uint8_t*)sr);
     			TURN_LOG_FUNC(TURN_LOG_LEVEL_ERROR,
     					"Cannot connect new detached udp client socket from local addr %s to remote addr %s\n",sl,sr);
     			IOA_CLOSE_SOCKET(ret);
    @@ -573,13 +573,13 @@ static int create_new_connected_udp_socket(
     #if DTLSv1_2_SUPPORTED
     		if(get_dtls_version(ioa_network_buffer_data(server->sm.m.sm.nd.nbh),
     							(int)ioa_network_buffer_get_size(server->sm.m.sm.nd.nbh)) == 1) {
    -			connecting_ssl = SSL_NEW(server->dtls_ctx_v1_2);
    +			connecting_ssl = SSL_new(server->dtls_ctx_v1_2);
     		} else {
    -			connecting_ssl = SSL_NEW(server->dtls_ctx);
    +			connecting_ssl = SSL_new(server->dtls_ctx);
     		}
     #else
     		{
    -			connecting_ssl = SSL_NEW(server->dtls_ctx);
    +			connecting_ssl = SSL_new(server->dtls_ctx);
     		}
     #endif
     
    @@ -597,7 +597,7 @@ static int create_new_connected_udp_socket(
     				SSL_set_shutdown(connecting_ssl, SSL_RECEIVED_SHUTDOWN);
     				SSL_shutdown(connecting_ssl);
     			}
    -			SSL_FREE(connecting_ssl);
    +			SSL_free(connecting_ssl);
     			IOA_CLOSE_SOCKET(ret);
     			return -1;
     		}
    @@ -651,7 +651,7 @@ static void udp_server_input_handler(evutil_socket_t fd, short what, void* arg)
     	int flags = MSG_DONTWAIT;
     
     	bsize = udp_recvfrom(fd, &(server->sm.m.sm.nd.src_addr), &(server->addr),
    -			(s08bits*)ioa_network_buffer_data(elem), (int)ioa_network_buffer_get_capacity_udp(),
    +			(char*)ioa_network_buffer_data(elem), (int)ioa_network_buffer_get_capacity_udp(),
     			&(server->sm.m.sm.nd.recv_ttl), &(server->sm.m.sm.nd.recv_tos),
     			server->e->cmsg, flags, NULL);
     
    @@ -671,8 +671,8 @@ static void udp_server_input_handler(evutil_socket_t fd, short what, void* arg)
     
     		//Linux
     		int eflags = MSG_ERRQUEUE | MSG_DONTWAIT;
    -		static s08bits buffer[65535];
    -		u32bits errcode = 0;
    +		static char buffer[65535];
    +		uint32_t errcode = 0;
     		ioa_addr orig_addr;
     		int ttl = 0;
     		int tos = 0;
    @@ -782,7 +782,7 @@ static int create_server_socket(dtls_listener_relay_server_type* server, int rep
     		  if(addr_bind(udp_listen_fd,&server->addr,1,1,UDP_SOCKET)<0) {
     			  perror("Cannot bind local socket to addr");
     			  char saddr[129];
    -			  addr_to_string(&server->addr,(u08bits*)saddr);
    +			  addr_to_string(&server->addr,(uint8_t*)saddr);
     			  TURN_LOG_FUNC(TURN_LOG_LEVEL_WARNING,"Cannot bind DTLS/UDP listener socket to addr %s\n",saddr);
     			  if(addr_bind_cycle++<max_binding_time) {
     				  TURN_LOG_FUNC(TURN_LOG_LEVEL_INFO,"Trying to bind DTLS/UDP listener socket to addr %s, again...\n",saddr);
    @@ -860,7 +860,7 @@ static int reopen_server_socket(dtls_listener_relay_server_type* server, evutil_
     		if(addr_bind(udp_listen_fd,&server->addr,1,1,UDP_SOCKET)<0) {
     			perror("Cannot bind local socket to addr");
     			char saddr[129];
    -			addr_to_string(&server->addr,(u08bits*)saddr);
    +			addr_to_string(&server->addr,(uint8_t*)saddr);
     			TURN_LOG_FUNC(TURN_LOG_LEVEL_INFO,"Cannot bind listener socket to addr %s\n",saddr);
     			return -1;
     		}
    @@ -925,7 +925,7 @@ static int init_server(dtls_listener_relay_server_type* server,
     
       if(ifname) STRCPY(server->ifname,ifname);
     
    -  if(make_ioa_addr((const u08bits*)local_address, port, &server->addr)<0) {
    +  if(make_ioa_addr((const uint8_t*)local_address, port, &server->addr)<0) {
     	  TURN_LOG_FUNC(TURN_LOG_LEVEL_ERROR,"Cannot create a DTLS/UDP listener for address: %s\n",local_address);
     	  return -1;
       }
    @@ -1014,7 +1014,7 @@ ioa_engine_handle get_engine(dtls_listener_relay_server_type* server)
     void udp_send_message(dtls_listener_relay_server_type *server, ioa_network_buffer_handle nbh, ioa_addr *dest)
     {
     	if(server && dest && nbh && (server->udp_listen_s))
    -		udp_send(server->udp_listen_s, dest, (s08bits*)ioa_network_buffer_data(nbh), (int)ioa_network_buffer_get_size(nbh));
    +		udp_send(server->udp_listen_s, dest, (char*)ioa_network_buffer_data(nbh), (int)ioa_network_buffer_get_size(nbh));
     }
     
     //////////////////////////////////////////////////////////////////
    
  • src/apps/relay/http_server.c+45 36 modified
    @@ -59,14 +59,14 @@ static void write_http_echo(ioa_socket_handle s)
     		if((sat == HTTP_CLIENT_SOCKET) || (sat == HTTPS_CLIENT_SOCKET)) {
     			ioa_network_buffer_handle nbh_http = ioa_network_buffer_allocate(s->e);
     			size_t len_http = ioa_network_buffer_get_size(nbh_http);
    -			u08bits *data = ioa_network_buffer_data(nbh_http);
    +			uint8_t *data = ioa_network_buffer_data(nbh_http);
     			char data_http[1025];
     			char content_http[1025];
     			const char* title = "TURN Server";
     			snprintf(content_http,sizeof(content_http)-1,"<!DOCTYPE html>\r\n<html>\r\n  <head>\r\n    <title>%s</title>\r\n  </head>\r\n  <body>\r\n    <b>%s</b> <br> <b><i>use https connection for the admin session</i></b>\r\n  </body>\r\n</html>\r\n",title,title);
     			snprintf(data_http,sizeof(data_http)-1,"HTTP/1.0 200 OK\r\nServer: %s\r\nContent-Type: text/html; charset=UTF-8\r\nContent-Length: %d\r\n\r\n%.906s",TURN_SOFTWARE,(int)strlen(content_http),content_http);
     			len_http = strlen(data_http);
    -			ns_bcopy(data_http,data,len_http);
    +			bcopy(data_http,data,len_http);
     			ioa_network_buffer_set_size(nbh_http,len_http);
     			send_data_from_ioa_socket_nbh(s, NULL, nbh_http, TTL_IGNORE, TOS_IGNORE,NULL);
     		}
    @@ -103,36 +103,45 @@ const char* get_http_date_header()
     
     static struct headers_list * post_parse(char *data, size_t data_len)
     {
    -	while((*data=='\r')||(*data=='\n')) ++data;
    -	char *post_data = (char*)calloc(data_len + 1, sizeof(char));
    -	memcpy(post_data, data, data_len);
    -	char *fmarker = NULL;
    -	char *fsplit = strtok_r(post_data, "&", &fmarker);
    -	struct headers_list *list = (struct headers_list*)malloc(sizeof(struct headers_list));
    -	ns_bzero(list,sizeof(struct headers_list));
    -	while (fsplit != NULL) {
    -		char *vmarker = NULL;
    -		char *key = strtok_r(fsplit, "=", &vmarker);
    -		char *value = strtok_r(NULL, "=", &vmarker);
    -		char empty[1];
    -		empty[0]=0;
    -		value = value ? value : empty;
    -		value = evhttp_decode_uri(value);
    -		char *p = value;
    -		while (*p) {
    -			if (*p == '+')
    -				*p = ' ';
    -			p++;
    +	while((*data=='\r')||(*data=='\n')) { ++data; --data_len; }
    +	if (data_len) {
    +		char *post_data = (char*)calloc(data_len + 1, sizeof(char));
    +		if (post_data != NULL) {
    +			memcpy(post_data, data, data_len);
    +			char *fmarker = NULL;
    +			char *fsplit = strtok_r(post_data, "&", &fmarker);
    +			struct headers_list *list = (struct headers_list*)malloc(sizeof(struct headers_list));
    +			bzero(list,sizeof(struct headers_list));
    +			while (fsplit != NULL) {
    +				char *vmarker = NULL;
    +				char *key = strtok_r(fsplit, "=", &vmarker);
    +				if (key == NULL)
    +					break;
    +				else {
    +					char *value = strtok_r(NULL, "=", &vmarker);
    +					char empty[1];
    +					empty[0]=0;
    +					value = value ? value : empty;
    +					value = evhttp_decode_uri(value);
    +					char *p = value;
    +					while (*p) {
    +						if (*p == '+')
    +							*p = ' ';
    +						p++;
    +					}
    +					list->keys = (char**)realloc(list->keys,sizeof(char*)*(list->n+1));
    +					list->keys[list->n] = strdup(key);
    +					list->values = (char**)realloc(list->values,sizeof(char*)*(list->n+1));
    +					list->values[list->n] = value;
    +					++(list->n);
    +					fsplit = strtok_r(NULL, "&", &fmarker);
    +				}
    +			}
    +			free(post_data);
    +			return list;
     		}
    -		list->keys = (char**)realloc(list->keys,sizeof(char*)*(list->n+1));
    -		list->keys[list->n] = strdup(key);
    -		list->values = (char**)realloc(list->values,sizeof(char*)*(list->n+1));
    -		list->values[list->n] = value;
    -		++(list->n);
    -		fsplit = strtok_r(NULL, "&", &fmarker);
     	}
    -	free(post_data);
    -	return list;
    +	return NULL;
     }
     
     static struct http_request* parse_http_request_1(struct http_request* ret, char* request, int parse_post)
    @@ -156,13 +165,13 @@ static struct http_request* parse_http_request_1(struct http_request* ret, char*
     				const char *query = evhttp_uri_get_query(uri);
     				if(query) {
     					struct evkeyvalq* kv = (struct evkeyvalq*)malloc(sizeof(struct evkeyvalq));
    -					ns_bzero(kv,sizeof(struct evkeyvalq));
    +					bzero(kv,sizeof(struct evkeyvalq));
     					if(evhttp_parse_query_str(query, kv)<0) {
     						free(ret);
     						ret = NULL;
     					} else {
     						ret->headers = (struct http_headers*)malloc(sizeof(struct http_headers));
    -						ns_bzero(ret->headers,sizeof(struct http_headers));
    +						bzero(ret->headers,sizeof(struct http_headers));
     						ret->headers->uri_headers = kv;
     					}
     				}
    @@ -178,7 +187,7 @@ static struct http_request* parse_http_request_1(struct http_request* ret, char*
     					if(body && body[0]) {
     						if(!ret->headers) {
     							ret->headers = (struct http_headers*)malloc(sizeof(struct http_headers));
    -							ns_bzero(ret->headers,sizeof(struct http_headers));
    +							bzero(ret->headers,sizeof(struct http_headers));
     						}
     						ret->headers->post_headers = post_parse(body,strlen(body));
     					}
    @@ -199,7 +208,7 @@ struct http_request* parse_http_request(char* request) {
     	if(request) {
     
     		ret = (struct http_request*)malloc(sizeof(struct http_request));
    -		ns_bzero(ret,sizeof(struct http_request));
    +		bzero(ret,sizeof(struct http_request));
     
     		if(strstr(request,"GET ") == request) {
     			ret->rtype = HRT_GET;
    @@ -318,7 +327,7 @@ struct str_buffer {
     struct str_buffer* str_buffer_new(void)
     {
     	struct str_buffer* ret = (struct str_buffer*)malloc(sizeof(struct str_buffer));
    -	ns_bzero(ret,sizeof(struct str_buffer));
    +	bzero(ret,sizeof(struct str_buffer));
     	ret->buffer = (char*)malloc(1);
     	ret->buffer[0] = 0;
     	ret->capacity = 1;
    @@ -333,7 +342,7 @@ void str_buffer_append(struct str_buffer* sb, const char* str)
     			sb->capacity += len + 1024;
     			sb->buffer = (char*)realloc(sb->buffer,sb->capacity);
     		}
    -		ns_bcopy(str,sb->buffer+sb->sz,len+1);
    +		bcopy(str,sb->buffer+sb->sz,len+1);
     		sb->sz += len;
     	}
     }
    
  • src/apps/relay/mainrelay.c+118 55 modified
    @@ -29,6 +29,7 @@
      */
     
     #include "mainrelay.h"
    +#include "dbdrivers/dbdriver.h"
     
     #if (defined LIBRESSL_VERSION_NUMBER && OPENSSL_VERSION_NUMBER == 0x20000000L)
     #undef OPENSSL_VERSION_NUMBER
    @@ -89,7 +90,7 @@ NULL,
     NULL,
     #endif
     
    -DH_1066, "", "", "",
    +DH_2066, "", "", "",
     "turn_server_cert.pem","turn_server_pkey.pem", "", "",
     0,0,0,
     #if !TLS_SUPPORTED
    @@ -109,8 +110,8 @@ NULL, PTHREAD_MUTEX_INITIALIZER,
     //////////////// Common params ////////////////////
     TURN_VERBOSE_NONE,0,0,0,0,
     "/var/run/turnserver.pid",
    -DEFAULT_STUN_PORT,DEFAULT_STUN_TLS_PORT,0,0,1,
    -0,0,0,0,
    +DEFAULT_STUN_PORT,DEFAULT_STUN_TLS_PORT,0,0,0,1,
    +0,0,0,0,0,
     "",
     "",0,
     {
    @@ -156,7 +157,10 @@ DEFAULT_CPUS_NUMBER,
     ///////// Encryption /////////
     "", /* secret_key_file */
     "", /* secret_key */
    -0   /* keep_address_family */
    +0,  /* keep_address_family */
    +0,  /* no_auth_pings */
    +0,  /* no_dynamic_ip_list */
    +0   /* no_dynamic_realms */
     };
     
     //////////////// OpenSSL Init //////////////////////
    @@ -359,7 +363,7 @@ int get_a_local_relay(int family, ioa_addr *relay_addr)
     				} else
     					continue;
     
    -				if (make_ioa_addr((const u08bits*) saddr, 0, relay_addr) < 0) {
    +				if (make_ioa_addr((const uint8_t*) saddr, 0, relay_addr) < 0) {
     					continue;
     				} else {
     					ret = 0;
    @@ -401,6 +405,8 @@ static char Usage[] = "Usage: turnserver [options]\n"
     "                                                or in old RFC 3489 sense, default is \"listening port plus one\").\n"
     " --alt-tls-listening-port	<port>		Alternative listening port for TLS and DTLS,\n"
     " 						the default is \"TLS/DTLS port plus one\".\n"
    +" --tcp-proxy-port		<port>		Support connections from TCP loadbalancer on this port. The loadbalancer should\n"
    +"						use the binary proxy protocol (https://www.haproxy.org/download/1.8/doc/proxy-protocol.txt)\n"
     " -L, --listening-ip		<ip>		Listener IP address of relay server. Multiple listeners can be specified.\n"
     " --aux-server			<ip:port>	Auxiliary STUN/TURN server listening endpoint.\n"
     "						Auxiliary servers do not have alternative ports and\n"
    @@ -447,7 +453,7 @@ static char Usage[] = "Usage: turnserver [options]\n"
     " -v, --verbose					'Moderate' verbose mode.\n"
     " -V, --Verbose					Extra verbose mode, very annoying (for debug purposes only).\n"
     " -o, --daemon					Start process as daemon (detach from current shell).\n"
    -" --prod       	 				Production mode: hide the software version.\n"
    +" --no-software-attribute	 		Production mode: hide the software version (formerly --prod).\n"
     " -f, --fingerprint				Use fingerprints in the TURN messages.\n"
     " -a, --lt-cred-mech				Use the long-term credential mechanism.\n"
     " -z, --no-auth					Do not use any credential mechanism, allow anonymous access.\n"
    @@ -481,7 +487,7 @@ static char Usage[] = "Usage: turnserver [options]\n"
     #if !defined(TURN_NO_PQ)
     " -e, --psql-userdb, --sql-userdb <conn-string>	PostgreSQL database connection string, if used (default - empty, no PostreSQL DB used).\n"
     "		                                This database can be used for long-term credentials mechanism users,\n"
    -"		                                and it can store the secret value(s) for secret-based timed authentication in TURN RESP API.\n"
    +"		                                and it can store the secret value(s) for secret-based timed authentication in TURN REST API.\n"
     "						See http://www.postgresql.org/docs/8.4/static/libpq-connect.html for 8.x PostgreSQL\n"
     "						versions format, see \n"
     "						http://www.postgresql.org/docs/9.2/static/libpq-connect.html#LIBPQ-CONNSTRING\n"
    @@ -490,7 +496,7 @@ static char Usage[] = "Usage: turnserver [options]\n"
     #if !defined(TURN_NO_MYSQL)
     " -M, --mysql-userdb	<connection-string>	MySQL database connection string, if used (default - empty, no MySQL DB used).\n"
     "	                                	This database can be used for long-term credentials mechanism users,\n"
    -"		                                and it can store the secret value(s) for secret-based timed authentication in TURN RESP API.\n"
    +"		                                and it can store the secret value(s) for secret-based timed authentication in TURN REST API.\n"
     "						The connection string my be space-separated list of parameters:\n"
     "	        	          		\"host=<ip-addr> dbname=<database-name> user=<database-user> \\\n							password=<database-user-password> port=<db-port> connect_timeout=<seconds> read_timeout=<seconds>\".\n\n"
     "						The connection string parameters for the secure communications (SSL):\n"
    @@ -507,12 +513,12 @@ static char Usage[] = "Usage: turnserver [options]\n"
     #if !defined(TURN_NO_MONGO)
     " -J, --mongo-userdb	<connection-string>	MongoDB connection string, if used (default - empty, no MongoDB used).\n"
     "	                                	This database can be used for long-term credentials mechanism users,\n"
    -"		                                and it can store the secret value(s) for secret-based timed authentication in TURN RESP API.\n"
    +"		                                and it can store the secret value(s) for secret-based timed authentication in TURN REST API.\n"
     #endif
     #if !defined(TURN_NO_HIREDIS)
     " -N, --redis-userdb	<connection-string>	Redis user database connection string, if used (default - empty, no Redis DB used).\n"
     "	                                	This database can be used for long-term credentials mechanism users,\n"
    -"		                                and it can store the secret value(s) for secret-based timed authentication in TURN RESP API.\n"
    +"		                                and it can store the secret value(s) for secret-based timed authentication in TURN REST API.\n"
     "						The connection string my be space-separated list of parameters:\n"
     "	        	          		\"host=<ip-addr> dbname=<db-number> \\\n								password=<database-user-password> port=<db-port> connect_timeout=<seconds>\".\n\n"
     "	        	          		All connection-string parameters are optional.\n\n"
    @@ -531,6 +537,9 @@ static char Usage[] = "Usage: turnserver [options]\n"
     "						That database value can be changed on-the-fly\n"
     "						by a separate program, so this is why it is 'dynamic'.\n"
     "						Multiple shared secrets can be used (both in the database and in the \"static\" fashion).\n"
    +" --no-auth-pings				Disable periodic health checks to 'dynamic' auth secret tables.\n"
    +" --no-dynamic-ip-list				Do not use dynamic allowed/denied peer ip list.\n"
    +" --no-dynamic-realms				Do not use dynamic realm assignment and options.\n"
     " --server-name					Server name used for\n"
     "						the oAuth authentication purposes.\n"
     "						The default value is the realm name.\n"
    @@ -554,10 +563,10 @@ static char Usage[] = "Usage: turnserver [options]\n"
     "						if pre-OpenSSL 1.0.2 is used. With OpenSSL 1.0.2+,\n"
     "						an optimal curve will be automatically calculated, if not defined\n"
     "						by this option.\n"
    -" --dh566					Use 566 bits predefined DH TLS key. Default size of the predefined key is 1066.\n"
    -" --dh2066					Use 2066 bits predefined DH TLS key. Default size of the predefined key is 1066.\n"
    +" --dh566					Use 566 bits predefined DH TLS key. Default size of the predefined key is 2066.\n"
    +" --dh1066					Use 1066 bits predefined DH TLS key. Default size of the predefined key is 2066.\n"
     " --dh-file	<dh-file-name>			Use custom DH TLS key, stored in PEM format in the file.\n"
    -"						Flags --dh566 and --dh2066 are ignored when the DH key is taken from a file.\n"
    +"						Flags --dh566 and --dh1066 are ignored when the DH key is taken from a file.\n"
     " --no-tlsv1					Do not allow TLSv1/DTLSv1 protocol.\n"
     " --no-tlsv1_1					Do not allow TLSv1.1 protocol.\n"
     " --no-tlsv1_2					Do not allow TLSv1.2/DTLSv1.2 protocol.\n"
    @@ -660,7 +669,7 @@ static char AdminUsage[] = "Usage: turnadmin [command] [options]\n"
     	"	-D, --delete-admin		delete an admin user\n"
     	"	-l, --list			list all long-term mechanism users\n"
     	"	-L, --list-admin		list all admin users\n"
    -	"	-s, --set-secret=<value>	Add shared secret for TURN RESP API\n"
    +	"	-s, --set-secret=<value>	Add shared secret for TURN REST API\n"
     	"	-S, --show-secret		Show stored shared secrets for TURN REST API\n"
     	"	-X, --delete-secret=<value>	Delete a shared secret\n"
     	"	    --delete-all-secrets	Delete all shared secrets for REST API\n"
    @@ -712,6 +721,7 @@ static char AdminUsage[] = "Usage: turnadmin [command] [options]\n"
     enum EXTRA_OPTS {
     	NO_UDP_OPT=256,
     	NO_TCP_OPT,
    +	TCP_PROXY_PORT_OPT,
     	NO_TLS_OPT,
     	NO_DTLS_OPT,
     	NO_UDP_RELAY_OPT,
    @@ -729,6 +739,9 @@ enum EXTRA_OPTS {
     	CHANNEL_LIFETIME_OPT,
     	PERMISSION_LIFETIME_OPT,
     	AUTH_SECRET_OPT,
    +	NO_AUTH_PINGS_OPT,
    +	NO_DYNAMIC_IP_LIST_OPT,
    +	NO_DYNAMIC_REALMS_OPT,
     	DEL_ALL_AUTH_SECRETS_OPT,
     	STATIC_AUTH_SECRET_VAL_OPT,
     	AUTH_SECRET_TS_EXP, /* deprecated */
    @@ -765,7 +778,7 @@ enum EXTRA_OPTS {
     	CLI_MAX_SESSIONS_OPT,
     	EC_CURVE_NAME_OPT,
     	DH566_OPT,
    -	DH2066_OPT,
    +	DH1066_OPT,
     	NE_TYPE_OPT,
     	NO_SSLV2_OPT, /*deprecated*/
     	NO_SSLV3_OPT, /*deprecated*/
    @@ -778,7 +791,7 @@ enum EXTRA_OPTS {
     	ADMIN_USER_QUOTA_OPT,
     	SERVER_NAME_OPT,
     	OAUTH_OPT,
    -	PROD_OPT,
    +	NO_SOFTWARE_ATTRIBUTE_OPT,
     	NO_HTTP_OPT,
     	SECRET_KEY_OPT
     };
    @@ -804,6 +817,7 @@ static const struct myoption long_options[] = {
     				{ "tls-listening-port", required_argument, NULL, TLS_PORT_OPT },
     				{ "alt-listening-port", required_argument, NULL, ALT_PORT_OPT },
     				{ "alt-tls-listening-port", required_argument, NULL, ALT_TLS_PORT_OPT },
    +				{ "tcp-proxy-port", required_argument, NULL, TCP_PROXY_PORT_OPT },
     				{ "listening-ip", required_argument, NULL, 'L' },
     				{ "relay-device", required_argument, NULL, 'i' },
     				{ "relay-ip", required_argument, NULL, 'E' },
    @@ -832,6 +846,9 @@ static const struct myoption long_options[] = {
     #endif
     				{ "use-auth-secret", optional_argument, NULL, AUTH_SECRET_OPT },
     				{ "static-auth-secret", required_argument, NULL, STATIC_AUTH_SECRET_VAL_OPT },
    +				{ "no-auth-pings", optional_argument, NULL, NO_AUTH_PINGS_OPT },
    +				{ "no-dynamic-ip-list", optional_argument, NULL, NO_DYNAMIC_IP_LIST_OPT },
    +				{ "no-dynamic-realms", optional_argument, NULL, NO_DYNAMIC_REALMS_OPT },
     /* deprecated: */		{ "secret-ts-exp-time", optional_argument, NULL, AUTH_SECRET_TS_EXP },
     				{ "realm", required_argument, NULL, 'r' },
     				{ "server-name", required_argument, NULL, SERVER_NAME_OPT },
    @@ -843,7 +860,8 @@ static const struct myoption long_options[] = {
     				{ "verbose", optional_argument, NULL, 'v' },
     				{ "Verbose", optional_argument, NULL, 'V' },
     				{ "daemon", optional_argument, NULL, 'o' },
    -				{ "prod", optional_argument, NULL, PROD_OPT },
    +/* deprecated: */		{ "prod", optional_argument, NULL, NO_SOFTWARE_ATTRIBUTE_OPT },
    +				{ "no-software-attribute", optional_argument, NULL, NO_SOFTWARE_ATTRIBUTE_OPT },
     				{ "fingerprint", optional_argument, NULL, 'f' },
     				{ "check-origin-consistency", optional_argument, NULL, CHECK_ORIGIN_CONSISTENCY_OPT },
     				{ "no-udp", optional_argument, NULL, NO_UDP_OPT },
    @@ -895,7 +913,7 @@ static const struct myoption long_options[] = {
     				{ "cli-max-output-sessions", required_argument, NULL, CLI_MAX_SESSIONS_OPT },
     				{ "ec-curve-name", required_argument, NULL, EC_CURVE_NAME_OPT },
     				{ "dh566", optional_argument, NULL, DH566_OPT },
    -				{ "dh2066", optional_argument, NULL, DH2066_OPT },
    +				{ "dh1066", optional_argument, NULL, DH1066_OPT },
     				{ "ne", required_argument, NULL, NE_TYPE_OPT },
     				{ "no-sslv2", optional_argument, NULL, NO_SSLV2_OPT }, /* deprecated */
     				{ "no-sslv3", optional_argument, NULL, NO_SSLV3_OPT }, /* deprecated */
    @@ -1161,9 +1179,9 @@ static void set_option(int c, char *value)
     	  if(get_bool_value(value))
     		  turn_params.dh_key_size = DH_566;
     	  break;
    -  case DH2066_OPT:
    +  case DH1066_OPT:
     	  if(get_bool_value(value))
    -		  turn_params.dh_key_size = DH_2066;
    +		  turn_params.dh_key_size = DH_1066;
     	  break;
       case EC_CURVE_NAME_OPT:
     	  STRCPY(turn_params.ec_curve_name,value);
    @@ -1181,7 +1199,7 @@ static void set_option(int c, char *value)
     	  use_cli = !get_bool_value(value);
     	  break;
       case CLI_IP_OPT:
    -	  if(make_ioa_addr((const u08bits*)value,0,&cli_addr)<0) {
    +	  if(make_ioa_addr((const uint8_t*)value,0,&cli_addr)<0) {
     		  TURN_LOG_FUNC(TURN_LOG_LEVEL_ERROR,"Cannot set cli address: %s\n",value);
     	  } else{
     		  cli_addr_set = 1;
    @@ -1197,7 +1215,7 @@ static void set_option(int c, char *value)
     	  use_web_admin = get_bool_value(value);
     	  break;
       case WEB_ADMIN_IP_OPT:
    -	  if(make_ioa_addr((const u08bits*)value, 0, &web_admin_addr) < 0) {
    +	  if(make_ioa_addr((const uint8_t*)value, 0, &web_admin_addr) < 0) {
     		  TURN_LOG_FUNC(TURN_LOG_LEVEL_ERROR, "Cannot set web-admin address: %s\n", value);
     	  } else {
     		  web_admin_addr_set = 1;
    @@ -1265,6 +1283,10 @@ static void set_option(int c, char *value)
     	case ALT_TLS_PORT_OPT:
     		turn_params.alt_tls_listener_port = atoi(value);
     		break;
    +	case TCP_PROXY_PORT_OPT:
    +		turn_params.tcp_proxy_port = atoi(value);
    +		turn_params.tcp_use_proxy = 1;
    +		break;
     	case MIN_PORT_OPT:
     		turn_params.min_port = atoi(value);
     		break;
    @@ -1312,29 +1334,29 @@ static void set_option(int c, char *value)
     		if(value) {
     			char *div = strchr(value,'/');
     			if(div) {
    -				char *nval=turn_strdup(value);
    +				char *nval=strdup(value);
     				div = strchr(nval,'/');
     				div[0]=0;
     				++div;
     				ioa_addr apub,apriv;
    -				if(make_ioa_addr((const u08bits*)nval,0,&apub)<0) {
    +				if(make_ioa_addr((const uint8_t*)nval,0,&apub)<0) {
     					TURN_LOG_FUNC(TURN_LOG_LEVEL_ERROR,"-X : Wrong address format: %s\n",nval);
     				} else {
    -					if(make_ioa_addr((const u08bits*)div,0,&apriv)<0) {
    +					if(make_ioa_addr((const uint8_t*)div,0,&apriv)<0) {
     						TURN_LOG_FUNC(TURN_LOG_LEVEL_ERROR,"-X : Wrong address format: %s\n",div);
     					} else {
     						ioa_addr_add_mapping(&apub,&apriv);
     					}
     				}
    -				turn_free(nval,strlen(nval)+1);
    +				free(nval);
     			} else {
     				if(turn_params.external_ip) {
     					TURN_LOG_FUNC(TURN_LOG_LEVEL_ERROR, "You cannot define external IP more than once in the configuration\n");
     				} else {
     					turn_params.external_ip = (ioa_addr*)allocate_super_memory_engine(turn_params.listener.ioa_eng, sizeof(ioa_addr));
    -					if(make_ioa_addr((const u08bits*)value,0,turn_params.external_ip)<0) {
    +					if(make_ioa_addr((const uint8_t*)value,0,turn_params.external_ip)<0) {
     						TURN_LOG_FUNC(TURN_LOG_LEVEL_ERROR,"-X : Wrong address format: %s\n",value);
    -						turn_free(turn_params.external_ip,sizeof(ioa_addr));
    +						free(turn_params.external_ip);
     						turn_params.external_ip = NULL;
     					}
     				}
    @@ -1377,8 +1399,8 @@ static void set_option(int c, char *value)
     			anon_credentials = 1;
     		}
     		break;
    -	case PROD_OPT:
    -		turn_params.prod = get_bool_value(value);
    +	case NO_SOFTWARE_ATTRIBUTE_OPT:
    +		turn_params.no_software_attribute = get_bool_value(value);
     		break;
     	case 'f':
     		turn_params.fingerprint = get_bool_value(value);
    @@ -1428,6 +1450,15 @@ static void set_option(int c, char *value)
     		turn_params.ct = TURN_CREDENTIALS_LONG_TERM;
     		use_lt_credentials = 1;
     		break;
    +	case NO_AUTH_PINGS_OPT:
    +		turn_params.no_auth_pings = 1;
    +		break;
    +	case NO_DYNAMIC_IP_LIST_OPT:
    +		turn_params.no_dynamic_ip_list = 1;
    +		break;
    +	case NO_DYNAMIC_REALMS_OPT:
    +		turn_params.no_dynamic_realms = 1;
    +		break;
     	case STATIC_AUTH_SECRET_VAL_OPT:
     		add_to_secrets_list(&turn_params.default_users_db.ram_db.static_auth_secrets,value);
     		turn_params.use_auth_secret_with_timestamp = 1;
    @@ -1646,7 +1677,9 @@ static void read_config_file(int argc, char **argv, int pass)
     				if (!s[0])
     					continue;
     				size_t slen = strlen(s);
    -				while (slen && ((s[slen - 1] == 10) || (s[slen - 1] == 13)))
    +
    +				// strip white-spaces from config file lines end
    +				while (slen && isspace(s[slen - 1]))
     					s[--slen] = 0;
     				if (slen) {
     					int c = 0;
    @@ -1682,27 +1715,37 @@ static void read_config_file(int argc, char **argv, int pass)
     				config_file);
     
     		if (full_path_to_config_file) {
    -			turn_free(full_path_to_config_file, strlen(full_path_to_config_file)+1);
    +			free(full_path_to_config_file);
     			full_path_to_config_file = NULL;
     		}
     	}
     }
     
    +static int disconnect_database(void)
    +{
    +	const turn_dbdriver_t * dbd = get_dbdriver();
    +	if (dbd && dbd->disconnect) {
    +			dbd->disconnect();
    +	}
    +	return 0;
    +}
    +
     static int adminmain(int argc, char **argv)
     {
     	int c = 0;
    +	int rc = 0;
     
     	TURNADMIN_COMMAND_TYPE ct = TA_COMMAND_UNKNOWN;
     
     	int is_admin = 0;
     	FILE* fptr;
     	unsigned char generated_key[16]; //changed
     
    -	u08bits user[STUN_MAX_USERNAME_SIZE+1]="\0";
    -	u08bits realm[STUN_MAX_REALM_SIZE+1]="\0";
    -	u08bits pwd[STUN_MAX_PWD_SIZE+1]="\0";
    -	u08bits secret[AUTH_SECRET_SIZE+1]="\0";
    -	u08bits origin[STUN_MAX_ORIGIN_SIZE+1]="\0";
    +	uint8_t user[STUN_MAX_USERNAME_SIZE+1]="\0";
    +	uint8_t realm[STUN_MAX_REALM_SIZE+1]="\0";
    +	uint8_t pwd[STUN_MAX_PWD_SIZE+1]="\0";
    +	uint8_t secret[AUTH_SECRET_SIZE+1]="\0";
    +	uint8_t origin[STUN_MAX_ORIGIN_SIZE+1]="\0";
     	perf_options_t po = {(band_limit_t)-1,-1,-1};
     
     	struct uoptions uo;
    @@ -1823,26 +1866,26 @@ static int adminmain(int argc, char **argv)
     #endif
             case 'u':
                 STRCPY(user,optarg);
    -            if(!is_secure_string((u08bits*)user,1)) {
    +            if(!is_secure_string((uint8_t*)user,1)) {
                     TURN_LOG_FUNC(TURN_LOG_LEVEL_ERROR, "Wrong user name structure or symbols, choose another name: %s\n",user);
                     exit(-1);
                 }
    -            if(SASLprep((u08bits*)user)<0) {
    +            if(SASLprep((uint8_t*)user)<0) {
                     TURN_LOG_FUNC(TURN_LOG_LEVEL_ERROR, "Wrong user name: %s\n",user);
                     exit(-1);
                 }
                 break;
             case 'r':
                 set_default_realm_name(optarg);
                 STRCPY(realm,optarg);
    -            if(SASLprep((u08bits*)realm)<0) {
    +            if(SASLprep((uint8_t*)realm)<0) {
                     TURN_LOG_FUNC(TURN_LOG_LEVEL_ERROR, "Wrong realm: %s\n",realm);
                     exit(-1);
                 }
                 break;
             case 'p':
                 STRCPY(pwd,optarg);
    -            if(SASLprep((u08bits*)pwd)<0) {
    +            if(SASLprep((uint8_t*)pwd)<0) {
                     TURN_LOG_FUNC(TURN_LOG_LEVEL_ERROR, "Wrong password: %s\n",pwd);
                     exit(-1);
                 }
    @@ -1868,9 +1911,15 @@ static int adminmain(int argc, char **argv)
                 }
                 else{
     				fseek (fptr, 0, SEEK_SET);
    -				if( fread(generated_key, sizeof(char), 16, fptr) !=0 ){
    +				rc = fread(generated_key, sizeof(char), 16, fptr);
    +				if( rc == 0 ){
     					TURN_LOG_FUNC(TURN_LOG_LEVEL_ERROR, "%s: ERROR: Secret-Key file is empty\n",__FUNCTION__);
     				}
    +				else{
    +					if( rc != 16 ){
    +						TURN_LOG_FUNC(TURN_LOG_LEVEL_ERROR, "%s: ERROR: Secret-Key length is not enough\n",__FUNCTION__);
    +					}
    +				}
     				fclose (fptr);
                 }
                 break;
    @@ -1905,7 +1954,11 @@ static int adminmain(int argc, char **argv)
     		exit(-1);
     	}
     
    -	return adminuser(user, realm, pwd, secret, origin, ct, &po, is_admin);
    +	int result = adminuser(user, realm, pwd, secret, origin, ct, &po, is_admin);
    +
    +	disconnect_database();
    +
    +	return result;
     }
     
     static void print_features(unsigned long mfn)
    @@ -2038,6 +2091,7 @@ static void set_network_engine(void)
     
     static void drop_privileges(void)
     {
    +	setgroups(0, NULL);
     	if(procgroupid_set) {
     		if(getgid() != procgroupid) {
     			if (setgid(procgroupid) != 0) {
    @@ -2153,8 +2207,8 @@ int main(int argc, char **argv)
     
     #endif
     
    -	ns_bzero(&turn_params.default_users_db,sizeof(default_users_db_t));
    -	turn_params.default_users_db.ram_db.static_accounts = ur_string_map_create(turn_free_simple);
    +	bzero(&turn_params.default_users_db,sizeof(default_users_db_t));
    +	turn_params.default_users_db.ram_db.static_accounts = ur_string_map_create(free);
     
     	if(strstr(argv[0],"turnadmin"))
     		return adminmain(argc,argv);
    @@ -2237,19 +2291,19 @@ int main(int argc, char **argv)
     
     	if(use_ltc && use_tltc) {
     		TURN_LOG_FUNC(TURN_LOG_LEVEL_WARNING, "\nCONFIGURATION ALERT: You specified --lt-cred-mech and --use-auth-secret in the same time.\n"
    -                       "Be aware that you could not mix the username/password and the shared secret based auth methohds. \n"
    +                       "Be aware that you could not mix the username/password and the shared secret based auth methods. \n"
                            "Shared secret overrides username/password based auth method. Check your configuration!\n");
     	}
     
     	if(turn_params.allow_loopback_peers) {
     		TURN_LOG_FUNC(TURN_LOG_LEVEL_WARNING, "CONFIG WARNING: allow_loopback_peers opens a possible security vulnerability. Do not use in production!!\n");
    -		if(cli_password[0]==0) {
    +		if(cli_password[0]==0 && use_cli) {
     			TURN_LOG_FUNC(TURN_LOG_LEVEL_ERROR, "\nCONFIG ERROR: allow_loopback_peers and empty cli password cannot be used together.\n");
     			exit(-1);
     		}
             }
     
    -	if(cli_password[0]==0) {
    +	if(use_cli && cli_password[0]==0 && use_cli) {
     		TURN_LOG_FUNC(TURN_LOG_LEVEL_ERROR, "\nCONFIG ERROR: Empty cli-password, and so telnet cli interface is disabled! Please set a non empty cli-password!\n");
     		use_cli = 0;
     	}
    @@ -2336,7 +2390,7 @@ int main(int argc, char **argv)
     				const char* sra = (const char*)turn_params.relay_addrs[ir];
     				if((strstr(sra,"127.0.0.1") != sra)&&(strstr(sra,"::1")!=sra)) {
     					ioa_addr ra;
    -					if(make_ioa_addr((const u08bits*)sra,0,&ra)<0) {
    +					if(make_ioa_addr((const uint8_t*)sra,0,&ra)<0) {
     						TURN_LOG_FUNC(TURN_LOG_LEVEL_ERROR,"-X : Wrong address format: %s\n",sra);
     					} else if(ra.ss.sa_family == turn_params.external_ip->ss.sa_family) {
     						ioa_addr_add_mapping(turn_params.external_ip,&ra);
    @@ -2412,6 +2466,8 @@ int main(int argc, char **argv)
     
     	run_listener_server(&(turn_params.listener));
     
    +	disconnect_database();
    +
     	return 0;
     }
     
    @@ -2537,7 +2593,7 @@ static void adjust_key_file_name(char *fn, const char* file_title, int critical)
     	  fn[sizeof(turn_params.cert_file)-1]=0;
     
     	  if(full_path_to_file)
    -	    turn_free(full_path_to_file,strlen(full_path_to_file)+1);
    +	    free(full_path_to_file);
     	  return;
     	}
     
    @@ -2549,7 +2605,7 @@ static void adjust_key_file_name(char *fn, const char* file_title, int critical)
     			  TURN_LOG_FUNC(TURN_LOG_LEVEL_WARNING,"WARNING: cannot start TLS and DTLS listeners because %s file is not set properly\n",file_title);
     		}
     		if(full_path_to_file)
    -			turn_free(full_path_to_file,strlen(full_path_to_file)+1);
    +			free(full_path_to_file);
     		return;
     	}
     }
    @@ -2749,6 +2805,7 @@ static void set_ctx(SSL_CTX** out, const char *protocol, const SSL_METHOD* metho
     {
     	SSL_CTX* ctx = SSL_CTX_new(method);
     	int err = 0;
    +	int rc = 0;
     #if ALPN_SUPPORTED
     	SSL_CTX_set_alpn_select_cb(ctx, ServerALPNCallback, NULL);
     #endif
    @@ -2873,10 +2930,10 @@ static void set_ctx(SSL_CTX** out, const char *protocol, const SSL_METHOD* metho
     		if(!dh) {
     			if(turn_params.dh_key_size == DH_566)
     				dh = get_dh566();
    -			else if(turn_params.dh_key_size == DH_2066)
    -				dh = get_dh2066();
    -			else
    +			else if(turn_params.dh_key_size == DH_1066)
     				dh = get_dh1066();
    +			else
    +				dh = get_dh2066();
     		}
     
     		/*
    @@ -2908,9 +2965,15 @@ static void set_ctx(SSL_CTX** out, const char *protocol, const SSL_METHOD* metho
     				perror("Cannot open Secret-Key file");
     			} else {
     				fseek (f, 0, SEEK_SET);
    -				if ( fread(turn_params.secret_key, sizeof(char), 16, f) != 0 ){
    +				rc = fread(turn_params.secret_key, sizeof(char), 16, f);
    +				if( rc == 0 ){
     					TURN_LOG_FUNC(TURN_LOG_LEVEL_ERROR, "%s: ERROR: Secret-Key file is empty\n",__FUNCTION__);
     				}
    +				else{
    +					if( rc != 16 ){
    +						TURN_LOG_FUNC(TURN_LOG_LEVEL_ERROR, "%s: ERROR: Secret-Key length is not enough\n",__FUNCTION__);
    +					}
    +				}
     				fclose (f);
     			}
     		}
    
  • src/apps/relay/mainrelay.h+9 4 modified
    @@ -98,7 +98,7 @@ extern "C" {
     
     #define DEFAULT_EC_CURVE_NAME "prime256v1"
     
    -#define MAX_NUMBER_OF_GENERAL_RELAY_SERVERS ((u08bits)(0x80))
    +#define MAX_NUMBER_OF_GENERAL_RELAY_SERVERS ((uint8_t)(0x80))
     
     #define TURNSERVER_ID_BOUNDARY_BETWEEN_TCP_AND_UDP MAX_NUMBER_OF_GENERAL_RELAY_SERVERS
     #define TURNSERVER_ID_BOUNDARY_BETWEEN_UDP_AND_TCP TURNSERVER_ID_BOUNDARY_BETWEEN_TCP_AND_UDP
    @@ -213,7 +213,7 @@ typedef struct _turn_params_ {
     
       int verbose;
       int turn_daemon;
    -  int prod;
    +  int no_software_attribute;
       int web_admin_listen_on_workers;
     
       int do_not_use_config_file;
    @@ -226,10 +226,12 @@ typedef struct _turn_params_ {
       int tls_listener_port;
       int alt_listener_port;
       int alt_tls_listener_port;
    +  int tcp_proxy_port;
       int rfc5780;
     
       int no_udp;
       int no_tcp;
    +  int tcp_use_proxy;
       
       vint no_tcp_relay;
       vint no_udp_relay;
    @@ -249,8 +251,8 @@ typedef struct _turn_params_ {
     
     //////////////// Relay servers /////////////
     
    -  u16bits min_port;
    -  u16bits max_port;
    +  uint16_t min_port;
    +  uint16_t max_port;
     
       vint check_origin;
     
    @@ -322,6 +324,9 @@ typedef struct _turn_params_ {
       char secret_key_file[1025];
       unsigned char secret_key[1025];
       int keep_address_family;
    +  int no_auth_pings;
    +  int no_dynamic_ip_list;
    +  int no_dynamic_realms;
     
     } turn_params_t;
     
    
  • src/apps/relay/netengine.c+44 44 modified
    @@ -182,13 +182,13 @@ static void add_aux_server_list(const char *saddr, turn_server_addrs_list_t *lis
     {
     	if(saddr && list) {
     		ioa_addr addr;
    -		if(make_ioa_addr_from_full_string((const u08bits*)saddr, 0, &addr)!=0) {
    +		if(make_ioa_addr_from_full_string((const uint8_t*)saddr, 0, &addr)!=0) {
     			TURN_LOG_FUNC(TURN_LOG_LEVEL_ERROR, "Wrong full address format: %s\n",saddr);
     		} else {
    -		  list->addrs = (ioa_addr*)turn_realloc(list->addrs,0,sizeof(ioa_addr)*(list->size+1));
    +		  list->addrs = (ioa_addr*)realloc(list->addrs,sizeof(ioa_addr)*(list->size+1));
     			addr_cpy(&(list->addrs[(list->size)++]),&addr);
     			{
    -				u08bits s[1025];
    +				uint8_t s[1025];
     				addr_to_string(&addr, s);
     				TURN_LOG_FUNC(TURN_LOG_LEVEL_INFO, "Aux server: %s\n",s);
     			}
    @@ -210,13 +210,13 @@ static void add_alt_server(const char *saddr, int default_port, turn_server_addr
     
     		turn_mutex_lock(&(list->m));
     
    -		if(make_ioa_addr_from_full_string((const u08bits*)saddr, default_port, &addr)!=0) {
    +		if(make_ioa_addr_from_full_string((const uint8_t*)saddr, default_port, &addr)!=0) {
     			TURN_LOG_FUNC(TURN_LOG_LEVEL_ERROR, "Wrong IP address format: %s\n",saddr);
     		} else {
    -		  list->addrs = (ioa_addr*)turn_realloc(list->addrs,0,sizeof(ioa_addr)*(list->size+1));
    +		  list->addrs = (ioa_addr*)realloc(list->addrs,sizeof(ioa_addr)*(list->size+1));
     			addr_cpy(&(list->addrs[(list->size)++]),&addr);
     			{
    -				u08bits s[1025];
    +				uint8_t s[1025];
     				addr_to_string(&addr, s);
     				TURN_LOG_FUNC(TURN_LOG_LEVEL_INFO, "Alternate server added: %s\n",s);
     			}
    @@ -234,7 +234,7 @@ static void del_alt_server(const char *saddr, int default_port, turn_server_addr
     
     		turn_mutex_lock(&(list->m));
     
    -		if(make_ioa_addr_from_full_string((const u08bits*)saddr, default_port, &addr)!=0) {
    +		if(make_ioa_addr_from_full_string((const uint8_t*)saddr, default_port, &addr)!=0) {
     			TURN_LOG_FUNC(TURN_LOG_LEVEL_ERROR, "Wrong IP address format: %s\n",saddr);
     		} else {
     
    @@ -250,20 +250,20 @@ static void del_alt_server(const char *saddr, int default_port, turn_server_addr
     			if(found) {
     
     				size_t j;
    -				ioa_addr *new_addrs = (ioa_addr*)turn_malloc(sizeof(ioa_addr)*(list->size-1));
    +				ioa_addr *new_addrs = (ioa_addr*)malloc(sizeof(ioa_addr)*(list->size-1));
     				for(j=0;j<i;++j) {
     					addr_cpy(&(new_addrs[j]),&(list->addrs[j]));
     				}
     				for(j=i;j<list->size-1;++j) {
     					addr_cpy(&(new_addrs[j]),&(list->addrs[j+1]));
     				}
     
    -				turn_free(list->addrs,0);
    +				free(list->addrs);
     				list->addrs = new_addrs;
     				list->size -= 1;
     
     				{
    -					u08bits s[1025];
    +					uint8_t s[1025];
     					addr_to_string(&addr, s);
     					TURN_LOG_FUNC(TURN_LOG_LEVEL_INFO, "Alternate server removed: %s\n",s);
     				}
    @@ -336,7 +336,7 @@ static void update_ssl_ctx(evutil_socket_t sock, short events, update_ssl_ctx_cb
     
     void set_ssl_ctx(ioa_engine_handle e, turn_params_t *params)
     {
    -	update_ssl_ctx_cb_args_t *args = (update_ssl_ctx_cb_args_t *)turn_malloc(sizeof(update_ssl_ctx_cb_args_t));
    +	update_ssl_ctx_cb_args_t *args = (update_ssl_ctx_cb_args_t *)malloc(sizeof(update_ssl_ctx_cb_args_t));
     	args->engine = e;
     	args->params = params;
     	args->next = NULL;
    @@ -357,12 +357,12 @@ void set_ssl_ctx(ioa_engine_handle e, turn_params_t *params)
     
     void add_listener_addr(const char* addr) {
     	ioa_addr baddr;
    -	if(make_ioa_addr((const u08bits*)addr,0,&baddr)<0) {
    +	if(make_ioa_addr((const uint8_t*)addr,0,&baddr)<0) {
     		TURN_LOG_FUNC(TURN_LOG_LEVEL_ERROR,"Cannot add a listener address: %s\n",addr);
     	} else {
     
     	  char sbaddr[129];
    -	  addr_to_string_no_port(&baddr,(u08bits*)sbaddr);
    +	  addr_to_string_no_port(&baddr,(uint8_t*)sbaddr);
     
     		size_t i = 0;
     		for(i=0;i<turn_params.listener.addrs_number;++i) {
    @@ -372,24 +372,24 @@ void add_listener_addr(const char* addr) {
     		}
     		++turn_params.listener.addrs_number;
     		++turn_params.listener.services_number;
    -		turn_params.listener.addrs = (char**)turn_realloc(turn_params.listener.addrs, 0, sizeof(char*)*turn_params.listener.addrs_number);
    -		turn_params.listener.addrs[turn_params.listener.addrs_number-1]=turn_strdup(sbaddr);
    -		turn_params.listener.encaddrs = (ioa_addr**)turn_realloc(turn_params.listener.encaddrs, 0, sizeof(ioa_addr*)*turn_params.listener.addrs_number);
    -		turn_params.listener.encaddrs[turn_params.listener.addrs_number-1]=(ioa_addr*)turn_malloc(sizeof(ioa_addr));
    +		turn_params.listener.addrs = (char**)realloc(turn_params.listener.addrs, sizeof(char*)*turn_params.listener.addrs_number);
    +		turn_params.listener.addrs[turn_params.listener.addrs_number-1]=strdup(sbaddr);
    +		turn_params.listener.encaddrs = (ioa_addr**)realloc(turn_params.listener.encaddrs, sizeof(ioa_addr*)*turn_params.listener.addrs_number);
    +		turn_params.listener.encaddrs[turn_params.listener.addrs_number-1]=(ioa_addr*)malloc(sizeof(ioa_addr));
     		addr_cpy(turn_params.listener.encaddrs[turn_params.listener.addrs_number-1],&baddr);
     		TURN_LOG_FUNC(TURN_LOG_LEVEL_INFO, "Listener address to use: %s\n",sbaddr);
     	}
     }
     
     int add_relay_addr(const char* addr) {
     	ioa_addr baddr;
    -	if(make_ioa_addr((const u08bits*)addr,0,&baddr)<0) {
    +	if(make_ioa_addr((const uint8_t*)addr,0,&baddr)<0) {
     		TURN_LOG_FUNC(TURN_LOG_LEVEL_ERROR,"Cannot add a relay address: %s\n",addr);
     		return -1;
     	} else {
     
     		char sbaddr[129];
    -		addr_to_string_no_port(&baddr,(u08bits*)sbaddr);
    +		addr_to_string_no_port(&baddr,(uint8_t*)sbaddr);
     
     		size_t i = 0;
     		for(i=0;i<turn_params.relays_number;++i) {
    @@ -399,8 +399,8 @@ int add_relay_addr(const char* addr) {
     		}
     
     		++turn_params.relays_number;
    -		turn_params.relay_addrs = (char**)turn_realloc(turn_params.relay_addrs, 0, sizeof(char*)*turn_params.relays_number);
    -		turn_params.relay_addrs[turn_params.relays_number-1]=turn_strdup(sbaddr);
    +		turn_params.relay_addrs = (char**)realloc(turn_params.relay_addrs, sizeof(char*)*turn_params.relays_number);
    +		turn_params.relay_addrs[turn_params.relays_number-1]=strdup(sbaddr);
     
     		TURN_LOG_FUNC(TURN_LOG_LEVEL_INFO, "Relay address to use: %s\n",sbaddr);
     		return 1;
    @@ -412,7 +412,7 @@ static void allocate_relay_addrs_ports(void) {
     	TURN_LOG_FUNC(TURN_LOG_LEVEL_INFO, "Wait for relay ports initialization...\n");
     	for(i=0;i<(int)turn_params.relays_number;i++) {
     		ioa_addr baddr;
    -		if(make_ioa_addr((const u08bits*)turn_params.relay_addrs[i],0,&baddr)>=0) {
    +		if(make_ioa_addr((const uint8_t*)turn_params.relay_addrs[i],0,&baddr)>=0) {
     			TURN_LOG_FUNC(TURN_LOG_LEVEL_INFO, "  relay %s initialization...\n",turn_params.relay_addrs[i]);
     			turnipports_add_ip(STUN_ATTRIBUTE_TRANSPORT_UDP_VALUE, &baddr);
     			turnipports_add_ip(STUN_ATTRIBUTE_TRANSPORT_TCP_VALUE, &baddr);
    @@ -464,7 +464,7 @@ static void auth_server_receive_message(struct bufferevent *bev, void *ptr)
           if(get_user_key(am.in_oauth,&(am.out_oauth),&(am.max_session_time),am.username,am.realm,key,am.in_buffer.nbh)<0) {
         	  am.success = 0;
           } else {
    -    	  ns_bcopy(key,am.key,sizeof(hmackey_t));
    +    	  bcopy(key,am.key,sizeof(hmackey_t));
         	  am.success = 1;
           }
         }
    @@ -560,14 +560,14 @@ static int send_socket_to_general_relay(ioa_engine_handle e, struct message_to_r
     	return 0;
     }
     
    -static int send_socket_to_relay(turnserver_id id, u64bits cid, stun_tid *tid, ioa_socket_handle s, 
    +static int send_socket_to_relay(turnserver_id id, uint64_t cid, stun_tid *tid, ioa_socket_handle s, 
     				int message_integrity, MESSAGE_TO_RELAY_TYPE rmt, ioa_net_data *nd,
     				int can_resume)
     {
     	int ret = -1;
     
     	struct message_to_relay sm;
    -	ns_bzero(&sm,sizeof(struct message_to_relay));
    +	bzero(&sm,sizeof(struct message_to_relay));
     	sm.t = rmt;
     
     	ioa_socket_handle s_to_delete = s;
    @@ -698,7 +698,7 @@ int send_session_cancellation_to_relay(turnsession_id sid)
     	int ret = 0;
     
     	struct message_to_relay sm;
    -	ns_bzero(&sm,sizeof(struct message_to_relay));
    +	bzero(&sm,sizeof(struct message_to_relay));
     	sm.t = RMT_CANCEL_SESSION;
     
     	turnserver_id id = (turnserver_id)(sid / TURN_SESSION_ID_FACTOR);
    @@ -914,7 +914,7 @@ static int send_message_from_listener_to_client(ioa_engine_handle e, ioa_network
     	addr_cpy(&(mm.m.tc.destination),destination);
     	mm.m.tc.nbh = ioa_network_buffer_allocate(e);
     	ioa_network_buffer_header_init(mm.m.tc.nbh);
    -	ns_bcopy(ioa_network_buffer_data(nbh),ioa_network_buffer_data(mm.m.tc.nbh),ioa_network_buffer_get_size(nbh));
    +	bcopy(ioa_network_buffer_data(nbh),ioa_network_buffer_data(mm.m.tc.nbh),ioa_network_buffer_get_size(nbh));
     	ioa_network_buffer_set_size(mm.m.tc.nbh,ioa_network_buffer_get_size(nbh));
     
     	struct evbuffer *output = bufferevent_get_output(turn_params.listener.out_buf);
    @@ -996,7 +996,7 @@ static void listener_receive_message(struct bufferevent *bev, void *ptr)
     		}
     
     		if(!found) {
    -			u08bits saddr[129];
    +			uint8_t saddr[129];
     			addr_to_string(&mm.m.tc.origin, saddr);
     			TURN_LOG_FUNC(TURN_LOG_LEVEL_ERROR,"%s: Cannot find local source %s\n",__FUNCTION__,saddr);
     		}
    @@ -1205,7 +1205,7 @@ static void setup_socket_per_endpoint_udp_listener_servers(void)
     			char saddr[129];
     			addr_cpy(&addr,&turn_params.aux_servers_list.addrs[i]);
     			int port = (int)addr_get_port(&addr);
    -			addr_to_string_no_port(&addr,(u08bits*)saddr);
    +			addr_to_string_no_port(&addr,(uint8_t*)saddr);
     
     			turn_params.listener.aux_udp_services[index] = (dtls_listener_relay_server_type**)allocate_super_memory_engine(udp_relay_servers[udp_relay_server_index]->ioa_eng, sizeof(dtls_listener_relay_server_type*));
     			turn_params.listener.aux_udp_services[index][0] = create_dtls_listener_server(turn_params.listener_ifname, saddr, port, turn_params.verbose, udp_relay_servers[udp_relay_server_index]->ioa_eng, &(udp_relay_servers[udp_relay_server_index]->server), 1, NULL);
    @@ -1324,7 +1324,7 @@ static void setup_socket_per_thread_udp_listener_servers(void)
     			char saddr[129];
     			addr_cpy(&addr,&turn_params.aux_servers_list.addrs[i]);
     			int port = (int)addr_get_port(&addr);
    -			addr_to_string_no_port(&addr,(u08bits*)saddr);
    +			addr_to_string_no_port(&addr,(uint8_t*)saddr);
     
     			turn_params.listener.aux_udp_services[index] = (dtls_listener_relay_server_type**)allocate_super_memory_engine(turn_params.listener.ioa_eng, sizeof(dtls_listener_relay_server_type*) * get_real_general_relay_servers_number());
     
    @@ -1405,7 +1405,7 @@ static void setup_socket_per_session_udp_listener_servers(void)
     			char saddr[129];
     			addr_cpy(&addr,&turn_params.aux_servers_list.addrs[i]);
     			int port = (int)addr_get_port(&addr);
    -			addr_to_string_no_port(&addr,(u08bits*)saddr);
    +			addr_to_string_no_port(&addr,(uint8_t*)saddr);
     
     			turn_params.listener.aux_udp_services[index] = (dtls_listener_relay_server_type**)allocate_super_memory_engine(turn_params.listener.ioa_eng, sizeof(dtls_listener_relay_server_type*));
     
    @@ -1473,15 +1473,15 @@ static void setup_tcp_listener_servers(ioa_engine_handle e, struct relay_server
     	/* Create listeners */
     
     	/* Aux TCP servers */
    -	if(!turn_params.no_tls || !turn_params.no_tcp) {
    +	if(!turn_params.tcp_use_proxy && (!turn_params.no_tls || !turn_params.no_tcp)) {
     
     		for(i=0; i<turn_params.aux_servers_list.size; i++) {
     
     			ioa_addr addr;
     			char saddr[129];
     			addr_cpy(&addr,&turn_params.aux_servers_list.addrs[i]);
     			int port = (int)addr_get_port(&addr);
    -			addr_to_string_no_port(&addr,(u08bits*)saddr);
    +			addr_to_string_no_port(&addr,(uint8_t*)saddr);
     
     			aux_tcp_services[i] = create_tls_listener_server(turn_params.listener_ifname, saddr, port, turn_params.verbose, e, send_socket_to_general_relay, relay_server);
     		}
    @@ -1494,15 +1494,15 @@ static void setup_tcp_listener_servers(ioa_engine_handle e, struct relay_server
     
     		/* TCP: */
     		if(!turn_params.no_tcp) {
    -			tcp_services[index] = create_tls_listener_server(turn_params.listener_ifname, turn_params.listener.addrs[i], turn_params.listener_port, turn_params.verbose, e, send_socket_to_general_relay, relay_server);
    +			tcp_services[index] = create_tls_listener_server(turn_params.listener_ifname, turn_params.listener.addrs[i], turn_params.tcp_use_proxy?turn_params.tcp_proxy_port:turn_params.listener_port, turn_params.verbose, e, send_socket_to_general_relay, relay_server);
     			if(turn_params.rfc5780)
    -				tcp_services[index+1] = create_tls_listener_server(turn_params.listener_ifname, turn_params.listener.addrs[i], get_alt_listener_port(), turn_params.verbose, e, send_socket_to_general_relay, relay_server);
    +				tcp_services[index+1] = turn_params.tcp_use_proxy?NULL:create_tls_listener_server(turn_params.listener_ifname, turn_params.listener.addrs[i], get_alt_listener_port(), turn_params.verbose, e, send_socket_to_general_relay, relay_server);
     		} else {
     			tcp_services[index] = NULL;
     			if(turn_params.rfc5780)
     				tcp_services[index+1] = NULL;
     		}
    -		if(!turn_params.no_tls && (turn_params.no_tcp || (turn_params.listener_port != turn_params.tls_listener_port))) {
    +		if(!turn_params.no_tls && !turn_params.tcp_use_proxy && (turn_params.no_tcp || (turn_params.listener_port != turn_params.tls_listener_port))) {
     			tls_services[index] = create_tls_listener_server(turn_params.listener_ifname, turn_params.listener.addrs[i], turn_params.tls_listener_port, turn_params.verbose, e, send_socket_to_general_relay, relay_server);
     			if(turn_params.rfc5780)
     				tls_services[index+1] = create_tls_listener_server(turn_params.listener_ifname, turn_params.listener.addrs[i], get_alt_tls_listener_port(), turn_params.verbose, e, send_socket_to_general_relay, relay_server);
    @@ -1599,9 +1599,6 @@ void run_listener_server(struct listener_server *ls)
     		run_events(ls->event_base, ls->ioa_eng);
     
     		rollover_logfile();
    -
    -		tm_print();
    -
     	}
     }
     
    @@ -1654,7 +1651,7 @@ static void setup_relay_server(struct relay_server *rs, ioa_engine_handle e, int
     			 &turn_params.permission_lifetime,
     			 &turn_params.stun_only,
     			 &turn_params.no_stun,
    -			 &turn_params.prod,
    +			 &turn_params.no_software_attribute,
     			 &turn_params.web_admin_listen_on_workers,
     			 &turn_params.alternate_servers_list,
     			 &turn_params.tls_alternate_servers_list,
    @@ -1757,7 +1754,7 @@ static void* run_auth_server_thread(void *arg)
     
     	} else {
     
    -		ns_bzero(as,sizeof(struct auth_server));
    +		bzero(as,sizeof(struct auth_server));
     
     		as->id = id;
     
    @@ -1779,7 +1776,10 @@ static void* run_auth_server_thread(void *arg)
     		barrier_wait();
     
     		while(run_auth_server_flag) {
    -			auth_ping(as->rch);
    +			if (!turn_params.no_auth_pings) {
    +				auth_ping(as->rch);
    +			}
    +
     			run_events(as->event_base,NULL);
     		}
     	}
    @@ -1815,7 +1815,7 @@ static void* run_admin_server_thread(void *arg)
     
     static void setup_admin_server(void)
     {
    -	ns_bzero(&adminserver,sizeof(struct admin_server));
    +	bzero(&adminserver,sizeof(struct admin_server));
     	adminserver.listen_fd = -1;
     	adminserver.verbose = turn_params.verbose;
     
    @@ -1900,7 +1900,7 @@ void setup_server(void)
     
     void init_listener(void)
     {
    -	ns_bzero(&turn_params.listener,sizeof(struct listener_server));
    +	bzero(&turn_params.listener,sizeof(struct listener_server));
     }
     
     ///////////////////////////////
    
  • src/apps/relay/ns_ioalib_engine_impl.c+222 120 modified
    @@ -202,8 +202,8 @@ static void log_socket_event(ioa_socket_handle s, const char *msg, int error) {
     		{
     			char sraddr[129]="\0";
     			char sladdr[129]="\0";
    -			addr_to_string(&(s->remote_addr),(u08bits*)sraddr);
    -			addr_to_string(&(s->local_addr),(u08bits*)sladdr);
    +			addr_to_string(&(s->remote_addr),(uint8_t*)sraddr);
    +			addr_to_string(&(s->local_addr),(uint8_t*)sladdr);
     
     			if(EVUTIL_SOCKET_ERROR()) {
     				TURN_LOG_FUNC(ll,"session %018llu: %s: %s (local %s, remote %s)\n",(unsigned long long)id,
    @@ -281,7 +281,7 @@ static void pop_elem_from_buffer_list(stun_buffer_list *bufs)
     		stun_buffer_list_elem *ret = bufs->head;
     		bufs->head=ret->next;
     		--bufs->tsz;
    -		turn_free(ret,sizeof(stun_buffer_list_elem));
    +		free(ret);
     	}
     }
     
    @@ -292,11 +292,15 @@ static stun_buffer_list_elem *new_blist_elem(ioa_engine_handle e)
     	stun_buffer_list_elem *ret = get_elem_from_buffer_list(&(e->bufs));
     
     	if(!ret) {
    -	  ret = (stun_buffer_list_elem *)turn_malloc(sizeof(stun_buffer_list_elem));
    -	  ret->buf.len = 0;
    -	  ret->buf.offset = 0;
    -	  ret->buf.coffset = 0;
    +	  ret = (stun_buffer_list_elem *)malloc(sizeof(stun_buffer_list_elem));
     	  ret->next = NULL;
    +	  if (!ret) {
    +		TURN_LOG_FUNC(TURN_LOG_LEVEL_ERROR, "%s: Cannot allocate memory for STUN buffer!\n", __FUNCTION__);
    +	  }
    +	}
    +
    +	if(ret) {
    +	  bzero(&ret->buf, sizeof(stun_buffer));
     	}
     
     	return ret;
    @@ -309,11 +313,11 @@ static inline void add_elem_to_buffer_list(stun_buffer_list *bufs, stun_buffer_l
     	bufs->tsz += 1;
     }
     
    -static void add_buffer_to_buffer_list(stun_buffer_list *bufs, s08bits *buf, size_t len)
    +static void add_buffer_to_buffer_list(stun_buffer_list *bufs, char *buf, size_t len)
     {
     	if(bufs && buf && (bufs->tsz<MAX_SOCKET_BUFFER_BACKLOG)) {
    -	  stun_buffer_list_elem *buf_elem = (stun_buffer_list_elem *)turn_malloc(sizeof(stun_buffer_list_elem));
    -	  ns_bcopy(buf,buf_elem->buf.buf,len);
    +	  stun_buffer_list_elem *buf_elem = (stun_buffer_list_elem *)malloc(sizeof(stun_buffer_list_elem));
    +	  bcopy(buf,buf_elem->buf.buf,len);
     	  buf_elem->buf.len = len;
     	  buf_elem->buf.offset = 0;
     	  buf_elem->buf.coffset = 0;
    @@ -327,7 +331,7 @@ static void free_blist_elem(ioa_engine_handle e, stun_buffer_list_elem *buf_elem
     		if(e && (e->bufs.tsz<MAX_BUFFER_QUEUE_SIZE_PER_ENGINE)) {
     			add_elem_to_buffer_list(&(e->bufs), buf_elem);
     		} else {
    -			turn_free(buf_elem,sizeof(stun_buffer_list_elem));
    +			free(buf_elem);
     		}
     	}
     }
    @@ -345,8 +349,8 @@ static void timer_handler(ioa_engine_handle e, void* arg) {
     }
     
     ioa_engine_handle create_ioa_engine(super_memory_t *sm,
    -				struct event_base *eb, turnipports *tp, const s08bits* relay_ifname,
    -				size_t relays_number, s08bits **relay_addrs, int default_relays,
    +				struct event_base *eb, turnipports *tp, const char* relay_ifname,
    +				size_t relays_number, char **relay_addrs, int default_relays,
     				int verbose
     #if !defined(TURN_NO_HIREDIS)
     				,const char* redis_report_connection_string
    @@ -410,7 +414,7 @@ ioa_engine_handle create_ioa_engine(super_memory_t *sm,
     					TURN_LOG_FUNC(TURN_LOG_LEVEL_ERROR,"FATAL: cannot create preferable timeval for %d secs (%d number)\n",predef_timer_intervals[t],t);
     					exit(-1);
     				} else {
    -					ns_bcopy(ptv,&(e->predef_timers[t]),sizeof(struct timeval));
    +					bcopy(ptv,&(e->predef_timers[t]),sizeof(struct timeval));
     					e->predef_timer_intervals[t] = predef_timer_intervals[t];
     				}
     			}
    @@ -423,7 +427,7 @@ ioa_engine_handle create_ioa_engine(super_memory_t *sm,
     			size_t i = 0;
     			e->relay_addrs = (ioa_addr*)allocate_super_memory_region(sm, relays_number * sizeof(ioa_addr)+8);
     			for (i = 0; i < relays_number; i++) {
    -				if(make_ioa_addr((u08bits*) relay_addrs[i], 0, &(e->relay_addrs[i]))<0) {
    +				if(make_ioa_addr((uint8_t*) relay_addrs[i], 0, &(e->relay_addrs[i]))<0) {
     					TURN_LOG_FUNC(TURN_LOG_LEVEL_ERROR,"Cannot add a relay address: %s\n",relay_addrs[i]);
     				}
     			}
    @@ -543,13 +547,13 @@ static void timer_event_handler(evutil_socket_t fd, short what, void* arg)
     	cb(e, ctx);
     }
     
    -ioa_timer_handle set_ioa_timer(ioa_engine_handle e, int secs, int ms, ioa_timer_event_handler cb, void* ctx, int persist, const s08bits *txt)
    +ioa_timer_handle set_ioa_timer(ioa_engine_handle e, int secs, int ms, ioa_timer_event_handler cb, void* ctx, int persist, const char *txt)
     {
     	ioa_timer_handle ret = NULL;
     
     	if (e && cb && secs > 0) {
     
    -		timer_event * te = (timer_event*) turn_malloc(sizeof(timer_event));
    +		timer_event * te = (timer_event*) malloc(sizeof(timer_event));
     		int flags = EV_TIMEOUT;
     		if (persist)
     			flags |= EV_PERSIST;
    @@ -562,7 +566,7 @@ ioa_timer_handle set_ioa_timer(ioa_engine_handle e, int secs, int ms, ioa_timer_
     		te->e = e;
     		te->ev = ev;
     		te->cb = cb;
    -		te->txt = turn_strdup(txt);
    +		te->txt = strdup(txt);
     
     		if(!ms) {
     			tv.tv_usec = 0;
    @@ -603,10 +607,10 @@ void delete_ioa_timer(ioa_timer_handle th)
     		stop_ioa_timer(th);
     		timer_event *te = (timer_event *)th;
     		if(te->txt) {
    -			turn_free(te->txt,strlen(te->txt)+1);
    +			free(te->txt);
     			te->txt = NULL;
     		}
    -		turn_free(th,sizeof(timer_event));
    +		free(th);
     	}
     }
     
    @@ -628,9 +632,9 @@ int ioa_socket_check_bandwidth(ioa_socket_handle s, ioa_network_buffer_handle nb
     		struct traffic_bytes *traffic = &(s->data_traffic);
     
     		if(s->sat == CLIENT_SOCKET) {
    -			u08bits *buf = ioa_network_buffer_data(nbh);
    +			uint8_t *buf = ioa_network_buffer_data(nbh);
     			if(stun_is_command_message_str(buf,sz)) {
    -				u16bits method = stun_get_method_str(buf,sz);
    +				uint16_t method = stun_get_method_str(buf,sz);
     				if((method != STUN_METHOD_SEND) && (method != STUN_METHOD_DATA)) {
     					traffic = &(s->control_traffic);
     				}
    @@ -675,7 +679,7 @@ int ioa_socket_check_bandwidth(ioa_socket_handle s, ioa_network_buffer_handle nb
     	return 1;
     }
     
    -int get_ioa_socket_from_reservation(ioa_engine_handle e, u64bits in_reservation_token, ioa_socket_handle *s)
    +int get_ioa_socket_from_reservation(ioa_engine_handle e, uint64_t in_reservation_token, ioa_socket_handle *s)
     {
       if (e && in_reservation_token && s) {
         *s = rtcp_map_get(e->map_rtcp, in_reservation_token);
    @@ -903,8 +907,8 @@ ioa_socket_handle create_unbound_relay_ioa_socket(ioa_engine_handle e, int famil
     		return NULL;
     	}
     
    -	ret = (ioa_socket*)turn_malloc(sizeof(ioa_socket));
    -	ns_bzero(ret,sizeof(ioa_socket));
    +	ret = (ioa_socket*)malloc(sizeof(ioa_socket));
    +	bzero(ret,sizeof(ioa_socket));
     
     	ret->magic = SOCKET_MAGIC;
     
    @@ -948,10 +952,10 @@ static int bind_ioa_socket(ioa_socket_handle s, const ioa_addr* local_addr, int
     
     int create_relay_ioa_sockets(ioa_engine_handle e,
     				ioa_socket_handle client_s,
    -				int address_family, u08bits transport,
    +				int address_family, uint8_t transport,
     				int even_port, ioa_socket_handle *rtp_s,
     				ioa_socket_handle *rtcp_s, uint64_t *out_reservation_token,
    -				int *err_code, const u08bits **reason,
    +				int *err_code, const uint8_t **reason,
     				accept_cb acb, void *acbarg)
     {
     
    @@ -972,7 +976,7 @@ int create_relay_ioa_sockets(ioa_engine_handle e,
     
     		if(*err_code) {
     			if(*err_code == 440)
    -				*reason = (const u08bits *) "Unsupported address family";
    +				*reason = (const uint8_t *) "Unsupported address family";
     			return -1;
     		}
     
    @@ -1129,7 +1133,7 @@ static void tcp_listener_input_handler(struct evconnlistener *l, evutil_socket_t
     	ioa_socket_handle list_s = (ioa_socket_handle) arg;
     
     	ioa_addr client_addr;
    -	ns_bcopy(sa,&client_addr,socklen);
    +	bcopy(sa,&client_addr,socklen);
     
     	addr_debug_print(((list_s->e) && list_s->e->verbose), &client_addr,"tcp accepted from");
     
    @@ -1245,7 +1249,6 @@ ioa_socket_handle ioa_create_connecting_tcp_relay_socket(ioa_socket_handle s, io
     	ret->conn_bev = bufferevent_socket_new(ret->e->event_base,
     					ret->fd,
     					TURN_BUFFEREVENTS_OPTIONS);
    -	debug_ptr_add(ret->conn_bev);
     	bufferevent_setcb(ret->conn_bev, NULL, NULL, connect_eventcb, ret);
     
     	ret->conn_arg = arg;
    @@ -1348,8 +1351,8 @@ ioa_socket_handle create_ioa_socket_from_fd(ioa_engine_handle e,
     		return NULL;
     	}
     
    -	ret = (ioa_socket*)turn_malloc(sizeof(ioa_socket));
    -	ns_bzero(ret,sizeof(ioa_socket));
    +	ret = (ioa_socket*)malloc(sizeof(ioa_socket));
    +	bzero(ret,sizeof(ioa_socket));
     
     	ret->magic = SOCKET_MAGIC;
     
    @@ -1470,7 +1473,7 @@ static void close_socket_net_data(ioa_socket_handle s)
     					log_socket_event(s, "SSL shutdown received, socket to be closed",0);
     				}
     			}
    -			SSL_FREE(s->ssl);
    +			SSL_free(s->ssl);
     		}
     
     		if (s->fd >= 0) {
    @@ -1529,7 +1532,7 @@ void close_ioa_socket(ioa_socket_handle s)
     		}
     
     		if(s->special_session) {
    -			turn_free(s->special_session,s->special_session_size);
    +			free(s->special_session);
     			s->special_session = NULL;
     		}
     		s->special_session_size = 0;
    @@ -1543,7 +1546,7 @@ void close_ioa_socket(ioa_socket_handle s)
     		s->sub_session = NULL;
     		s->magic = 0;
     
    -		turn_free(s,sizeof(ioa_socket));
    +		free(s);
     	}
     }
     
    @@ -1613,15 +1616,15 @@ ioa_socket_handle detach_ioa_socket(ioa_socket_handle s)
     
     		ioa_network_buffer_delete(s->e, s->defer_nbh);
     
    -		ret = (ioa_socket*)turn_malloc(sizeof(ioa_socket));
    +		ret = (ioa_socket*)malloc(sizeof(ioa_socket));
     		if(!ret) {
     			TURN_LOG_FUNC(TURN_LOG_LEVEL_ERROR,"%s: Cannot allocate new socket structure\n",__FUNCTION__);
     			if(udp_fd>=0)
     				close(udp_fd);
     			return ret;
     		}
     
    -		ns_bzero(ret,sizeof(ioa_socket));
    +		bzero(ret,sizeof(ioa_socket));
     
     		ret->magic = SOCKET_MAGIC;
     
    @@ -1801,14 +1804,14 @@ int ssl_read(evutil_socket_t fd, SSL* ssl, ioa_network_buffer_handle nbh, int ve
     	if (!ssl || !nbh)
     		return -1;
     
    -	s08bits* buffer = (s08bits*)ioa_network_buffer_data(nbh);
    +	char* buffer = (char*)ioa_network_buffer_data(nbh);
     	int buf_size = (int)ioa_network_buffer_get_capacity_udp();
     	int read_len = (int)ioa_network_buffer_get_size(nbh);
     
     	if(read_len < 1)
     		return -1;
     
    -	s08bits *new_buffer = buffer + buf_size;
    +	char *new_buffer = buffer + buf_size;
     	int old_buffer_len = read_len;
     
     	int len = 0;
    @@ -1901,7 +1904,7 @@ int ssl_read(evutil_socket_t fd, SSL* ssl, ioa_network_buffer_handle nbh, int ve
     			case SSL_ERROR_SSL:
     				if (verbose) {
     					TURN_LOG_FUNC(TURN_LOG_LEVEL_INFO, "SSL read error: ");
    -					s08bits buf[65536];
    +					char buf[65536];
     					TURN_LOG_FUNC(TURN_LOG_LEVEL_INFO, "%s (%d)\n", ERR_error_string(ERR_get_error(), buf), SSL_get_error(ssl, len));
     				}
     				if (verbose)
    @@ -1918,7 +1921,7 @@ int ssl_read(evutil_socket_t fd, SSL* ssl, ioa_network_buffer_handle nbh, int ve
     	}
     
     	if(ret>0) {
    -		ioa_network_buffer_add_offset_size(nbh, (u16bits)buf_size, 0, (size_t)ret);
    +		ioa_network_buffer_add_offset_size(nbh, (uint16_t)buf_size, 0, (size_t)ret);
     	}
     #if OPENSSL_VERSION_NUMBER < 0x10100000L
     	ssl->rbio = NULL;
    @@ -1937,7 +1940,7 @@ static int socket_readerr(evutil_socket_t fd, ioa_addr *orig_addr)
     
     #if defined(CMSG_SPACE) && defined(MSG_ERRQUEUE) && defined(IP_RECVERR)
     
    -	u08bits ecmsg[TURN_CMSG_SZ+1];
    +	uint8_t ecmsg[TURN_CMSG_SZ+1];
     	int flags = MSG_ERRQUEUE;
     	int len = 0;
     
    @@ -1977,7 +1980,7 @@ static int socket_readerr(evutil_socket_t fd, ioa_addr *orig_addr)
     typedef unsigned char recv_ttl_t;
     typedef unsigned char recv_tos_t;
     
    -int udp_recvfrom(evutil_socket_t fd, ioa_addr* orig_addr, const ioa_addr *like_addr, s08bits* buffer, int buf_size, int *ttl, int *tos, s08bits *ecmsg, int flags, u32bits *errcode)
    +int udp_recvfrom(evutil_socket_t fd, ioa_addr* orig_addr, const ioa_addr *like_addr, char* buffer, int buf_size, int *ttl, int *tos, char *ecmsg, int flags, uint32_t *errcode)
     {
     	int len = 0;
     
    @@ -1996,7 +1999,7 @@ int udp_recvfrom(evutil_socket_t fd, ioa_addr* orig_addr, const ioa_addr *like_a
     	  len = recvfrom(fd, buffer, buf_size, flags, (struct sockaddr*) orig_addr, (socklen_t*) &slen);
     	} while (len < 0 && (errno == EINTR));
     	if(len<0 && errcode)
    -		*errcode = (u32bits)errno;
    +		*errcode = (uint32_t)errno;
     #else
     	struct msghdr msg;
     	struct iovec iov;
    @@ -2033,7 +2036,7 @@ int udp_recvfrom(evutil_socket_t fd, ioa_addr* orig_addr, const ioa_addr *like_a
     	if((len<0) && (!(flags & MSG_ERRQUEUE))) {
     		//Linux
     		int eflags = MSG_ERRQUEUE | MSG_DONTWAIT;
    -		u32bits errcode1 = 0;
    +		uint32_t errcode1 = 0;
     		udp_recvfrom(fd, orig_addr, like_addr, buffer, buf_size, ttl, tos, ecmsg, eflags, &errcode1);
     		//try again...
     		do {
    @@ -2158,6 +2161,67 @@ static TURN_TLS_TYPE check_tentative_tls(ioa_socket_raw fd)
     }
     #endif
     
    +static ssize_t socket_parse_proxy_v2(ioa_socket_handle s, uint8_t *buf, size_t len)
    +{
    +	if(len < 16){
    +		return 0 ;
    +	}
    +
    +	/* Check for proxy-v2 magic field */
    +	char magic[] = {0x0D, 0x0A, 0x0D, 0x0A, 0x00, 0x0D, 0x0A, 0x51, 0x55, 0x49, 0x54, 0x0A};
    +	if(memcmp(magic, buf, sizeof(magic))){
    +		return -1;
    +	}
    +
    +	/* Check version */
    +	uint8_t version = buf[12] >> 4;
    +	if(version != 2) return -1;
    +
    +	/* Read data */
    +	uint8_t command = buf[12] & 0xF;
    +	uint8_t family  = buf[13] >> 4;
    +	uint8_t proto   = buf[13] & 0xF;
    +	size_t plen   = ((size_t)buf[14] << 8) | buf[15];
    +
    +	size_t tlen = 16 + plen;
    +	if(len < tlen) return 0;
    +
    +	/* A local connection is used by the proxy itself and does not carry a valid address */
    +	if(command == 0) return tlen;
    +
    +	/* Accept only proxied TCP connections */
    +	if(command != 1 || proto != 1) return -1;
    +
    +	/* Read the address */
    +	if(family == 1 && plen >= 12){ /* IPv4 */
    +		struct sockaddr_in remote, local;
    +		remote.sin_family = local.sin_family = AF_INET;
    +		memcpy(&remote.sin_addr.s_addr, &buf[16], 4);
    +		memcpy(&local.sin_addr.s_addr,  &buf[20], 4);
    +		memcpy(&remote.sin_port, &buf[24], 2);
    +		memcpy(&local.sin_port,  &buf[26], 2);
    +
    +		addr_cpy4(&(s->local_addr),  &local);
    +		addr_cpy4(&(s->remote_addr), &remote);
    +
    +	}else if(family == 2 && plen >= 36){ /* IPv6 */
    +		struct sockaddr_in6 remote, local;
    +		remote.sin6_family = local.sin6_family = AF_INET6;
    +		memcpy(&remote.sin6_addr.s6_addr, &buf[16], 16);
    +		memcpy(&local.sin6_addr.s6_addr,  &buf[32], 16);
    +		memcpy(&remote.sin6_port, &buf[48], 2);
    +		memcpy(&local.sin6_port,  &buf[50], 2);
    +
    +		addr_cpy6(&(s->local_addr),  &local);
    +		addr_cpy6(&(s->remote_addr), &remote);
    +
    +        }else{
    +		return -1;
    +	}
    +
    +	return tlen;
    +}
    +
     static int socket_input_worker(ioa_socket_handle s)
     {
     	int len = 0;
    @@ -2240,25 +2304,25 @@ static int socket_input_worker(ioa_socket_handle s)
     #if TLSv1_2_SUPPORTED
     			case TURN_TLS_v1_2:
     				if(s->e->tls_ctx_v1_2) {
    -					set_socket_ssl(s,SSL_NEW(s->e->tls_ctx_v1_2));
    +					set_socket_ssl(s,SSL_new(s->e->tls_ctx_v1_2));
     				}
     				break;
     #endif
     #if TLSv1_1_SUPPORTED
     			case TURN_TLS_v1_1:
     				if(s->e->tls_ctx_v1_1) {
    -					set_socket_ssl(s,SSL_NEW(s->e->tls_ctx_v1_1));
    +					set_socket_ssl(s,SSL_new(s->e->tls_ctx_v1_1));
     				}
     				break;
     #endif
     			case TURN_TLS_v1_0:
     				if(s->e->tls_ctx_v1_0) {
    -					set_socket_ssl(s,SSL_NEW(s->e->tls_ctx_v1_0));
    +					set_socket_ssl(s,SSL_new(s->e->tls_ctx_v1_0));
     				}
     				break;
     			default:
     				if(s->e->tls_ctx_ssl23) {
    -					set_socket_ssl(s,SSL_NEW(s->e->tls_ctx_ssl23));
    +					set_socket_ssl(s,SSL_new(s->e->tls_ctx_ssl23));
     				} else {
     					s->tobeclosed = 1;
     					return 0;
    @@ -2270,7 +2334,6 @@ static int socket_input_worker(ioa_socket_handle s)
     								s->ssl,
     								BUFFEREVENT_SSL_ACCEPTING,
     								TURN_BUFFEREVENTS_OPTIONS);
    -				debug_ptr_add(s->bev);
     				bufferevent_setcb(s->bev, socket_input_handler_bev, socket_output_handler_bev,
     								eventcb_bev, s);
     				bufferevent_setwatermark(s->bev, EV_READ|EV_WRITE, 0, BUFFEREVENT_HIGH_WATERMARK);
    @@ -2286,7 +2349,6 @@ static int socket_input_worker(ioa_socket_handle s)
     			s->bev = bufferevent_socket_new(s->e->event_base,
     						s->fd,
     						TURN_BUFFEREVENTS_OPTIONS);
    -			debug_ptr_add(s->bev);
     			bufferevent_setcb(s->bev, socket_input_handler_bev, socket_output_handler_bev,
     				eventcb_bev, s);
     			bufferevent_setwatermark(s->bev, EV_READ|EV_WRITE, 0, BUFFEREVENT_HIGH_WATERMARK);
    @@ -2308,25 +2370,25 @@ static int socket_input_worker(ioa_socket_handle s)
     #if TLSv1_2_SUPPORTED
     			case TURN_TLS_v1_2:
     				if(s->e->tls_ctx_v1_2) {
    -					set_socket_ssl(s,SSL_NEW(s->e->tls_ctx_v1_2));
    +					set_socket_ssl(s,SSL_new(s->e->tls_ctx_v1_2));
     				}
     				break;
     #endif
     #if TLSv1_1_SUPPORTED
     			case TURN_TLS_v1_1:
     				if(s->e->tls_ctx_v1_1) {
    -					set_socket_ssl(s,SSL_NEW(s->e->tls_ctx_v1_1));
    +					set_socket_ssl(s,SSL_new(s->e->tls_ctx_v1_1));
     				}
     				break;
     #endif
     			case TURN_TLS_v1_0:
     				if(s->e->tls_ctx_v1_0) {
    -					set_socket_ssl(s,SSL_NEW(s->e->tls_ctx_v1_0));
    +					set_socket_ssl(s,SSL_new(s->e->tls_ctx_v1_0));
     				}
     				break;
     			default:
     				if(s->e->tls_ctx_ssl23) {
    -					set_socket_ssl(s,SSL_NEW(s->e->tls_ctx_ssl23));
    +					set_socket_ssl(s,SSL_new(s->e->tls_ctx_ssl23));
     				} else {
     					s->tobeclosed = 1;
     					return 0;
    @@ -2338,7 +2400,6 @@ static int socket_input_worker(ioa_socket_handle s)
     								s->ssl,
     								BUFFEREVENT_SSL_ACCEPTING,
     								TURN_BUFFEREVENTS_OPTIONS);
    -				debug_ptr_add(s->bev);
     				bufferevent_setcb(s->bev, socket_input_handler_bev, socket_output_handler_bev,
     								eventcb_bev, s);
     				bufferevent_setwatermark(s->bev, EV_READ|EV_WRITE, 0, BUFFEREVENT_HIGH_WATERMARK);
    @@ -2354,7 +2415,6 @@ static int socket_input_worker(ioa_socket_handle s)
     			s->bev = bufferevent_socket_new(s->e->event_base,
     						s->fd,
     						TURN_BUFFEREVENTS_OPTIONS);
    -			debug_ptr_add(s->bev);
     			bufferevent_setcb(s->bev, socket_input_handler_bev, socket_output_handler_bev,
     				eventcb_bev, s);
     			bufferevent_setwatermark(s->bev, EV_READ|EV_WRITE, 0, BUFFEREVENT_HIGH_WATERMARK);
    @@ -2377,39 +2437,57 @@ static int socket_input_worker(ioa_socket_handle s)
     		struct evbuffer *inbuf = bufferevent_get_input(s->bev);
     		if(inbuf) {
     			ev_ssize_t blen = evbuffer_copyout(inbuf, buf_elem->buf.buf, STUN_BUFFER_SIZE);
    +
     			if(blen>0) {
     				int mlen = 0;
     
     				if(blen>(ev_ssize_t)STUN_BUFFER_SIZE)
     				  blen=(ev_ssize_t)STUN_BUFFER_SIZE;
     
    -				if(is_stream_socket(s->st) && ((s->sat == TCP_CLIENT_DATA_SOCKET)||(s->sat==TCP_RELAY_DATA_SOCKET))) {
    -					mlen = blen;
    -				} else {
    -					mlen = stun_get_message_len_str(buf_elem->buf.buf, blen, 1, &app_msg_len);
    -				}
    -
    -				if(mlen>0 && mlen<=(int)blen) {
    -					len = (int)bufferevent_read(s->bev, buf_elem->buf.buf, mlen);
    -					if(len < 0) {
    -						ret = -1;
    +				if(s->st == TCP_SOCKET_PROXY){
    +					ssize_t tlen = socket_parse_proxy_v2(s, buf_elem->buf.buf, blen);
    +					blen = 0;
    +					if (tlen < 0){
     						s->tobeclosed = 1;
     						s->broken = 1;
    -						log_socket_event(s, "socket read failed, to be closed",1);
    -					} else if((s->st == TLS_SOCKET)||(s->st == TLS_SCTP_SOCKET)) {
    -#if TLS_SUPPORTED
    -						SSL *ctx = bufferevent_openssl_get_ssl(s->bev);
    -						if(!ctx || SSL_get_shutdown(ctx)) {
    +						ret = -1;
    +						log_socket_event(s, "proxy protocol violated",1);
    +					}else if(tlen > 0){
    +						bufferevent_read(s->bev, buf_elem->buf.buf, tlen);
    +
    +						blen = evbuffer_copyout(inbuf, buf_elem->buf.buf, STUN_BUFFER_SIZE);
    +						s->st = TCP_SOCKET;
    +					}
    +				}
    +
    +				if(blen){
    +					if(is_stream_socket(s->st) && ((s->sat == TCP_CLIENT_DATA_SOCKET)||(s->sat==TCP_RELAY_DATA_SOCKET))) {
    +						mlen = blen;
    +					} else {
    +						mlen = stun_get_message_len_str(buf_elem->buf.buf, blen, 1, &app_msg_len);
    +					}
    +
    +					if(mlen>0 && mlen<=(int)blen) {
    +						len = (int)bufferevent_read(s->bev, buf_elem->buf.buf, mlen);
    +						if(len < 0) {
     							ret = -1;
     							s->tobeclosed = 1;
    -						}
    +							s->broken = 1;
    +							log_socket_event(s, "socket read failed, to be closed",1);
    +						} else if((s->st == TLS_SOCKET)||(s->st == TLS_SCTP_SOCKET)) {
    +#if TLS_SUPPORTED
    +							SSL *ctx = bufferevent_openssl_get_ssl(s->bev);
    +							if(!ctx || SSL_get_shutdown(ctx)) {
    +								ret = -1;
    +								s->tobeclosed = 1;
    +							}
     #endif
    -					}
    -					if(ret != -1) {
    -						ret = len;
    +						}
    +						if(ret != -1) {
    +							ret = len;
    +						}
     					}
     				}
    -
     			} else if(blen<0) {
     				s->tobeclosed = 1;
     				s->broken = 1;
    @@ -2426,7 +2504,7 @@ static int socket_input_worker(ioa_socket_handle s)
     		if(len == 0)
     			len = -1;
     	} else if(s->fd>=0){ /* UDP and DTLS */
    -		ret = udp_recvfrom(s->fd, &remote_addr, &(s->local_addr), (s08bits*)(buf_elem->buf.buf), UDP_STUN_BUFFER_SIZE, &ttl, &tos, s->e->cmsg, 0, NULL);
    +		ret = udp_recvfrom(s->fd, &remote_addr, &(s->local_addr), (char*)(buf_elem->buf.buf), UDP_STUN_BUFFER_SIZE, &ttl, &tos, s->e->cmsg, 0, NULL);
     		len = ret;
     		if(s->ssl && (len>0)) { /* DTLS */
     			send_ssl_backlog_buffers(s);
    @@ -2466,7 +2544,7 @@ static int socket_input_worker(ioa_socket_handle s)
     			if(s->read_cb) {
     				ioa_net_data nd;
     
    -				ns_bzero(&nd,sizeof(ioa_net_data));
    +				bzero(&nd,sizeof(ioa_net_data));
     				addr_cpy(&(nd.src_addr),&remote_addr);
     				nd.nbh = buf_elem;
     				nd.recv_ttl = ttl;
    @@ -2552,7 +2630,7 @@ void close_ioa_socket_after_processing_if_necessary(ioa_socket_handle s)
     	if (s && ioa_socket_tobeclosed(s)) {
     
     		if(s->special_session) {
    -			turn_free(s->special_session,s->special_session_size);
    +			free(s->special_session);
     			s->special_session = NULL;
     		}
     		s->special_session_size = 0;
    @@ -2738,14 +2816,14 @@ static void eventcb_bev(struct bufferevent *bev, short events, void *arg)
     			s->tobeclosed = 1;
     
     			if(s->special_session) {
    -				turn_free(s->special_session,s->special_session_size);
    +				free(s->special_session);
     				s->special_session = NULL;
     			}
     			s->special_session_size = 0;
     
     			if(!(s->session) && !(s->sub_session)) {
     				char sraddr[129]="\0";
    -				addr_to_string(&(s->remote_addr),(u08bits*)sraddr);
    +				addr_to_string(&(s->remote_addr),(uint8_t*)sraddr);
     				TURN_LOG_FUNC(TURN_LOG_LEVEL_INFO, "%s https server socket closed: 0x%lx, st=%d, sat=%d, remote addr=%s\n", __FUNCTION__,(long)s, get_ioa_socket_type(s), get_ioa_socket_app_type(s),sraddr);
     				IOA_CLOSE_SOCKET(s);
     				return;
    @@ -2772,7 +2850,7 @@ static void eventcb_bev(struct bufferevent *bev, short events, void *arg)
     
     						{
     							char sraddr[129]="\0";
    -							addr_to_string(&(s->remote_addr),(u08bits*)sraddr);
    +							addr_to_string(&(s->remote_addr),(uint8_t*)sraddr);
     							if (events & BEV_EVENT_EOF) {
     								if(server->verbose)
     								  TURN_LOG_FUNC(TURN_LOG_LEVEL_INFO,"session %018llu: %s socket closed remotely %s\n",
    @@ -2815,7 +2893,7 @@ static void eventcb_bev(struct bufferevent *bev, short events, void *arg)
     	}
     }
     
    -static int ssl_send(ioa_socket_handle s, const s08bits* buffer, int len, int verbose)
    +static int ssl_send(ioa_socket_handle s, const char* buffer, int len, int verbose)
     {
     
     	if (!s || !(s->ssl) || !buffer || (s->fd<0))
    @@ -2930,7 +3008,7 @@ static int ssl_send(ioa_socket_handle s, const s08bits* buffer, int len, int ver
     		case SSL_ERROR_SSL:
     			if (verbose) {
     				TURN_LOG_FUNC(TURN_LOG_LEVEL_INFO, "SSL write error: ");
    -				s08bits buf[65536];
    +				char buf[65536];
     				TURN_LOG_FUNC(TURN_LOG_LEVEL_INFO, "%s (%d)\n", ERR_error_string(ERR_get_error(), buf),
     								SSL_get_error(ssl, rc));
     			}
    @@ -2950,7 +3028,7 @@ static int send_ssl_backlog_buffers(ioa_socket_handle s)
     	if(s) {
     		stun_buffer_list_elem *buf_elem = s->bufs.head;
     		while(buf_elem) {
    -			int rc = ssl_send(s, (s08bits*)buf_elem->buf.buf + buf_elem->buf.offset - buf_elem->buf.coffset, (size_t)buf_elem->buf.len, ((s->e) && s->e->verbose));
    +			int rc = ssl_send(s, (char*)buf_elem->buf.buf + buf_elem->buf.offset - buf_elem->buf.coffset, (size_t)buf_elem->buf.len, ((s->e) && s->e->verbose));
     			if(rc<1)
     				break;
     			++ret;
    @@ -2981,7 +3059,7 @@ int would_block(void) {
     	return (errno == EAGAIN);
     }
     
    -int udp_send(ioa_socket_handle s, const ioa_addr* dest_addr, const s08bits* buffer, int len)
    +int udp_send(ioa_socket_handle s, const ioa_addr* dest_addr, const char* buffer, int len)
     {
     	int rc = 0;
     	evutil_socket_t fd = -1;
    @@ -3124,15 +3202,15 @@ int send_data_from_ioa_socket_nbh(ioa_socket_handle s, ioa_addr* dest_addr,
     						send_ssl_backlog_buffers(s);
     						ret = ssl_send(
     								s,
    -								(s08bits*) ioa_network_buffer_data(nbh),
    +								(char*) ioa_network_buffer_data(nbh),
     								ioa_network_buffer_get_size(nbh),
     								((s->e) && s->e->verbose));
     						if (ret < 0)
     							s->tobeclosed = 1;
     						else if (ret == 0)
     							add_buffer_to_buffer_list(
     									&(s->bufs),
    -									(s08bits*) ioa_network_buffer_data(nbh),
    +									(char*) ioa_network_buffer_data(nbh),
     									ioa_network_buffer_get_size(nbh));
     					} else if (s->fd >= 0) {
     
    @@ -3144,7 +3222,7 @@ int send_data_from_ioa_socket_nbh(ioa_socket_handle s, ioa_addr* dest_addr,
     
     						ret = udp_send(s,
     									dest_addr,
    -									(s08bits*) ioa_network_buffer_data(nbh),ioa_network_buffer_get_size(nbh));
    +									(char*) ioa_network_buffer_data(nbh),ioa_network_buffer_get_size(nbh));
     						if (ret < 0) {
     							s->tobeclosed = 1;
     #if defined(EADDRNOTAVAIL)
    @@ -3154,9 +3232,9 @@ int send_data_from_ioa_socket_nbh(ioa_socket_handle s, ioa_addr* dest_addr,
     #if defined(EADDRNOTAVAIL)
     							if(dest_addr && (perr==EADDRNOTAVAIL)) {
     							  char sfrom[129];
    -							  addr_to_string(&(s->local_addr), (u08bits*)sfrom);
    +							  addr_to_string(&(s->local_addr), (uint8_t*)sfrom);
     							  char sto[129];
    -							  addr_to_string(dest_addr, (u08bits*)sto);
    +							  addr_to_string(dest_addr, (uint8_t*)sto);
     							  TURN_LOG_FUNC(TURN_LOG_LEVEL_ERROR,
     									"%s: network error: address unreachable from %s to %s\n", 
     									__FUNCTION__,sfrom,sto);
    @@ -3282,6 +3360,7 @@ int register_callback_on_ioa_socket(ioa_engine_handle e, ioa_socket_handle s, in
     					break;
     				case SCTP_SOCKET:
     				case TCP_SOCKET:
    +				case TCP_SOCKET_PROXY:
     					if(s->bev) {
     						if(!clean_preexisting) {
     							TURN_LOG_FUNC(TURN_LOG_LEVEL_ERROR,
    @@ -3298,7 +3377,6 @@ int register_callback_on_ioa_socket(ioa_engine_handle e, ioa_socket_handle s, in
     						s->bev = bufferevent_socket_new(s->e->event_base,
     									s->fd,
     									TURN_BUFFEREVENTS_OPTIONS);
    -						debug_ptr_add(s->bev);
     						bufferevent_setcb(s->bev, socket_input_handler_bev, socket_output_handler_bev,
     										eventcb_bev, s);
     						bufferevent_setwatermark(s->bev, EV_READ|EV_WRITE, 0, BUFFEREVENT_HIGH_WATERMARK);
    @@ -3317,20 +3395,18 @@ int register_callback_on_ioa_socket(ioa_engine_handle e, ioa_socket_handle s, in
     #if TLS_SUPPORTED
     						if(!(s->ssl)) {
     							//??? how we can get to this point ???
    -							set_socket_ssl(s,SSL_NEW(e->tls_ctx_ssl23));
    +							set_socket_ssl(s,SSL_new(e->tls_ctx_ssl23));
     							s->bev = bufferevent_openssl_socket_new(s->e->event_base,
     											s->fd,
     											s->ssl,
     											BUFFEREVENT_SSL_ACCEPTING,
     											TURN_BUFFEREVENTS_OPTIONS);
    -							debug_ptr_add(s->bev);
     						} else {
     							s->bev = bufferevent_openssl_socket_new(s->e->event_base,
     											s->fd,
     											s->ssl,
     											BUFFEREVENT_SSL_OPEN,
     											TURN_BUFFEREVENTS_OPTIONS);
    -							debug_ptr_add(s->bev);
     						}
     						bufferevent_setcb(s->bev, socket_input_handler_bev, socket_output_handler_bev,
     							eventcb_bev, s);
    @@ -3414,7 +3490,7 @@ void ioa_network_buffer_header_init(ioa_network_buffer_handle nbh)
     	UNUSED_ARG(nbh);
     }
     
    -u08bits *ioa_network_buffer_data(ioa_network_buffer_handle nbh)
    +uint8_t *ioa_network_buffer_data(ioa_network_buffer_handle nbh)
     {
     	stun_buffer_list_elem *buf_elem = (stun_buffer_list_elem *)nbh;
     	return buf_elem->buf.buf + buf_elem->buf.offset - buf_elem->buf.coffset;
    @@ -3454,7 +3530,7 @@ void ioa_network_buffer_set_size(ioa_network_buffer_handle nbh, size_t len)
       buf_elem->buf.len=(size_t)len;
     }
     
    -void ioa_network_buffer_add_offset_size(ioa_network_buffer_handle nbh, u16bits offset, u08bits coffset, size_t len)
    +void ioa_network_buffer_add_offset_size(ioa_network_buffer_handle nbh, uint16_t offset, uint8_t coffset, size_t len)
     {
       stun_buffer_list_elem *buf_elem = (stun_buffer_list_elem *)nbh;
       buf_elem->buf.len=(size_t)len;
    @@ -3470,13 +3546,13 @@ void ioa_network_buffer_add_offset_size(ioa_network_buffer_handle nbh, u16bits o
       }
     }
     
    -u16bits ioa_network_buffer_get_offset(ioa_network_buffer_handle nbh)
    +uint16_t ioa_network_buffer_get_offset(ioa_network_buffer_handle nbh)
     {
       stun_buffer_list_elem *buf_elem = (stun_buffer_list_elem *)nbh;
       return buf_elem->buf.offset;
     }
     
    -u08bits ioa_network_buffer_get_coffset(ioa_network_buffer_handle nbh)
    +uint8_t ioa_network_buffer_get_coffset(ioa_network_buffer_handle nbh)
     {
       stun_buffer_list_elem *buf_elem = (stun_buffer_list_elem *)nbh;
       return buf_elem->buf.coffset;
    @@ -3570,6 +3646,13 @@ void turn_report_allocation_delete(void *a)
     						snprintf(key, sizeof(key), "turn/user/%s/allocation/%018llu/total_traffic", (char*)ss->username, (unsigned long long)ss->id);
     					}
     					send_message_to_redis(e->rch, "publish", key, "rcvp=%lu, rcvb=%lu, sentp=%lu, sentb=%lu", (unsigned long)(ss->t_received_packets), (unsigned long)(ss->t_received_bytes), (unsigned long)(ss->t_sent_packets), (unsigned long)(ss->t_sent_bytes));
    +					if (ss->realm_options.name[0]) {
    +						snprintf(key, sizeof(key), "turn/realm/%s/user/%s/allocation/%018llu/total_traffic/peer", ss->realm_options.name, (char*)ss->username, (unsigned long long)(ss->id));
    +					}
    +					else {
    +						snprintf(key, sizeof(key), "turn/user/%s/allocation/%018llu/total_traffic/peer", (char*)ss->username, (unsigned long long)(ss->id));
    +					}
    +					send_message_to_redis(e->rch, "publish", key, "rcvp=%lu, rcvb=%lu, sentp=%lu, sentb=%lu", (unsigned long)(ss->t_peer_received_packets), (unsigned long)(ss->t_peer_received_bytes), (unsigned long)(ss->t_peer_sent_packets), (unsigned long)(ss->t_peer_sent_bytes));
     				}
     #endif
     			}
    @@ -3584,9 +3667,10 @@ void turn_report_session_usage(void *session, int force_invalid)
     		turn_turnserver *server = (turn_turnserver*)ss->server;
     		if(server && (ss->received_packets || ss->sent_packets || force_invalid)) {
     			ioa_engine_handle e = turn_server_get_engine(server);
    -			if(((ss->received_packets+ss->sent_packets)&2047)==0 || force_invalid) {
    +			if(((ss->received_packets+ss->sent_packets+ss->peer_received_packets+ss->peer_sent_packets)&4095)==0 || force_invalid) {
     				if(e && e->verbose) {
     					TURN_LOG_FUNC(TURN_LOG_LEVEL_INFO,"session %018llu: usage: realm=<%s>, username=<%s>, rp=%lu, rb=%lu, sp=%lu, sb=%lu\n", (unsigned long long)(ss->id), (char*)ss->realm_options.name, (char*)ss->username, (unsigned long)(ss->received_packets), (unsigned long)(ss->received_bytes),(unsigned long)(ss->sent_packets),(unsigned long)(ss->sent_bytes));
    +					TURN_LOG_FUNC(TURN_LOG_LEVEL_INFO, "session %018llu: peer usage: realm=<%s>, username=<%s>, rp=%lu, rb=%lu, sp=%lu, sb=%lu\n", (unsigned long long)(ss->id), (char*)ss->realm_options.name, (char*)ss->username, (unsigned long)(ss->peer_received_packets), (unsigned long)(ss->peer_received_bytes), (unsigned long)(ss->peer_sent_packets), (unsigned long)(ss->peer_sent_bytes));
     				}
     #if !defined(TURN_NO_HIREDIS)
     				{
    @@ -3597,20 +3681,34 @@ void turn_report_session_usage(void *session, int force_invalid)
     						snprintf(key,sizeof(key),"turn/user/%s/allocation/%018llu/traffic",(char*)ss->username, (unsigned long long)(ss->id));
     					}
     					send_message_to_redis(e->rch, "publish", key, "rcvp=%lu, rcvb=%lu, sentp=%lu, sentb=%lu",(unsigned long)(ss->received_packets), (unsigned long)(ss->received_bytes),(unsigned long)(ss->sent_packets),(unsigned long)(ss->sent_bytes));
    +					if (ss->realm_options.name[0]) {
    +						snprintf(key, sizeof(key), "turn/realm/%s/user/%s/allocation/%018llu/traffic/peer", ss->realm_options.name, (char*)ss->username, (unsigned long long)(ss->id));
    +					}
    +					else {
    +						snprintf(key, sizeof(key), "turn/user/%s/allocation/%018llu/traffic/peer", (char*)ss->username, (unsigned long long)(ss->id));
    +					}
    +					send_message_to_redis(e->rch, "publish", key, "rcvp=%lu, rcvb=%lu, sentp=%lu, sentb=%lu", (unsigned long)(ss->peer_received_packets), (unsigned long)(ss->peer_received_bytes), (unsigned long)(ss->peer_sent_packets), (unsigned long)(ss->peer_sent_bytes));
     				}
     #endif
     				ss->t_received_packets += ss->received_packets;
     				ss->t_received_bytes += ss->received_bytes;
     				ss->t_sent_packets += ss->sent_packets;
     				ss->t_sent_bytes += ss->sent_bytes;
    +				ss->t_peer_received_packets += ss->peer_received_packets;
    +				ss->t_peer_received_bytes += ss->peer_received_bytes;
    +				ss->t_peer_sent_packets += ss->peer_sent_packets;
    +				ss->t_peer_sent_bytes += ss->peer_sent_bytes;
     
     				{
     					turn_time_t ct = get_turn_server_time(server);
     					if(ct != ss->start_time) {
     						ct = ct - ss->start_time;
    -						ss->received_rate = (u32bits)(ss->t_received_bytes / ct);
    -						ss->sent_rate = (u32bits)(ss->t_sent_bytes / ct);
    +						ss->received_rate = (uint32_t)(ss->t_received_bytes / ct);
    +						ss->sent_rate = (uint32_t)(ss->t_sent_bytes / ct);
     						ss->total_rate = ss->received_rate + ss->sent_rate;
    +						ss->peer_received_rate = (uint32_t)(ss->t_peer_received_bytes / ct);
    +						ss->peer_sent_rate = (uint32_t)(ss->t_peer_sent_bytes / ct);
    +						ss->peer_total_rate = ss->peer_received_rate + ss->peer_sent_rate;
     					}
     				}
     
    @@ -3620,6 +3718,10 @@ void turn_report_session_usage(void *session, int force_invalid)
     				ss->received_bytes=0;
     				ss->sent_packets=0;
     				ss->sent_bytes=0;
    +				ss->peer_received_packets = 0;
    +				ss->peer_received_bytes = 0;
    +				ss->peer_sent_packets = 0;
    +				ss->peer_sent_bytes = 0;
     			}
     		}
     	}
    @@ -3652,26 +3754,26 @@ struct _super_memory {
     	size_t *sm_allocated;
     	size_t sm_total_sz;
     	size_t sm_chunk;
    -	u32bits id;
    +	uint32_t id;
     };
     
     static void init_super_memory_region(super_memory_t *r)
     {
     	if(r) {
    -		ns_bzero(r,sizeof(super_memory_t));
    +		bzero(r,sizeof(super_memory_t));
     
    -		r->super_memory = (char**)turn_malloc(sizeof(char*));
    -		r->super_memory[0] = (char*)turn_malloc(TURN_SM_SIZE);
    -		ns_bzero(r->super_memory[0],TURN_SM_SIZE);
    +		r->super_memory = (char**)malloc(sizeof(char*));
    +		r->super_memory[0] = (char*)malloc(TURN_SM_SIZE);
    +		bzero(r->super_memory[0],TURN_SM_SIZE);
     
    -		r->sm_allocated = (size_t*)turn_malloc(sizeof(size_t*));
    +		r->sm_allocated = (size_t*)malloc(sizeof(size_t*));
     		r->sm_allocated[0] = 0;
     
     		r->sm_total_sz = TURN_SM_SIZE;
     		r->sm_chunk = 0;
     
     		while(r->id == 0)
    -			r->id = (u32bits)random();
    +			r->id = (uint32_t)random();
     
     		pthread_mutex_init(&r->mutex_sm, NULL);
     	}
    @@ -3684,7 +3786,7 @@ void init_super_memory(void)
     
     super_memory_t* new_super_memory_region(void)
     {
    -	super_memory_t* r = (super_memory_t*)turn_malloc(sizeof(super_memory_t));
    +	super_memory_t* r = (super_memory_t*)malloc(sizeof(super_memory_t));
     	init_super_memory_region(r);
     	return r;
     }
    @@ -3698,8 +3800,8 @@ void* allocate_super_memory_region_func(super_memory_t *r, size_t size, const ch
     	void *ret = NULL;
     
     	if(!r) {
    -		ret = turn_malloc(size);
    -		ns_bzero(ret, size);
    +		ret = malloc(size);
    +		bzero(ret, size);
     		return ret;
     	}
     
    @@ -3731,10 +3833,10 @@ void* allocate_super_memory_region_func(super_memory_t *r, size_t size, const ch
     
     		if(!region) {
     			r->sm_chunk += 1;
    -			r->super_memory = (char**)turn_realloc(r->super_memory,0, (r->sm_chunk+1) * sizeof(char*));
    -			r->super_memory[r->sm_chunk] = (char*)turn_malloc(TURN_SM_SIZE);
    -			ns_bzero(r->super_memory[r->sm_chunk],TURN_SM_SIZE);
    -			r->sm_allocated = (size_t*)turn_realloc(r->sm_allocated,0,(r->sm_chunk+1) * sizeof(size_t*));
    +			r->super_memory = (char**)realloc(r->super_memory,(r->sm_chunk+1) * sizeof(char*));
    +			r->super_memory[r->sm_chunk] = (char*)malloc(TURN_SM_SIZE);
    +			bzero(r->super_memory[r->sm_chunk],TURN_SM_SIZE);
    +			r->sm_allocated = (size_t*)realloc(r->sm_allocated,(r->sm_chunk+1) * sizeof(size_t*));
     			r->sm_allocated[r->sm_chunk] = 0;
     			region = r->super_memory[r->sm_chunk];
     			rsz = r->sm_allocated + r->sm_chunk;
    @@ -3743,7 +3845,7 @@ void* allocate_super_memory_region_func(super_memory_t *r, size_t size, const ch
     		{
     			char* ptr = region + *rsz;
     
    -			ns_bzero(ptr, size);
    +			bzero(ptr, size);
     
     			*rsz += size;
     
    @@ -3754,8 +3856,8 @@ void* allocate_super_memory_region_func(super_memory_t *r, size_t size, const ch
     	pthread_mutex_unlock(&r->mutex_sm);
     
     	if(!ret) {
    -		ret = turn_malloc(size);
    -		ns_bzero(ret, size);
    +		ret = malloc(size);
    +		bzero(ret, size);
     	}
     
     	return ret;
    
  • src/apps/relay/ns_ioalib_impl.h+9 9 modified
    @@ -157,11 +157,11 @@ struct _ioa_engine
     #endif
       turn_time_t jiffie; /* bandwidth check interval */
       ioa_timer_handle timer_ev;
    -  s08bits cmsg[TURN_CMSG_SZ+1];
    +  char cmsg[TURN_CMSG_SZ+1];
       int predef_timer_intervals[PREDEF_TIMERS_NUM];
       struct timeval predef_timers[PREDEF_TIMERS_NUM];
       /* Relays */
    -  s08bits relay_ifname[1025];
    +  char relay_ifname[1025];
       int default_relays;
       size_t relays_number;
       size_t relay_addr_counter;
    @@ -180,15 +180,15 @@ struct _ioa_socket
     {
     	evutil_socket_t fd;
     	struct _ioa_socket *parent_s;
    -	u32bits magic;
    +	uint32_t magic;
     	ur_addr_map *sockets_container; /* relay container for UDP sockets */
     	struct bufferevent *bev;
     	ioa_network_buffer_handle defer_nbh;
     	int family;
     	SOCKET_TYPE st;
     	SOCKET_APP_TYPE sat;
     	SSL* ssl;
    -	u32bits ssl_renegs;
    +	uint32_t ssl_renegs;
     	int in_write;
     	int bound;
     	int local_addr_known;
    @@ -236,7 +236,7 @@ typedef struct _timer_event
     	ioa_engine_handle e;
     	ioa_timer_event_handler cb;
     	void *ctx;
    -	s08bits* txt;
    +	char* txt;
     } timer_event;
     
     ///////////////////////////////////
    @@ -250,8 +250,8 @@ int get_realm_data(char* name, realm_params_t* rp);
     
     ioa_engine_handle create_ioa_engine(super_memory_t *sm,
     				struct event_base *eb, turnipports* tp,
    -				const s08bits* relay_if,
    -				size_t relays_number, s08bits **relay_addrs, int default_relays,
    +				const char* relay_if,
    +				size_t relays_number, char **relay_addrs, int default_relays,
     				int verbose
     #if !defined(TURN_NO_HIREDIS)
     				,const char* redis_report_connection_string
    @@ -273,8 +273,8 @@ void delete_socket_from_map(ioa_socket_handle s);
     
     int is_connreset(void);
     int would_block(void);
    -int udp_send(ioa_socket_handle s, const ioa_addr* dest_addr, const s08bits* buffer, int len);
    -int udp_recvfrom(evutil_socket_t fd, ioa_addr* orig_addr, const ioa_addr *like_addr, s08bits* buffer, int buf_size, int *ttl, int *tos, s08bits *ecmsg, int flags, u32bits *errcode);
    +int udp_send(ioa_socket_handle s, const ioa_addr* dest_addr, const char* buffer, int len);
    +int udp_recvfrom(evutil_socket_t fd, ioa_addr* orig_addr, const ioa_addr *like_addr, char* buffer, int buf_size, int *ttl, int *tos, char *ecmsg, int flags, uint32_t *errcode);
     int ssl_read(evutil_socket_t fd, SSL* ssl, ioa_network_buffer_handle nbh, int verbose);
     
     int set_raw_socket_ttl_options(evutil_socket_t fd, int family);
    
  • src/apps/relay/tls_listener.c+7 5 modified
    @@ -76,13 +76,15 @@ static void server_input_handler(struct evconnlistener *l, evutil_socket_t fd,
     	if (!server)
     		return;
     
    -	ns_bcopy(sa,&(server->sm.m.sm.nd.src_addr),socklen);
    +	bcopy(sa,&(server->sm.m.sm.nd.src_addr),socklen);
     
     	addr_debug_print(server->verbose, &(server->sm.m.sm.nd.src_addr),"tcp or tls connected to");
     
     	SOCKET_TYPE st = TENTATIVE_TCP_SOCKET;
     
    -	if(turn_params.no_tls)
    +	if(turn_params.tcp_use_proxy)
    +		st = TCP_SOCKET_PROXY;
    +	else if(turn_params.no_tls)
     		st = TCP_SOCKET;
     	else if(turn_params.no_tcp)
     		st = TLS_SOCKET;
    @@ -141,7 +143,7 @@ static void sctp_server_input_handler(struct evconnlistener *l, evutil_socket_t
     	if (!server)
     		return;
     
    -	ns_bcopy(sa,&(server->sm.m.sm.nd.src_addr),socklen);
    +	bcopy(sa,&(server->sm.m.sm.nd.src_addr),socklen);
     
     	addr_debug_print(server->verbose, &(server->sm.m.sm.nd.src_addr),"sctp or tls/sctp connected to");
     
    @@ -216,7 +218,7 @@ static int create_server_listener(tls_listener_relay_server_type* server) {
       	 if(addr_bind(tls_listen_fd,&server->addr,1,1,TCP_SOCKET)<0) {
       		perror("Cannot bind local socket to addr");
       		char saddr[129];
    -  		addr_to_string(&server->addr,(u08bits*)saddr);
    +  		addr_to_string(&server->addr,(uint8_t*)saddr);
       		TURN_LOG_FUNC(TURN_LOG_LEVEL_WARNING,"Cannot bind TLS/TCP listener socket to addr %s\n",saddr);
       		if(addr_bind_cycle++<max_binding_time) {
       		  TURN_LOG_FUNC(TURN_LOG_LEVEL_INFO,"Trying to bind TLS/TCP listener socket to addr %s, again...\n",saddr);
    @@ -322,7 +324,7 @@ static int init_server(tls_listener_relay_server_type* server,
     
       if(ifname) STRCPY(server->ifname,ifname);
     
    -  if(make_ioa_addr((const u08bits*)local_address, port, &server->addr)<0) {
    +  if(make_ioa_addr((const uint8_t*)local_address, port, &server->addr)<0) {
     	  TURN_LOG_FUNC(TURN_LOG_LEVEL_ERROR,"Cannot create a TCP/TLS listener for address: %s\n",local_address);
     	  return -1;
       }
    
  • src/apps/relay/turn_admin_server.c+118 117 modified
    @@ -282,9 +282,9 @@ static void cli_print_addr(struct cli_session* cs, ioa_addr *value, int use_port
     			sc=" (**)";
     		char s[256];
     		if(!use_port)
    -			addr_to_string_no_port(value,(u08bits*)s);
    +			addr_to_string_no_port(value,(uint8_t*)s);
     		else
    -			addr_to_string(value,(u08bits*)s);
    +			addr_to_string(value,(uint8_t*)s);
     		myprintf(cs,"  %s: %s%s\n",name,s,sc);
     	}
     }
    @@ -301,9 +301,9 @@ static void cli_print_addr_list(struct cli_session* cs, turn_server_addrs_list_t
     		size_t i;
     		for(i=0;i<value->size;i++) {
     			if(!use_port)
    -				addr_to_string_no_port(&(value->addrs[i]),(u08bits*)s);
    +				addr_to_string_no_port(&(value->addrs[i]),(uint8_t*)s);
     			else
    -				addr_to_string(&(value->addrs[i]),(u08bits*)s);
    +				addr_to_string(&(value->addrs[i]),(uint8_t*)s);
     			myprintf(cs,"  %s: %s%s\n",name,s,sc);
     		}
     	}
    @@ -462,13 +462,11 @@ static int print_session(ur_map_key_type key, ur_map_value_type value, void *arg
     			if(!ur_string_map_get(csarg->users, (ur_string_map_key_type)(char*)tsi->username, &value)) {
     				value = (ur_string_map_value_type)csarg->users_number;
     				csarg->users_number += 1;
    -				csarg->user_counters = (size_t*)turn_realloc(csarg->user_counters,
    -						(size_t)value * sizeof(size_t),
    +				csarg->user_counters = (size_t*)realloc(csarg->user_counters,
     						csarg->users_number * sizeof(size_t));
    -				csarg->user_names = (char**)turn_realloc(csarg->user_names,
    -						(size_t)value * sizeof(char*),
    +				csarg->user_names = (char**)realloc(csarg->user_names,
     						csarg->users_number * sizeof(char*));
    -				csarg->user_names[(size_t)value] = turn_strdup((char*)tsi->username);
    +				csarg->user_names[(size_t)value] = strdup((char*)tsi->username);
     				csarg->user_counters[(size_t)value] = 0;
     				ur_string_map_put(csarg->users, (ur_string_map_key_type)(char*)tsi->username, value);
     			}
    @@ -506,13 +504,13 @@ static int print_session(ur_map_key_type key, ur_map_value_type value, void *arg
     				myprintf(cs,"      client protocol %s, relay protocol %s\n",socket_type_name(tsi->client_protocol),socket_type_name(tsi->peer_protocol));
     				{
     					if(!tsi->local_addr_data.saddr[0])
    -						addr_to_string(&(tsi->local_addr_data.addr),(u08bits*)tsi->local_addr_data.saddr);
    +						addr_to_string(&(tsi->local_addr_data.addr),(uint8_t*)tsi->local_addr_data.saddr);
     					if(!tsi->remote_addr_data.saddr[0])
    -						addr_to_string(&(tsi->remote_addr_data.addr),(u08bits*)tsi->remote_addr_data.saddr);
    +						addr_to_string(&(tsi->remote_addr_data.addr),(uint8_t*)tsi->remote_addr_data.saddr);
     					if(!tsi->relay_addr_data_ipv4.saddr[0])
    -						addr_to_string(&(tsi->relay_addr_data_ipv4.addr),(u08bits*)tsi->relay_addr_data_ipv4.saddr);
    +						addr_to_string(&(tsi->relay_addr_data_ipv4.addr),(uint8_t*)tsi->relay_addr_data_ipv4.saddr);
     					if(!tsi->relay_addr_data_ipv6.saddr[0])
    -						addr_to_string(&(tsi->relay_addr_data_ipv6.addr),(u08bits*)tsi->relay_addr_data_ipv6.saddr);
    +						addr_to_string(&(tsi->relay_addr_data_ipv6.addr),(uint8_t*)tsi->relay_addr_data_ipv6.saddr);
     					myprintf(cs,"      client addr %s, server addr %s\n",
     									tsi->remote_addr_data.saddr,
     									tsi->local_addr_data.saddr);
    @@ -538,13 +536,13 @@ static int print_session(ur_map_key_type key, ur_map_value_type value, void *arg
     					size_t i;
     					for(i=0;i<tsi->main_peers_size;++i) {
     						if(!(tsi->main_peers_data[i].saddr[0]))
    -							addr_to_string(&(tsi->main_peers_data[i].addr),(u08bits*)tsi->main_peers_data[i].saddr);
    +							addr_to_string(&(tsi->main_peers_data[i].addr),(uint8_t*)tsi->main_peers_data[i].saddr);
     						myprintf(cs,"          %s\n",tsi->main_peers_data[i].saddr);
     					}
     					if(tsi->extra_peers_size && tsi->extra_peers_data) {
     						for(i=0;i<tsi->extra_peers_size;++i) {
     							if(!(tsi->extra_peers_data[i].saddr[0]))
    -								addr_to_string(&(tsi->extra_peers_data[i].addr),(u08bits*)tsi->extra_peers_data[i].saddr);
    +								addr_to_string(&(tsi->extra_peers_data[i].addr),(uint8_t*)tsi->extra_peers_data[i].saddr);
     							myprintf(cs,"          %s\n",tsi->extra_peers_data[i].saddr);
     						}
     					}
    @@ -633,14 +631,14 @@ static void print_sessions(struct cli_session* cs, const char* pn, int exact_mat
     		}
     
     		if(arg.user_counters)
    -			turn_free(arg.user_counters,sizeof(size_t)*arg.users_number);
    +			free(arg.user_counters);
     		if(arg.user_names) {
     			size_t i;
     			for(i=0;i<arg.users_number;++i) {
     				if(arg.user_names[i])
    -					turn_free(arg.user_names[i],strlen(arg.user_names[i])+1);
    +					free(arg.user_names[i]);
     			}
    -			turn_free(arg.user_names,sizeof(char*) * arg.users_number);
    +			free(arg.user_names);
     		}
     		if(arg.users)
     			ur_string_map_free(&arg.users);
    @@ -890,7 +888,7 @@ static void close_cli_session(struct cli_session* cs)
     			cs->fd = -1;
     		}
     
    -		turn_free(cs,sizeof(struct cli_session));
    +		free(cs);
     	}
     }
     
    @@ -935,8 +933,8 @@ static int run_cli_input(struct cli_session* cs, const char *buf0, unsigned int
     
     	if(cs && buf0 && cs->ts && cs->bev) {
     
    -		char *buf = (char*)turn_malloc(len+1);
    -		ns_bcopy(buf0,buf,len);
    +		char *buf = (char*)malloc(len+1);
    +		bcopy(buf0,buf,len);
     		buf[len]=0;
     
     		char *cmd = buf;
    @@ -1074,7 +1072,7 @@ static int run_cli_input(struct cli_session* cs, const char *buf0, unsigned int
     			type_cli_cursor(cs);
     		}
     
    -		turn_free(buf,len+1);
    +		free(buf);
     	}
     
     	return ret;
    @@ -1157,8 +1155,8 @@ static void cliserver_input_handler(struct evconnlistener *l, evutil_socket_t fd
     
     	addr_debug_print(adminserver.verbose, (ioa_addr*)sa,"CLI connected to");
     
    -	struct cli_session *clisession = (struct cli_session*)turn_malloc(sizeof(struct cli_session));
    -	ns_bzero(clisession,sizeof(struct cli_session));
    +	struct cli_session *clisession = (struct cli_session*)malloc(sizeof(struct cli_session));
    +	bzero(clisession,sizeof(struct cli_session));
     
     	clisession->rp = get_realm(NULL);
     
    @@ -1171,7 +1169,6 @@ static void cliserver_input_handler(struct evconnlistener *l, evutil_socket_t fd
     	clisession->bev = bufferevent_socket_new(adminserver.event_base,
     					fd,
     					TURN_BUFFEREVENTS_OPTIONS);
    -	debug_ptr_add(clisession->bev);
     	bufferevent_setcb(clisession->bev, cli_socket_input_handler_bev, NULL,
     			cli_eventcb_bev, clisession);
     	bufferevent_setwatermark(clisession->bev, EV_READ|EV_WRITE, 0, BUFFEREVENT_HIGH_WATERMARK);
    @@ -1352,7 +1349,7 @@ void setup_admin_thread(void)
     	// Setup the web-admin server
     	if(use_web_admin) {
     		if(!web_admin_addr_set) {
    -			if(make_ioa_addr((const u08bits*)WEB_ADMIN_DEFAULT_IP, 0, &web_admin_addr) < 0) {
    +			if(make_ioa_addr((const uint8_t*)WEB_ADMIN_DEFAULT_IP, 0, &web_admin_addr) < 0) {
     				TURN_LOG_FUNC(TURN_LOG_LEVEL_ERROR, "Cannot set web-admin address %s\n", WEB_ADMIN_DEFAULT_IP);
     				return;
     			}
    @@ -1361,7 +1358,7 @@ void setup_admin_thread(void)
     		addr_set_port(&web_admin_addr, web_admin_port);
     	
     		char saddr[129];
    -		addr_to_string_no_port(&web_admin_addr,(u08bits*)saddr);
    +		addr_to_string_no_port(&web_admin_addr,(uint8_t*)saddr);
     	
     		tls_listener_relay_server_type *tls_service = create_tls_listener_server(turn_params.listener_ifname, saddr, web_admin_port, turn_params.verbose, adminserver.e, send_socket_to_admin_server, NULL);
     	
    @@ -1375,7 +1372,7 @@ void setup_admin_thread(void)
         
     	if(use_cli) {
     		if(!cli_addr_set) {
    -			if(make_ioa_addr((const u08bits*)CLI_DEFAULT_IP,0,&cli_addr)<0) {
    +			if(make_ioa_addr((const uint8_t*)CLI_DEFAULT_IP,0,&cli_addr)<0) {
     				TURN_LOG_FUNC(TURN_LOG_LEVEL_ERROR,"Cannot set cli address %s\n",CLI_DEFAULT_IP);
     				return;
     			}
    @@ -1393,7 +1390,7 @@ void setup_admin_thread(void)
     		if(addr_bind(adminserver.listen_fd,&cli_addr,1,1,TCP_SOCKET)<0) {
     			perror("Cannot bind CLI socket to addr");
     			char saddr[129];
    -			addr_to_string(&cli_addr,(u08bits*)saddr);
    +			addr_to_string(&cli_addr,(uint8_t*)saddr);
     			TURN_LOG_FUNC(TURN_LOG_LEVEL_ERROR,"Cannot bind CLI listener socket to addr %s\n",saddr);
     			socket_closesocket(adminserver.listen_fd);
     			return;
    @@ -1424,7 +1421,7 @@ void admin_server_receive_message(struct bufferevent *bev, void *ptr)
     {
     	UNUSED_ARG(ptr);
     
    -	struct turn_session_info *tsi = (struct turn_session_info*)turn_malloc(sizeof(struct turn_session_info));
    +	struct turn_session_info *tsi = (struct turn_session_info*)malloc(sizeof(struct turn_session_info));
     	turn_session_info_init(tsi);
     	int n = 0;
     	struct evbuffer *input = bufferevent_get_input(bev);
    @@ -1439,13 +1436,13 @@ void admin_server_receive_message(struct bufferevent *bev, void *ptr)
     		if (ur_map_get(adminserver.sessions, (ur_map_key_type)tsi->id, &t) && t) {
     			struct turn_session_info *old = (struct turn_session_info*)t;
     			turn_session_info_clean(old);
    -			turn_free(old,sizeof(struct turn_session_info));
    +			free(old);
     			ur_map_del(adminserver.sessions, (ur_map_key_type)tsi->id, NULL);
     		}
     
     		if(tsi->valid) {
     			ur_map_put(adminserver.sessions, (ur_map_key_type)tsi->id, (ur_map_value_type)tsi);
    -			tsi = (struct turn_session_info*)turn_malloc(sizeof(struct turn_session_info));
    +			tsi = (struct turn_session_info*)malloc(sizeof(struct turn_session_info));
     			turn_session_info_init(tsi);
     		} else {
     			turn_session_info_clean(tsi);
    @@ -1454,7 +1451,7 @@ void admin_server_receive_message(struct bufferevent *bev, void *ptr)
     
     	if(tsi) {
     		turn_session_info_clean(tsi);
    -		turn_free(tsi,sizeof(struct turn_session_info));
    +		free(tsi);
     	}
     }
     
    @@ -1662,7 +1659,7 @@ static void https_finish_page(struct str_buffer *sb, ioa_socket_handle s, int cc
     	str_buffer_append(sb,"</body>\r\n</html>\r\n");
     
     	send_str_from_ioa_socket_tcp(s,"HTTP/1.1 200 OK\r\nServer: ");
    -	if(!turn_params.prod) {
    +	if(!turn_params.no_software_attribute) {
     		send_str_from_ioa_socket_tcp(s,TURN_SOFTWARE);
     	}
     	send_str_from_ioa_socket_tcp(s,"\r\n");
    @@ -1898,9 +1895,9 @@ static void https_print_addr(struct str_buffer* sb, ioa_addr *value, int use_por
     	if(sb && name && value) {
     		char s[256];
     		if(!use_port)
    -			addr_to_string_no_port(value,(u08bits*)s);
    +			addr_to_string_no_port(value,(uint8_t*)s);
     		else
    -			addr_to_string(value,(u08bits*)s);
    +			addr_to_string(value,(uint8_t*)s);
     		sbprintf(sb,"<tr><td>  %s</td><td> %s</td></tr>\r\n",name,s);
     	}
     }
    @@ -1912,9 +1909,9 @@ static size_t https_print_addr_list(struct str_buffer* sb, turn_server_addrs_lis
     		size_t i;
     		for(i=0;i<value->size;i++) {
     			if(!use_port)
    -				addr_to_string_no_port(&(value->addrs[i]),(u08bits*)s);
    +				addr_to_string_no_port(&(value->addrs[i]),(uint8_t*)s);
     			else
    -				addr_to_string(&(value->addrs[i]),(u08bits*)s);
    +				addr_to_string(&(value->addrs[i]),(uint8_t*)s);
     			sbprintf(sb,"</tr><td>  %s</td><td> %s</td></tr>\r\n",name,s);
     		}
     		return i;
    @@ -2016,13 +2013,13 @@ static void update_param(const char* pn, const char *value)
     			if (dbd && dbd->set_realm_option_one) {
     				if(strstr(pn,"cr-total-quota")==pn) {
     					rp->options.perf_options.total_quota = atoi(value);
    -					dbd->set_realm_option_one((u08bits*)rp->options.name,rp->options.perf_options.total_quota,"total-quota");
    +					dbd->set_realm_option_one((uint8_t*)rp->options.name,rp->options.perf_options.total_quota,"total-quota");
     				} else if(strstr(pn,"cr-user-quota")==pn) {
     					rp->options.perf_options.user_quota = atoi(value);
    -					dbd->set_realm_option_one((u08bits*)rp->options.name,rp->options.perf_options.user_quota,"user-quota");
    +					dbd->set_realm_option_one((uint8_t*)rp->options.name,rp->options.perf_options.user_quota,"user-quota");
     				} else if(strstr(pn,"cr-max-bps")==pn) {
     					rp->options.perf_options.max_bps = (band_limit_t)strtoul(value,NULL,10);
    -					dbd->set_realm_option_one((u08bits*)rp->options.name,rp->options.perf_options.max_bps,"max-bps");
    +					dbd->set_realm_option_one((uint8_t*)rp->options.name,rp->options.perf_options.max_bps,"max-bps");
     				}
     			}
     		}
    @@ -2358,13 +2355,13 @@ static int https_print_session(ur_map_key_type key, ur_map_value_type value, voi
     			str_buffer_append(sb,"</td><td>");
     			{
     				if(!tsi->local_addr_data.saddr[0])
    -					addr_to_string(&(tsi->local_addr_data.addr),(u08bits*)tsi->local_addr_data.saddr);
    +					addr_to_string(&(tsi->local_addr_data.addr),(uint8_t*)tsi->local_addr_data.saddr);
     				if(!tsi->remote_addr_data.saddr[0])
    -					addr_to_string(&(tsi->remote_addr_data.addr),(u08bits*)tsi->remote_addr_data.saddr);
    +					addr_to_string(&(tsi->remote_addr_data.addr),(uint8_t*)tsi->remote_addr_data.saddr);
     				if(!tsi->relay_addr_data_ipv4.saddr[0])
    -					addr_to_string(&(tsi->relay_addr_data_ipv4.addr),(u08bits*)tsi->relay_addr_data_ipv4.saddr);
    +					addr_to_string(&(tsi->relay_addr_data_ipv4.addr),(uint8_t*)tsi->relay_addr_data_ipv4.saddr);
     				if(!tsi->relay_addr_data_ipv6.saddr[0])
    -					addr_to_string(&(tsi->relay_addr_data_ipv6.addr),(u08bits*)tsi->relay_addr_data_ipv6.saddr);
    +					addr_to_string(&(tsi->relay_addr_data_ipv6.addr),(uint8_t*)tsi->relay_addr_data_ipv6.saddr);
     				str_buffer_append(sb,tsi->remote_addr_data.saddr);
     				str_buffer_append(sb,"</td><td>");
     				str_buffer_append(sb,tsi->local_addr_data.saddr);
    @@ -2400,15 +2397,15 @@ static int https_print_session(ur_map_key_type key, ur_map_value_type value, voi
     					size_t i;
     					for(i=0;i<tsi->main_peers_size;++i) {
     						if(!(tsi->main_peers_data[i].saddr[0]))
    -							addr_to_string(&(tsi->main_peers_data[i].addr),(u08bits*)tsi->main_peers_data[i].saddr);
    +							addr_to_string(&(tsi->main_peers_data[i].addr),(uint8_t*)tsi->main_peers_data[i].saddr);
     						str_buffer_append(sb," ");
     						str_buffer_append(sb,tsi->main_peers_data[i].saddr);
     						str_buffer_append(sb," ");
     					}
     					if(tsi->extra_peers_size && tsi->extra_peers_data) {
     						for(i=0;i<tsi->extra_peers_size;++i) {
     							if(!(tsi->extra_peers_data[i].saddr[0]))
    -								addr_to_string(&(tsi->extra_peers_data[i].addr),(u08bits*)tsi->extra_peers_data[i].saddr);
    +								addr_to_string(&(tsi->extra_peers_data[i].addr),(uint8_t*)tsi->extra_peers_data[i].saddr);
     							str_buffer_append(sb," ");
     							str_buffer_append(sb,tsi->extra_peers_data[i].saddr);
     							str_buffer_append(sb," ");
    @@ -2512,7 +2509,7 @@ static size_t https_print_users(struct str_buffer* sb)
     		secrets_list_t users,realms;
     		init_secrets_list(&users);
     		init_secrets_list(&realms);
    -		dbd->list_users((u08bits*)current_eff_realm(),&users,&realms);
    +		dbd->list_users((uint8_t*)current_eff_realm(),&users,&realms);
     
     		size_t sz = get_secrets_list_size(&users);
     		size_t i;
    @@ -2551,7 +2548,7 @@ static size_t https_print_users(struct str_buffer* sb)
     	return ret;
     }
     
    -static void write_users_page(ioa_socket_handle s, const u08bits *add_user, const u08bits *add_realm, const char* msg)
    +static void write_users_page(ioa_socket_handle s, const uint8_t *add_user, const uint8_t *add_realm, const char* msg)
     {
     	if(s && !ioa_socket_tobeclosed(s)) {
     
    @@ -2660,7 +2657,7 @@ static size_t https_print_secrets(struct str_buffer* sb)
     		secrets_list_t secrets,realms;
     		init_secrets_list(&secrets);
     		init_secrets_list(&realms);
    -		dbd->list_secrets((u08bits*)current_eff_realm(),&secrets,&realms);
    +		dbd->list_secrets((uint8_t*)current_eff_realm(),&secrets,&realms);
     
     		size_t sz = get_secrets_list_size(&secrets);
     		size_t i;
    @@ -2794,7 +2791,7 @@ static size_t https_print_origins(struct str_buffer* sb)
     		secrets_list_t origins,realms;
     		init_secrets_list(&origins);
     		init_secrets_list(&realms);
    -		dbd->list_origins((u08bits*)current_eff_realm(),&origins,&realms);
    +		dbd->list_origins((uint8_t*)current_eff_realm(),&origins,&realms);
     
     		size_t sz = get_secrets_list_size(&origins);
     		size_t i;
    @@ -3009,20 +3006,20 @@ static void write_https_oauth_show_keys(ioa_socket_handle s, const char* kid)
     				const turn_dbdriver_t * dbd = get_dbdriver();
     				if (dbd && dbd->get_oauth_key) {
     					oauth_key_data_raw key;
    -					if((*dbd->get_oauth_key)((const u08bits*)kid,&key)<0) {
    +					if((*dbd->get_oauth_key)((const uint8_t*)kid,&key)<0) {
     						str_buffer_append(sb,"data retrieval error");
     					} else {
     
     						oauth_key_data okd;
    -						ns_bzero(&okd,sizeof(okd));
    +						bzero(&okd,sizeof(okd));
     
     						convert_oauth_key_data_raw(&key, &okd);
     
     						char err_msg[1025] = "\0";
     						size_t err_msg_size = sizeof(err_msg) - 1;
     
     						oauth_key okey;
    -						ns_bzero(&okey,sizeof(okey));
    +						bzero(&okey,sizeof(okey));
     
     						if (convert_oauth_key_data(&okd, &okey, err_msg, err_msg_size) < 0) {
     							str_buffer_append(sb,err_msg);
    @@ -3233,9 +3230,11 @@ static void handle_update_request(ioa_socket_handle s, struct http_request* hr)
     
     					if(current_realm()[0] && strcmp(current_realm(),r)) {
     						//forbidden
    +					} else if (strcmp(kind, "allowed") != 0 && strcmp(kind, "denied") != 0) {
    +						//forbidden
     					} else {
     
    -						u08bits realm[STUN_MAX_REALM_SIZE+1]="\0";
    +						uint8_t realm[STUN_MAX_REALM_SIZE+1]="\0";
     						STRCPY(realm,r);
     
     						dbd->set_permission_ip(kind, realm, ip, 1);
    @@ -3266,9 +3265,11 @@ static void handle_update_request(ioa_socket_handle s, struct http_request* hr)
     
     						if(current_realm()[0] && strcmp(current_realm(),r)) {
     							//forbidden
    +						} else if (strcmp(kind, "allowed") != 0 && strcmp(kind, "denied") != 0) {
    +							//forbidden
     						} else {
     
    -							u08bits realm[STUN_MAX_REALM_SIZE+1]="\0";
    +							uint8_t realm[STUN_MAX_REALM_SIZE+1]="\0";
     							STRCPY(realm,r);
     
     							dbd->set_permission_ip(kind, realm, ip, 0);
    @@ -3289,18 +3290,18 @@ static void handle_logon_request(ioa_socket_handle s, struct http_request* hr)
     
     		struct admin_session* as = (struct admin_session*)s->special_session;
     		if(!as) {
    -			as = (struct admin_session*)turn_malloc(sizeof(struct admin_session));
    -			ns_bzero(as,sizeof(struct admin_session));
    +			as = (struct admin_session*)malloc(sizeof(struct admin_session));
    +			bzero(as,sizeof(struct admin_session));
     			s->special_session = as;
     			s->special_session_size = sizeof(struct admin_session);
     		}
     
    -		if(!(as->as_ok) && uname && is_secure_string((const u08bits*)uname,1) && pwd) {
    +		if(!(as->as_ok) && uname && is_secure_string((const uint8_t*)uname,1) && pwd) {
     			const turn_dbdriver_t * dbd = get_dbdriver();
     			if (dbd && dbd->get_admin_user) {
     				password_t password;
     				char realm[STUN_MAX_REALM_SIZE+1]="\0";
    -				if((*(dbd->get_admin_user))((const u08bits*)uname,(u08bits*)realm,password)>=0) {
    +				if((*(dbd->get_admin_user))((const uint8_t*)uname,(uint8_t*)realm,password)>=0) {
     					if(!check_password(pwd,(char*)password)) {
     						STRCPY(as->as_login,uname);
     						STRCPY(as->as_realm,realm);
    @@ -3413,17 +3414,17 @@ static void handle_https(ioa_socket_handle s, ioa_network_buffer_handle nbh)
     					}
     
     					{
    -						const u08bits *user = (const u08bits*)get_http_header_value(hr, HR_DELETE_USER, NULL);
    +						const uint8_t *user = (const uint8_t*)get_http_header_value(hr, HR_DELETE_USER, NULL);
     						if(user && user[0]) {
    -							const u08bits *realm = (const u08bits*)get_http_header_value(hr, HR_DELETE_REALM, "");
    +							const uint8_t *realm = (const uint8_t*)get_http_header_value(hr, HR_DELETE_REALM, "");
     							if(!is_superuser()) {
    -								realm = (const u08bits*)current_realm();
    +								realm = (const uint8_t*)current_realm();
     							}
     							if(realm && realm[0]) {
     								const turn_dbdriver_t * dbd = get_dbdriver();
     								if (dbd && dbd->del_user) {
    -									u08bits u[STUN_MAX_USERNAME_SIZE+1];
    -									u08bits r[STUN_MAX_REALM_SIZE+1];
    +									uint8_t u[STUN_MAX_USERNAME_SIZE+1];
    +									uint8_t r[STUN_MAX_REALM_SIZE+1];
     									STRCPY(u,user);
     									STRCPY(r,realm);
     									dbd->del_user(u,r);
    @@ -3432,31 +3433,31 @@ static void handle_https(ioa_socket_handle s, ioa_network_buffer_handle nbh)
     						}
     					}
     
    -					const u08bits *add_realm = (const u08bits*)current_eff_realm();
    -					const u08bits *add_user = (const u08bits*)get_http_header_value(hr, HR_ADD_USER,"");
    +					const uint8_t *add_realm = (const uint8_t*)current_eff_realm();
    +					const uint8_t *add_user = (const uint8_t*)get_http_header_value(hr, HR_ADD_USER,"");
     					const char* msg = "";
     					if(wrong_html_name((const char*)add_user)) {
     						msg = "Error: wrong user name";
    -						add_user = (const u08bits*)"";
    +						add_user = (const uint8_t*)"";
     					}
     					if(add_user[0]) {
    -						add_realm = (const u08bits*)get_http_header_value(hr, HR_ADD_REALM, current_realm());
    +						add_realm = (const uint8_t*)get_http_header_value(hr, HR_ADD_REALM, current_realm());
     						if(!is_superuser()) {
    -							add_realm = (const u08bits*)current_realm();
    +							add_realm = (const uint8_t*)current_realm();
     						}
     						if(!add_realm[0]) {
    -							add_realm=(const u08bits*)current_eff_realm();
    +							add_realm=(const uint8_t*)current_eff_realm();
     						}
     						if(!add_realm[0]) {
    -							add_realm = (const u08bits*)get_realm(NULL)->options.name;
    +							add_realm = (const uint8_t*)get_realm(NULL)->options.name;
     						}
     						if(wrong_html_name((const char*)add_realm)) {
     							msg = "Error: wrong realm name";
    -							add_realm = (const u08bits*)"";
    +							add_realm = (const uint8_t*)"";
     						}
     						if(add_realm[0]) {
    -							const u08bits *pwd = (const u08bits*)get_http_header_value(hr, HR_PASSWORD, NULL);
    -							const u08bits *pwd1 = (const u08bits*)get_http_header_value(hr, HR_PASSWORD1, NULL);
    +							const uint8_t *pwd = (const uint8_t*)get_http_header_value(hr, HR_PASSWORD, NULL);
    +							const uint8_t *pwd1 = (const uint8_t*)get_http_header_value(hr, HR_PASSWORD1, NULL);
     							if(pwd && pwd1 && pwd[0] && pwd1[0] && !strcmp((const char*)pwd,(const char*)pwd1)) {
     
     								const turn_dbdriver_t * dbd = get_dbdriver();
    @@ -3466,9 +3467,9 @@ static void handle_https(ioa_socket_handle s, ioa_network_buffer_handle nbh)
     									char skey[sizeof(hmackey_t) * 2 + 1];
     
     									{
    -										u08bits u[STUN_MAX_USERNAME_SIZE+1];
    -										u08bits r[STUN_MAX_REALM_SIZE+1];
    -										u08bits p[STUN_MAX_PWD_SIZE+1];
    +										uint8_t u[STUN_MAX_USERNAME_SIZE+1];
    +										uint8_t r[STUN_MAX_REALM_SIZE+1];
    +										uint8_t p[STUN_MAX_PWD_SIZE+1];
     										STRCPY(u,add_user);
     										STRCPY(r,add_realm);
     										STRCPY(p,pwd);
    @@ -3487,8 +3488,8 @@ static void handle_https(ioa_socket_handle s, ioa_network_buffer_handle nbh)
     										(*dbd->set_user_key)(u, r, skey);
     									}
     
    -									add_realm=(const u08bits*)"";
    -									add_user=(const u08bits*)"";
    +									add_realm=(const uint8_t*)"";
    +									add_user=(const uint8_t*)"";
     								}
     							} else {
     								msg = "Error: wrong password";
    @@ -3513,17 +3514,17 @@ static void handle_https(ioa_socket_handle s, ioa_network_buffer_handle nbh)
     					}
     
     					{
    -						const u08bits *secret = (const u08bits*)get_http_header_value(hr, HR_DELETE_SECRET, NULL);
    +						const uint8_t *secret = (const uint8_t*)get_http_header_value(hr, HR_DELETE_SECRET, NULL);
     						if(secret && secret[0]) {
    -							const u08bits *realm = (const u08bits*)get_http_header_value(hr, HR_DELETE_REALM, NULL);
    +							const uint8_t *realm = (const uint8_t*)get_http_header_value(hr, HR_DELETE_REALM, NULL);
     							if(!is_superuser()) {
    -								realm = (const u08bits*)current_realm();
    +								realm = (const uint8_t*)current_realm();
     							}
     							if(realm && realm[0]) {
     								const turn_dbdriver_t * dbd = get_dbdriver();
     								if (dbd && dbd->del_secret) {
    -									u08bits ss[AUTH_SECRET_SIZE+1];
    -									u08bits r[STUN_MAX_REALM_SIZE+1];
    +									uint8_t ss[AUTH_SECRET_SIZE+1];
    +									uint8_t r[STUN_MAX_REALM_SIZE+1];
     									STRCPY(ss,secret);
     									STRCPY(r,realm);
     									dbd->del_secret(ss,r);
    @@ -3532,40 +3533,40 @@ static void handle_https(ioa_socket_handle s, ioa_network_buffer_handle nbh)
     						}
     					}
     
    -					const u08bits *add_realm = (const u08bits*)current_eff_realm();
    -					const u08bits *add_secret = (const u08bits*)get_http_header_value(hr, HR_ADD_SECRET, "");
    +					const uint8_t *add_realm = (const uint8_t*)current_eff_realm();
    +					const uint8_t *add_secret = (const uint8_t*)get_http_header_value(hr, HR_ADD_SECRET, "");
     					const char* msg = "";
     					if(wrong_html_name((const char*)add_secret)) {
     						msg = "Error: wrong secret value";
    -						add_secret = (const u08bits*)"";
    +						add_secret = (const uint8_t*)"";
     					}
     					if(add_secret[0]) {
    -						add_realm = (const u08bits*)get_http_header_value(hr, HR_ADD_REALM, current_realm());
    +						add_realm = (const uint8_t*)get_http_header_value(hr, HR_ADD_REALM, current_realm());
     						if(!is_superuser()) {
    -							add_realm = (const u08bits*)current_realm();
    +							add_realm = (const uint8_t*)current_realm();
     						}
     						if(!add_realm[0]) {
    -							add_realm=(const u08bits*)current_eff_realm();
    +							add_realm=(const uint8_t*)current_eff_realm();
     						}
     						if(!add_realm[0]) {
    -							add_realm = (const u08bits*)get_realm(NULL)->options.name;
    +							add_realm = (const uint8_t*)get_realm(NULL)->options.name;
     						}
     						if(wrong_html_name((const char*)add_realm)) {
     							msg = "Error: wrong realm name";
    -							add_realm = (const u08bits*)"";
    +							add_realm = (const uint8_t*)"";
     						}
     						if(add_realm[0]) {
     							const turn_dbdriver_t * dbd = get_dbdriver();
     							if (dbd && dbd->set_secret) {
    -								u08bits ss[AUTH_SECRET_SIZE+1];
    -								u08bits r[STUN_MAX_REALM_SIZE+1];
    +								uint8_t ss[AUTH_SECRET_SIZE+1];
    +								uint8_t r[STUN_MAX_REALM_SIZE+1];
     								STRCPY(ss,add_secret);
     								STRCPY(r,add_realm);
     								(*dbd->set_secret)(ss, r);
     							}
     
    -							add_secret=(const u08bits*)"";
    -							add_realm=(const u08bits*)"";
    +							add_secret=(const uint8_t*)"";
    +							add_realm=(const uint8_t*)"";
     						}
     					}
     
    @@ -3586,48 +3587,48 @@ static void handle_https(ioa_socket_handle s, ioa_network_buffer_handle nbh)
     					}
     
     					if(is_superuser()) {
    -						const u08bits *origin = (const u08bits*)get_http_header_value(hr, HR_DELETE_ORIGIN, NULL);
    +						const uint8_t *origin = (const uint8_t*)get_http_header_value(hr, HR_DELETE_ORIGIN, NULL);
     						if(origin && origin[0]) {
     							const turn_dbdriver_t * dbd = get_dbdriver();
     							if (dbd && dbd->del_origin) {
    -								u08bits o[STUN_MAX_ORIGIN_SIZE+1];
    +								uint8_t o[STUN_MAX_ORIGIN_SIZE+1];
     								STRCPY(o,origin);
     								dbd->del_origin(o);
    -								u08bits corigin[STUN_MAX_ORIGIN_SIZE+1];
    +								uint8_t corigin[STUN_MAX_ORIGIN_SIZE+1];
     								get_canonic_origin((const char *)origin, (char *)corigin, sizeof(corigin)-1);
     								dbd->del_origin(corigin);
     							}
     						}
     					}
     
    -					const u08bits *add_realm = (const u08bits*)current_eff_realm();
    -					const u08bits *add_origin = (const u08bits*)get_http_header_value(hr, HR_ADD_ORIGIN, "");
    +					const uint8_t *add_realm = (const uint8_t*)current_eff_realm();
    +					const uint8_t *add_origin = (const uint8_t*)get_http_header_value(hr, HR_ADD_ORIGIN, "");
     					const char* msg = "";
    -					u08bits corigin[STUN_MAX_ORIGIN_SIZE+1];
    +					uint8_t corigin[STUN_MAX_ORIGIN_SIZE+1];
     					get_canonic_origin((const char *)add_origin, (char *)corigin, sizeof(corigin)-1);
     					if(corigin[0]) {
    -						add_realm = (const u08bits*)get_http_header_value(hr, HR_ADD_REALM, current_realm());
    +						add_realm = (const uint8_t*)get_http_header_value(hr, HR_ADD_REALM, current_realm());
     						if(!is_superuser()) {
    -							add_realm = (const u08bits*)current_realm();
    +							add_realm = (const uint8_t*)current_realm();
     						}
     						if(!add_realm[0]) {
    -							add_realm=(const u08bits*)current_eff_realm();
    +							add_realm=(const uint8_t*)current_eff_realm();
     						}
     						if(!add_realm[0]) {
    -							add_realm = (const u08bits*)get_realm(NULL)->options.name;
    +							add_realm = (const uint8_t*)get_realm(NULL)->options.name;
     						}
     						if(add_realm[0]) {
     							const turn_dbdriver_t * dbd = get_dbdriver();
     							if (dbd && dbd->add_origin) {
    -								u08bits o[STUN_MAX_ORIGIN_SIZE+1];
    -								u08bits r[STUN_MAX_REALM_SIZE+1];
    +								uint8_t o[STUN_MAX_ORIGIN_SIZE+1];
    +								uint8_t r[STUN_MAX_REALM_SIZE+1];
     								STRCPY(o,corigin);
     								STRCPY(r,add_realm);
     								(*dbd->add_origin)(o, r);
     							}
     
    -							add_origin=(const u08bits*)"";
    -							add_realm=(const u08bits*)"";
    +							add_origin=(const uint8_t*)"";
    +							add_realm=(const uint8_t*)"";
     						}
     					}
     
    @@ -3661,7 +3662,7 @@ static void handle_https(ioa_socket_handle s, ioa_network_buffer_handle nbh)
     						if(del_kid[0]) {
     							const turn_dbdriver_t * dbd = get_dbdriver();
     							if (dbd && dbd->del_oauth_key) {
    -								(*dbd->del_oauth_key)((const u08bits*)del_kid);
    +								(*dbd->del_oauth_key)((const uint8_t*)del_kid);
     							}
     						}
     					}
    @@ -3687,21 +3688,21 @@ static void handle_https(ioa_socket_handle s, ioa_network_buffer_handle nbh)
     							msg = "You must enter the key value.";
     						} else {
     							oauth_key_data_raw key;
    -							ns_bzero(&key,sizeof(key));
    +							bzero(&key,sizeof(key));
     							STRCPY(key.kid,add_kid);
     
     							if(add_lt && add_lt[0]) {
    -								key.lifetime = (u32bits)strtoul(add_lt,NULL,10);
    +								key.lifetime = (uint32_t)strtoul(add_lt,NULL,10);
     								if(key.lifetime) {
     									if(add_ts && add_ts[0]) {
    -										key.timestamp = (u64bits)strtoull(add_ts,NULL,10);
    +										key.timestamp = (uint64_t)strtoull(add_ts,NULL,10);
     									}
     									if(!key.timestamp) {
    -										key.timestamp = (u64bits)time(NULL);
    +										key.timestamp = (uint64_t)time(NULL);
     									}
     								}
     							} else if(add_ts && add_ts[0]) {
    -								key.timestamp = (u64bits)strtoull(add_ts,NULL,10);
    +								key.timestamp = (uint64_t)strtoull(add_ts,NULL,10);
     							}
     
     							if(add_realm && add_realm[0]) STRCPY(key.realm,add_realm);
    
  • src/apps/relay/turn_ports.c+56 56 modified
    @@ -39,38 +39,38 @@
     ////////// DATA ////////////////////////////////////////////
     
     #define PORTS_SIZE (0xFFFF+1)
    -#define TPS_OUT_OF_RANGE ((u32bits)(-1))
    -#define TPS_TAKEN_SINGLE ((u32bits)(-2))
    -#define TPS_TAKEN_EVEN ((u32bits)(-3))
    -#define TPS_TAKEN_ODD ((u32bits)(-4))
    +#define TPS_OUT_OF_RANGE ((uint32_t)(-1))
    +#define TPS_TAKEN_SINGLE ((uint32_t)(-2))
    +#define TPS_TAKEN_EVEN ((uint32_t)(-3))
    +#define TPS_TAKEN_ODD ((uint32_t)(-4))
     
     struct _turnports {
    -  u32bits status[PORTS_SIZE];
    -  u32bits low;
    -  u32bits high;
    -  u16bits range_start;
    -  u16bits range_stop;
    -  u16bits ports[PORTS_SIZE];
    +  uint32_t status[PORTS_SIZE];
    +  uint32_t low;
    +  uint32_t high;
    +  uint16_t range_start;
    +  uint16_t range_stop;
    +  uint16_t ports[PORTS_SIZE];
       TURN_MUTEX_DECLARE(mutex)
     };
     typedef struct _turnports turnports;
     
     /////////////// TURNPORTS statics //////////////////////////
     
    -static turnports* turnports_create(super_memory_t *sm, u16bits start, u16bits end);
    -static u16bits turnports_size(turnports* tp);
    +static turnports* turnports_create(super_memory_t *sm, uint16_t start, uint16_t end);
    +static uint16_t turnports_size(turnports* tp);
     
     static int turnports_allocate(turnports* tp);
    -static int turnports_allocate_even(turnports* tp, int allocate_rtcp, u64bits *reservation_token);
    +static int turnports_allocate_even(turnports* tp, int allocate_rtcp, uint64_t *reservation_token);
     
    -static void turnports_release(turnports* tp, u16bits port);
    +static void turnports_release(turnports* tp, uint16_t port);
     
    -static int turnports_is_allocated(turnports* tp, u16bits port);
    -static int turnports_is_available(turnports* tp, u16bits port);
    +static int turnports_is_allocated(turnports* tp, uint16_t port);
    +static int turnports_is_available(turnports* tp, uint16_t port);
     
     /////////////// UTILS //////////////////////////////////////
     
    -static int is_taken(u32bits status) {
    +static int is_taken(uint32_t status) {
     	int ret = -1;
     	switch (status) {
     	case TPS_TAKEN_SINGLE :
    @@ -90,42 +90,42 @@ static void turnports_randomize(turnports* tp) {
         unsigned int i=0;
         unsigned int cycles=size*10;
         for(i=0;i<cycles;i++) {
    -      u16bits port1 = (u16bits)(tp->low + (u16bits)(((unsigned long)random())%((unsigned long)size)));
    -      u16bits port2 = (u16bits)(tp->low + (u16bits)(((unsigned long)random())%((unsigned long)size)));
    +      uint16_t port1 = (uint16_t)(tp->low + (uint16_t)(((unsigned long)random())%((unsigned long)size)));
    +      uint16_t port2 = (uint16_t)(tp->low + (uint16_t)(((unsigned long)random())%((unsigned long)size)));
           if(port1!=port2) {
         	  int pos1=tp->status[port1];
         	  int pos2=tp->status[port2];
         	  int tmp=(int)tp->status[port1];
         	  tp->status[port1]=tp->status[port2];
    -    	  tp->status[port2]=(u32bits)tmp;
    +    	  tp->status[port2]=(uint32_t)tmp;
         	  tmp=(int)tp->ports[pos1];
         	  tp->ports[pos1]=tp->ports[pos2];
    -    	  tp->ports[pos2]=(u16bits)tmp;
    +    	  tp->ports[pos2]=(uint16_t)tmp;
           }
         }
       }
     }   
     
    -static void turnports_init(turnports* tp, u16bits start, u16bits end) {
    +static void turnports_init(turnports* tp, uint16_t start, uint16_t end) {
     
       tp->low=start;
    -  tp->high=((u32bits)end)+1;
    +  tp->high=((uint32_t)end)+1;
     
       tp->range_start=start;
       tp->range_stop=end;
       
       int i=0;
       for(i=0;i<start;i++) {
         tp->status[i]=TPS_OUT_OF_RANGE;
    -    tp->ports[i]=(u16bits)i;
    +    tp->ports[i]=(uint16_t)i;
       }
       for(i=start;i<=end;i++) {
    -    tp->status[i]=(u32bits)i;
    -    tp->ports[i]=(u16bits)i;
    +    tp->status[i]=(uint32_t)i;
    +    tp->ports[i]=(uint16_t)i;
       }
       for(i=((int)end)+1;i<PORTS_SIZE;i++) {
         tp->status[i]=TPS_OUT_OF_RANGE;
    -    tp->ports[i]=(u16bits)i;
    +    tp->ports[i]=(uint16_t)i;
       }
     
       turnports_randomize(tp);
    @@ -135,7 +135,7 @@ static void turnports_init(turnports* tp, u16bits start, u16bits end) {
     
     /////////////// FUNC ///////////////////////////////////////
     
    -turnports* turnports_create(super_memory_t *sm, u16bits start, u16bits end) {
    +turnports* turnports_create(super_memory_t *sm, uint16_t start, uint16_t end) {
     
       if(start>end) return NULL;
     
    @@ -145,11 +145,11 @@ turnports* turnports_create(super_memory_t *sm, u16bits start, u16bits end) {
       return ret;
     }
     
    -u16bits turnports_size(turnports* tp) {
    +uint16_t turnports_size(turnports* tp) {
       if(!tp) return 0;
       else {
         TURN_MUTEX_LOCK(&tp->mutex);
    -    u16bits ret = (u16bits)((tp->high-tp->low));
    +    uint16_t ret = (uint16_t)((tp->high-tp->low));
         TURN_MUTEX_UNLOCK(&tp->mutex);
         return ret;
       }
    @@ -170,7 +170,7 @@ int turnports_allocate(turnports* tp) {
         	  return -1;
           }
           
    -      int position=(u16bits)(tp->low & 0x0000FFFF);
    +      int position=(uint16_t)(tp->low & 0x0000FFFF);
           
           port=(int)tp->ports[position];
           if(port<(int)(tp->range_start) || port>((int)(tp->range_stop))) {
    @@ -196,10 +196,10 @@ int turnports_allocate(turnports* tp) {
       return port;
     }
     
    -void turnports_release(turnports* tp, u16bits port) {
    +void turnports_release(turnports* tp, uint16_t port) {
       TURN_MUTEX_LOCK(&tp->mutex);
       if(tp && port>=tp->range_start && port<=tp->range_stop) {
    -    u16bits position=(u16bits)(tp->high & 0x0000FFFF);
    +    uint16_t position=(uint16_t)(tp->high & 0x0000FFFF);
         if(is_taken(tp->status[port])) {
           tp->status[port]=tp->high;
           tp->ports[position]=port;
    @@ -209,12 +209,12 @@ void turnports_release(turnports* tp, u16bits port) {
       TURN_MUTEX_UNLOCK(&tp->mutex);
     }
     
    -int turnports_allocate_even(turnports* tp, int allocate_rtcp, u64bits *reservation_token) {
    +int turnports_allocate_even(turnports* tp, int allocate_rtcp, uint64_t *reservation_token) {
       if(tp) {
         TURN_MUTEX_LOCK(&tp->mutex);
    -    u16bits size = turnports_size(tp);
    +    uint16_t size = turnports_size(tp);
         if(size>1) {
    -      u16bits i=0;
    +      uint16_t i=0;
           for(i=0;i<size;i++) {
         	  int port=turnports_allocate(tp);
         	  if(port & 0x00000001) {
    @@ -233,11 +233,11 @@ int turnports_allocate_even(turnports* tp, int allocate_rtcp, u64bits *reservati
         				  tp->status[port]=TPS_TAKEN_EVEN;
         				  tp->status[rtcp_port]=TPS_TAKEN_ODD;
         				  if(reservation_token) {
    -    					  u16bits *v16=(u16bits*)reservation_token;
    -    					  u32bits *v32=(u32bits*)reservation_token;
    -    					  v16[0]=(u16bits)(tp->ports[(u16bits)(tp->low & 0x0000FFFF)]);
    -    					  v16[1]=(u16bits)(tp->ports[(u16bits)(tp->high & 0x0000FFFF)]);
    -    					  v32[1]=(u32bits)turn_random();
    +    					  uint16_t *v16=(uint16_t*)reservation_token;
    +    					  uint32_t *v32=(uint32_t*)reservation_token;
    +    					  v16[0]=(uint16_t)(tp->ports[(uint16_t)(tp->low & 0x0000FFFF)]);
    +    					  v16[1]=(uint16_t)(tp->ports[(uint16_t)(tp->high & 0x0000FFFF)]);
    +    					  v32[1]=(uint32_t)turn_random();
         				  }
         				  TURN_MUTEX_UNLOCK(&tp->mutex);
         				  return port;
    @@ -251,7 +251,7 @@ int turnports_allocate_even(turnports* tp, int allocate_rtcp, u64bits *reservati
       return -1;
     }
     
    -int turnports_is_allocated(turnports* tp, u16bits port) {
    +int turnports_is_allocated(turnports* tp, uint16_t port) {
       if(!tp) return 0;
       else {
         TURN_MUTEX_LOCK(&tp->mutex);
    @@ -261,12 +261,12 @@ int turnports_is_allocated(turnports* tp, u16bits port) {
       }
     }
     
    -int turnports_is_available(turnports* tp, u16bits port) {
    +int turnports_is_available(turnports* tp, uint16_t port) {
       if(tp) {
         TURN_MUTEX_LOCK(&tp->mutex);
    -    u32bits status = tp->status[port];
    +    uint32_t status = tp->status[port];
         if((status!=TPS_OUT_OF_RANGE) && !is_taken(status)) {
    -      u16bits position=(u16bits)(status & 0x0000FFFF);
    +      uint16_t position=(uint16_t)(status & 0x0000FFFF);
           if(tp->ports[position]==port) {
         	  TURN_MUTEX_UNLOCK(&tp->mutex);
         	  return 1;
    @@ -282,16 +282,16 @@ int turnports_is_available(turnports* tp, u16bits port) {
     struct _turnipports
     {
     	super_memory_t *sm;
    -	u16bits start;
    -	u16bits end;
    +	uint16_t start;
    +	uint16_t end;
     	ur_addr_map ip_to_turnports_udp;
     	ur_addr_map ip_to_turnports_tcp;
     	TURN_MUTEX_DECLARE(mutex)
     };
     
     //////////////////////////////////////////////////
     
    -static ur_addr_map *get_map(turnipports *tp, u08bits transport)
    +static ur_addr_map *get_map(turnipports *tp, uint8_t transport)
     {
     	if(transport == STUN_ATTRIBUTE_TRANSPORT_TCP_VALUE)
     		return &(tp->ip_to_turnports_tcp);
    @@ -301,7 +301,7 @@ static ur_addr_map *get_map(turnipports *tp, u08bits transport)
     
     static turnipports* turnipports_singleton = NULL;
     
    -turnipports* turnipports_create(super_memory_t *sm, u16bits start, u16bits end)
    +turnipports* turnipports_create(super_memory_t *sm, uint16_t start, uint16_t end)
     {
     	turnipports *ret = (turnipports*) allocate_super_memory_region(sm, sizeof(turnipports));
     	ret->sm = sm;
    @@ -314,7 +314,7 @@ turnipports* turnipports_create(super_memory_t *sm, u16bits start, u16bits end)
     	return ret;
     }
     
    -static turnports* turnipports_add(turnipports* tp, u08bits transport, const ioa_addr *backend_addr)
    +static turnports* turnipports_add(turnipports* tp, uint8_t transport, const ioa_addr *backend_addr)
     {
     	ur_addr_map_value_type t = 0;
     	if (tp && backend_addr) {
    @@ -331,12 +331,12 @@ static turnports* turnipports_add(turnipports* tp, u08bits transport, const ioa_
     	return (turnports*) t;
     }
     
    -void turnipports_add_ip(u08bits transport, const ioa_addr *backend_addr)
    +void turnipports_add_ip(uint8_t transport, const ioa_addr *backend_addr)
     {
     	turnipports_add(turnipports_singleton, transport, backend_addr);
     }
     
    -int turnipports_allocate(turnipports* tp, u08bits transport, const ioa_addr *backend_addr)
    +int turnipports_allocate(turnipports* tp, uint8_t transport, const ioa_addr *backend_addr)
     {
     	int ret = -1;
     	if (tp && backend_addr) {
    @@ -349,7 +349,7 @@ int turnipports_allocate(turnipports* tp, u08bits transport, const ioa_addr *bac
     }
     
     int turnipports_allocate_even(turnipports* tp, const ioa_addr *backend_addr, int allocate_rtcp,
    -				u64bits *reservation_token)
    +				uint64_t *reservation_token)
     {
     	int ret = -1;
     	if (tp && backend_addr) {
    @@ -361,7 +361,7 @@ int turnipports_allocate_even(turnipports* tp, const ioa_addr *backend_addr, int
     	return ret;
     }
     
    -void turnipports_release(turnipports* tp, u08bits transport, const ioa_addr *socket_addr)
    +void turnipports_release(turnipports* tp, uint8_t transport, const ioa_addr *socket_addr)
     {
     	if (tp && socket_addr) {
     		ioa_addr ba;
    @@ -376,7 +376,7 @@ void turnipports_release(turnipports* tp, u08bits transport, const ioa_addr *soc
     	}
     }
     
    -int turnipports_is_allocated(turnipports* tp, u08bits transport, const ioa_addr *backend_addr, u16bits port)
    +int turnipports_is_allocated(turnipports* tp, uint8_t transport, const ioa_addr *backend_addr, uint16_t port)
     {
     	int ret = 0;
     	if (tp && backend_addr) {
    @@ -393,7 +393,7 @@ int turnipports_is_allocated(turnipports* tp, u08bits transport, const ioa_addr
     	return ret;
     }
     
    -int turnipports_is_available(turnipports* tp, u08bits transport, const ioa_addr *backend_addr, u16bits port)
    +int turnipports_is_available(turnipports* tp, uint8_t transport, const ioa_addr *backend_addr, uint16_t port)
     {
     	int ret = 0;
     	if (tp && backend_addr) {
    
  • src/apps/relay/turn_ports.h+7 7 modified
    @@ -51,18 +51,18 @@ typedef struct _turnipports turnipports;
     
     //////////////////////////////////////////////////
     
    -turnipports* turnipports_create(super_memory_t *sm, u16bits start, u16bits end);
    +turnipports* turnipports_create(super_memory_t *sm, uint16_t start, uint16_t end);
     
    -void turnipports_add_ip(u08bits transport, const ioa_addr *backend_addr);
    +void turnipports_add_ip(uint8_t transport, const ioa_addr *backend_addr);
     
    -int turnipports_allocate(turnipports* tp, u08bits transport, const ioa_addr *backend_addr);
    +int turnipports_allocate(turnipports* tp, uint8_t transport, const ioa_addr *backend_addr);
     int turnipports_allocate_even(turnipports* tp, const ioa_addr *backend_addr, 
    -			      int allocate_rtcp, u64bits *reservation_token);
    +			      int allocate_rtcp, uint64_t *reservation_token);
     
    -void turnipports_release(turnipports* tp, u08bits transport, const ioa_addr *socket_addr);
    +void turnipports_release(turnipports* tp, uint8_t transport, const ioa_addr *socket_addr);
     
    -int turnipports_is_allocated(turnipports* tp, u08bits transport, const ioa_addr *backend_addr, u16bits port);
    -int turnipports_is_available(turnipports* tp, u08bits transport, const ioa_addr *backend_addr, u16bits port);
    +int turnipports_is_allocated(turnipports* tp, uint8_t transport, const ioa_addr *backend_addr, uint16_t port);
    +int turnipports_is_available(turnipports* tp, uint8_t transport, const ioa_addr *backend_addr, uint16_t port);
     
     //////////////////////////////////////////////////
     
    
  • src/apps/relay/userdb.c+89 89 modified
    @@ -105,7 +105,7 @@ void create_default_realm()
     	/* init everything: */
     	TURN_MUTEX_INIT_RECURSIVE(&o_to_realm_mutex);
     	init_secrets_list(&realms_list);
    -	o_to_realm = ur_string_map_create(turn_free_simple);
    +	o_to_realm = ur_string_map_create(free);
     	default_realm_params_ptr = &_default_realm_params;
     	realms = ur_string_map_create(NULL);
     	lock_realms();
    @@ -117,7 +117,7 @@ void get_default_realm_options(realm_options_t* ro)
     {
     	if(ro) {
     		lock_realms();
    -		ns_bcopy(&(default_realm_params_ptr->options),ro,sizeof(realm_options_t));
    +		bcopy(&(default_realm_params_ptr->options),ro,sizeof(realm_options_t));
     		unlock_realms();
     	}
     }
    @@ -141,8 +141,8 @@ realm_params_t* get_realm(char* name)
     			unlock_realms();
     			return (realm_params_t*)value;
     		} else {
    -			realm_params_t *ret = (realm_params_t*)turn_malloc(sizeof(realm_params_t));
    -			ns_bcopy(default_realm_params_ptr,ret,sizeof(realm_params_t));
    +			realm_params_t *ret = (realm_params_t*)malloc(sizeof(realm_params_t));
    +			bcopy(default_realm_params_ptr,ret,sizeof(realm_params_t));
     			STRCPY(ret->options.name,name);
     			value = (ur_string_map_value_type)ret;
     			ur_string_map_put(realms, key, value);
    @@ -159,7 +159,7 @@ realm_params_t* get_realm(char* name)
     int get_realm_data(char* name, realm_params_t* rp)
     {
     	lock_realms();
    -	ns_bcopy(get_realm(name),rp,sizeof(realm_params_t));
    +	bcopy(get_realm(name),rp,sizeof(realm_params_t));
     	unlock_realms();
     	return 0;
     }
    @@ -169,12 +169,12 @@ int get_realm_options_by_origin(char *origin, realm_options_t* ro)
     	ur_string_map_value_type value = 0;
     	TURN_MUTEX_LOCK(&o_to_realm_mutex);
     	if (ur_string_map_get(o_to_realm, (ur_string_map_key_type) origin, &value) && value) {
    -		char *realm = turn_strdup((char*)value);
    +		char *realm = strdup((char*)value);
     		TURN_MUTEX_UNLOCK(&o_to_realm_mutex);
     		realm_params_t rp;
     		get_realm_data(realm, &rp);
    -		ns_bcopy(&(rp.options),ro,sizeof(realm_options_t));
    -		turn_free(realm,strlen(realm)+1);
    +		bcopy(&(rp.options),ro,sizeof(realm_options_t));
    +		free(realm);
     		return 1;
     	} else {
     		TURN_MUTEX_UNLOCK(&o_to_realm_mutex);
    @@ -187,7 +187,7 @@ void get_realm_options_by_name(char *realm, realm_options_t* ro)
     {
     	realm_params_t rp;
     	get_realm_data(realm, &rp);
    -	ns_bcopy(&(rp.options),ro,sizeof(realm_options_t));
    +	bcopy(&(rp.options),ro,sizeof(realm_options_t));
     }
     
     int change_total_quota(char *realm, int value)
    @@ -251,7 +251,7 @@ static void must_set_admin_origin(void *origin0)
     void init_secrets_list(secrets_list_t *sl)
     {
     	if(sl) {
    -		ns_bzero(sl,sizeof(secrets_list_t));
    +		bzero(sl,sizeof(secrets_list_t));
     	}
     }
     
    @@ -262,10 +262,10 @@ void clean_secrets_list(secrets_list_t *sl)
     			size_t i = 0;
     			for(i = 0;i<sl->sz;++i) {
     				if(sl->secrets[i]) {
    -					turn_free(sl->secrets[i], strlen(sl->secrets[i])+1);
    +					free(sl->secrets[i]);
     				}
     			}
    -			turn_free(sl->secrets,(sl->sz)*sizeof(char*));
    +			free(sl->secrets);
     			sl->secrets = NULL;
     			sl->sz = 0;
     		}
    @@ -291,15 +291,15 @@ const char* get_secrets_list_elem(secrets_list_t *sl, size_t i)
     void add_to_secrets_list(secrets_list_t *sl, const char* elem)
     {
     	if(sl && elem) {
    -	  sl->secrets = (char**)turn_realloc(sl->secrets,0,(sizeof(char*)*(sl->sz+1)));
    -	  sl->secrets[sl->sz] = turn_strdup(elem);
    +	  sl->secrets = (char**)realloc(sl->secrets,(sizeof(char*)*(sl->sz+1)));
    +	  sl->secrets[sl->sz] = strdup(elem);
     	  sl->sz += 1;
     	}
     }
     
     ////////////////////////////////////////////
     
    -static int get_auth_secrets(secrets_list_t *sl, u08bits *realm)
    +static int get_auth_secrets(secrets_list_t *sl, uint8_t *realm)
     {
     	int ret = -1;
       const turn_dbdriver_t * dbd = get_dbdriver();
    @@ -384,21 +384,21 @@ static char *get_real_username(char *usname)
     					usname = col+1;
     				} else {
     					*col=0;
    -					usname = turn_strdup(usname);
    +					usname = strdup(usname);
     					*col=turn_params.rest_api_separator;
     					return usname;
     				}
     			}
     		}
     	}
     
    -	return turn_strdup(usname);
    +	return strdup(usname);
     }
     
     /*
      * Password retrieval
      */
    -int get_user_key(int in_oauth, int *out_oauth, int *max_session_time, u08bits *usname, u08bits *realm, hmackey_t key, ioa_network_buffer_handle nbh)
    +int get_user_key(int in_oauth, int *out_oauth, int *max_session_time, uint8_t *usname, uint8_t *realm, hmackey_t key, ioa_network_buffer_handle nbh)
     {
     	int ret = -1;
     
    @@ -413,7 +413,7 @@ int get_user_key(int in_oauth, int *out_oauth, int *max_session_time, u08bits *u
     		if(sar) {
     
     			int len = stun_attr_get_len(sar);
    -			const u08bits *value = stun_attr_get_value(sar);
    +			const uint8_t *value = stun_attr_get_value(sar);
     
     			*out_oauth = 1;
     
    @@ -424,7 +424,7 @@ int get_user_key(int in_oauth, int *out_oauth, int *max_session_time, u08bits *u
     				if (dbd && dbd->get_oauth_key) {
     
     					oauth_key_data_raw rawKey;
    -					ns_bzero(&rawKey,sizeof(rawKey));
    +					bzero(&rawKey,sizeof(rawKey));
     
     					int gres = (*(dbd->get_oauth_key))(usname,&rawKey);
     					if(gres<0)
    @@ -440,32 +440,32 @@ int get_user_key(int in_oauth, int *out_oauth, int *max_session_time, u08bits *u
     					}
     
     					oauth_key_data okd;
    -					ns_bzero(&okd,sizeof(okd));
    +					bzero(&okd,sizeof(okd));
     
     					convert_oauth_key_data_raw(&rawKey, &okd);
     
     					char err_msg[1025] = "\0";
     					size_t err_msg_size = sizeof(err_msg) - 1;
     
     					oauth_key okey;
    -					ns_bzero(&okey,sizeof(okey));
    +					bzero(&okey,sizeof(okey));
     
     					if (convert_oauth_key_data(&okd, &okey, err_msg, err_msg_size) < 0) {
     						TURN_LOG_FUNC(TURN_LOG_LEVEL_ERROR, "%s\n", err_msg);
     						return -1;
     					}
     
     					oauth_token dot;
    -					ns_bzero((&dot),sizeof(dot));
    +					bzero((&dot),sizeof(dot));
     
     					encoded_oauth_token etoken;
    -					ns_bzero(&etoken,sizeof(etoken));
    +					bzero(&etoken,sizeof(etoken));
     
     					if((size_t)len > sizeof(etoken.token)) {
     						TURN_LOG_FUNC(TURN_LOG_LEVEL_ERROR, "Encoded oAuth token is too large\n");
     						return -1;
     					}
    -					ns_bcopy(value,etoken.token,(size_t)len);
    +					bcopy(value,etoken.token,(size_t)len);
     					etoken.size = (size_t)len;
     
     					const char* server_name = (char*)turn_params.oauth_server_name;
    @@ -477,7 +477,7 @@ int get_user_key(int in_oauth, int *out_oauth, int *max_session_time, u08bits *u
     						}
     					}
     
    -					if (decode_oauth_token((const u08bits *) server_name, &etoken,&okey, &dot) < 0) {
    +					if (decode_oauth_token((const uint8_t *) server_name, &etoken,&okey, &dot) < 0) {
     						TURN_LOG_FUNC(TURN_LOG_LEVEL_ERROR, "Cannot decode oauth token\n");
     						return -1;
     					}
    @@ -515,10 +515,10 @@ int get_user_key(int in_oauth, int *out_oauth, int *max_session_time, u08bits *u
     							}
     						}
     
    -						ns_bcopy(dot.enc_block.mac_key,key,dot.enc_block.key_length);
    +						bcopy(dot.enc_block.mac_key,key,dot.enc_block.key_length);
     
     						if(rawKey.realm[0]) {
    -							ns_bcopy(rawKey.realm,realm,sizeof(rawKey.realm));
    +							bcopy(rawKey.realm,realm,sizeof(rawKey.realm));
     						}
     
     						ret = 0;
    @@ -548,7 +548,7 @@ int get_user_key(int in_oauth, int *out_oauth, int *max_session_time, u08bits *u
     
     		if(!turn_time_before(ts, ctime)) {
     
    -			u08bits hmac[MAXSHASIZE];
    +			uint8_t hmac[MAXSHASIZE];
     			unsigned int hmac_len;
     			password_t pwdtmp;
     
    @@ -577,15 +577,15 @@ int get_user_key(int in_oauth, int *out_oauth, int *max_session_time, u08bits *u
     				const char* secret = get_secrets_list_elem(&sl,sll);
     
     				if(secret) {
    -					if(stun_calculate_hmac(usname, strlen((char*)usname), (const u08bits*)secret, strlen(secret), hmac, &hmac_len, SHATYPE_DEFAULT)>=0) {
    +					if(stun_calculate_hmac(usname, strlen((char*)usname), (const uint8_t*)secret, strlen(secret), hmac, &hmac_len, SHATYPE_DEFAULT)>=0) {
     						size_t pwd_length = 0;
     						char *pwd = base64_encode(hmac,hmac_len,&pwd_length);
     
     						if(pwd) {
     							if(pwd_length<1) {
    -								turn_free(pwd,strlen(pwd)+1);
    +								free(pwd);
     							} else {
    -								if(stun_produce_integrity_key_str((u08bits*)usname, realm, (u08bits*)pwd, key, SHATYPE_DEFAULT)>=0) {
    +								if(stun_produce_integrity_key_str((uint8_t*)usname, realm, (uint8_t*)pwd, key, SHATYPE_DEFAULT)>=0) {
     
     									if(stun_check_message_integrity_by_key_str(TURN_CREDENTIALS_LONG_TERM,
     										ioa_network_buffer_data(nbh),
    @@ -597,7 +597,7 @@ int get_user_key(int in_oauth, int *out_oauth, int *max_session_time, u08bits *u
     										ret = 0;
     									}
     								}
    -								turn_free(pwd,pwd_length);
    +								free(pwd);
     
     								if(ret==0)
     									break;
    @@ -622,7 +622,7 @@ int get_user_key(int in_oauth, int *out_oauth, int *max_session_time, u08bits *u
     
     	if(ret==0) {
     		size_t sz = get_hmackey_size(SHATYPE_DEFAULT);
    -		ns_bcopy(ukey,key,sz);
    +		bcopy(ukey,key,sz);
     		return 0;
     	}
     
    @@ -634,12 +634,12 @@ int get_user_key(int in_oauth, int *out_oauth, int *max_session_time, u08bits *u
     	return ret;
     }
     
    -u08bits *start_user_check(turnserver_id id, turn_credential_type ct, int in_oauth, int *out_oauth, u08bits *usname, u08bits *realm, get_username_resume_cb resume, ioa_net_data *in_buffer, u64bits ctxkey, int *postpone_reply)
    +uint8_t *start_user_check(turnserver_id id, turn_credential_type ct, int in_oauth, int *out_oauth, uint8_t *usname, uint8_t *realm, get_username_resume_cb resume, ioa_net_data *in_buffer, uint64_t ctxkey, int *postpone_reply)
     {
     	*postpone_reply = 1;
     
     	struct auth_message am;
    -	ns_bzero(&am,sizeof(struct auth_message));
    +	bzero(&am,sizeof(struct auth_message));
     	am.id = id;
     	am.ct = ct;
     	am.in_oauth = in_oauth;
    @@ -656,11 +656,11 @@ u08bits *start_user_check(turnserver_id id, turn_credential_type ct, int in_oaut
     	return NULL;
     }
     
    -int check_new_allocation_quota(u08bits *user, int oauth, u08bits *realm)
    +int check_new_allocation_quota(uint8_t *user, int oauth, uint8_t *realm)
     {
     	int ret = 0;
     	if (user || oauth) {
    -		u08bits *username = oauth ? (u08bits*)turn_strdup("") : (u08bits*)get_real_username((char*)user);
    +		uint8_t *username = oauth ? (uint8_t*)strdup("") : (uint8_t*)get_real_username((char*)user);
     		realm_params_t *rp = get_realm((char*)realm);
     		ur_string_map_lock(rp->status.alloc_counters);
     		if (rp->options.perf_options.total_quota && (rp->status.total_current_allocs >= rp->options.perf_options.total_quota)) {
    @@ -683,16 +683,16 @@ int check_new_allocation_quota(u08bits *user, int oauth, u08bits *realm)
     		} else {
     			++(rp->status.total_current_allocs);
     		}
    -		turn_free(username,strlen((char*)username)+1);
    +		free(username);
     		ur_string_map_unlock(rp->status.alloc_counters);
     	}
     	return ret;
     }
     
    -void release_allocation_quota(u08bits *user, int oauth, u08bits *realm)
    +void release_allocation_quota(uint8_t *user, int oauth, uint8_t *realm)
     {
     	if (user) {
    -		u08bits *username = oauth ? (u08bits*)turn_strdup("") : (u08bits*)get_real_username((char*)user);
    +		uint8_t *username = oauth ? (uint8_t*)strdup("") : (uint8_t*)get_real_username((char*)user);
     		realm_params_t *rp = get_realm((char*)realm);
     		ur_string_map_lock(rp->status.alloc_counters);
     		if(username[0]) {
    @@ -706,7 +706,7 @@ void release_allocation_quota(u08bits *user, int oauth, u08bits *realm)
     		if (rp->status.total_current_allocs)
     			--(rp->status.total_current_allocs);
     		ur_string_map_unlock(rp->status.alloc_counters);
    -		turn_free(username, strlen((char*)username)+1);
    +		free(username);
     	}
     }
     
    @@ -721,38 +721,38 @@ int add_static_user_account(char *user)
     			TURN_LOG_FUNC(TURN_LOG_LEVEL_ERROR, "Wrong user account: %s\n",user);
     		} else {
     			size_t ulen = s-user;
    -			char *usname = (char*)turn_malloc(sizeof(char)*(ulen+1));
    +			char *usname = (char*)malloc(sizeof(char)*(ulen+1));
     			strncpy(usname,user,ulen);
     			usname[ulen]=0;
    -			if(SASLprep((u08bits*)usname)<0) {
    +			if(SASLprep((uint8_t*)usname)<0) {
     				TURN_LOG_FUNC(TURN_LOG_LEVEL_ERROR, "Wrong user name: %s\n",user);
    -				turn_free(usname,sizeof(char)*(ulen+1));
    +				free(usname);
     				return -1;
     			}
     			s = skip_blanks(s+1);
    -			hmackey_t *key = (hmackey_t*)turn_malloc(sizeof(hmackey_t));
    +			hmackey_t *key = (hmackey_t*)malloc(sizeof(hmackey_t));
     			if(strstr(s,"0x")==s) {
     				char *keysource = s + 2;
     				size_t sz = get_hmackey_size(SHATYPE_DEFAULT);
     				if(strlen(keysource)<sz*2) {
     					TURN_LOG_FUNC(TURN_LOG_LEVEL_ERROR, "Wrong key format: %s\n",s);
     				} if(convert_string_key_to_binary(keysource, *key, sz)<0) {
     					TURN_LOG_FUNC(TURN_LOG_LEVEL_ERROR, "Wrong key: %s\n",s);
    -					turn_free(usname,strlen(usname)+1);
    -					turn_free(key,sizeof(hmackey_t));
    +					free(usname);
    +					free(key);
     					return -1;
     				}
     			} else {
     				//this is only for default realm
    -				stun_produce_integrity_key_str((u08bits*)usname, (u08bits*)get_realm(NULL)->options.name, (u08bits*)s, *key, SHATYPE_DEFAULT);
    +				stun_produce_integrity_key_str((uint8_t*)usname, (uint8_t*)get_realm(NULL)->options.name, (uint8_t*)s, *key, SHATYPE_DEFAULT);
     			}
     			{
     				ur_string_map_lock(turn_params.default_users_db.ram_db.static_accounts);
     				ur_string_map_put(turn_params.default_users_db.ram_db.static_accounts, (ur_string_map_key_type)usname, (ur_string_map_value_type)*key);
     				ur_string_map_unlock(turn_params.default_users_db.ram_db.static_accounts);
     			}
     			turn_params.default_users_db.ram_db.users_number++;
    -			turn_free(usname,strlen(usname)+1);
    +			free(usname);
     			return 0;
     		}
     	}
    @@ -762,7 +762,7 @@ int add_static_user_account(char *user)
     
     ////////////////// Admin /////////////////////////
     
    -static int list_users(u08bits *realm, int is_admin)
    +static int list_users(uint8_t *realm, int is_admin)
     {
       const turn_dbdriver_t * dbd = get_dbdriver();
       if (dbd) {
    @@ -780,7 +780,7 @@ static int list_users(u08bits *realm, int is_admin)
       return 0;
     }
     
    -static int show_secret(u08bits *realm)
    +static int show_secret(uint8_t *realm)
     {
       const turn_dbdriver_t * dbd = get_dbdriver();
       if (dbd && dbd->list_secrets) {
    @@ -790,7 +790,7 @@ static int show_secret(u08bits *realm)
       return 0;
     }
     
    -static int del_secret(u08bits *secret, u08bits *realm) {
    +static int del_secret(uint8_t *secret, uint8_t *realm) {
     
     	must_set_admin_realm(realm);
     
    @@ -802,7 +802,7 @@ static int del_secret(u08bits *secret, u08bits *realm) {
     	return 0;
     }
     
    -static int set_secret(u08bits *secret, u08bits *realm) {
    +static int set_secret(uint8_t *secret, uint8_t *realm) {
     
     	if(!secret || (secret[0]==0))
     		return 0;
    @@ -819,9 +819,9 @@ static int set_secret(u08bits *secret, u08bits *realm) {
     	return 0;
     }
     
    -static int add_origin(u08bits *origin0, u08bits *realm)
    +static int add_origin(uint8_t *origin0, uint8_t *realm)
     {
    -	u08bits origin[STUN_MAX_ORIGIN_SIZE+1];
    +	uint8_t origin[STUN_MAX_ORIGIN_SIZE+1];
     
     	get_canonic_origin((const char *)origin0, (char *)origin, sizeof(origin)-1);
     
    @@ -833,9 +833,9 @@ static int add_origin(u08bits *origin0, u08bits *realm)
     	return 0;
     }
     
    -static int del_origin(u08bits *origin0)
    +static int del_origin(uint8_t *origin0)
     {
    -	u08bits origin[STUN_MAX_ORIGIN_SIZE+1];
    +	uint8_t origin[STUN_MAX_ORIGIN_SIZE+1];
     
     	get_canonic_origin((const char *)origin0, (char *)origin, sizeof(origin)-1);
     
    @@ -847,7 +847,7 @@ static int del_origin(u08bits *origin0)
     	return 0;
     }
     
    -static int list_origins(u08bits *realm)
    +static int list_origins(uint8_t *realm)
     {
       const turn_dbdriver_t * dbd = get_dbdriver();
       if (dbd && dbd->list_origins) {
    @@ -857,7 +857,7 @@ static int list_origins(u08bits *realm)
       return 0;
     }
     
    -static int set_realm_option_one(u08bits *realm, unsigned long value, const char* opt)
    +static int set_realm_option_one(uint8_t *realm, unsigned long value, const char* opt)
     {
     	if(value == (unsigned long)-1)
     		return 0;
    @@ -870,15 +870,15 @@ static int set_realm_option_one(u08bits *realm, unsigned long value, const char*
     	return 0;
     }
     
    -static int set_realm_option(u08bits *realm, perf_options_t *po)
    +static int set_realm_option(uint8_t *realm, perf_options_t *po)
     {
     	set_realm_option_one(realm,(unsigned long)po->max_bps,"max-bps");
     	set_realm_option_one(realm,(unsigned long)po->user_quota,"user-quota");
     	set_realm_option_one(realm,(unsigned long)po->total_quota,"total-quota");
     	return 0;
     }
     
    -static int list_realm_options(u08bits *realm)
    +static int list_realm_options(uint8_t *realm)
     {
       const turn_dbdriver_t * dbd = get_dbdriver();
       if (dbd && dbd->list_realm_options) {
    @@ -888,7 +888,7 @@ static int list_realm_options(u08bits *realm)
     	return 0;
     }
     
    -int adminuser(u08bits *user, u08bits *realm, u08bits *pwd, u08bits *secret, u08bits *origin, TURNADMIN_COMMAND_TYPE ct, perf_options_t *po, int is_admin)
    +int adminuser(uint8_t *user, uint8_t *realm, uint8_t *pwd, uint8_t *secret, uint8_t *origin, TURNADMIN_COMMAND_TYPE ct, perf_options_t *po, int is_admin)
     {
     	hmackey_t key;
     	char skey[sizeof(hmackey_t) * 2 + 1];
    @@ -1021,7 +1021,7 @@ void run_db_test(void)
     		printf("DB TEST 2:\n");
     		oauth_key_data_raw key_;
     		oauth_key_data_raw *key=&key_;
    -		dbd->get_oauth_key((const u08bits*)"north",key);
    +		dbd->get_oauth_key((const uint8_t*)"north",key);
     		printf("  kid=%s, ikm_key=%s, timestamp=%llu, lifetime=%lu, as_rs_alg=%s\n",
     		    		key->kid, key->ikm_key, (unsigned long long)key->timestamp, (unsigned long)key->lifetime, key->as_rs_alg);
     
    @@ -1032,22 +1032,22 @@ void run_db_test(void)
     		STRCPY(key->kid,"kid");
     		key->timestamp = 123;
     		key->lifetime = 456;
    -		dbd->del_oauth_key((const u08bits*)"kid");
    +		dbd->del_oauth_key((const uint8_t*)"kid");
     		dbd->set_oauth_key(key);
     		dbd->list_oauth_keys();
     
     		printf("DB TEST 4:\n");
    -		dbd->get_oauth_key((const u08bits*)"kid",key);
    +		dbd->get_oauth_key((const uint8_t*)"kid",key);
     		printf("  kid=%s, ikm_key=%s, timestamp=%llu, lifetime=%lu, as_rs_alg=%s\n",
     		    		key->kid, key->ikm_key, (unsigned long long)key->timestamp, (unsigned long)key->lifetime, key->as_rs_alg);
     
     		printf("DB TEST 5:\n");
    -		dbd->del_oauth_key((const u08bits*)"kid");
    +		dbd->del_oauth_key((const uint8_t*)"kid");
     		dbd->list_oauth_keys();
     
     		printf("DB TEST 6:\n");
     
    -		dbd->get_oauth_key((const u08bits*)"north",key);
    +		dbd->get_oauth_key((const uint8_t*)"north",key);
     
     		oauth_key_data oakd;
     		convert_oauth_key_data_raw(key, &oakd);
    @@ -1084,10 +1084,10 @@ static ip_range_list_t* ipblacklist = NULL;
     void init_dynamic_ip_lists(void)
     {
     #if !defined(TURN_NO_RWLOCK)
    -	whitelist_rwlock = (pthread_rwlock_t*) turn_malloc(sizeof(pthread_rwlock_t));
    +	whitelist_rwlock = (pthread_rwlock_t*) malloc(sizeof(pthread_rwlock_t));
     	pthread_rwlock_init(whitelist_rwlock, NULL);
     
    -	blacklist_rwlock = (pthread_rwlock_t*) turn_malloc(sizeof(pthread_rwlock_t));
    +	blacklist_rwlock = (pthread_rwlock_t*) malloc(sizeof(pthread_rwlock_t));
     	pthread_rwlock_init(blacklist_rwlock, NULL);
     #else
     	turn_mutex_init(&whitelist_mutex);
    @@ -1163,11 +1163,11 @@ const ip_range_list_t* ioa_get_blacklist(ioa_engine_handle e)
     
     ip_range_list_t* get_ip_list(const char *kind)
     {
    -	ip_range_list_t *ret = (ip_range_list_t*) turn_malloc(sizeof(ip_range_list_t));
    -	ns_bzero(ret,sizeof(ip_range_list_t));
    +	ip_range_list_t *ret = (ip_range_list_t*) malloc(sizeof(ip_range_list_t));
    +	bzero(ret,sizeof(ip_range_list_t));
     
     	const turn_dbdriver_t * dbd = get_dbdriver();
    -	if (dbd && dbd->get_ip_list) {
    +	if (dbd && dbd->get_ip_list && !turn_params.no_dynamic_ip_list) {
     		(*dbd->get_ip_list)(kind, ret);
     	}
     
    @@ -1178,8 +1178,8 @@ void ip_list_free(ip_range_list_t *l)
     {
     	if(l) {
     		if(l->rs)
    -		  turn_free(l->rs,l->ranges_number * sizeof(ip_range_t));
    -		turn_free(l,sizeof(ip_range_list_t));
    +		  free(l->rs);
    +		free(l);
     	}
     }
     
    @@ -1209,7 +1209,7 @@ void update_white_and_black_lists(void)
     
     int add_ip_list_range(const char * range0, const char * realm, ip_range_list_t * list)
     {
    -	char *range = turn_strdup(range0);
    +	char *range = strdup(range0);
     
     	char* separator = strchr(range, '-');
     
    @@ -1219,16 +1219,16 @@ int add_ip_list_range(const char * range0, const char * realm, ip_range_list_t *
     
     	ioa_addr min, max;
     
    -	if (make_ioa_addr((const u08bits*) range, 0, &min) < 0) {
    +	if (make_ioa_addr((const uint8_t*) range, 0, &min) < 0) {
     		TURN_LOG_FUNC(TURN_LOG_LEVEL_ERROR, "Wrong address format: %s\n", range);
    -		turn_free(range,0);
    +		free(range);
     		return -1;
     	}
     
     	if (separator) {
    -		if (make_ioa_addr((const u08bits*) separator + 1, 0, &max) < 0) {
    +		if (make_ioa_addr((const uint8_t*) separator + 1, 0, &max) < 0) {
     			TURN_LOG_FUNC(TURN_LOG_LEVEL_ERROR, "Wrong address format: %s\n", separator + 1);
    -			turn_free(range,0);
    +			free(range);
     			return -1;
     		}
     	} else {
    @@ -1240,21 +1240,21 @@ int add_ip_list_range(const char * range0, const char * realm, ip_range_list_t *
     		*separator = '-';
     
     	++(list->ranges_number);
    -	list->rs = (ip_range_t*) turn_realloc(list->rs, 0, sizeof(ip_range_t) * list->ranges_number);
    +	list->rs = (ip_range_t*) realloc(list->rs, sizeof(ip_range_t) * list->ranges_number);
     	STRCPY(list->rs[list->ranges_number - 1].str,range);
     	if(realm)
     		STRCPY(list->rs[list->ranges_number - 1].realm,realm);
     	else
     		list->rs[list->ranges_number - 1].realm[0]=0;
    -	turn_free(range,0);
    +	free(range);
     	ioa_addr_range_set(&(list->rs[list->ranges_number - 1].enc), &min, &max);
     
     	return 0;
     }
     
     int check_ip_list_range(const char * range0)
     {
    -	char *range = turn_strdup(range0);
    +	char *range = strdup(range0);
     
     	char* separator = strchr(range, '-');
     
    @@ -1264,16 +1264,16 @@ int check_ip_list_range(const char * range0)
     
     	ioa_addr min, max;
     
    -	if (make_ioa_addr((const u08bits*) range, 0, &min) < 0) {
    +	if (make_ioa_addr((const uint8_t*) range, 0, &min) < 0) {
     		TURN_LOG_FUNC(TURN_LOG_LEVEL_ERROR, "Wrong address range format: %s\n", range);
    -		turn_free(range,0);
    +		free(range);
     		return -1;
     	}
     
     	if (separator) {
    -		if (make_ioa_addr((const u08bits*) separator + 1, 0, &max) < 0) {
    +		if (make_ioa_addr((const uint8_t*) separator + 1, 0, &max) < 0) {
     			TURN_LOG_FUNC(TURN_LOG_LEVEL_ERROR, "Wrong address range format: %s\n", separator + 1);
    -			turn_free(range,0);
    +			free(range);
     			return -1;
     		}
     	} else {
    @@ -1284,7 +1284,7 @@ int check_ip_list_range(const char * range0)
     	if (separator)
     		*separator = '-';
     
    -	turn_free(range,0);
    +	free(range);
     
     	return 0;
     }
    @@ -1303,7 +1303,7 @@ void reread_realms(void)
     	}
     
     	const turn_dbdriver_t * dbd = get_dbdriver();
    -	if (dbd && dbd->reread_realms) {
    +	if (dbd && dbd->reread_realms && !turn_params.no_dynamic_realms) {
     		(*dbd->reread_realms)(&realms_list);
     	}
     }
    
  • src/apps/relay/userdb.h+8 8 modified
    @@ -83,13 +83,13 @@ struct auth_message {
     	int in_oauth;
     	int out_oauth;
     	int max_session_time;
    -	u08bits username[STUN_MAX_USERNAME_SIZE + 1];
    -	u08bits realm[STUN_MAX_REALM_SIZE + 1];
    +	uint8_t username[STUN_MAX_USERNAME_SIZE + 1];
    +	uint8_t realm[STUN_MAX_REALM_SIZE + 1];
     	hmackey_t key;
     	password_t pwd;
     	get_username_resume_cb resume_func;
     	ioa_net_data in_buffer;
    -	u64bits ctxkey;
    +	uint64_t ctxkey;
     	int success;
     };
     
    @@ -185,10 +185,10 @@ void add_to_secrets_list(secrets_list_t *sl, const char* elem);
     
     /////////// USER DB CHECK //////////////////
     
    -int get_user_key(int in_oauth, int *out_oauth, int *max_session_time, u08bits *uname, u08bits *realm, hmackey_t key, ioa_network_buffer_handle nbh);
    -u08bits *start_user_check(turnserver_id id, turn_credential_type ct, int in_oauth, int *out_oauth, u08bits *uname, u08bits *realm, get_username_resume_cb resume, ioa_net_data *in_buffer, u64bits ctxkey, int *postpone_reply);
    -int check_new_allocation_quota(u08bits *username, int oauth, u08bits *realm);
    -void release_allocation_quota(u08bits *username, int oauth, u08bits *realm);
    +int get_user_key(int in_oauth, int *out_oauth, int *max_session_time, uint8_t *uname, uint8_t *realm, hmackey_t key, ioa_network_buffer_handle nbh);
    +uint8_t *start_user_check(turnserver_id id, turn_credential_type ct, int in_oauth, int *out_oauth, uint8_t *uname, uint8_t *realm, get_username_resume_cb resume, ioa_net_data *in_buffer, uint64_t ctxkey, int *postpone_reply);
    +int check_new_allocation_quota(uint8_t *username, int oauth, uint8_t *realm);
    +void release_allocation_quota(uint8_t *username, int oauth, uint8_t *realm);
     
     /////////// Handle user DB /////////////////
     
    @@ -199,7 +199,7 @@ void release_allocation_quota(u08bits *username, int oauth, u08bits *realm);
     void auth_ping(redis_context_handle rch);
     void reread_realms(void);
     int add_static_user_account(char *user);
    -int adminuser(u08bits *user, u08bits *realm, u08bits *pwd, u08bits *secret, u08bits *origin, TURNADMIN_COMMAND_TYPE ct, perf_options_t* po, int is_admin);
    +int adminuser(uint8_t *user, uint8_t *realm, uint8_t *pwd, uint8_t *secret, uint8_t *origin, TURNADMIN_COMMAND_TYPE ct, perf_options_t* po, int is_admin);
     
     int add_ip_list_range(const char* range, const char* realm, ip_range_list_t * list);
     int check_ip_list_range(const char* range);
    
  • src/apps/rfc5769/rfc5769check.c+34 34 modified
    @@ -96,24 +96,24 @@ static int check_oauth(void) {
     					printf("\n");
     
     				oauth_token ot;
    -				ns_bzero(&ot,sizeof(ot));
    +				bzero(&ot,sizeof(ot));
     				ot.enc_block.key_length = (uint16_t)mac_key_length;
     				STRCPY(ot.enc_block.mac_key,mac_key);
     				ot.enc_block.timestamp = token_timestamp;
     				ot.enc_block.lifetime = token_lifetime;
     
     				oauth_token dot;
    -				ns_bzero((&dot),sizeof(dot));
    +				bzero((&dot),sizeof(dot));
     				oauth_key key;
    -				ns_bzero(&key,sizeof(key));
    +				bzero(&key,sizeof(key));
     
     				{
     					oauth_key_data okd;
    -					ns_bzero(&okd,sizeof(okd));
    +					bzero(&okd,sizeof(okd));
     
     					{
     					  oauth_key_data_raw okdr;
    -					  ns_bzero(&okdr,sizeof(okdr));
    +					  bzero(&okdr,sizeof(okdr));
     
     						STRCPY(okdr.kid,kid);
     						STRCPY(okdr.ikm_key,base64encoded_ltp);
    @@ -141,10 +141,10 @@ static int check_oauth(void) {
     
     				{
     					encoded_oauth_token etoken;
    -					ns_bzero(&etoken,sizeof(etoken));
    +					bzero(&etoken,sizeof(etoken));
     
    -					if (encode_oauth_token((const u08bits *) server_name, &etoken,
    -							&key, &ot, (const u08bits*)gcm_nonce) < 0) {
    +					if (encode_oauth_token((const uint8_t *) server_name, &etoken,
    +							&key, &ot, (const uint8_t*)gcm_nonce) < 0) {
     						fprintf(stderr, "%s: cannot encode oauth token\n",
     								__FUNCTION__);
     						return -1;
    @@ -154,7 +154,7 @@ static int check_oauth(void) {
     						print_field5769("encoded token",etoken.token,etoken.size);
     					}
     
    -					if (decode_oauth_token((const u08bits *) server_name, &etoken,
    +					if (decode_oauth_token((const uint8_t *) server_name, &etoken,
     							&key, &dot) < 0) {
     						fprintf(stderr, "%s: cannot decode oauth token\n",
     								__FUNCTION__);
    @@ -235,7 +235,7 @@ int main(int argc, const char **argv)
     					     "\x80\x28\x00\x04"
     					       "\xe5\x7a\x3b\xcf";
     
    -		u08bits buf[sizeof(reqstc)];
    +		uint8_t buf[sizeof(reqstc)];
     		memcpy(buf, reqstc, sizeof(reqstc));
     
     		{//fingerprintfs etc
    @@ -252,9 +252,9 @@ int main(int argc, const char **argv)
     		}
     
     		{//short-term credentials
    -			u08bits uname[33];
    -			u08bits realm[33];
    -			u08bits upwd[33];
    +			uint8_t uname[33];
    +			uint8_t realm[33];
    +			uint8_t upwd[33];
     			strcpy((char*) upwd, "VOkJxbRl1RmTxUk/WvJxBt");
     
     			res = stun_check_message_integrity_str(TURN_CREDENTIALS_SHORT_TERM, buf, sizeof(reqstc) - 1, uname, realm, upwd, shatype);
    @@ -303,17 +303,17 @@ int main(int argc, const char **argv)
     			"\xf6\x70\x24\x65\x6d\xd6\x4a\x3e\x02\xb8\xe0\x71"
     			"\x2e\x85\xc9\xa2\x8c\xa8\x96\x66";
     
    -		u08bits user[] = "\xe3\x83\x9e\xe3\x83\x88\xe3\x83\xaa\xe3\x83\x83"
    +		uint8_t user[] = "\xe3\x83\x9e\xe3\x83\x88\xe3\x83\xaa\xe3\x83\x83"
     			"\xe3\x82\xaf\xe3\x82\xb9";
     
    -		u08bits realm[33];
    -		u08bits nonce[29];
    -		u08bits upwd[33];
    +		uint8_t realm[33];
    +		uint8_t nonce[29];
    +		uint8_t upwd[33];
     
    -		u08bits buf[sizeof(reqltc)];
    +		uint8_t buf[sizeof(reqltc)];
     		memcpy(buf, reqltc, sizeof(reqltc));
     
    -		u08bits uname[sizeof(user)];
    +		uint8_t uname[sizeof(user)];
     		memcpy(uname, user, sizeof(user));
     
     		strcpy((char*) realm, "example.org");
    @@ -338,13 +338,13 @@ int main(int argc, const char **argv)
     		{ //encoding test
     			printf("RFC 5769 message encoding test result: ");
     			size_t len = 0;
    -			u16bits message_type = STUN_METHOD_BINDING;
    +			uint16_t message_type = STUN_METHOD_BINDING;
     			stun_tid tid;
    -			u16bits *buf16 = (u16bits*)buf;
    -			u32bits *buf32 = (u32bits*)buf;
    +			uint16_t *buf16 = (uint16_t*)buf;
    +			uint32_t *buf32 = (uint32_t*)buf;
     			memcpy(tid.tsx_id,"\x78\xad\x34\x33\xc6\xad\x72\xc0\x29\xda\x41\x2e",12);
     			stun_init_buffer_str(buf,&len);
    -			message_type &= (u16bits)(0x3FFF);
    +			message_type &= (uint16_t)(0x3FFF);
     			buf16[0]=nswap16(message_type);
     			buf16[1]=0;
     			buf32[1]=nswap32(STUN_MAGIC_COOKIE);
    @@ -363,7 +363,7 @@ int main(int argc, const char **argv)
     					int cols = 4;
     					for(line = 0;line<lines;line++) {
     						for(col = 0; col<cols; col++) {
    -							u08bits c = buf[line*4+col];
    +							uint8_t c = buf[line*4+col];
     							printf(" %2x",(int)c);
     						}
     						printf("\n");
    @@ -403,7 +403,7 @@ int main(int argc, const char **argv)
     			"\x80\x28\x00\x04"
     			"\xc0\x7d\x4c\x96";
     
    -		u08bits buf[sizeof(respv4)];
    +		uint8_t buf[sizeof(respv4)];
     		memcpy(buf, respv4, sizeof(respv4));
     
     		{//fingerprintfs etc
    @@ -420,9 +420,9 @@ int main(int argc, const char **argv)
     		}
     
     		{//short-term credentials
    -			u08bits uname[33];
    -			u08bits realm[33];
    -			u08bits upwd[33];
    +			uint8_t uname[33];
    +			uint8_t realm[33];
    +			uint8_t upwd[33];
     			strcpy((char*) upwd, "VOkJxbRl1RmTxUk/WvJxBt");
     
     			res = stun_check_message_integrity_str(TURN_CREDENTIALS_SHORT_TERM, buf, sizeof(respv4) - 1, uname, realm, upwd, shatype);
    @@ -465,7 +465,7 @@ int main(int argc, const char **argv)
     				exit(-1);
     			}
     
    -			make_ioa_addr((const u08bits*)"192.0.2.1", 32853, &addr4_test);
    +			make_ioa_addr((const uint8_t*)"192.0.2.1", 32853, &addr4_test);
     			if(addr_eq(&addr4,&addr4_test)) {
     				printf("success\n");
     			} else {
    @@ -491,7 +491,7 @@ int main(int argc, const char **argv)
     						     "\x80\x28\x00\x04"
     						       "\xc8\xfb\x0b\x4c";
     
    -		u08bits buf[sizeof(respv6)];
    +		uint8_t buf[sizeof(respv6)];
     
     		{ //decoding test
     			memcpy(buf, respv6, sizeof(respv6));
    @@ -508,9 +508,9 @@ int main(int argc, const char **argv)
     		}
     
     		{//short-term credentials test
    -			u08bits uname[33];
    -			u08bits realm[33];
    -			u08bits upwd[33];
    +			uint8_t uname[33];
    +			uint8_t realm[33];
    +			uint8_t upwd[33];
     			strcpy((char*) upwd, "VOkJxbRl1RmTxUk/WvJxBt");
     
     			res = stun_check_message_integrity_str(TURN_CREDENTIALS_SHORT_TERM, buf, sizeof(respv6) - 1, uname, realm, upwd, shatype);
    @@ -554,7 +554,7 @@ int main(int argc, const char **argv)
     				exit(-1);
     			}
     
    -			make_ioa_addr((const u08bits*) "2001:db8:1234:5678:11:2233:4455:6677", 32853, &addr6_test);
    +			make_ioa_addr((const uint8_t*) "2001:db8:1234:5678:11:2233:4455:6677", 32853, &addr6_test);
     			if (addr_eq(&addr6, &addr6_test)) {
     				printf("success\n");
     			} else {
    
  • src/apps/stunclient/stunclient.c+14 14 modified
    @@ -58,7 +58,7 @@ static int run_stunclient(const char* rip, int rport, int *port, int *rfc5780, i
     	int new_udp_fd = -1;
     
     	memset((void *) &remote_addr, 0, sizeof(ioa_addr));
    -	if (make_ioa_addr((const u08bits*) rip, rport, &remote_addr) < 0)
    +	if (make_ioa_addr((const uint8_t*) rip, rport, &remote_addr) < 0)
     		err(-1, NULL);
     
     	if (udp_fd < 0) {
    @@ -90,7 +90,7 @@ static int run_stunclient(const char* rip, int rport, int *port, int *rfc5780, i
     
     	if (response_port >= 0) {
     	  turn::StunAttrResponsePort rpa;
    -		rpa.setResponsePort((u16bits)response_port);
    +		rpa.setResponsePort((uint16_t)response_port);
     		try {
     			req.addAttr(rpa);
     		} catch(turn::WrongStunAttrFormatException &ex1) {
    @@ -168,7 +168,7 @@ static int run_stunclient(const char* rip, int rport, int *port, int *rfc5780, i
     	{
     		int len = 0;
     		stun_buffer buf;
    -		u08bits *ptr = buf.buf;
    +		uint8_t *ptr = buf.buf;
     		int recvd = 0;
     		const int to_recv = sizeof(buf.buf);
     
    @@ -253,8 +253,8 @@ static int run_stunclient(const char* rip, int rport, int *port, int *rfc5780, i
     	int new_udp_fd = -1;
     	stun_buffer buf;
     
    -	ns_bzero(&remote_addr, sizeof(remote_addr));
    -	if (make_ioa_addr((const u08bits*) rip, rport, &remote_addr) < 0)
    +	bzero(&remote_addr, sizeof(remote_addr));
    +	if (make_ioa_addr((const uint8_t*) rip, rport, &remote_addr) < 0)
     		err(-1, NULL);
     
     	if (udp_fd < 0) {
    @@ -283,13 +283,13 @@ static int run_stunclient(const char* rip, int rport, int *port, int *rfc5780, i
     	stun_prepare_binding_request(&buf);
     
     	if (response_port >= 0) {
    -		stun_attr_add_response_port_str((u08bits*) (buf.buf), (size_t*) &(buf.len), (u16bits) response_port);
    +		stun_attr_add_response_port_str((uint8_t*) (buf.buf), (size_t*) &(buf.len), (uint16_t) response_port);
     	}
     	if (change_ip || change_port) {
    -		stun_attr_add_change_request_str((u08bits*) buf.buf, (size_t*) &(buf.len), change_ip, change_port);
    +		stun_attr_add_change_request_str((uint8_t*) buf.buf, (size_t*) &(buf.len), change_ip, change_port);
     	}
     	if (padding) {
    -		if(stun_attr_add_padding_str((u08bits*) buf.buf, (size_t*) &(buf.len), 1500)<0) {
    +		if(stun_attr_add_padding_str((uint8_t*) buf.buf, (size_t*) &(buf.len), 1500)<0) {
     			printf("%s: ERROR: Cannot add padding\n",__FUNCTION__);
     		}
     	}
    @@ -323,7 +323,7 @@ static int run_stunclient(const char* rip, int rport, int *port, int *rfc5780, i
     
     	{
     		int len = 0;
    -		u08bits *ptr = buf.buf;
    +		uint8_t *ptr = buf.buf;
     		int recvd = 0;
     		const int to_recv = sizeof(buf.buf);
     
    @@ -358,11 +358,11 @@ static int run_stunclient(const char* rip, int rport, int *port, int *rfc5780, i
     								printf("\n========================================\n");
     								printf("RFC 5780 response %d\n",++counter);
     								ioa_addr other_addr;
    -								stun_attr_get_addr_str((u08bits *) buf.buf, (size_t) buf.len, sar, &other_addr, NULL);
    +								stun_attr_get_addr_str((uint8_t *) buf.buf, (size_t) buf.len, sar, &other_addr, NULL);
     								sar = stun_attr_get_first_by_type_str(buf.buf, buf.len, STUN_ATTRIBUTE_RESPONSE_ORIGIN);
     								if (sar) {
     									ioa_addr response_origin;
    -									stun_attr_get_addr_str((u08bits *) buf.buf, (size_t) buf.len, sar, &response_origin, NULL);
    +									stun_attr_get_addr_str((uint8_t *) buf.buf, (size_t) buf.len, sar, &response_origin, NULL);
     									addr_debug_print(1, &response_origin, "Response origin: ");
     								}
     								addr_debug_print(1, &other_addr, "Other addr: ");
    @@ -377,7 +377,7 @@ static int run_stunclient(const char* rip, int rport, int *port, int *rfc5780, i
     					}
     				} else {
     					int err_code = 0;
    -					u08bits err_msg[1025] = "\0";
    +					uint8_t err_msg[1025] = "\0";
     					size_t err_msg_size = sizeof(err_msg);
     					if (stun_is_error_response(&buf, &err_code, err_msg, err_msg_size)) {
     						printf("The response is an error %d (%s)\n", err_code, (char*) err_msg);
    @@ -418,7 +418,7 @@ int main(int argc, char **argv)
       set_logfile("stdout");
       set_system_parameters(0);
       
    -  ns_bzero(local_addr, sizeof(local_addr));
    +  bzero(local_addr, sizeof(local_addr));
     
       while ((c = getopt(argc, argv, "p:L:f")) != -1) {
         switch(c) {
    @@ -445,7 +445,7 @@ int main(int argc, char **argv)
       addr_set_any(&real_local_addr);
     
       if(local_addr[0]) {
    -      if(make_ioa_addr((const u08bits*)local_addr, 0, &real_local_addr)<0) {
    +      if(make_ioa_addr((const uint8_t*)local_addr, 0, &real_local_addr)<0) {
             err(-1,NULL);
           }
       }
    
  • src/apps/uclient/mainuclient.c+7 7 modified
    @@ -60,7 +60,7 @@ ioa_addr peer_addr;
     int no_rtcp = 0;
     int default_address_family = STUN_ATTRIBUTE_REQUESTED_ADDRESS_FAMILY_VALUE_DEFAULT;
     int dont_fragment = 0;
    -u08bits g_uname[STUN_MAX_USERNAME_SIZE+1];
    +uint8_t g_uname[STUN_MAX_USERNAME_SIZE+1];
     password_t g_upwd;
     char g_auth_secret[1025]="\0";
     int g_use_auth_secret_with_timestamp = 0;
    @@ -73,7 +73,7 @@ char pkey_file[1025]="";
     SSL_CTX *root_tls_ctx[32];
     int root_tls_ctx_num = 0;
     
    -u08bits relay_transport = STUN_ATTRIBUTE_TRANSPORT_UDP_VALUE;
    +uint8_t relay_transport = STUN_ATTRIBUTE_TRANSPORT_UDP_VALUE;
     unsigned char client_ifname[1025] = "";
     int passive_tcp = 0;
     int mandatory_channel_padding = 0;
    @@ -179,7 +179,7 @@ int main(int argc, char **argv)
     
     	set_system_parameters(0);
     
    -	ns_bzero(local_addr, sizeof(local_addr));
    +	bzero(local_addr, sizeof(local_addr));
     
     	while ((c = getopt(argc, argv, "a:d:p:l:n:L:m:e:r:u:w:i:k:z:W:C:E:F:o:bZvsyhcxXgtTSAPDNOUMRIGBJ")) != -1) {
     		switch (c){
    @@ -389,7 +389,7 @@ int main(int argc, char **argv)
     			STRCPY(g_uname,new_uname);
     		}
     		{
    -			u08bits hmac[MAXSHASIZE];
    +			uint8_t hmac[MAXSHASIZE];
     			unsigned int hmac_len;
     
     			switch(shatype) {
    @@ -408,13 +408,13 @@ int main(int argc, char **argv)
     
     			hmac[0]=0;
     
    -			if(stun_calculate_hmac(g_uname, strlen((char*)g_uname), (u08bits*)g_auth_secret, strlen(g_auth_secret), hmac, &hmac_len, shatype)>=0) {
    +			if(stun_calculate_hmac(g_uname, strlen((char*)g_uname), (uint8_t*)g_auth_secret, strlen(g_auth_secret), hmac, &hmac_len, shatype)>=0) {
     				size_t pwd_length = 0;
     				char *pwd = base64_encode(hmac,hmac_len,&pwd_length);
     
     				if(pwd) {
     					if(pwd_length>0) {
    -						ns_bcopy(pwd,g_upwd,pwd_length);
    +						bcopy(pwd,g_upwd,pwd_length);
     						g_upwd[pwd_length]=0;
     					}
     				}
    @@ -454,7 +454,7 @@ int main(int argc, char **argv)
     
     	if (!c2c) {
     
    -		if (make_ioa_addr((const u08bits*) peer_address, peer_port, &peer_addr) < 0) {
    +		if (make_ioa_addr((const uint8_t*) peer_address, peer_port, &peer_addr) < 0) {
     			return -1;
     		}
     
    
  • src/apps/uclient/session.h+11 11 modified
    @@ -61,7 +61,7 @@ typedef enum _UR_STATE UR_STATE;
     typedef struct
     {
     	/* RFC 6062 */
    -	u32bits cid;
    +	uint32_t cid;
     	ioa_addr tcp_data_local_addr;
     	ioa_socket_raw tcp_data_fd;
     	SSL *tcp_data_ssl;
    @@ -79,11 +79,11 @@ typedef struct {
       ioa_socket_raw fd;
       SSL *ssl;
       int broken;
    -  u08bits nonce[STUN_MAX_NONCE_SIZE+1];
    -  u08bits realm[STUN_MAX_REALM_SIZE+1];
    +  uint8_t nonce[STUN_MAX_NONCE_SIZE+1];
    +  uint8_t realm[STUN_MAX_REALM_SIZE+1];
       /* oAuth */
       int oauth;
    -  u08bits server_name[STUN_MAX_SERVER_NAME_SIZE+1];
    +  uint8_t server_name[STUN_MAX_SERVER_NAME_SIZE+1];
       hmackey_t key;
       int key_set;
       int cok;
    @@ -106,26 +106,26 @@ typedef struct {
       struct event *input_tcp_data_ev;
       stun_buffer in_buffer;
       stun_buffer out_buffer;
    -  u32bits refresh_time;
    -  u32bits finished_time;
    +  uint32_t refresh_time;
    +  uint32_t finished_time;
       //Msg counters:
       int tot_msgnum;
       int wmsgnum;
       int rmsgnum;
       int recvmsgnum;
    -  u32bits recvtimems;
    -  u32bits to_send_timems;
    +  uint32_t recvtimems;
    +  uint32_t to_send_timems;
       //Statistics:
       size_t loss;
    -  u64bits latency;
    -  u64bits jitter;
    +  uint64_t latency;
    +  uint64_t jitter;
     } app_ur_session;
     
     ///////////////////////////////////////////////////////
     
     typedef struct _message_info {
     	int msgnum;
    -	u64bits mstime;
    +	uint64_t mstime;
     } message_info;
     
     ///////////////////////////////////////////////////////////////////////////////
    
  • src/apps/uclient/startuclient.c+54 54 modified
    @@ -89,7 +89,7 @@ static SSL* tls_connect(ioa_socket_raw fd, ioa_addr *remote_addr, int *try_again
     
     	SSL *ssl;
     
    -	ssl = SSL_NEW(root_tls_ctx[ctxtype]);
    +	ssl = SSL_new(root_tls_ctx[ctxtype]);
     
     #if ALPN_SUPPORTED
     	SSL_set_alpn_protos(ssl, kALPNProtos, kALPNProtosLen);
    @@ -161,7 +161,7 @@ static SSL* tls_connect(ioa_socket_raw fd, ioa_addr *remote_addr, int *try_again
     								(int)ERR_get_error(), ERR_error_string(ERR_get_error(), buf), (int)SSL_get_error(ssl, rc));
     				if(connect_cycle<MAX_TLS_CYCLES) {
     					if(try_again) {
    -						SSL_FREE(ssl);
    +						SSL_free(ssl);
     						*try_again = 1;
     						return NULL;
     					}
    @@ -222,12 +222,12 @@ static int clnet_connect(uint16_t clnet_remote_port, const char *remote_address,
     	clnet_fd = -1;
     	connect_err = 0;
     
    -	ns_bzero(&remote_addr, sizeof(ioa_addr));
    -	if (make_ioa_addr((const u08bits*) remote_address, clnet_remote_port,
    +	bzero(&remote_addr, sizeof(ioa_addr));
    +	if (make_ioa_addr((const uint8_t*) remote_address, clnet_remote_port,
     			&remote_addr) < 0)
     		return -1;
     
    -	ns_bzero(&local_addr, sizeof(ioa_addr));
    +	bzero(&local_addr, sizeof(ioa_addr));
     
     	clnet_fd = socket(remote_addr.ss.sa_family,
     			use_sctp ? SCTP_CLIENT_STREAM_SOCKET_TYPE : (use_tcp ? CLIENT_STREAM_SOCKET_TYPE : CLIENT_DGRAM_SOCKET_TYPE),
    @@ -250,11 +250,11 @@ static int clnet_connect(uint16_t clnet_remote_port, const char *remote_address,
     	if(clnet_info->is_peer && (*local_address==0)) {
     
     		if(remote_addr.ss.sa_family == AF_INET6) {
    -			if (make_ioa_addr((const u08bits*) "::1", 0, &local_addr) < 0) {
    +			if (make_ioa_addr((const uint8_t*) "::1", 0, &local_addr) < 0) {
     			    return -1;
     			}
     		} else {
    -			if (make_ioa_addr((const u08bits*) "127.0.0.1", 0, &local_addr) < 0) {
    +			if (make_ioa_addr((const uint8_t*) "127.0.0.1", 0, &local_addr) < 0) {
     			    return -1;
     			}
     		}
    @@ -263,7 +263,7 @@ static int clnet_connect(uint16_t clnet_remote_port, const char *remote_address,
     
     	} else if (strlen(local_address) > 0) {
     
    -		if (make_ioa_addr((const u08bits*) local_address, 0,
    +		if (make_ioa_addr((const uint8_t*) local_address, 0,
     			    &local_addr) < 0)
     			return -1;
     
    @@ -315,9 +315,9 @@ int read_mobility_ticket(app_ur_conn_info *clnet_info, stun_buffer *message)
     		if(s_mobile_id_sar) {
     			int smid_len = stun_attr_get_len(s_mobile_id_sar);
     			if(smid_len>0 && (((size_t)smid_len)<sizeof(clnet_info->s_mobile_id))) {
    -				const u08bits* smid_val = stun_attr_get_value(s_mobile_id_sar);
    +				const uint8_t* smid_val = stun_attr_get_value(s_mobile_id_sar);
     				if(smid_val) {
    -					ns_bcopy(smid_val, clnet_info->s_mobile_id, (size_t)smid_len);
    +					bcopy(smid_val, clnet_info->s_mobile_id, (size_t)smid_len);
     					clnet_info->s_mobile_id[smid_len] = 0;
     					if (clnet_verbose)
     						TURN_LOG_FUNC(TURN_LOG_LEVEL_INFO,
    @@ -348,7 +348,7 @@ static int clnet_allocate(int verbose,
     		app_ur_conn_info *clnet_info,
     		ioa_addr *relay_addr,
     		int af,
    -		char *turn_addr, u16bits *turn_port) {
    +		char *turn_addr, uint16_t *turn_port) {
     
     	int af_cycle = 0;
     	int reopen_socket = 0;
    @@ -368,7 +368,7 @@ static int clnet_allocate(int verbose,
     		if(reopen_socket && !use_tcp) {
     			socket_closesocket(clnet_info->fd);
     			clnet_info->fd = -1;
    -			if (clnet_connect(addr_get_port(&(clnet_info->remote_addr)), clnet_info->rsaddr, (u08bits*)clnet_info->ifname, clnet_info->lsaddr,
    +			if (clnet_connect(addr_get_port(&(clnet_info->remote_addr)), clnet_info->rsaddr, (uint8_t*)clnet_info->ifname, clnet_info->lsaddr,
     					verbose, clnet_info) < 0) {
     				exit(-1);
     			}
    @@ -394,7 +394,7 @@ static int clnet_allocate(int verbose,
     		} else if(rt) {
     			ep = -1;
     		} else if(!ep) {
    -			ep = (((u08bits)random()) % 2);
    +			ep = (((uint8_t)random()) % 2);
     			ep = ep-1;
     		}
     
    @@ -448,7 +448,7 @@ static int clnet_allocate(int verbose,
     					}
     					response_message.len = len;
     					int err_code = 0;
    -					u08bits err_msg[129];
    +					uint8_t err_msg[129];
     					if (stun_is_success_response(&response_message)) {
     						allocate_received = 1;
     						allocate_finished = 1;
    @@ -542,8 +542,8 @@ static int clnet_allocate(int verbose,
     							if(stun_attr_get_first_addr(&response_message, STUN_ATTRIBUTE_ALTERNATE_SERVER, &alternate_server, NULL)==-1) {
     								//error
     							} else if(turn_addr && turn_port){
    -								addr_to_string_no_port(&alternate_server, (u08bits*)turn_addr);
    -								*turn_port = (u16bits)addr_get_port(&alternate_server);
    +								addr_to_string_no_port(&alternate_server, (uint8_t*)turn_addr);
    +								*turn_port = (uint16_t)addr_get_port(&alternate_server);
     							}
     
     						}
    @@ -600,7 +600,7 @@ static int clnet_allocate(int verbose,
     			  int close_socket = (int)(random()%2);
     			  if(ssl && !close_socket) {
     				  SSL_shutdown(ssl);
    -				  SSL_FREE(ssl);
    +				  SSL_free(ssl);
     				  fd = -1;
     			  } else if(fd>=0) {
     				  close(fd);
    @@ -610,7 +610,7 @@ static int clnet_allocate(int verbose,
     		  }
     
     		  app_ur_conn_info ci;
    -		  ns_bcopy(clnet_info,&ci,sizeof(ci));
    +		  bcopy(clnet_info,&ci,sizeof(ci));
     		  ci.fd = -1;
     		  ci.ssl = NULL;
     		  clnet_info->fd = -1;
    @@ -624,7 +624,7 @@ static int clnet_allocate(int verbose,
     
     		  if(ssl) {
     			  SSL_shutdown(ssl);
    -		  	  SSL_FREE(ssl);
    +		  	  SSL_free(ssl);
     		  } else if(fd>=0) {
     		  	  close(fd);
     		  }
    @@ -651,10 +651,10 @@ static int clnet_allocate(int verbose,
     			}
     
     			if(dual_allocation && !mobility) {
    -				int t = ((u08bits)random())%3;
    +				int t = ((uint8_t)random())%3;
     				if(t) {
    -					u08bits field[4];
    -					field[0] = (t==1) ? (u08bits)STUN_ATTRIBUTE_REQUESTED_ADDRESS_FAMILY_VALUE_IPV4 : (u08bits)STUN_ATTRIBUTE_REQUESTED_ADDRESS_FAMILY_VALUE_IPV6;
    +					uint8_t field[4];
    +					field[0] = (t==1) ? (uint8_t)STUN_ATTRIBUTE_REQUESTED_ADDRESS_FAMILY_VALUE_IPV4 : (uint8_t)STUN_ATTRIBUTE_REQUESTED_ADDRESS_FAMILY_VALUE_IPV6;
     					field[1]=0;
     					field[2]=0;
     					field[3]=0;
    @@ -709,7 +709,7 @@ static int clnet_allocate(int verbose,
     					}
     					response_message.len = len;
     					int err_code = 0;
    -					u08bits err_msg[129];
    +					uint8_t err_msg[129];
     					if (stun_is_success_response(&response_message)) {
     						read_mobility_ticket(clnet_info, &response_message);
     						refresh_received = 1;
    @@ -753,7 +753,7 @@ static int turn_channel_bind(int verbose, uint16_t *chn,
     		int cb_sent = 0;
     
     		if(negative_test) {
    -			*chn = stun_set_channel_bind_request(&request_message, peer_addr, (u16bits)random());
    +			*chn = stun_set_channel_bind_request(&request_message, peer_addr, (uint16_t)random());
     		} else {
     			*chn = stun_set_channel_bind_request(&request_message, peer_addr, *chn);
     		}
    @@ -796,7 +796,7 @@ static int turn_channel_bind(int verbose, uint16_t *chn,
     							"cb response received: \n");
     				}
     				int err_code = 0;
    -				u08bits err_msg[129];
    +				uint8_t err_msg[129];
     				if (stun_is_success_response(&response_message)) {
     
     					cb_received = 1;
    @@ -844,7 +844,7 @@ static int turn_create_permission(int verbose, app_ur_conn_info *clnet_info,
     
     	char saddr[129]="\0";
     	if (verbose) {
    -		addr_to_string(peer_addr,(u08bits*)saddr);
    +		addr_to_string(peer_addr,(uint8_t*)saddr);
     	}
     
     	stun_buffer request_message, response_message;
    @@ -901,7 +901,7 @@ static int turn_create_permission(int verbose, app_ur_conn_info *clnet_info,
     							"cp response received: \n");
     				}
     				int err_code = 0;
    -				u08bits err_msg[129];
    +				uint8_t err_msg[129];
     				if (stun_is_success_response(&response_message)) {
     
     					cp_received = 1;
    @@ -1031,18 +1031,18 @@ int start_connection(uint16_t clnet_remote_port0,
     				if(random() % 2 == 0)
     					sarbaddr = "2001::172";
     				ioa_addr arbaddr;
    -				make_ioa_addr((const u08bits*)sarbaddr, 333, &arbaddr);
    +				make_ioa_addr((const uint8_t*)sarbaddr, 333, &arbaddr);
     				int i;
     				int maxi = (unsigned short)random() % EXTRA_CREATE_PERMS;
     				for(i=0;i<maxi;i++) {
    -					u16bits chni=0;
    +					uint16_t chni=0;
     					int port = (unsigned short)random();
     					if(port<1024) port += 1024;
     					addr_set_port(&arbaddr, port);
    -					u08bits *u=(u08bits*)&(arbaddr.s4.sin_addr);
    +					uint8_t *u=(uint8_t*)&(arbaddr.s4.sin_addr);
     					u[(unsigned short)random()%4] = u[(unsigned short)random()%4] + 1;
     					//char sss[128];
    -					//addr_to_string(&arbaddr,(u08bits*)sss);
    +					//addr_to_string(&arbaddr,(uint8_t*)sss);
     					//printf("%s: 111.111: %s\n",__FUNCTION__,sss);
     					turn_channel_bind(verbose, &chni, clnet_info, &arbaddr);
     				}
    @@ -1061,17 +1061,17 @@ int start_connection(uint16_t clnet_remote_port0,
     				if(random() % 2 == 0)
     					sarbaddr = "2001::172";
     				ioa_addr arbaddr[EXTRA_CREATE_PERMS];
    -				make_ioa_addr((const u08bits*)sarbaddr, 333, &arbaddr[0]);
    +				make_ioa_addr((const uint8_t*)sarbaddr, 333, &arbaddr[0]);
     				int i;
     				int maxi = (unsigned short)random() % EXTRA_CREATE_PERMS;
     				for(i=0;i<maxi;i++) {
     					if(i>0)
     						addr_cpy(&arbaddr[i],&arbaddr[0]);
     					addr_set_port(&arbaddr[i], (unsigned short)random());
    -					u08bits *u=(u08bits*)&(arbaddr[i].s4.sin_addr);
    +					uint8_t *u=(uint8_t*)&(arbaddr[i].s4.sin_addr);
     					u[(unsigned short)random()%4] = u[(unsigned short)random()%4] + 1;
     					//char sss[128];
    -					//addr_to_string(&arbaddr[i],(u08bits*)sss);
    +					//addr_to_string(&arbaddr[i],(uint8_t*)sss);
     					//printf("%s: 111.111: %s\n",__FUNCTION__,sss);
     				}
     				turn_create_permission(verbose, clnet_info, arbaddr, maxi);
    @@ -1097,17 +1097,17 @@ int start_connection(uint16_t clnet_remote_port0,
     				if(random() % 2 == 0)
     					sarbaddr = "2001::172";
     				ioa_addr arbaddr[EXTRA_CREATE_PERMS];
    -				make_ioa_addr((const u08bits*)sarbaddr, 333, &arbaddr[0]);
    +				make_ioa_addr((const uint8_t*)sarbaddr, 333, &arbaddr[0]);
     				int i;
     				int maxi = (unsigned short)random() % EXTRA_CREATE_PERMS;
     				for(i=0;i<maxi;i++) {
     					if(i>0)
     						addr_cpy(&arbaddr[i],&arbaddr[0]);
     					addr_set_port(&arbaddr[i], (unsigned short)random());
    -					u08bits *u=(u08bits*)&(arbaddr[i].s4.sin_addr);
    +					uint8_t *u=(uint8_t*)&(arbaddr[i].s4.sin_addr);
     					u[(unsigned short)random()%4] = u[(unsigned short)random()%4] + 1;
     					//char sss[128];
    -					//addr_to_string(&arbaddr,(u08bits*)sss);
    +					//addr_to_string(&arbaddr,(uint8_t*)sss);
     					//printf("%s: 111.111: %s\n",__FUNCTION__,sss);
     				}
     				turn_create_permission(verbose, clnet_info, arbaddr, maxi);
    @@ -1269,18 +1269,18 @@ int start_c2c_connection(uint16_t clnet_remote_port0,
     			if(random() % 2 == 0)
     				sarbaddr = "2001::172";
     			ioa_addr arbaddr;
    -			make_ioa_addr((const u08bits*)sarbaddr, 333, &arbaddr);
    +			make_ioa_addr((const uint8_t*)sarbaddr, 333, &arbaddr);
     			int i;
     			int maxi = (unsigned short)random() % EXTRA_CREATE_PERMS;
     			for(i=0;i<maxi;i++) {
    -				u16bits chni=0;
    +				uint16_t chni=0;
     				int port = (unsigned short)random();
     				if(port<1024) port += 1024;
     				addr_set_port(&arbaddr, port);
    -				u08bits *u=(u08bits*)&(arbaddr.s4.sin_addr);
    +				uint8_t *u=(uint8_t*)&(arbaddr.s4.sin_addr);
     				u[(unsigned short)random()%4] = u[(unsigned short)random()%4] + 1;
     				//char sss[128];
    -				//addr_to_string(&arbaddr,(u08bits*)sss);
    +				//addr_to_string(&arbaddr,(uint8_t*)sss);
     				//printf("%s: 111.111: %s\n",__FUNCTION__,sss);
     				turn_channel_bind(verbose, &chni, clnet_info1, &arbaddr);
     			}
    @@ -1293,17 +1293,17 @@ int start_c2c_connection(uint16_t clnet_remote_port0,
     			if(random() % 2 == 0)
     				sarbaddr = "2001::172";
     			ioa_addr arbaddr[EXTRA_CREATE_PERMS];
    -			make_ioa_addr((const u08bits*)sarbaddr, 333, &arbaddr[0]);
    +			make_ioa_addr((const uint8_t*)sarbaddr, 333, &arbaddr[0]);
     			int i;
     			int maxi = (unsigned short)random() % EXTRA_CREATE_PERMS;
     			for(i=0;i<maxi;i++) {
     				if(i>0)
     					addr_cpy(&arbaddr[i],&arbaddr[0]);
     				addr_set_port(&arbaddr[i], (unsigned short)random());
    -				u08bits *u=(u08bits*)&(arbaddr[i].s4.sin_addr);
    +				uint8_t *u=(uint8_t*)&(arbaddr[i].s4.sin_addr);
     				u[(unsigned short)random()%4] = u[(unsigned short)random()%4] + 1;
     				//char sss[128];
    -				//addr_to_string(&arbaddr[i],(u08bits*)sss);
    +				//addr_to_string(&arbaddr[i],(uint8_t*)sss);
     				//printf("%s: 111.111: %s\n",__FUNCTION__,sss);
     			}
     			turn_create_permission(verbose, clnet_info1, arbaddr, maxi);
    @@ -1336,15 +1336,15 @@ int start_c2c_connection(uint16_t clnet_remote_port0,
     			if(random() % 2 == 0)
     				sarbaddr = "2001::172";
     			ioa_addr arbaddr;
    -			make_ioa_addr((const u08bits*)sarbaddr, 333, &arbaddr);
    +			make_ioa_addr((const uint8_t*)sarbaddr, 333, &arbaddr);
     			int i;
     			int maxi = (unsigned short)random() % EXTRA_CREATE_PERMS;
     			for(i=0;i<maxi;i++) {
     				addr_set_port(&arbaddr, (unsigned short)random());
    -				u08bits *u=(u08bits*)&(arbaddr.s4.sin_addr);
    +				uint8_t *u=(uint8_t*)&(arbaddr.s4.sin_addr);
     				u[(unsigned short)random()%4] = u[(unsigned short)random()%4] + 1;
     				//char sss[128];
    -				//addr_to_string(&arbaddr,(u08bits*)sss);
    +				//addr_to_string(&arbaddr,(uint8_t*)sss);
     				//printf("%s: 111.111: %s\n",__FUNCTION__,sss);
     				turn_create_permission(verbose, clnet_info1, &arbaddr, 1);
     			}
    @@ -1427,11 +1427,11 @@ static int turn_tcp_connection_bind(int verbose, app_ur_conn_info *clnet_info, a
     	{
     		int cb_sent = 0;
     
    -		u32bits cid = atc->cid;
    +		uint32_t cid = atc->cid;
     
     		stun_init_request(STUN_METHOD_CONNECTION_BIND, &request_message);
     
    -		stun_attr_add(&request_message, STUN_ATTRIBUTE_CONNECTION_ID, (const s08bits*)&cid,4);
    +		stun_attr_add(&request_message, STUN_ATTRIBUTE_CONNECTION_ID, (const char*)&cid,4);
     
     		add_origin(&request_message);
     
    @@ -1474,7 +1474,7 @@ static int turn_tcp_connection_bind(int verbose, app_ur_conn_info *clnet_info, a
     							"connect bind response received: \n");
     				}
     				int err_code = 0;
    -				u08bits err_msg[129];
    +				uint8_t err_msg[129];
     				if (stun_is_success_response(&response_message)) {
     
     					if(clnet_info->nonce[0]) {
    @@ -1515,7 +1515,7 @@ static int turn_tcp_connection_bind(int verbose, app_ur_conn_info *clnet_info, a
     	return 0;
     }
     
    -void tcp_data_connect(app_ur_session *elem, u32bits cid)
    +void tcp_data_connect(app_ur_session *elem, uint32_t cid)
     {
     	int clnet_fd;
     	int connect_cycle = 0;
    @@ -1536,9 +1536,9 @@ void tcp_data_connect(app_ur_session *elem, u32bits cid)
     
     	++elem->pinfo.tcp_conn_number;
     	int i = (int)(elem->pinfo.tcp_conn_number-1);
    -	elem->pinfo.tcp_conn=(app_tcp_conn_info**)turn_realloc(elem->pinfo.tcp_conn,0,elem->pinfo.tcp_conn_number*sizeof(app_tcp_conn_info*));
    -	elem->pinfo.tcp_conn[i]=(app_tcp_conn_info*)turn_malloc(sizeof(app_tcp_conn_info));
    -	ns_bzero(elem->pinfo.tcp_conn[i],sizeof(app_tcp_conn_info));
    +	elem->pinfo.tcp_conn=(app_tcp_conn_info**)realloc(elem->pinfo.tcp_conn,elem->pinfo.tcp_conn_number*sizeof(app_tcp_conn_info*));
    +	elem->pinfo.tcp_conn[i]=(app_tcp_conn_info*)malloc(sizeof(app_tcp_conn_info));
    +	bzero(elem->pinfo.tcp_conn[i],sizeof(app_tcp_conn_info));
     
     	elem->pinfo.tcp_conn[i]->tcp_data_fd = clnet_fd;
     	elem->pinfo.tcp_conn[i]->cid = cid;
    
  • src/apps/uclient/startuclient.h+1 1 modified
    @@ -71,7 +71,7 @@ int start_connection(uint16_t clnet_remote_port,
     
     int turn_tcp_connect(int verbose, app_ur_conn_info *clnet_info, ioa_addr *peer_addr);
     
    -void tcp_data_connect(app_ur_session *elem, u32bits cid);
    +void tcp_data_connect(app_ur_session *elem, uint32_t cid);
     
     int socket_connect(evutil_socket_t clnet_fd, ioa_addr *remote_addr, int *connect_err);
     
    
  • src/apps/uclient/uclient.c+64 61 modified
    @@ -46,20 +46,20 @@ static int verbose_packets=0;
     static size_t current_clients_number = 0;
     
     static int start_full_timer=0;
    -static u32bits tot_messages=0;
    -static u32bits tot_send_messages=0;
    -static u64bits tot_send_bytes = 0;
    -static u32bits tot_recv_messages=0;
    -static u64bits tot_recv_bytes = 0;
    -static u64bits tot_send_dropped = 0;
    +static uint32_t tot_messages=0;
    +static uint32_t tot_send_messages=0;
    +static uint64_t tot_send_bytes = 0;
    +static uint32_t tot_recv_messages=0;
    +static uint64_t tot_recv_bytes = 0;
    +static uint64_t tot_send_dropped = 0;
     
     struct event_base* client_event_base=NULL;
     
     static int client_write(app_ur_session *elem);
     static int client_shutdown(app_ur_session *elem);
     
    -static u64bits current_time = 0;
    -static u64bits current_mstime = 0;
    +static uint64_t current_time = 0;
    +static uint64_t current_mstime = 0;
     
     static char buffer_to_send[65536]="\0";
     
    @@ -74,26 +74,26 @@ static app_ur_session** elems = NULL;
     
     int RTP_PACKET_INTERVAL = 20;
     
    -static inline s64bits time_minus(u64bits t1, u64bits t2) {
    -	return ( (s64bits)t1 - (s64bits)t2 );
    +static inline int64_t time_minus(uint64_t t1, uint64_t t2) {
    +	return ( (int64_t)t1 - (int64_t)t2 );
     }
     
    -static u64bits total_loss = 0;
    -static u64bits total_jitter = 0;
    -static u64bits total_latency = 0;
    +static uint64_t total_loss = 0;
    +static uint64_t total_jitter = 0;
    +static uint64_t total_latency = 0;
     
    -static u64bits min_latency = 0xFFFFFFFF;
    -static u64bits max_latency = 0;
    -static u64bits min_jitter = 0xFFFFFFFF;
    -static u64bits max_jitter = 0;
    +static uint64_t min_latency = 0xFFFFFFFF;
    +static uint64_t max_latency = 0;
    +static uint64_t min_jitter = 0xFFFFFFFF;
    +static uint64_t max_jitter = 0;
     
     
     static int show_statistics = 0;
     
     ///////////////////////////////////////////////////////////////////////////////
     
     static void __turn_getMSTime(void) {
    -  static u64bits start_sec = 0;
    +  static uint64_t start_sec = 0;
       struct timespec tp={0,0};
     #if defined(CLOCK_REALTIME)
       clock_gettime(CLOCK_REALTIME, &tp);
    @@ -102,21 +102,21 @@ static void __turn_getMSTime(void) {
     #endif
       if(!start_sec)
         start_sec = tp.tv_sec;
    -  if(current_time != (u64bits)((u64bits)(tp.tv_sec)-start_sec))
    +  if(current_time != (uint64_t)((uint64_t)(tp.tv_sec)-start_sec))
         show_statistics = 1;
    -  current_time = (u64bits)((u64bits)(tp.tv_sec)-start_sec);
    -  current_mstime = (u64bits)((current_time * 1000) + (tp.tv_nsec/1000000));
    +  current_time = (uint64_t)((uint64_t)(tp.tv_sec)-start_sec);
    +  current_mstime = (uint64_t)((current_time * 1000) + (tp.tv_nsec/1000000));
     }
     
     ////////////////////////////////////////////////////////////////////
     
    -static int refresh_channel(app_ur_session* elem, u16bits method, uint32_t lt);
    +static int refresh_channel(app_ur_session* elem, uint16_t method, uint32_t lt);
     
     //////////////////////// SS ////////////////////////////////////////
     
     static app_ur_session* init_app_session(app_ur_session *ss) {
       if(ss) {
    -    ns_bzero(ss,sizeof(app_ur_session));
    +    bzero(ss,sizeof(app_ur_session));
         ss->pinfo.fd=-1;
       }
       return ss;
    @@ -125,7 +125,7 @@ static app_ur_session* init_app_session(app_ur_session *ss) {
     static app_ur_session* create_new_ss(void)
     {
     	++current_clients_number;
    -	return init_app_session((app_ur_session*) turn_malloc(sizeof(app_ur_session)));
    +	return init_app_session((app_ur_session*) malloc(sizeof(app_ur_session)));
     }
     
     static void uc_delete_session_elem_data(app_ur_session* cdi) {
    @@ -142,20 +142,20 @@ static void uc_delete_session_elem_data(app_ur_session* cdi) {
     	      SSL_shutdown(cdi->pinfo.tcp_conn[i]->tcp_data_ssl);
     	    }
     	    if(cdi->pinfo.tcp_conn[i]->tcp_data_ssl) {
    -	      SSL_FREE(cdi->pinfo.tcp_conn[i]->tcp_data_ssl);
    +	      SSL_free(cdi->pinfo.tcp_conn[i]->tcp_data_ssl);
     	    }
     	    if(cdi->pinfo.tcp_conn[i]->tcp_data_fd>=0) {
     	    	socket_closesocket(cdi->pinfo.tcp_conn[i]->tcp_data_fd);
     	      cdi->pinfo.tcp_conn[i]->tcp_data_fd=-1;
     	    }
    -	    turn_free(cdi->pinfo.tcp_conn[i], 111);
    +	    free(cdi->pinfo.tcp_conn[i]);
     	    cdi->pinfo.tcp_conn[i]=NULL;
     	  }
     	}
           }
           cdi->pinfo.tcp_conn_number=0;
           if(cdi->pinfo.tcp_conn) {
    -    	  turn_free(cdi->pinfo.tcp_conn, 111);
    +    	  free(cdi->pinfo.tcp_conn);
         	  cdi->pinfo.tcp_conn=NULL;
           }
         }
    @@ -166,7 +166,7 @@ static void uc_delete_session_elem_data(app_ur_session* cdi) {
     	    }
         }
         if(cdi->pinfo.ssl) {
    -	    SSL_FREE(cdi->pinfo.ssl);
    +	    SSL_free(cdi->pinfo.ssl);
         }
         if(cdi->pinfo.fd>=0) {
         	socket_closesocket(cdi->pinfo.fd);
    @@ -202,7 +202,7 @@ int send_buffer(app_ur_conn_info *clnet_info, stun_buffer* message, int data_con
     			while(np-->0) {
     				int pos = (int)((unsigned long)random()%(unsigned long)message->len);
     				int val = (int)((unsigned long)random()%256);
    -				message->buf[pos]=(u08bits)val;
    +				message->buf[pos]=(uint8_t)val;
     			}
     		}
     	}
    @@ -361,7 +361,7 @@ int recv_buffer(app_ur_conn_info *clnet_info, stun_buffer* message, int sync, in
     	int rc = 0;
     
     	stun_tid tid;
    -	u16bits method = 0;
    +	uint16_t method = 0;
     
     	if(request_message) {
     		stun_tid_from_message(request_message, &tid);
    @@ -620,7 +620,7 @@ int recv_buffer(app_ur_conn_info *clnet_info, stun_buffer* message, int sync, in
     		if(request_message) {
     
     			stun_tid recv_tid;
    -			u16bits recv_method = 0;
    +			uint16_t recv_method = 0;
     
     			stun_tid_from_message(message, &recv_tid);
     			recv_method = stun_get_method(message);
    @@ -652,7 +652,7 @@ static int client_read(app_ur_session *elem, int is_tcp_data, app_tcp_conn_info
     
     	app_ur_conn_info *clnet_info = &(elem->pinfo);
     	int err_code = 0;
    -	u08bits err_msg[129];
    +	uint8_t err_msg[129];
     	int rc = 0;
     	int applen = 0;
     
    @@ -678,26 +678,29 @@ static int client_read(app_ur_session *elem, int is_tcp_data, app_tcp_conn_info
     
     		if(is_tcp_data) {
     		  if ((int)elem->in_buffer.len == clmessage_length) {
    -		    ns_bcopy((elem->in_buffer.buf), &mi, sizeof(message_info));
    +		    bcopy((elem->in_buffer.buf), &mi, sizeof(message_info));
     		    miset=1;
    +		  } else {
    +			/* TODO: make a more clean fix */ 
    +			buffers=(int)elem->in_buffer.len / clmessage_length;
     		  }
     		} else if (stun_is_indication(&(elem->in_buffer))) {
     
     			uint16_t method = stun_get_method(&elem->in_buffer);
     
     			if((method == STUN_METHOD_CONNECTION_ATTEMPT)&& is_TCP_relay()) {
     			  stun_attr_ref sar = stun_attr_get_first(&(elem->in_buffer));
    -			  u32bits cid = 0;
    +			  uint32_t cid = 0;
     			  while(sar) {
     				  int attr_type = stun_attr_get_type(sar);
     				  if(attr_type == STUN_ATTRIBUTE_CONNECTION_ID) {
    -					  cid = *((const u32bits*)stun_attr_get_value(sar));
    +					  cid = *((const uint32_t*)stun_attr_get_value(sar));
     					  break;
     				  }
     				  sar = stun_attr_get_next_str(elem->in_buffer.buf,elem->in_buffer.len,sar);
     			  }
     			  if(negative_test) {
    -				  tcp_data_connect(elem,(u64bits)random());
    +				  tcp_data_connect(elem,(uint64_t)random());
     			  } else {
     				  /* positive test */
     				  tcp_data_connect(elem,cid);
    @@ -725,9 +728,9 @@ static int client_read(app_ur_session *elem, int is_tcp_data, app_tcp_conn_info
     					return rc;
     				}
     
    -				const u08bits* data = stun_attr_get_value(sar);
    +				const uint8_t* data = stun_attr_get_value(sar);
     
    -				ns_bcopy(data, &mi, sizeof(message_info));
    +				bcopy(data, &mi, sizeof(message_info));
     				miset=1;
     			}
     
    @@ -740,11 +743,11 @@ static int client_read(app_ur_session *elem, int is_tcp_data, app_tcp_conn_info
     
     			if(is_TCP_relay() && (stun_get_method(&(elem->in_buffer)) == STUN_METHOD_CONNECT)) {
     				stun_attr_ref sar = stun_attr_get_first(&(elem->in_buffer));
    -				u32bits cid = 0;
    +				uint32_t cid = 0;
     				while(sar) {
     				  int attr_type = stun_attr_get_type(sar);
     				  if(attr_type == STUN_ATTRIBUTE_CONNECTION_ID) {
    -					  cid = *((const u32bits*)stun_attr_get_value(sar));
    +					  cid = *((const uint32_t*)stun_attr_get_value(sar));
     					  break;
     				  }
     				  sar = stun_attr_get_next_str(elem->in_buffer.buf,elem->in_buffer.len,sar);
    @@ -783,7 +786,7 @@ static int client_read(app_ur_session *elem, int is_tcp_data, app_tcp_conn_info
     					return rc;
     				}
     
    -				ns_bcopy(elem->in_buffer.buf + 4, &mi, sizeof(message_info));
    +				bcopy(elem->in_buffer.buf + 4, &mi, sizeof(message_info));
     				miset=1;
     				applen = elem->in_buffer.len -4;
     			}
    @@ -801,14 +804,14 @@ static int client_read(app_ur_session *elem, int is_tcp_data, app_tcp_conn_info
     			if(mi.msgnum != elem->recvmsgnum+1)
     				++(elem->loss);
     			else {
    -			  u64bits clatency = (u64bits)time_minus(current_mstime,mi.mstime);
    +			  uint64_t clatency = (uint64_t)time_minus(current_mstime,mi.mstime);
     			  if(clatency>max_latency)
     			    max_latency = clatency;
     			  if(clatency<min_latency)
     			    min_latency = clatency;
     			  elem->latency += clatency;
     			  if(elem->rmsgnum>0) {
    -			    u64bits cjitter = abs((int)(current_mstime-elem->recvtimems)-RTP_PACKET_INTERVAL);
    +			    uint64_t cjitter = abs((int)(current_mstime-elem->recvtimems)-RTP_PACKET_INTERVAL);
     			    
     			    if(cjitter>max_jitter)
     			      max_jitter = cjitter;
    @@ -1002,7 +1005,7 @@ static int start_client(const char *remote_address, int port,
         ss_rtcp = create_new_ss();
     
       app_ur_conn_info clnet_info_probe; /* for load balancing probe */
    -  ns_bzero(&clnet_info_probe,sizeof(clnet_info_probe));
    +  bzero(&clnet_info_probe,sizeof(clnet_info_probe));
       clnet_info_probe.fd = -1;
     
       app_ur_conn_info *clnet_info=&(ss->pinfo);
    @@ -1022,7 +1025,7 @@ static int start_client(const char *remote_address, int port,
     		   clnet_info_rtcp, &chnum_rtcp);
     		   
       if(clnet_info_probe.ssl) {
    -  	SSL_FREE(clnet_info_probe.ssl);
    +  	SSL_free(clnet_info_probe.ssl);
       	clnet_info_probe.fd = -1;
       } else if(clnet_info_probe.fd != -1) {
     	  socket_closesocket(clnet_info_probe.fd);
    @@ -1096,7 +1099,7 @@ static int start_c2c(const char *remote_address, int port,
         ss2_rtcp = create_new_ss();
     
       app_ur_conn_info clnet_info_probe; /* for load balancing probe */
    -  ns_bzero(&clnet_info_probe,sizeof(clnet_info_probe));
    +  bzero(&clnet_info_probe,sizeof(clnet_info_probe));
       clnet_info_probe.fd = -1;
     
       app_ur_conn_info *clnet_info1=&(ss1->pinfo);
    @@ -1126,7 +1129,7 @@ static int start_c2c(const char *remote_address, int port,
     		       clnet_info2_rtcp, &chnum2_rtcp);
     		       
       if(clnet_info_probe.ssl) {
    -	SSL_FREE(clnet_info_probe.ssl);
    +	SSL_free(clnet_info_probe.ssl);
     	clnet_info_probe.fd = -1;
       } else if(clnet_info_probe.fd != -1) {
     	  socket_closesocket(clnet_info_probe.fd);
    @@ -1219,7 +1222,7 @@ static int start_c2c(const char *remote_address, int port,
       return 0;
     }
     
    -static int refresh_channel(app_ur_session* elem, u16bits method, uint32_t lt)
    +static int refresh_channel(app_ur_session* elem, uint16_t method, uint32_t lt)
     {
     
     	stun_buffer message;
    @@ -1234,10 +1237,10 @@ static int refresh_channel(app_ur_session* elem, u16bits method, uint32_t lt)
     		stun_attr_add(&message, STUN_ATTRIBUTE_LIFETIME, (const char*) &lt, 4);
     
     		if(dual_allocation && !mobility) {
    -			int t = ((u08bits)random())%3;
    +			int t = ((uint8_t)random())%3;
     			if(t) {
    -				u08bits field[4];
    -				field[0] = (t==1) ? (u08bits)STUN_ATTRIBUTE_REQUESTED_ADDRESS_FAMILY_VALUE_IPV4 : (u08bits)STUN_ATTRIBUTE_REQUESTED_ADDRESS_FAMILY_VALUE_IPV6;
    +				uint8_t field[4];
    +				field[0] = (t==1) ? (uint8_t)STUN_ATTRIBUTE_REQUESTED_ADDRESS_FAMILY_VALUE_IPV4 : (uint8_t)STUN_ATTRIBUTE_REQUESTED_ADDRESS_FAMILY_VALUE_IPV6;
     				field[1]=0;
     				field[2]=0;
     				field[3]=0;
    @@ -1388,10 +1391,10 @@ void start_mclient(const char *remote_address, int port,
     	      ++mclient;
     	}
     
    -	elems = (app_ur_session**)turn_malloc(sizeof(app_ur_session)*((mclient*2)+1)+sizeof(void*));
    +	elems = (app_ur_session**)malloc(sizeof(app_ur_session)*((mclient*2)+1)+sizeof(void*));
     
     	__turn_getMSTime();
    -	u32bits stime = current_time;
    +	uint32_t stime = current_time;
     
     	memset(buffer_to_send, 7, clmessage_length);
     
    @@ -1483,7 +1486,7 @@ void start_mclient(const char *remote_address, int port,
     	stime = current_time;
     
     	if(is_TCP_relay()) {
    -		u64bits connect_wait_start_time = current_time;
    +		uint64_t connect_wait_start_time = current_time;
     		while(1) {
     			int i = 0;
     			int completed = 0;
    @@ -1525,7 +1528,7 @@ void start_mclient(const char *remote_address, int port,
     	stime = current_time;
     
     	for(i=0;i<total_clients;i++) {
    -		elems[i]->to_send_timems = current_mstime + 1000 + ((u32bits)random())%5000;
    +		elems[i]->to_send_timems = current_mstime + 1000 + ((uint32_t)random())%5000;
     	}
     
     	tot_messages = elems[0]->tot_msgnum * total_clients;
    @@ -1586,7 +1589,7 @@ void start_mclient(const char *remote_address, int port,
     				(unsigned long)min_jitter,
     				(unsigned long)max_jitter);
     
    -	turn_free(elems,0);
    +	free(elems);
     }
     
     ///////////////////////////////////////////
    @@ -1602,7 +1605,7 @@ int add_integrity(app_ur_conn_info *clnet_info, stun_buffer *message)
     
     		if(oauth && clnet_info->oauth) {
     
    -			u16bits method = stun_get_method_str(message->buf, message->len);
    +			uint16_t method = stun_get_method_str(message->buf, message->len);
     
     			int cok = clnet_info->cok;
     
    @@ -1613,7 +1616,7 @@ int add_integrity(app_ur_conn_info *clnet_info, stun_buffer *message)
     				clnet_info->cok = cok;
     				oauth_token otoken;
     				encoded_oauth_token etoken;
    -				u08bits nonce[12];
    +				uint8_t nonce[12];
     				RAND_bytes((unsigned char*)nonce,12);
     				long halflifetime = OAUTH_SESSION_LIFETIME/2;
     				long random_lifetime = 0;
    @@ -1639,13 +1642,13 @@ int add_integrity(app_ur_conn_info *clnet_info, stun_buffer *message)
     					return -1;
     				}
     				stun_attr_add_str(message->buf, (size_t*)&(message->len), STUN_ATTRIBUTE_OAUTH_ACCESS_TOKEN,
    -					(const u08bits*)etoken.token, (int)etoken.size);
    +					(const uint8_t*)etoken.token, (int)etoken.size);
     
    -				ns_bcopy(otoken.enc_block.mac_key,clnet_info->key,otoken.enc_block.key_length);
    +				bcopy(otoken.enc_block.mac_key,clnet_info->key,otoken.enc_block.key_length);
     				clnet_info->key_set = 1;
     			}
     
    -			if(stun_attr_add_integrity_by_key_str(message->buf, (size_t*)&(message->len), (u08bits*)okey_array[cok].kid,
    +			if(stun_attr_add_integrity_by_key_str(message->buf, (size_t*)&(message->len), (uint8_t*)okey_array[cok].kid,
     					clnet_info->realm, clnet_info->key, clnet_info->nonce, shatype)<0) {
     				TURN_LOG_FUNC(TURN_LOG_LEVEL_INFO," Cannot add integrity to the message\n");
     				return -1;
    
  • src/apps/uclient/uclient.h+2 2 modified
    @@ -60,15 +60,15 @@ extern ioa_addr peer_addr;
     extern int no_rtcp;
     extern int default_address_family;
     extern int dont_fragment;
    -extern u08bits g_uname[STUN_MAX_USERNAME_SIZE+1];
    +extern uint8_t g_uname[STUN_MAX_USERNAME_SIZE+1];
     extern password_t g_upwd;
     extern char g_auth_secret[1025];
     extern int g_use_auth_secret_with_timestamp;
     extern int use_fingerprints;
     extern SSL_CTX *root_tls_ctx[32];
     extern int root_tls_ctx_num;
     extern int RTP_PACKET_INTERVAL;
    -extern u08bits relay_transport;
    +extern uint8_t relay_transport;
     extern unsigned char client_ifname[1025];
     extern struct event_base* client_event_base;
     extern int passive_tcp;
    
  • src/client/ns_turn_ioaddr.c+47 47 modified
    @@ -34,7 +34,7 @@
     
     //////////////////////////////////////////////////////////////
     
    -u32bits get_ioa_addr_len(const ioa_addr* addr) {
    +uint32_t get_ioa_addr_len(const ioa_addr* addr) {
       if(addr->ss.sa_family == AF_INET) return sizeof(struct sockaddr_in);
       else if(addr->ss.sa_family == AF_INET6) return sizeof(struct sockaddr_in6);
       return 0;
    @@ -44,7 +44,7 @@ u32bits get_ioa_addr_len(const ioa_addr* addr) {
     
     void addr_set_any(ioa_addr *addr) {
     	if(addr)
    -		ns_bzero(addr,sizeof(ioa_addr));
    +		bzero(addr,sizeof(ioa_addr));
     }
     
     int addr_any(const ioa_addr* addr) {
    @@ -59,7 +59,7 @@ int addr_any(const ioa_addr* addr) {
         else {
           size_t i;
           for(i=0;i<sizeof(addr->s6.sin6_addr);i++) 
    -	if(((const s08bits*)&(addr->s6.sin6_addr))[i]) return 0;
    +	if(((const char*)&(addr->s6.sin6_addr))[i]) return 0;
         }
       }
     
    @@ -75,73 +75,73 @@ int addr_any_no_port(const ioa_addr* addr) {
       } else if(addr->ss.sa_family == AF_INET6) {
         size_t i;
         for(i=0;i<sizeof(addr->s6.sin6_addr);i++) 
    -      if(((const s08bits*)(&(addr->s6.sin6_addr)))[i]) return 0;
    +      if(((const char*)(&(addr->s6.sin6_addr)))[i]) return 0;
       }
     
       return 1;
     }
     
    -u32bits hash_int32(u32bits a)
    +uint32_t hash_int32(uint32_t a)
     {
     	a = a ^ (a>>4);
     	a = (a^0xdeadbeef) + (a<<5);
     	a = a ^ (a>>11);
     	return a;
     }
     
    -u64bits hash_int64(u64bits a)
    +uint64_t hash_int64(uint64_t a)
     {
     	a = a ^ (a>>4);
     	a = (a^0xdeadbeefdeadbeefLL) + (a<<5);
     	a = a ^ (a>>11);
     	return a;
     }
     
    -u32bits addr_hash(const ioa_addr *addr)
    +uint32_t addr_hash(const ioa_addr *addr)
     {
     	if(!addr)
     		return 0;
     
    -	u32bits ret = 0;
    +	uint32_t ret = 0;
     	if (addr->ss.sa_family == AF_INET) {
     		ret = hash_int32(addr->s4.sin_addr.s_addr + addr->s4.sin_port);
     	} else {
    -		u64bits a[2];
    -		ns_bcopy(&(addr->s6.sin6_addr), &a, sizeof(a));
    -		ret = (u32bits)((hash_int64(a[0])<<3) + (hash_int64(a[1] + addr->s6.sin6_port)));
    +		uint64_t a[2];
    +		bcopy(&(addr->s6.sin6_addr), &a, sizeof(a));
    +		ret = (uint32_t)((hash_int64(a[0])<<3) + (hash_int64(a[1] + addr->s6.sin6_port)));
     	}
     	return ret;
     }
     
    -u32bits addr_hash_no_port(const ioa_addr *addr)
    +uint32_t addr_hash_no_port(const ioa_addr *addr)
     {
     	if(!addr)
     		return 0;
     
    -	u32bits ret = 0;
    +	uint32_t ret = 0;
     	if (addr->ss.sa_family == AF_INET) {
     		ret = hash_int32(addr->s4.sin_addr.s_addr);
     	} else {
    -		u64bits a[2];
    -		ns_bcopy(&(addr->s6.sin6_addr), &a, sizeof(a));
    -		ret = (u32bits)((hash_int64(a[0])<<3) + (hash_int64(a[1])));
    +		uint64_t a[2];
    +		bcopy(&(addr->s6.sin6_addr), &a, sizeof(a));
    +		ret = (uint32_t)((hash_int64(a[0])<<3) + (hash_int64(a[1])));
     	}
     	return ret;
     }
     
     void addr_cpy(ioa_addr* dst, const ioa_addr* src) {
     	if(dst && src)
    -		ns_bcopy(src,dst,sizeof(ioa_addr));
    +		bcopy(src,dst,sizeof(ioa_addr));
     }
     
     void addr_cpy4(ioa_addr* dst, const struct sockaddr_in* src) {
     	if(src && dst)
    -		ns_bcopy(src,dst,sizeof(struct sockaddr_in));
    +		bcopy(src,dst,sizeof(struct sockaddr_in));
     }
     
     void addr_cpy6(ioa_addr* dst, const struct sockaddr_in6* src) {
     	if(src && dst)
    -		ns_bcopy(src,dst,sizeof(struct sockaddr_in6));
    +		bcopy(src,dst,sizeof(struct sockaddr_in6));
     }
     
     int addr_eq(const ioa_addr* a1, const ioa_addr *a2) {
    @@ -183,7 +183,7 @@ int addr_eq_no_port(const ioa_addr* a1, const ioa_addr *a2) {
       return 0;
     }
     
    -int make_ioa_addr(const u08bits* saddr0, int port, ioa_addr *addr) {
    +int make_ioa_addr(const uint8_t* saddr0, int port, ioa_addr *addr) {
     
       if(!saddr0 || !addr) return -1;
     
    @@ -203,7 +203,7 @@ int make_ioa_addr(const u08bits* saddr0, int port, ioa_addr *addr) {
     	  }
       }
     
    -  ns_bzero(addr, sizeof(ioa_addr));
    +  bzero(addr, sizeof(ioa_addr));
       if((len == 0)||
          (inet_pton(AF_INET, saddr, &addr->s4.sin_addr) == 1)) {
         addr->s4.sin_family = AF_INET;
    @@ -247,15 +247,15 @@ int make_ioa_addr(const u08bits* saddr0, int port, ioa_addr *addr) {
     
         	if(addr_result->ai_family == family) {
         		if (addr_result->ai_family == AF_INET) {
    -    			ns_bcopy(addr_result->ai_addr, addr, addr_result->ai_addrlen);
    +    			bcopy(addr_result->ai_addr, addr, addr_result->ai_addrlen);
         			addr->s4.sin_port = nswap16(port);
     #if defined(TURN_HAS_SIN_LEN) /* tested when configured */
         			addr->s4.sin_len = sizeof(struct sockaddr_in);
     #endif
         			found = 1;
         			break;
         		} else if (addr_result->ai_family == AF_INET6) {
    -    			ns_bcopy(addr_result->ai_addr, addr, addr_result->ai_addrlen);
    +    			bcopy(addr_result->ai_addr, addr, addr_result->ai_addrlen);
         			addr->s6.sin6_port = nswap16(port);
     #if defined(SIN6_LEN) /* this define is required by IPv6 if used */
         			addr->s6.sin6_len = sizeof(struct sockaddr_in6);
    @@ -315,43 +315,43 @@ static char* get_addr_string_and_port(char* s0, int *port)
     	return NULL;
     }
     
    -int make_ioa_addr_from_full_string(const u08bits* saddr, int default_port, ioa_addr *addr)
    +int make_ioa_addr_from_full_string(const uint8_t* saddr, int default_port, ioa_addr *addr)
     {
     	if(!addr)
     		return -1;
     
     	int ret = -1;
     	int port = 0;
    -	char* s = turn_strdup((const char*)saddr);
    +	char* s = strdup((const char*)saddr);
     	char *sa = get_addr_string_and_port(s,&port);
     	if(sa) {
     		if(port<1)
     			port = default_port;
    -		ret = make_ioa_addr((u08bits*)sa,port,addr);
    +		ret = make_ioa_addr((uint8_t*)sa,port,addr);
     	}
    -	turn_free(s,strlen(s)+1);
    +	free(s);
     	return ret;
     }
     
    -int addr_to_string(const ioa_addr* addr, u08bits* saddr)
    +int addr_to_string(const ioa_addr* addr, uint8_t* saddr)
     {
     
     	if (addr && saddr) {
     
    -		s08bits addrtmp[INET6_ADDRSTRLEN];
    +		char addrtmp[INET6_ADDRSTRLEN];
     
     		if (addr->ss.sa_family == AF_INET) {
     			inet_ntop(AF_INET, &addr->s4.sin_addr, addrtmp, INET_ADDRSTRLEN);
     			if(addr_get_port(addr)>0)
    -			  snprintf((s08bits*)saddr, MAX_IOA_ADDR_STRING, "%s:%d", addrtmp, addr_get_port(addr));
    +			  snprintf((char*)saddr, MAX_IOA_ADDR_STRING, "%s:%d", addrtmp, addr_get_port(addr));
     			else
    -			  strncpy((s08bits*)saddr, addrtmp, MAX_IOA_ADDR_STRING);
    +			  strncpy((char*)saddr, addrtmp, MAX_IOA_ADDR_STRING);
     		} else if (addr->ss.sa_family == AF_INET6) {
     			inet_ntop(AF_INET6, &addr->s6.sin6_addr, addrtmp, INET6_ADDRSTRLEN);
     			if(addr_get_port(addr)>0)
    -			  snprintf((s08bits*)saddr, MAX_IOA_ADDR_STRING, "[%s]:%d", addrtmp, addr_get_port(addr));
    +			  snprintf((char*)saddr, MAX_IOA_ADDR_STRING, "[%s]:%d", addrtmp, addr_get_port(addr));
     			else
    -			  strncpy((s08bits*)saddr, addrtmp, MAX_IOA_ADDR_STRING);
    +			  strncpy((char*)saddr, addrtmp, MAX_IOA_ADDR_STRING);
     		} else {
     			return -1;
     		}
    @@ -362,19 +362,19 @@ int addr_to_string(const ioa_addr* addr, u08bits* saddr)
     	return -1;
     }
     
    -int addr_to_string_no_port(const ioa_addr* addr, u08bits* saddr)
    +int addr_to_string_no_port(const ioa_addr* addr, uint8_t* saddr)
     {
     
     	if (addr && saddr) {
     
    -		s08bits addrtmp[MAX_IOA_ADDR_STRING];
    +		char addrtmp[MAX_IOA_ADDR_STRING];
     
     		if (addr->ss.sa_family == AF_INET) {
     			inet_ntop(AF_INET, &addr->s4.sin_addr, addrtmp, INET_ADDRSTRLEN);
    -			strncpy((s08bits*)saddr, addrtmp, MAX_IOA_ADDR_STRING);
    +			strncpy((char*)saddr, addrtmp, MAX_IOA_ADDR_STRING);
     		} else if (addr->ss.sa_family == AF_INET6) {
     			inet_ntop(AF_INET6, &addr->s6.sin6_addr, addrtmp, INET6_ADDRSTRLEN);
    -			strncpy((s08bits*)saddr, addrtmp, MAX_IOA_ADDR_STRING);
    +			strncpy((char*)saddr, addrtmp, MAX_IOA_ADDR_STRING);
     		} else {
     			return -1;
     		}
    @@ -425,11 +425,11 @@ int addr_less_eq(const ioa_addr* addr1, const ioa_addr* addr2) {
       else {
         if(addr1->ss.sa_family != addr2->ss.sa_family) return (addr1->ss.sa_family < addr2->ss.sa_family);
         else if(addr1->ss.sa_family == AF_INET) {
    -      return ((u32bits)nswap32(addr1->s4.sin_addr.s_addr) <= (u32bits)nswap32(addr2->s4.sin_addr.s_addr));
    +      return ((uint32_t)nswap32(addr1->s4.sin_addr.s_addr) <= (uint32_t)nswap32(addr2->s4.sin_addr.s_addr));
         } else if(addr1->ss.sa_family == AF_INET6) {
           int i;
           for(i=0;i<16;i++) {
    -	if((u08bits)(((const s08bits*)&(addr1->s6.sin6_addr))[i]) > (u08bits)(((const s08bits*)&(addr2->s6.sin6_addr))[i])) 
    +	if((uint8_t)(((const char*)&(addr1->s6.sin6_addr))[i]) > (uint8_t)(((const char*)&(addr2->s6.sin6_addr))[i])) 
     	  return 0;
           }
           return 1;
    @@ -465,10 +465,10 @@ int ioa_addr_is_multicast(ioa_addr *addr)
     {
     	if(addr) {
     		if(addr->ss.sa_family == AF_INET) {
    -			const u08bits *u = ((const u08bits*)&(addr->s4.sin_addr));
    +			const uint8_t *u = ((const uint8_t*)&(addr->s4.sin_addr));
     			return (u[0] > 223);
     		} else if(addr->ss.sa_family == AF_INET6) {
    -			u08bits u = ((const u08bits*)&(addr->s6.sin6_addr))[0];
    +			uint8_t u = ((const uint8_t*)&(addr->s6.sin6_addr))[0];
     			return (u == 255);
     		}
     	}
    @@ -479,10 +479,10 @@ int ioa_addr_is_loopback(ioa_addr *addr)
     {
     	if(addr) {
     		if(addr->ss.sa_family == AF_INET) {
    -			const u08bits *u = ((const u08bits*)&(addr->s4.sin_addr));
    +			const uint8_t *u = ((const uint8_t*)&(addr->s4.sin_addr));
     			return (u[0] == 127);
     		} else if(addr->ss.sa_family == AF_INET6) {
    -			const u08bits *u = ((const u08bits*)&(addr->s6.sin6_addr));
    +			const uint8_t *u = ((const uint8_t*)&(addr->s6.sin6_addr));
     			if(u[7] == 1) {
     				int i;
     				for(i=0;i<7;++i) {
    @@ -509,10 +509,10 @@ static size_t msz = 0;
     void ioa_addr_add_mapping(ioa_addr *apub, ioa_addr *apriv)
     {
     	size_t new_size = msz + sizeof(ioa_addr*);
    -	public_addrs = (ioa_addr**)turn_realloc(public_addrs, msz, new_size);
    -	private_addrs = (ioa_addr**)turn_realloc(private_addrs, msz, new_size);
    -	public_addrs[mcount]=(ioa_addr*)turn_malloc(sizeof(ioa_addr));
    -	private_addrs[mcount]=(ioa_addr*)turn_malloc(sizeof(ioa_addr));
    +	public_addrs = (ioa_addr**)realloc(public_addrs, new_size);
    +	private_addrs = (ioa_addr**)realloc(private_addrs, new_size);
    +	public_addrs[mcount]=(ioa_addr*)malloc(sizeof(ioa_addr));
    +	private_addrs[mcount]=(ioa_addr*)malloc(sizeof(ioa_addr));
     	addr_cpy(public_addrs[mcount],apub);
     	addr_cpy(private_addrs[mcount],apriv);
     	++mcount;
    
  • src/client/ns_turn_ioaddr.h+9 9 modified
    @@ -54,29 +54,29 @@ typedef struct {
     
     ////////////////////////////
     
    -u32bits get_ioa_addr_len(const ioa_addr* addr);
    +uint32_t get_ioa_addr_len(const ioa_addr* addr);
     
     ////////////////////////////
     
     void addr_set_any(ioa_addr *addr);
     int addr_any(const ioa_addr* addr);
     int addr_any_no_port(const ioa_addr* addr);
    -u32bits addr_hash(const ioa_addr *addr);
    -u32bits addr_hash_no_port(const ioa_addr *addr);
    +uint32_t addr_hash(const ioa_addr *addr);
    +uint32_t addr_hash_no_port(const ioa_addr *addr);
     void addr_cpy(ioa_addr* dst, const ioa_addr* src);
     void addr_cpy4(ioa_addr* dst, const struct sockaddr_in* src);
     void addr_cpy6(ioa_addr* dst, const struct sockaddr_in6* src);
     int addr_eq(const ioa_addr* a1, const ioa_addr *a2);
     int addr_eq_no_port(const ioa_addr* a1, const ioa_addr *a2);
    -int make_ioa_addr(const u08bits* saddr, int port, ioa_addr *addr);
    -int make_ioa_addr_from_full_string(const u08bits* saddr, int default_port, ioa_addr *addr);
    +int make_ioa_addr(const uint8_t* saddr, int port, ioa_addr *addr);
    +int make_ioa_addr_from_full_string(const uint8_t* saddr, int default_port, ioa_addr *addr);
     void addr_set_port(ioa_addr* addr, int port);
     int addr_get_port(const ioa_addr* addr);
    -int addr_to_string(const ioa_addr* addr, u08bits* saddr);
    -int addr_to_string_no_port(const ioa_addr* addr, u08bits* saddr);
    +int addr_to_string(const ioa_addr* addr, uint8_t* saddr);
    +int addr_to_string_no_port(const ioa_addr* addr, uint8_t* saddr);
     
    -u32bits hash_int32(u32bits a);
    -u64bits hash_int64(u64bits a);
    +uint32_t hash_int32(uint32_t a);
    +uint64_t hash_int64(uint64_t a);
     
     ///////////////////////////////////////////
     
    
  • src/client/ns_turn_msg_addr.c+25 25 modified
    @@ -32,7 +32,7 @@
     
     //////////////////////////////////////////////////////////////////////////////
     
    -int stun_addr_encode(const ioa_addr* ca, u08bits *cfield, int *clen, int xor_ed, u32bits mc, const u08bits *tsx_id) {
    +int stun_addr_encode(const ioa_addr* ca, uint8_t *cfield, int *clen, int xor_ed, uint32_t mc, const uint8_t *tsx_id) {
     
       if(!cfield || !clen || !ca || !tsx_id) return -1;
     
    @@ -48,18 +48,18 @@ int stun_addr_encode(const ioa_addr* ca, u08bits *cfield, int *clen, int xor_ed,
         if (xor_ed) {
     
           /* Port */
    -      ((u16bits*)cfield)[1] = (ca->s4.sin_port) ^ nswap16(mc >> 16);
    +      ((uint16_t*)cfield)[1] = (ca->s4.sin_port) ^ nswap16(mc >> 16);
     
           /* Address */
    -      ((u32bits*)cfield)[1] = (ca->s4.sin_addr.s_addr) ^ nswap32(mc);
    +      ((uint32_t*)cfield)[1] = (ca->s4.sin_addr.s_addr) ^ nswap32(mc);
     
         } else {
     
           /* Port */
    -      ((u16bits*)cfield)[1]=ca->s4.sin_port;
    +      ((uint16_t*)cfield)[1]=ca->s4.sin_port;
     
           /* Address */
    -      ((u32bits*)cfield)[1]=ca->s4.sin_addr.s_addr;
    +      ((uint32_t*)cfield)[1]=ca->s4.sin_addr.s_addr;
         }
     
       } else if (ca->ss.sa_family == AF_INET6) {
    @@ -74,29 +74,29 @@ int stun_addr_encode(const ioa_addr* ca, u08bits *cfield, int *clen, int xor_ed,
         if (xor_ed) {
     
           unsigned int i;
    -      u08bits *dst = ((u08bits*)cfield)+4;
    -      const u08bits *src = (const u08bits*)&(ca->s6.sin6_addr);
    -      u32bits magic = nswap32(mc);
    +      uint8_t *dst = ((uint8_t*)cfield)+4;
    +      const uint8_t *src = (const uint8_t*)&(ca->s6.sin6_addr);
    +      uint32_t magic = nswap32(mc);
     
           /* Port */
    -      ((u16bits*)cfield)[1] = ca->s6.sin6_port ^ nswap16(mc >> 16);
    +      ((uint16_t*)cfield)[1] = ca->s6.sin6_port ^ nswap16(mc >> 16);
     
           /* Address */
     
           for (i=0; i<4; ++i) {
    -	dst[i] = (u08bits)(src[i] ^ ((const u08bits*)&magic)[i]);
    +	dst[i] = (uint8_t)(src[i] ^ ((const uint8_t*)&magic)[i]);
           }
           for (i=0; i<12; ++i) {
    -	dst[i+4] = (u08bits)(src[i+4] ^ tsx_id[i]);
    +	dst[i+4] = (uint8_t)(src[i+4] ^ tsx_id[i]);
           }
     
         } else {
     
           /* Port */
    -      ((u16bits*)cfield)[1]=ca->s6.sin6_port;
    +      ((uint16_t*)cfield)[1]=ca->s6.sin6_port;
           
           /* Address */
    -      ns_bcopy(&ca->s6.sin6_addr, ((u08bits*)cfield)+4, 16);
    +      bcopy(&ca->s6.sin6_addr, ((uint8_t*)cfield)+4, 16);
         }
     
       } else {
    @@ -106,7 +106,7 @@ int stun_addr_encode(const ioa_addr* ca, u08bits *cfield, int *clen, int xor_ed,
       return 0;
     }
     
    -int stun_addr_decode(ioa_addr* ca, const u08bits *cfield, int len, int xor_ed, u32bits mc, const u08bits *tsx_id) {
    +int stun_addr_decode(ioa_addr* ca, const uint8_t *cfield, int len, int xor_ed, uint32_t mc, const uint8_t *tsx_id) {
     
       if(!cfield || !len || !ca || !tsx_id || (len<8)) return -1;
     
    @@ -129,10 +129,10 @@ int stun_addr_decode(ioa_addr* ca, const u08bits *cfield, int len, int xor_ed, u
         /* IPv4 address */
     
         /* Port */
    -    ca->s4.sin_port=((const u16bits*)cfield)[1];
    +    ca->s4.sin_port=((const uint16_t*)cfield)[1];
     
         /* Address */
    -    ca->s4.sin_addr.s_addr=((const u32bits*)cfield)[1];
    +    ca->s4.sin_addr.s_addr=((const uint32_t*)cfield)[1];
         
         if (xor_ed) {
           ca->s4.sin_port ^= nswap16(mc >> 16);
    @@ -146,29 +146,29 @@ int stun_addr_decode(ioa_addr* ca, const u08bits *cfield, int len, int xor_ed, u
         if(len!=20) return -1;
     
         /* Port */
    -    ca->s6.sin6_port = ((const u16bits*)cfield)[1];
    +    ca->s6.sin6_port = ((const uint16_t*)cfield)[1];
     
         /* Address */
    -    ns_bcopy(((const u08bits*)cfield)+4, &ca->s6.sin6_addr, 16);
    +    bcopy(((const uint8_t*)cfield)+4, &ca->s6.sin6_addr, 16);
     
         if (xor_ed) {
     
           unsigned int i;
    -      u08bits *dst;
    -      const u08bits *src;
    -      u32bits magic = nswap32(mc);
    +      uint8_t *dst;
    +      const uint8_t *src;
    +      uint32_t magic = nswap32(mc);
     
           /* Port */
           ca->s6.sin6_port ^= nswap16(mc >> 16);
     
           /* Address */
    -      src = ((const u08bits*)cfield)+4;
    -      dst = (u08bits*)&ca->s6.sin6_addr;
    +      src = ((const uint8_t*)cfield)+4;
    +      dst = (uint8_t*)&ca->s6.sin6_addr;
           for (i=0; i<4; ++i) {
    -	dst[i] = (u08bits)(src[i] ^ ((const u08bits*)&magic)[i]);
    +	dst[i] = (uint8_t)(src[i] ^ ((const uint8_t*)&magic)[i]);
           }
           for (i=0; i<12; ++i) {
    -	dst[i+4] = (u08bits)(src[i+4] ^ tsx_id[i]);
    +	dst[i+4] = (uint8_t)(src[i+4] ^ tsx_id[i]);
           }
         }
     
    
  • src/client/ns_turn_msg_addr.h+2 2 modified
    @@ -39,8 +39,8 @@ extern "C" {
     
     ///////////////////////////////////////////
     
    -int stun_addr_encode(const ioa_addr* ca, u08bits *cfield, int *clen, int xor_ed, u32bits mc, const u08bits *tsx_id);
    -int stun_addr_decode(ioa_addr* ca, const u08bits *cfield, int len, int xor_ed, u32bits mc, const u08bits *tsx_id);
    +int stun_addr_encode(const ioa_addr* ca, uint8_t *cfield, int *clen, int xor_ed, uint32_t mc, const uint8_t *tsx_id);
    +int stun_addr_decode(ioa_addr* ca, const uint8_t *cfield, int len, int xor_ed, uint32_t mc, const uint8_t *tsx_id);
     
     ///////////////////////////////////////////
     
    
  • src/client/ns_turn_msg.c+386 324 modified
    @@ -45,7 +45,7 @@ static void generate_random_nonce(unsigned char *nonce, size_t sz);
     
     ///////////
     
    -int stun_method_str(u16bits method, char *smethod)
    +int stun_method_str(uint16_t method, char *smethod)
     {
     	int ret = 0;
     
    @@ -87,7 +87,7 @@ int stun_method_str(u16bits method, char *smethod)
     	};
     
     	if(smethod) {
    -		ns_bcopy(s,smethod,strlen(s)+1);
    +		bcopy(s,smethod,strlen(s)+1);
     	}
     
     	return ret;
    @@ -103,23 +103,23 @@ long turn_random(void)
     
     static void turn_random_tid_size(void *id)
     {
    -	u32bits *ar=(u32bits*)id;
    +	uint32_t *ar=(uint32_t*)id;
     	if(!RAND_pseudo_bytes((unsigned char *)ar,12)) {
     		size_t i;
     		for(i=0;i<3;++i) {
    -			ar[i] = (u32bits)random();
    +			ar[i] = (uint32_t)random();
     		}
     	}
     }
     
    -int stun_calculate_hmac(const u08bits *buf, size_t len, const u08bits *key, size_t keylen, u08bits *hmac, unsigned int *hmac_len, SHATYPE shatype)
    +int stun_calculate_hmac(const uint8_t *buf, size_t len, const uint8_t *key, size_t keylen, uint8_t *hmac, unsigned int *hmac_len, SHATYPE shatype)
     {
     	ERR_clear_error();
     	UNUSED_ARG(shatype);
     
     	if(shatype == SHATYPE_SHA256) {
     #if !defined(OPENSSL_NO_SHA256) && defined(SHA256_DIGEST_LENGTH)
    -	  if (!HMAC(EVP_sha256(), key, keylen, buf, len, hmac, hmac_len)) {
    +	  if (!HMAC(EVP_sha256(), key, (int)keylen, buf, len, hmac, hmac_len)) {
     	    return -1;
     	  }
     #else
    @@ -128,7 +128,7 @@ int stun_calculate_hmac(const u08bits *buf, size_t len, const u08bits *key, size
     #endif
     	} else if(shatype == SHATYPE_SHA384) {
     #if !defined(OPENSSL_NO_SHA384) && defined(SHA384_DIGEST_LENGTH)
    -	  if (!HMAC(EVP_sha384(), key, keylen, buf, len, hmac, hmac_len)) {
    +	  if (!HMAC(EVP_sha384(), key, (int)keylen, buf, len, hmac, hmac_len)) {
     	    return -1;
     	  }
     #else
    @@ -137,38 +137,40 @@ int stun_calculate_hmac(const u08bits *buf, size_t len, const u08bits *key, size
     #endif
     	} else if(shatype == SHATYPE_SHA512) {
     #if !defined(OPENSSL_NO_SHA512) && defined(SHA512_DIGEST_LENGTH)
    -	  if (!HMAC(EVP_sha512(), key, keylen, buf, len, hmac, hmac_len)) {
    +	  if (!HMAC(EVP_sha512(), key, (int)keylen, buf, len, hmac, hmac_len)) {
     	    return -1;
     	  }
     #else
     	  fprintf(stderr,"SHA512 is not supported\n");
     	  return -1;
     #endif
     	} else
    -	  if (!HMAC(EVP_sha1(), key, keylen, buf, len, hmac, hmac_len)) {
    +	  if (!HMAC(EVP_sha1(), key, (int)keylen, buf, len, hmac, hmac_len)) {
     	    return -1;
     	  }
     
     	return 0;
     }
     
    -int stun_produce_integrity_key_str(u08bits *uname, u08bits *realm, u08bits *upwd, hmackey_t key, SHATYPE shatype)
    +int stun_produce_integrity_key_str(const uint8_t *uname, const uint8_t *realm, const uint8_t *upwd, hmackey_t key, SHATYPE shatype)
     {
    +	int ret;
    +
     	ERR_clear_error();
     	UNUSED_ARG(shatype);
     
    -	size_t ulen = strlen((s08bits*)uname);
    -	size_t rlen = strlen((s08bits*)realm);
    -	size_t plen = strlen((s08bits*)upwd);
    +	size_t ulen = strlen((const char*)uname);
    +	size_t rlen = strlen((const char*)realm);
    +	size_t plen = strlen((const char*)upwd);
     	size_t sz = ulen+1+rlen+1+plen+1+10;
     	size_t strl = ulen+1+rlen+1+plen;
    -	u08bits *str = (u08bits*)turn_malloc(sz+1);
    +	uint8_t *str = (uint8_t*)malloc(sz+1);
     
    -	strncpy((s08bits*)str,(s08bits*)uname,sz);
    +	strncpy((char*)str,(const char*)uname,sz);
     	str[ulen]=':';
    -	strncpy((s08bits*)str+ulen+1,(s08bits*)realm,sz-ulen-1);
    +	strncpy((char*)str+ulen+1,(const char*)realm,sz-ulen-1);
     	str[ulen+1+rlen]=':';
    -	strncpy((s08bits*)str+ulen+1+rlen+1,(s08bits*)upwd,sz-ulen-1-rlen-1);
    +	strncpy((char*)str+ulen+1+rlen+1,(const char*)upwd,sz-ulen-1-rlen-1);
     	str[strl]=0;
     
     	if(shatype == SHATYPE_SHA256) {
    @@ -188,9 +190,10 @@ int stun_produce_integrity_key_str(u08bits *uname, u08bits *realm, u08bits *upwd
     		EVP_DigestFinal(ctx,key,&keylen);
     		EVP_MD_CTX_free(ctx);
     #endif
    +		ret = 0;
     #else
     		fprintf(stderr,"SHA256 is not supported\n");
    -		return -1;
    +		ret = -1;
     #endif
     	} else if(shatype == SHATYPE_SHA384) {
     #if !defined(OPENSSL_NO_SHA384) && defined(SHA384_DIGEST_LENGTH)
    @@ -209,9 +212,10 @@ int stun_produce_integrity_key_str(u08bits *uname, u08bits *realm, u08bits *upwd
     		EVP_DigestFinal(ctx,key,&keylen);
     		EVP_MD_CTX_free(ctx);
     #endif
    +		ret = 0;
     #else
     		fprintf(stderr,"SHA384 is not supported\n");
    -		return -1;
    +		ret = -1;
     #endif
     	} else if(shatype == SHATYPE_SHA512) {
     #if !defined(OPENSSL_NO_SHA512) && defined(SHA512_DIGEST_LENGTH)
    @@ -230,20 +234,44 @@ int stun_produce_integrity_key_str(u08bits *uname, u08bits *realm, u08bits *upwd
     		EVP_DigestFinal(ctx,key,&keylen);
     		EVP_MD_CTX_free(ctx);
     #endif
    +		ret = 0;
     #else
     		fprintf(stderr,"SHA512 is not supported\n");
    -		return -1;
    +		ret = -1;
     #endif
     	} else {
    -		MD5_CTX ctx;
    -		MD5_Init(&ctx);
    -		MD5_Update(&ctx,str,strl);
    -		MD5_Final(key,&ctx);
    +#if OPENSSL_VERSION_NUMBER < 0x10100000L
    +		unsigned int keylen = 0;
    +		EVP_MD_CTX ctx;
    +		EVP_MD_CTX_init(&ctx);
    +#ifdef EVP_MD_CTX_FLAG_NON_FIPS_ALLOW
    +		if (FIPS_mode()) {
    +			EVP_MD_CTX_set_flags(&ctx,EVP_MD_CTX_FLAG_NON_FIPS_ALLOW);
    +		}
    +#endif
    +		EVP_DigestInit_ex(&ctx,EVP_md5(), NULL);
    +		EVP_DigestUpdate(&ctx,str,strl);
    +		EVP_DigestFinal(&ctx,key,&keylen);
    +		EVP_MD_CTX_cleanup(&ctx);
    +#else
    +		unsigned int keylen = 0;
    +		EVP_MD_CTX *ctx = EVP_MD_CTX_new();
    +#ifdef EVP_MD_CTX_FLAG_NON_FIPS_ALLOW
    +		if (FIPS_mode()) {
    +			EVP_MD_CTX_set_flags(ctx, EVP_MD_CTX_FLAG_NON_FIPS_ALLOW);
    +		}
    +#endif
    +		EVP_DigestInit_ex(ctx,EVP_md5(), NULL);
    +		EVP_DigestUpdate(ctx,str,strl);
    +		EVP_DigestFinal(ctx,key,&keylen);
    +		EVP_MD_CTX_free(ctx);
    +#endif
    +		ret = 0;
     	}
     
    -	turn_free(str,sz+1);
    +	free(str);
     
    -	return 0;
    +	return ret;
     }
     
     #define PWD_SALT_SIZE (8)
    @@ -264,15 +292,15 @@ static void generate_enc_password(const char* pwd, char *result, const unsigned
     	if(!orig_salt) {
     		generate_random_nonce(salt, PWD_SALT_SIZE);
     	} else {
    -		ns_bcopy(orig_salt,salt,PWD_SALT_SIZE);
    +		bcopy(orig_salt,salt,PWD_SALT_SIZE);
     		salt[PWD_SALT_SIZE]=0;
     	}
     	unsigned char rsalt[PWD_SALT_SIZE*2+1];
     	readable_string(salt,rsalt,PWD_SALT_SIZE);
     	result[0]='$';
     	result[1]='5';
     	result[2]='$';
    -	ns_bcopy((char*)rsalt,result+3,PWD_SALT_SIZE+PWD_SALT_SIZE);
    +	bcopy((char*)rsalt,result+3,PWD_SALT_SIZE+PWD_SALT_SIZE);
     	result[3+PWD_SALT_SIZE+PWD_SALT_SIZE]='$';
     	unsigned char* out = (unsigned char*)(result+3+PWD_SALT_SIZE+PWD_SALT_SIZE+1);
     	{
    @@ -350,61 +378,68 @@ int check_password(const char* pin, const char* pwd)
     
     /////////////////////////////////////////////////////////////////
     
    -static u32bits ns_crc32(const u08bits *buffer, u32bits len);
    +static uint32_t ns_crc32(const uint8_t *buffer, uint32_t len);
     
     void print_hmac(const char *name, const void *s, size_t len);
     
     /////////////////////////////////////////////////////////////////
     
    -int stun_get_command_message_len_str(const u08bits* buf, size_t len)
    +int stun_get_command_message_len_str(const uint8_t* buf, size_t len)
     {
     	if (len < STUN_HEADER_LENGTH)
     		return -1;
    -	return (int) (nswap16(((const u16bits*)(buf))[1]) + STUN_HEADER_LENGTH);
    +
    +	/* Validate the size the buffer claims to be */
    +	size_t bufLen = (size_t) (nswap16(((const uint16_t*)(buf))[1]) + STUN_HEADER_LENGTH);
    +	if (bufLen > len) {
    +		return -1;
    +	}
    +
    +	return bufLen;
     }
     
    -static int stun_set_command_message_len_str(u08bits* buf, int len) {
    +static int stun_set_command_message_len_str(uint8_t* buf, int len) {
       if(len<STUN_HEADER_LENGTH) return -1;
    -  ((u16bits*)buf)[1]=nswap16((u16bits)(len-STUN_HEADER_LENGTH));
    +  ((uint16_t*)buf)[1]=nswap16((uint16_t)(len-STUN_HEADER_LENGTH));
       return 0;
     }
     
     ///////////  Low-level binary //////////////////////////////////////////////
     
    -u16bits stun_make_type(u16bits method) {
    +uint16_t stun_make_type(uint16_t method) {
       method = method & 0x0FFF;
       return ((method & 0x000F) | ((method & 0x0070)<<1) | 
     	  ((method & 0x0380)<<2) | ((method & 0x0C00)<<2));
     }
     
    -u16bits stun_get_method_str(const u08bits *buf, size_t len) {
    -  if(!buf || len<2) return (u16bits)-1;
    +uint16_t stun_get_method_str(const uint8_t *buf, size_t len) {
    +  if(!buf || len<2) return (uint16_t)-1;
     
    -  u16bits tt = nswap16(((const u16bits*)buf)[0]);
    +  uint16_t tt = nswap16(((const uint16_t*)buf)[0]);
       
       return (tt & 0x000F) | ((tt & 0x00E0)>>1) | 
         ((tt & 0x0E00)>>2) | ((tt & 0x3000)>>2);
     }
     
    -u16bits stun_get_msg_type_str(const u08bits *buf, size_t len) {
    -  if(!buf || len<2) return (u16bits)-1;
    -  return ((nswap16(((const u16bits*)buf)[0])) & 0x3FFF);
    +uint16_t stun_get_msg_type_str(const uint8_t *buf, size_t len) {
    +  if(!buf || len<2) return (uint16_t)-1;
    +  return ((nswap16(((const uint16_t*)buf)[0])) & 0x3FFF);
     }
     
    -int is_channel_msg_str(const u08bits* buf, size_t blen) {
    -  return (buf && blen>=4 && STUN_VALID_CHANNEL(nswap16(((const u16bits*)buf)[0])));
    +int is_channel_msg_str(const uint8_t* buf, size_t blen) {
    +  return (buf && blen>=4 && STUN_VALID_CHANNEL(nswap16(((const uint16_t*)buf)[0])));
     }
     
     /////////////// message types /////////////////////////////////
     
    -int stun_is_command_message_str(const u08bits* buf, size_t blen)
    +int stun_is_command_message_str(const uint8_t* buf, size_t blen)
     {
     	if (buf && blen >= STUN_HEADER_LENGTH) {
    -		if (!STUN_VALID_CHANNEL(nswap16(((const u16bits*)buf)[0]))) {
    -			if ((((u08bits) buf[0]) & ((u08bits) (0xC0))) == 0) {
    -				if (nswap32(((const u32bits*)(buf))[1])
    +		if (!STUN_VALID_CHANNEL(nswap16(((const uint16_t*)buf)[0]))) {
    +			if ((((uint8_t) buf[0]) & ((uint8_t) (0xC0))) == 0) {
    +				if (nswap32(((const uint32_t*)(buf))[1])
     						== STUN_MAGIC_COOKIE) {
    -					u16bits len = nswap16(((const u16bits*)(buf))[1]);
    +					uint16_t len = nswap16(((const uint16_t*)(buf))[1]);
     					if ((len & 0x0003) == 0) {
     						if ((size_t) (len + STUN_HEADER_LENGTH) == blen) {
     							return 1;
    @@ -417,17 +452,17 @@ int stun_is_command_message_str(const u08bits* buf, size_t blen)
     	return 0;
     }
     
    -int old_stun_is_command_message_str(const u08bits* buf, size_t blen, u32bits *cookie)
    +int old_stun_is_command_message_str(const uint8_t* buf, size_t blen, uint32_t *cookie)
     {
     	if (buf && blen >= STUN_HEADER_LENGTH) {
    -		if (!STUN_VALID_CHANNEL(nswap16(((const u16bits*)buf)[0]))) {
    -			if ((((u08bits) buf[0]) & ((u08bits) (0xC0))) == 0) {
    -				if (nswap32(((const u32bits*)(buf))[1])
    +		if (!STUN_VALID_CHANNEL(nswap16(((const uint16_t*)buf)[0]))) {
    +			if ((((uint8_t) buf[0]) & ((uint8_t) (0xC0))) == 0) {
    +				if (nswap32(((const uint32_t*)(buf))[1])
     						!= STUN_MAGIC_COOKIE) {
    -					u16bits len = nswap16(((const u16bits*)(buf))[1]);
    +					uint16_t len = nswap16(((const uint16_t*)(buf))[1]);
     					if ((len & 0x0003) == 0) {
     						if ((size_t) (len + STUN_HEADER_LENGTH) == blen) {
    -							*cookie = nswap32(((const u32bits*)(buf))[1]);
    +							*cookie = nswap32(((const uint32_t*)(buf))[1]);
     							return 1;
     						}
     					}
    @@ -438,7 +473,7 @@ int old_stun_is_command_message_str(const u08bits* buf, size_t blen, u32bits *co
     	return 0;
     }
     
    -int stun_is_command_message_full_check_str(const u08bits* buf, size_t blen, int must_check_fingerprint, int *fingerprint_present) {
    +int stun_is_command_message_full_check_str(const uint8_t* buf, size_t blen, int must_check_fingerprint, int *fingerprint_present) {
     	if(!stun_is_command_message_str(buf,blen))
     		return 0;
     	stun_attr_ref sar = stun_attr_get_first_by_type_str(buf, blen, STUN_ATTRIBUTE_FINGERPRINT);
    @@ -452,46 +487,46 @@ int stun_is_command_message_full_check_str(const u08bits* buf, size_t blen, int
     	}
     	if(stun_attr_get_len(sar) != 4)
     		return 0;
    -	const u32bits* fingerprint = (const u32bits*)stun_attr_get_value(sar);
    +	const uint32_t* fingerprint = (const uint32_t*)stun_attr_get_value(sar);
     	if(!fingerprint)
     		return !must_check_fingerprint;
    -	u32bits crc32len = (u32bits)((((const u08bits*)fingerprint)-buf)-4);
    -	int ret = (*fingerprint == nswap32(ns_crc32(buf,crc32len) ^ ((u32bits)0x5354554e)));
    +	uint32_t crc32len = (uint32_t)((((const uint8_t*)fingerprint)-buf)-4);
    +	int ret = (*fingerprint == nswap32(ns_crc32(buf,crc32len) ^ ((uint32_t)0x5354554e)));
     	if(ret && fingerprint_present)
     		*fingerprint_present = ret;
     	return ret;
     }
     
    -int stun_is_command_message_offset_str(const u08bits* buf, size_t blen, int offset) {
    +int stun_is_command_message_offset_str(const uint8_t* buf, size_t blen, int offset) {
       return stun_is_command_message_str(buf + offset, blen);
     }
     
    -int stun_is_request_str(const u08bits* buf, size_t len) {
    +int stun_is_request_str(const uint8_t* buf, size_t len) {
       if(is_channel_msg_str(buf,len)) return 0;
       return IS_STUN_REQUEST(stun_get_msg_type_str(buf,len));
     }
     
    -int stun_is_success_response_str(const u08bits* buf, size_t len) {
    +int stun_is_success_response_str(const uint8_t* buf, size_t len) {
       if(is_channel_msg_str(buf,len)) return 0;
       return IS_STUN_SUCCESS_RESP(stun_get_msg_type_str(buf,len));
     }
     
    -int stun_is_error_response_str(const u08bits* buf, size_t len, int *err_code, u08bits *err_msg, size_t err_msg_size) {
    +int stun_is_error_response_str(const uint8_t* buf, size_t len, int *err_code, uint8_t *err_msg, size_t err_msg_size) {
       if(is_channel_msg_str(buf,len)) return 0;
       if(IS_STUN_ERR_RESP(stun_get_msg_type_str(buf,len))) {
         if(err_code) {
           stun_attr_ref sar = stun_attr_get_first_by_type_str(buf, len, STUN_ATTRIBUTE_ERROR_CODE);
           if(sar) {
         	  if(stun_attr_get_len(sar)>=4) {
    -    		  const u08bits* val = (const u08bits*)stun_attr_get_value(sar);
    +    		  const uint8_t* val = (const uint8_t*)stun_attr_get_value(sar);
         		  *err_code=(int)(val[2]*100 + val[3]);
         		  if(err_msg && err_msg_size>0) {
         			  err_msg[0]=0;
         			  if(stun_attr_get_len(sar)>4) {
         				  size_t msg_len = stun_attr_get_len(sar) - 4;
         				  if(msg_len>(err_msg_size-1))
         					  msg_len=err_msg_size - 1;
    -    				  ns_bcopy(val+4, err_msg, msg_len);
    +    				  bcopy(val+4, err_msg, msg_len);
         				  err_msg[msg_len]=0;
         			  }
         		  }
    @@ -503,8 +538,8 @@ int stun_is_error_response_str(const u08bits* buf, size_t len, int *err_code, u0
       return 0;
     }
     
    -int stun_is_challenge_response_str(const u08bits* buf, size_t len, int *err_code, u08bits *err_msg, size_t err_msg_size,
    -				u08bits *realm, u08bits *nonce, u08bits *server_name, int *oauth)
    +int stun_is_challenge_response_str(const uint8_t* buf, size_t len, int *err_code, uint8_t *err_msg, size_t err_msg_size,
    +				uint8_t *realm, uint8_t *nonce, uint8_t *server_name, int *oauth)
     {
     	int ret = stun_is_error_response_str(buf, len, err_code, err_msg, err_msg_size);
     
    @@ -515,21 +550,21 @@ int stun_is_challenge_response_str(const u08bits* buf, size_t len, int *err_code
     
     			int found_oauth = 0;
     
    -			const u08bits *value = stun_attr_get_value(sar);
    +			const uint8_t *value = stun_attr_get_value(sar);
     			if(value) {
     				size_t vlen = (size_t)stun_attr_get_len(sar);
    -				ns_bcopy(value,realm,vlen);
    +				bcopy(value,realm,vlen);
     				realm[vlen]=0;
     
     				{
    -					stun_attr_ref sar = stun_attr_get_first_by_type_str(buf,len,STUN_ATTRIBUTE_THIRD_PARTY_AUTHORIZATION);
    +					sar = stun_attr_get_first_by_type_str(buf,len,STUN_ATTRIBUTE_THIRD_PARTY_AUTHORIZATION);
     					if(sar) {
    -						const u08bits *value = stun_attr_get_value(sar);
    +						value = stun_attr_get_value(sar);
     						if(value) {
    -							size_t vlen = (size_t)stun_attr_get_len(sar);
    +							vlen = (size_t)stun_attr_get_len(sar);
     							if(vlen>0) {
     								if(server_name) {
    -									ns_bcopy(value,server_name,vlen);
    +									bcopy(value,server_name,vlen);
     								}
     								found_oauth = 1;
     							}
    @@ -542,7 +577,7 @@ int stun_is_challenge_response_str(const u08bits* buf, size_t len, int *err_code
     					value = stun_attr_get_value(sar);
     					if(value) {
     						vlen = (size_t)stun_attr_get_len(sar);
    -						ns_bcopy(value,nonce,vlen);
    +						bcopy(value,nonce,vlen);
     						nonce[vlen]=0;
     						if(oauth) {
     							*oauth = found_oauth;
    @@ -557,139 +592,139 @@ int stun_is_challenge_response_str(const u08bits* buf, size_t len, int *err_code
     	return 0;
     }
     
    -int stun_is_response_str(const u08bits* buf, size_t len) {
    +int stun_is_response_str(const uint8_t* buf, size_t len) {
       if(is_channel_msg_str(buf,len)) return 0;
       if(IS_STUN_SUCCESS_RESP(stun_get_msg_type_str(buf,len))) return 1;
       if(IS_STUN_ERR_RESP(stun_get_msg_type_str(buf,len))) return 1;
       return 0;
     }
     
    -int stun_is_indication_str(const u08bits* buf, size_t len) {
    +int stun_is_indication_str(const uint8_t* buf, size_t len) {
       if(is_channel_msg_str(buf,len)) return 0;
       return IS_STUN_INDICATION(stun_get_msg_type_str(buf,len));
     }
     
    -u16bits stun_make_request(u16bits method) {
    +uint16_t stun_make_request(uint16_t method) {
       return GET_STUN_REQUEST(stun_make_type(method));
     }
     
    -u16bits stun_make_indication(u16bits method) {
    +uint16_t stun_make_indication(uint16_t method) {
       return GET_STUN_INDICATION(stun_make_type(method));
     }
     
    -u16bits stun_make_success_response(u16bits method) {
    +uint16_t stun_make_success_response(uint16_t method) {
       return GET_STUN_SUCCESS_RESP(stun_make_type(method));
     }
     
    -u16bits stun_make_error_response(u16bits method) {
    +uint16_t stun_make_error_response(uint16_t method) {
       return GET_STUN_ERR_RESP(stun_make_type(method));
     }
     
     //////////////// INIT ////////////////////////////////////////////
     
    -void stun_init_buffer_str(u08bits *buf, size_t *len) {
    +void stun_init_buffer_str(uint8_t *buf, size_t *len) {
       *len=STUN_HEADER_LENGTH;
    -  ns_bzero(buf,*len);
    +  bzero(buf,*len);
     }
     
    -void stun_init_command_str(u16bits message_type, u08bits* buf, size_t *len) {
    +void stun_init_command_str(uint16_t message_type, uint8_t* buf, size_t *len) {
       stun_init_buffer_str(buf,len);
    -  message_type &= (u16bits)(0x3FFF);
    -  ((u16bits*)buf)[0]=nswap16(message_type);
    -  ((u16bits*)buf)[1]=0;
    -  ((u32bits*)buf)[1]=nswap32(STUN_MAGIC_COOKIE);
    +  message_type &= (uint16_t)(0x3FFF);
    +  ((uint16_t*)buf)[0]=nswap16(message_type);
    +  ((uint16_t*)buf)[1]=0;
    +  ((uint32_t*)buf)[1]=nswap32(STUN_MAGIC_COOKIE);
       stun_tid_generate_in_message_str(buf,NULL);
     }
     
    -void old_stun_init_command_str(u16bits message_type, u08bits* buf, size_t *len, u32bits cookie) {
    +void old_stun_init_command_str(uint16_t message_type, uint8_t* buf, size_t *len, uint32_t cookie) {
       stun_init_buffer_str(buf,len);
    -  message_type &= (u16bits)(0x3FFF);
    -  ((u16bits*)buf)[0]=nswap16(message_type);
    -  ((u16bits*)buf)[1]=0;
    -  ((u32bits*)buf)[1]=nswap32(cookie);
    +  message_type &= (uint16_t)(0x3FFF);
    +  ((uint16_t*)buf)[0]=nswap16(message_type);
    +  ((uint16_t*)buf)[1]=0;
    +  ((uint32_t*)buf)[1]=nswap32(cookie);
       stun_tid_generate_in_message_str(buf,NULL);
     }
     
    -void stun_init_request_str(u16bits method, u08bits* buf, size_t *len) {
    +void stun_init_request_str(uint16_t method, uint8_t* buf, size_t *len) {
       stun_init_command_str(stun_make_request(method), buf, len);
     }
     
    -void stun_init_indication_str(u16bits method, u08bits* buf, size_t *len) {
    +void stun_init_indication_str(uint16_t method, uint8_t* buf, size_t *len) {
       stun_init_command_str(stun_make_indication(method), buf, len);
     }
     
    -void stun_init_success_response_str(u16bits method, u08bits* buf, size_t *len, stun_tid* id) {
    +void stun_init_success_response_str(uint16_t method, uint8_t* buf, size_t *len, stun_tid* id) {
       stun_init_command_str(stun_make_success_response(method), buf, len);
       if(id) {
         stun_tid_message_cpy(buf, id);
       }
     }
     
    -void old_stun_init_success_response_str(u16bits method, u08bits* buf, size_t *len, stun_tid* id, u32bits cookie) {
    +void old_stun_init_success_response_str(uint16_t method, uint8_t* buf, size_t *len, stun_tid* id, uint32_t cookie) {
       old_stun_init_command_str(stun_make_success_response(method), buf, len, cookie);
       if(id) {
         stun_tid_message_cpy(buf, id);
       }
     }
     
    -const u08bits* get_default_reason(int error_code)
    +const uint8_t* get_default_reason(int error_code)
     {
    -	const u08bits* reason = (const u08bits *) "Unknown error";
    +	const uint8_t* reason = (const uint8_t *) "Unknown error";
     
     	switch (error_code){
     	case 300:
    -		reason = (const u08bits *) "Try Alternate";
    +		reason = (const uint8_t *) "Try Alternate";
     		break;
     	case 400:
    -		reason = (const u08bits *) "Bad Request";
    +		reason = (const uint8_t *) "Bad Request";
     		break;
     	case 401:
    -		reason = (const u08bits *) "Unauthorized";
    +		reason = (const uint8_t *) "Unauthorized";
     		break;
     	case 403:
    -		reason = (const u08bits *) "Forbidden";
    +		reason = (const uint8_t *) "Forbidden";
     		break;
     	case 404:
    -		reason = (const u08bits *) "Not Found";
    +		reason = (const uint8_t *) "Not Found";
     		break;
     	case 420:
    -		reason = (const u08bits *) "Unknown Attribute";
    +		reason = (const uint8_t *) "Unknown Attribute";
     		break;
     	case 437:
    -		reason = (const u08bits *) "Allocation Mismatch";
    +		reason = (const uint8_t *) "Allocation Mismatch";
     		break;
     	case 438:
    -		reason = (const u08bits *) "Stale Nonce";
    +		reason = (const uint8_t *) "Stale Nonce";
     		break;
     	case 440:
    -		reason = (const u08bits *) "Address Family not Supported";
    +		reason = (const uint8_t *) "Address Family not Supported";
     		break;
     	case 441:
    -		reason = (const u08bits *) "Wrong Credentials";
    +		reason = (const uint8_t *) "Wrong Credentials";
     		break;
     	case 442:
    -		reason = (const u08bits *) "Unsupported Transport Protocol";
    +		reason = (const uint8_t *) "Unsupported Transport Protocol";
     		break;
     	case 443:
    -		reason = (const u08bits *) "Peer Address Family Mismatch";
    +		reason = (const uint8_t *) "Peer Address Family Mismatch";
     		break;
     	case 446:
    -		reason = (const u08bits *) "Connection Already Exists";
    +		reason = (const uint8_t *) "Connection Already Exists";
     		break;
     	case 447:
    -		reason = (const u08bits *) "Connection Timeout or Failure";
    +		reason = (const uint8_t *) "Connection Timeout or Failure";
     		break;
     	case 486:
    -		reason = (const u08bits *) "Allocation Quota Reached";
    +		reason = (const uint8_t *) "Allocation Quota Reached";
     		break;
     	case 487:
    -		reason = (const u08bits *) "Role Conflict";
    +		reason = (const uint8_t *) "Role Conflict";
     		break;
     	case 500:
    -		reason = (const u08bits *) "Server Error";
    +		reason = (const uint8_t *) "Server Error";
     		break;
     	case 508:
    -		reason = (const u08bits *) "Insufficient Capacity";
    +		reason = (const uint8_t *) "Insufficient Capacity";
     		break;
     	default:
     		;
    @@ -698,23 +733,23 @@ const u08bits* get_default_reason(int error_code)
     	return reason;
     }
     
    -static void stun_init_error_response_common_str(u08bits* buf, size_t *len,
    -				u16bits error_code, const u08bits *reason,
    +static void stun_init_error_response_common_str(uint8_t* buf, size_t *len,
    +				uint16_t error_code, const uint8_t *reason,
     				stun_tid* id)
     {
     
     	if (!reason || !strcmp((const char*)reason,"Unknown error")) {
     		reason = get_default_reason(error_code);
     	}
     
    -	u08bits avalue[513];
    +	uint8_t avalue[513];
     	avalue[0] = 0;
     	avalue[1] = 0;
    -	avalue[2] = (u08bits) (error_code / 100);
    -	avalue[3] = (u08bits) (error_code % 100);
    -	strncpy((s08bits*) (avalue + 4), (const s08bits*) reason, sizeof(avalue)-4);
    +	avalue[2] = (uint8_t) (error_code / 100);
    +	avalue[3] = (uint8_t) (error_code % 100);
    +	strncpy((char*) (avalue + 4), (const char*) reason, sizeof(avalue)-4);
     	avalue[sizeof(avalue)-1]=0;
    -	int alen = 4 + strlen((const s08bits*) (avalue+4));
    +	int alen = 4 + (int)strlen((const char*) (avalue+4));
     
     	//"Manual" padding for compatibility with classic old stun:
     	{
    @@ -724,15 +759,15 @@ static void stun_init_error_response_common_str(u08bits* buf, size_t *len,
     		}
     	}
     
    -	stun_attr_add_str(buf, len, STUN_ATTRIBUTE_ERROR_CODE, (u08bits*) avalue, alen);
    +	stun_attr_add_str(buf, len, STUN_ATTRIBUTE_ERROR_CODE, (uint8_t*) avalue, alen);
     	if (id) {
     		stun_tid_message_cpy(buf, id);
     	}
     }
     
    -void old_stun_init_error_response_str(u16bits method, u08bits* buf, size_t *len,
    -				u16bits error_code, const u08bits *reason,
    -				stun_tid* id, u32bits cookie)
    +void old_stun_init_error_response_str(uint16_t method, uint8_t* buf, size_t *len,
    +				uint16_t error_code, const uint8_t *reason,
    +				stun_tid* id, uint32_t cookie)
     {
     
     	old_stun_init_command_str(stun_make_error_response(method), buf, len, cookie);
    @@ -742,8 +777,8 @@ void old_stun_init_error_response_str(u16bits method, u08bits* buf, size_t *len,
     					id);
     }
     
    -void stun_init_error_response_str(u16bits method, u08bits* buf, size_t *len,
    -				u16bits error_code, const u08bits *reason,
    +void stun_init_error_response_str(uint16_t method, uint8_t* buf, size_t *len,
    +				uint16_t error_code, const uint8_t *reason,
     				stun_tid* id)
     {
     
    @@ -756,13 +791,13 @@ void stun_init_error_response_str(u16bits method, u08bits* buf, size_t *len,
     
     /////////// CHANNEL ////////////////////////////////////////////////
     
    -int stun_init_channel_message_str(u16bits chnumber, u08bits* buf, size_t *len, int length, int do_padding)
    +int stun_init_channel_message_str(uint16_t chnumber, uint8_t* buf, size_t *len, int length, int do_padding)
     {
    -	u16bits rlen = (u16bits)length;
    +	uint16_t rlen = (uint16_t)length;
     
     	if(length<0 || (MAX_STUN_MESSAGE_SIZE<(4+length))) return -1;
    -	((u16bits*)(buf))[0]=nswap16(chnumber);
    -	((u16bits*)(buf))[1]=nswap16((u16bits)length);
    +	((uint16_t*)(buf))[0]=nswap16(chnumber);
    +	((uint16_t*)(buf))[1]=nswap16((uint16_t)length);
     
     	if(do_padding && (rlen & 0x0003))
     		rlen = ((rlen>>2)+1)<<2;
    @@ -772,23 +807,23 @@ int stun_init_channel_message_str(u16bits chnumber, u08bits* buf, size_t *len, i
     	return 0;
     }
     
    -int stun_is_channel_message_str(const u08bits *buf, size_t *blen, u16bits* chnumber, int mandatory_padding)
    +int stun_is_channel_message_str(const uint8_t *buf, size_t *blen, uint16_t* chnumber, int mandatory_padding)
     {
    -	u16bits datalen_header;
    -	u16bits datalen_actual;
    +	uint16_t datalen_header;
    +	uint16_t datalen_actual;
     
     	if (!blen || (*blen < 4))
     		return 0;
     
    -	u16bits chn = nswap16(((const u16bits*)(buf))[0]);
    +	uint16_t chn = nswap16(((const uint16_t*)(buf))[0]);
     	if (!STUN_VALID_CHANNEL(chn))
     		return 0;
     
    -	if(*blen>(u16bits)-1)
    -		*blen=(u16bits)-1;
    +	if(*blen>(uint16_t)-1)
    +		*blen=(uint16_t)-1;
     
    -	datalen_actual = (u16bits)(*blen) - 4;
    -	datalen_header = ((const u16bits*)buf)[1];
    +	datalen_actual = (uint16_t)(*blen) - 4;
    +	datalen_header = ((const uint16_t*)buf)[1];
     	datalen_header = nswap16(datalen_header);
     
     	if (datalen_header > datalen_actual)
    @@ -805,7 +840,7 @@ int stun_is_channel_message_str(const u08bits *buf, size_t *blen, u16bits* chnum
     			} else if ((datalen_actual < datalen_header) || (datalen_header == 0)) {
     				return 0;
     			} else {
    -				u16bits diff = datalen_actual - datalen_header;
    +				uint16_t diff = datalen_actual - datalen_header;
     				if (diff > 3)
     					return 0;
     			}
    @@ -891,15 +926,15 @@ int is_http(const char *s, size_t blen) {
     	return is_http_inline(s, blen);
     }
     
    -int stun_get_message_len_str(u08bits *buf, size_t blen, int padding, size_t *app_len) {
    +int stun_get_message_len_str(uint8_t *buf, size_t blen, int padding, size_t *app_len) {
     	if (buf && blen) {
     		/* STUN request/response ? */
     		if (buf && blen >= STUN_HEADER_LENGTH) {
    -			if (!STUN_VALID_CHANNEL(nswap16(((const u16bits*)buf)[0]))) {
    -				if ((((u08bits) buf[0]) & ((u08bits) (0xC0))) == 0) {
    -					if (nswap32(((const u32bits*)(buf))[1])
    +			if (!STUN_VALID_CHANNEL(nswap16(((const uint16_t*)buf)[0]))) {
    +				if ((((uint8_t) buf[0]) & ((uint8_t) (0xC0))) == 0) {
    +					if (nswap32(((const uint32_t*)(buf))[1])
     							== STUN_MAGIC_COOKIE) {
    -						u16bits len = nswap16(((const u16bits*)(buf))[1]);
    +						uint16_t len = nswap16(((const uint16_t*)(buf))[1]);
     						if ((len & 0x0003) == 0) {
     							len += STUN_HEADER_LENGTH;
     							if ((size_t) len <= blen) {
    @@ -923,10 +958,10 @@ int stun_get_message_len_str(u08bits *buf, size_t blen, int padding, size_t *app
     
     		/* STUN channel ? */
     		if(blen>=4) {
    -			u16bits chn=nswap16(((const u16bits*)(buf))[0]);
    +			uint16_t chn=nswap16(((const uint16_t*)(buf))[0]);
     			if(STUN_VALID_CHANNEL(chn)) {
     
    -				u16bits bret = (4+(nswap16(((const u16bits*)(buf))[1])));
    +				uint16_t bret = (4+(nswap16(((const uint16_t*)(buf))[1])));
     
     				*app_len = bret;
     
    @@ -947,14 +982,14 @@ int stun_get_message_len_str(u08bits *buf, size_t blen, int padding, size_t *app
     
     ////////// ALLOCATE ///////////////////////////////////
     
    -int stun_set_allocate_request_str(u08bits* buf, size_t *len, u32bits lifetime, int af4, int af6,
    -				u08bits transport, int mobile, const char* rt, int ep) {
    +int stun_set_allocate_request_str(uint8_t* buf, size_t *len, uint32_t lifetime, int af4, int af6,
    +				uint8_t transport, int mobile, const char* rt, int ep) {
     
       stun_init_request_str(STUN_METHOD_ALLOCATE, buf, len);
     
       //REQUESTED-TRANSPORT
       {
    -    u08bits field[4];
    +    uint8_t field[4];
         field[0]=transport;
         field[1]=0;
         field[2]=0;
    @@ -965,49 +1000,49 @@ int stun_set_allocate_request_str(u08bits* buf, size_t *len, u32bits lifetime, i
       //LIFETIME
       {
         if(lifetime<1) lifetime=STUN_DEFAULT_ALLOCATE_LIFETIME;
    -    u32bits field=nswap32(lifetime);
    -    if(stun_attr_add_str(buf,len,STUN_ATTRIBUTE_LIFETIME,(u08bits*)(&field),sizeof(field))<0) return -1;
    +    uint32_t field=nswap32(lifetime);
    +    if(stun_attr_add_str(buf,len,STUN_ATTRIBUTE_LIFETIME,(uint8_t*)(&field),sizeof(field))<0) return -1;
       }
     
       //MICE
       if(mobile) {
    -	  if(stun_attr_add_str(buf,len,STUN_ATTRIBUTE_MOBILITY_TICKET,(const u08bits*)"",0)<0) return -1;
    +	  if(stun_attr_add_str(buf,len,STUN_ATTRIBUTE_MOBILITY_TICKET,(const uint8_t*)"",0)<0) return -1;
       }
     
       if(ep>-1) {
     	  uint8_t value = ep ? 0x80 : 0x00;
    -	  if(stun_attr_add_str(buf,len,STUN_ATTRIBUTE_EVEN_PORT,(const u08bits*)&value,1)<0) return -1;
    +	  if(stun_attr_add_str(buf,len,STUN_ATTRIBUTE_EVEN_PORT,(const uint8_t*)&value,1)<0) return -1;
       }
     
       //RESERVATION-TOKEN, EVEN-PORT and DUAL-ALLOCATION are mutually exclusive:
       if(rt) {
     
    -	  stun_attr_add_str(buf,len, STUN_ATTRIBUTE_RESERVATION_TOKEN, (const u08bits*) rt, 8);
    +	  stun_attr_add_str(buf,len, STUN_ATTRIBUTE_RESERVATION_TOKEN, (const uint8_t*) rt, 8);
     
       } else {
     
     	  //ADRESS-FAMILY
     	  if (af4 && !af6) {
    -		  u08bits field[4];
    -		  field[0] = (u08bits)STUN_ATTRIBUTE_REQUESTED_ADDRESS_FAMILY_VALUE_IPV4;
    +		  uint8_t field[4];
    +		  field[0] = (uint8_t)STUN_ATTRIBUTE_REQUESTED_ADDRESS_FAMILY_VALUE_IPV4;
     		  field[1]=0;
     		  field[2]=0;
     		  field[3]=0;
     		  if(stun_attr_add_str(buf,len,STUN_ATTRIBUTE_REQUESTED_ADDRESS_FAMILY,field,sizeof(field))<0) return -1;
     	  }
     
     	  if (af6 && !af4) {
    -		  u08bits field[4];
    -		  field[0] = (u08bits)STUN_ATTRIBUTE_REQUESTED_ADDRESS_FAMILY_VALUE_IPV6;
    +		  uint8_t field[4];
    +		  field[0] = (uint8_t)STUN_ATTRIBUTE_REQUESTED_ADDRESS_FAMILY_VALUE_IPV6;
     		  field[1]=0;
     		  field[2]=0;
     		  field[3]=0;
     		  if(stun_attr_add_str(buf,len,STUN_ATTRIBUTE_REQUESTED_ADDRESS_FAMILY,field,sizeof(field))<0) return -1;
     	  }
     
     	  if (af4 && af6) {
    -	  	u08bits field[4];
    -	  	field[0] = (u08bits)STUN_ATTRIBUTE_REQUESTED_ADDRESS_FAMILY_VALUE_IPV6;
    +	  	uint8_t field[4];
    +	  	field[0] = (uint8_t)STUN_ATTRIBUTE_REQUESTED_ADDRESS_FAMILY_VALUE_IPV6;
     	  	field[1]=0;
     	  	field[2]=0;
     	  	field[3]=0;
    @@ -1018,11 +1053,11 @@ int stun_set_allocate_request_str(u08bits* buf, size_t *len, u32bits lifetime, i
       return 0;
     }
     
    -int stun_set_allocate_response_str(u08bits* buf, size_t *len, stun_tid* tid, 
    +int stun_set_allocate_response_str(uint8_t* buf, size_t *len, stun_tid* tid, 
     				   const ioa_addr *relayed_addr1, const ioa_addr *relayed_addr2,
     				   const ioa_addr *reflexive_addr,
    -				   u32bits lifetime, u32bits max_lifetime, int error_code, const u08bits *reason,
    -				   u64bits reservation_token, char* mobile_id) {
    +				   uint32_t lifetime, uint32_t max_lifetime, int error_code, const uint8_t *reason,
    +				   uint64_t reservation_token, char* mobile_id) {
     
       if(!error_code) {
     
    @@ -1042,19 +1077,19 @@ int stun_set_allocate_response_str(u08bits* buf, size_t *len, stun_tid* tid,
     
         if(reservation_token) {
           reservation_token=nswap64(reservation_token);
    -      stun_attr_add_str(buf,len,STUN_ATTRIBUTE_RESERVATION_TOKEN,(u08bits*)(&reservation_token),8);
    +      stun_attr_add_str(buf,len,STUN_ATTRIBUTE_RESERVATION_TOKEN,(uint8_t*)(&reservation_token),8);
         }
     
         {
           if(lifetime<1) lifetime=STUN_DEFAULT_ALLOCATE_LIFETIME;
           else if(lifetime>max_lifetime) lifetime = max_lifetime;
     
    -      u32bits field=nswap32(lifetime);
    -      if(stun_attr_add_str(buf,len,STUN_ATTRIBUTE_LIFETIME,(u08bits*)(&field),sizeof(field))<0) return -1;
    +      uint32_t field=nswap32(lifetime);
    +      if(stun_attr_add_str(buf,len,STUN_ATTRIBUTE_LIFETIME,(uint8_t*)(&field),sizeof(field))<0) return -1;
         }
     
         if(mobile_id && *mobile_id) {
    -	    if(stun_attr_add_str(buf,len,STUN_ATTRIBUTE_MOBILITY_TICKET,(u08bits*)mobile_id,strlen(mobile_id))<0) return -1;
    +	    if(stun_attr_add_str(buf,len,STUN_ATTRIBUTE_MOBILITY_TICKET,(uint8_t*)mobile_id,(int)strlen(mobile_id))<0) return -1;
         }
     
       } else {
    @@ -1066,11 +1101,11 @@ int stun_set_allocate_response_str(u08bits* buf, size_t *len, stun_tid* tid,
     
     /////////////// CHANNEL BIND ///////////////////////////////////////
     
    -u16bits stun_set_channel_bind_request_str(u08bits* buf, size_t *len,
    -					   const ioa_addr* peer_addr, u16bits channel_number) {
    +uint16_t stun_set_channel_bind_request_str(uint8_t* buf, size_t *len,
    +					   const ioa_addr* peer_addr, uint16_t channel_number) {
     
       if(!STUN_VALID_CHANNEL(channel_number)) {
    -    channel_number = 0x4000 + ((u16bits)(((u32bits)turn_random())%(0x7FFF-0x4000+1)));
    +    channel_number = 0x4000 + ((uint16_t)(((uint32_t)turn_random())%(0x7FFF-0x4000+1)));
       }
       
       stun_init_request_str(STUN_METHOD_CHANNEL_BIND, buf, len);
    @@ -1079,7 +1114,7 @@ u16bits stun_set_channel_bind_request_str(u08bits* buf, size_t *len,
       
       if(!peer_addr) {
         ioa_addr ca;
    -    ns_bzero(&ca,sizeof(ioa_addr));
    +    bzero(&ca,sizeof(ioa_addr));
         
         if(stun_attr_add_addr_str(buf,len,STUN_ATTRIBUTE_XOR_PEER_ADDRESS, &ca)<0) return 0;
       } else {
    @@ -1089,7 +1124,7 @@ u16bits stun_set_channel_bind_request_str(u08bits* buf, size_t *len,
       return channel_number;
     }
     
    -void stun_set_channel_bind_response_str(u08bits* buf, size_t *len, stun_tid* tid, int error_code, const u08bits *reason) {
    +void stun_set_channel_bind_response_str(uint8_t* buf, size_t *len, stun_tid* tid, int error_code, const uint8_t *reason) {
       if(!error_code) {
         stun_init_success_response_str(STUN_METHOD_CHANNEL_BIND, buf, len, tid);
       } else {
    @@ -1099,13 +1134,13 @@ void stun_set_channel_bind_response_str(u08bits* buf, size_t *len, stun_tid* tid
     
     /////////////// BINDING ///////////////////////////////////////
     
    -void stun_set_binding_request_str(u08bits* buf, size_t *len) {
    +void stun_set_binding_request_str(uint8_t* buf, size_t *len) {
       stun_init_request_str(STUN_METHOD_BINDING, buf, len);
     }
     
    -int stun_set_binding_response_str(u08bits* buf, size_t *len, stun_tid* tid, 
    -				  const ioa_addr *reflexive_addr, int error_code, const u08bits *reason,
    -				  u32bits cookie, int old_stun)
    +int stun_set_binding_response_str(uint8_t* buf, size_t *len, stun_tid* tid, 
    +				  const ioa_addr *reflexive_addr, int error_code, const uint8_t *reason,
    +				  uint32_t cookie, int old_stun)
     
     {
     	if (!error_code) {
    @@ -1131,7 +1166,7 @@ int stun_set_binding_response_str(u08bits* buf, size_t *len, stun_tid* tid,
     	return 0;
     }
     
    -int stun_is_binding_request_str(const u08bits* buf, size_t len, size_t offset)
    +int stun_is_binding_request_str(const uint8_t* buf, size_t len, size_t offset)
     {
       if(offset < len) {
         buf += offset;
    @@ -1145,7 +1180,7 @@ int stun_is_binding_request_str(const u08bits* buf, size_t len, size_t offset)
       return 0;
     }
     
    -int stun_is_binding_response_str(const u08bits* buf, size_t len) {
    +int stun_is_binding_response_str(const uint8_t* buf, size_t len) {
       if(stun_is_command_message_str(buf,len) &&
          (stun_get_method_str(buf,len)==STUN_METHOD_BINDING)) {
         if(stun_is_response_str(buf,len)) {
    @@ -1174,27 +1209,27 @@ int stun_tid_equals(const stun_tid *id1, const stun_tid *id2) {
     void stun_tid_cpy(stun_tid *id1, const stun_tid *id2) {
       if(!id1) return;
       if(!id2) return;
    -  ns_bcopy((const void*)(id2->tsx_id),(void*)(id1->tsx_id),STUN_TID_SIZE);
    +  bcopy((const void*)(id2->tsx_id),(void*)(id1->tsx_id),STUN_TID_SIZE);
     }
     
    -static void stun_tid_string_cpy(u08bits* s, const stun_tid* id) {
    +static void stun_tid_string_cpy(uint8_t* s, const stun_tid* id) {
       if(s && id) {
    -    ns_bcopy((const void*)(id->tsx_id),s,STUN_TID_SIZE);
    +    bcopy((const void*)(id->tsx_id),s,STUN_TID_SIZE);
       }
     }
     
    -static void stun_tid_from_string(const u08bits* s, stun_tid* id) {
    +static void stun_tid_from_string(const uint8_t* s, stun_tid* id) {
       if(s && id) {
    -    ns_bcopy(s,(void*)(id->tsx_id),STUN_TID_SIZE);
    +    bcopy(s,(void*)(id->tsx_id),STUN_TID_SIZE);
       }
     }
     
    -void stun_tid_from_message_str(const u08bits* buf, size_t len, stun_tid* id) {
    +void stun_tid_from_message_str(const uint8_t* buf, size_t len, stun_tid* id) {
     	UNUSED_ARG(len);
     	stun_tid_from_string(buf+8, id);
     }
     
    -void stun_tid_message_cpy(u08bits* buf, const stun_tid* id) {
    +void stun_tid_message_cpy(uint8_t* buf, const stun_tid* id) {
       if(buf && id) {
         stun_tid_string_cpy(buf+8, id);
       }
    @@ -1206,7 +1241,7 @@ void stun_tid_generate(stun_tid* id) {
       }
     }
     
    -void stun_tid_generate_in_message_str(u08bits* buf, stun_tid* id) {
    +void stun_tid_generate_in_message_str(uint8_t* buf, stun_tid* id) {
       stun_tid tmp;
       if(!id) id=&tmp;
       stun_tid_generate(id);
    @@ -1232,32 +1267,32 @@ turn_time_t stun_adjust_allocate_lifetime(turn_time_t lifetime, turn_time_t max_
     
     int stun_attr_get_type(stun_attr_ref attr) {
       if(attr)
    -    return (int)(nswap16(((const u16bits*)attr)[0]));
    +    return (int)(nswap16(((const uint16_t*)attr)[0]));
       return -1;
     }
     
     int stun_attr_get_len(stun_attr_ref attr) {
       if(attr)
    -    return (int)(nswap16(((const u16bits*)attr)[1]));
    +    return (int)(nswap16(((const uint16_t*)attr)[1]));
       return -1;
     }
     
    -const u08bits* stun_attr_get_value(stun_attr_ref attr) {
    +const uint8_t* stun_attr_get_value(stun_attr_ref attr) {
       if(attr) {
    -    int len = (int)(nswap16(((const u16bits*)attr)[1]));
    +    int len = (int)(nswap16(((const uint16_t*)attr)[1]));
         if(len<1) return NULL;
    -    return ((const u08bits*)attr)+4;
    +    return ((const uint8_t*)attr)+4;
       }
       return NULL;
     }
     
     int stun_get_requested_address_family(stun_attr_ref attr)
     {
     	if (attr) {
    -		int len = (int) (nswap16(((const u16bits*)attr)[1]));
    +		int len = (int) (nswap16(((const uint16_t*)attr)[1]));
     		if (len != 4)
     			return STUN_ATTRIBUTE_REQUESTED_ADDRESS_FAMILY_VALUE_INVALID;
    -		int val = ((const u08bits*) attr)[4];
    +		int val = ((const uint8_t*) attr)[4];
     		switch (val){
     		case STUN_ATTRIBUTE_REQUESTED_ADDRESS_FAMILY_VALUE_IPV4:
     			return val;
    @@ -1270,11 +1305,11 @@ int stun_get_requested_address_family(stun_attr_ref attr)
     	return STUN_ATTRIBUTE_REQUESTED_ADDRESS_FAMILY_VALUE_DEFAULT;
     }
     
    -u16bits stun_attr_get_channel_number(stun_attr_ref attr) {
    +uint16_t stun_attr_get_channel_number(stun_attr_ref attr) {
       if(attr) {
    -    const u08bits* value = stun_attr_get_value(attr);
    +    const uint8_t* value = stun_attr_get_value(attr);
         if(value && (stun_attr_get_len(attr) >= 2)) {
    -      u16bits cn=nswap16(((const u16bits*)value)[0]);
    +      uint16_t cn=nswap16(((const uint16_t*)value)[0]);
           if(STUN_VALID_CHANNEL(cn)) return cn;
         }
       }
    @@ -1283,21 +1318,21 @@ u16bits stun_attr_get_channel_number(stun_attr_ref attr) {
     
     band_limit_t stun_attr_get_bandwidth(stun_attr_ref attr) {
       if(attr) {
    -    const u08bits* value = stun_attr_get_value(attr);
    +    const uint8_t* value = stun_attr_get_value(attr);
         if(value && (stun_attr_get_len(attr) >= 4)) {
    -      u32bits bps=nswap32(((const u32bits*)value)[0]);
    +      uint32_t bps=nswap32(((const uint32_t*)value)[0]);
           return (band_limit_t)(bps << 7);
         }
       }
       return 0;
     }
     
    -u64bits stun_attr_get_reservation_token_value(stun_attr_ref attr)  {
    +uint64_t stun_attr_get_reservation_token_value(stun_attr_ref attr)  {
       if(attr) {
    -    const u08bits* value = stun_attr_get_value(attr);
    +    const uint8_t* value = stun_attr_get_value(attr);
         if(value && (stun_attr_get_len(attr) == 8)) {
    -      u64bits token;
    -      ns_bcopy(value, &token, sizeof(u64bits));
    +      uint64_t token;
    +      bcopy(value, &token, sizeof(uint64_t));
           return nswap64(token);
         }
       }
    @@ -1328,17 +1363,17 @@ int stun_attr_is_addr(stun_attr_ref attr) {
       return 0;
     }
     
    -u08bits stun_attr_get_even_port(stun_attr_ref attr) {
    +uint8_t stun_attr_get_even_port(stun_attr_ref attr) {
       if(attr) {
    -    const u08bits* value=stun_attr_get_value(attr);
    +    const uint8_t* value=stun_attr_get_value(attr);
         if(value) {
    -      if((u08bits)(value[0]) > 0x7F) return 1;
    +      if((uint8_t)(value[0]) > 0x7F) return 1;
         }
       }
       return 0;
     }
     
    -stun_attr_ref stun_attr_get_first_by_type_str(const u08bits* buf, size_t len, u16bits attr_type) {
    +stun_attr_ref stun_attr_get_first_by_type_str(const uint8_t* buf, size_t len, uint16_t attr_type) {
     
       stun_attr_ref attr=stun_attr_get_first_str(buf,len);
       while(attr) {
    @@ -1351,34 +1386,61 @@ stun_attr_ref stun_attr_get_first_by_type_str(const u08bits* buf, size_t len, u1
       return NULL;
     }
     
    -stun_attr_ref stun_attr_get_first_str(const u08bits* buf, size_t len) {
    +static stun_attr_ref stun_attr_check_valid(stun_attr_ref attr, size_t remaining) {
    +
    +  if(remaining >= 4) {
    +    /* Read the size of the attribute */
    +    size_t attrlen = stun_attr_get_len(attr);
    +    remaining -= 4;
    +
    +    /* Round to boundary */
    +    uint16_t rem4 = ((uint16_t)attrlen) & 0x0003;
    +    if(rem4) {
    +      attrlen = attrlen+4-(int)rem4;
    +    }
    +
    +    /* Check that there's enough space remaining */
    +    if(attrlen <= remaining) {
    +      return attr;
    +    }
    +  }
    +
    +  return NULL;
    +}
    +
    +stun_attr_ref stun_attr_get_first_str(const uint8_t* buf, size_t len) {
     
    -  if(stun_get_command_message_len_str(buf,len)>STUN_HEADER_LENGTH) {
    -    return (stun_attr_ref)(buf+STUN_HEADER_LENGTH);
    +  int bufLen = stun_get_command_message_len_str(buf,len);
    +  if(bufLen > STUN_HEADER_LENGTH) {
    +    stun_attr_ref attr = (stun_attr_ref)(buf+STUN_HEADER_LENGTH);
    +    return stun_attr_check_valid(attr, bufLen - STUN_HEADER_LENGTH);
       }
     
       return NULL;
     }
     
    -stun_attr_ref stun_attr_get_next_str(const u08bits* buf, size_t len, stun_attr_ref prev) {
    +stun_attr_ref stun_attr_get_next_str(const uint8_t* buf, size_t len, stun_attr_ref prev) {
     
       if(!prev) return stun_attr_get_first_str(buf,len);
       else {
    -    const u08bits* end = buf + stun_get_command_message_len_str(buf,len);
    +    const uint8_t* end = buf + stun_get_command_message_len_str(buf,len);
         int attrlen=stun_attr_get_len(prev);
    -    u16bits rem4 = ((u16bits)attrlen) & 0x0003;
    +    uint16_t rem4 = ((uint16_t)attrlen) & 0x0003;
         if(rem4) {
           attrlen = attrlen+4-(int)rem4;
         }
    -    const u08bits* attr_end=(const u08bits*)prev+4+attrlen;
    -    if(attr_end<end) return attr_end;
    +    /* Note the order here: operations on attrlen are untrusted as they may overflow */
    +    if(attrlen < end - (const uint8_t*)prev - 4) {
    +      const uint8_t* attr_end=(const uint8_t*)prev+4+attrlen;
    +      return stun_attr_check_valid(attr_end, end - attr_end);
    +    }
         return NULL;
       }
     }
     
    -int stun_attr_add_str(u08bits* buf, size_t *len, u16bits attr, const u08bits* avalue, int alen) {
    +int stun_attr_add_str(uint8_t* buf, size_t *len, uint16_t attr, const uint8_t* avalue, int alen) {
       if(alen<0) alen=0;
    -  u08bits tmp[1];
    +  uint8_t tmp[1];
       if(!avalue) {
         alen=0;
         avalue=tmp;
    @@ -1391,21 +1453,21 @@ int stun_attr_add_str(u08bits* buf, size_t *len, u16bits attr, const u08bits* av
       }
       if(newlen>=MAX_STUN_MESSAGE_SIZE) return -1;
       else {
    -    u08bits* attr_start=buf+clen;
    +    uint8_t* attr_start=buf+clen;
         
    -    u16bits *attr_start_16t=(u16bits*)attr_start;
    +    uint16_t *attr_start_16t=(uint16_t*)attr_start;
         
         stun_set_command_message_len_str(buf,newlen);
         *len = newlen;
         
         attr_start_16t[0]=nswap16(attr);
         attr_start_16t[1]=nswap16(alen);
    -    if(alen>0) ns_bcopy(avalue,attr_start+4,alen);
    +    if(alen>0) bcopy(avalue,attr_start+4,alen);
         return 0;
       }
     }
     
    -int stun_attr_add_addr_str(u08bits *buf, size_t *len, u16bits attr_type, const ioa_addr* ca) {
    +int stun_attr_add_addr_str(uint8_t *buf, size_t *len, uint16_t attr_type, const ioa_addr* ca) {
     
       stun_tid tid;
       stun_tid_from_message_str(buf, *len, &tid);
    @@ -1424,18 +1486,18 @@ int stun_attr_add_addr_str(u08bits *buf, size_t *len, u16bits attr_type, const i
       ioa_addr public_addr;
       map_addr_from_private_to_public(ca,&public_addr);
     
    -  u08bits cfield[64];
    +  uint8_t cfield[64];
       int clen=0;
       if(stun_addr_encode(&public_addr, cfield, &clen, xor_ed, STUN_MAGIC_COOKIE, tid.tsx_id)<0) {
         return -1;
       }
     
    -  if(stun_attr_add_str(buf,len,attr_type,(u08bits*)(&cfield),clen)<0) return -1;
    +  if(stun_attr_add_str(buf,len,attr_type,(uint8_t*)(&cfield),clen)<0) return -1;
     
       return 0;
     }
     
    -int stun_attr_get_addr_str(const u08bits *buf, size_t len, stun_attr_ref attr, ioa_addr* ca, const ioa_addr *default_addr) {
    +int stun_attr_get_addr_str(const uint8_t *buf, size_t len, stun_attr_ref attr, ioa_addr* ca, const ioa_addr *default_addr) {
     
       stun_tid tid;
       stun_tid_from_message_str(buf, len, &tid);
    @@ -1458,7 +1520,7 @@ int stun_attr_get_addr_str(const u08bits *buf, size_t len, stun_attr_ref attr, i
         ;
       };
     
    -  const u08bits *cfield=stun_attr_get_value(attr);
    +  const uint8_t *cfield=stun_attr_get_value(attr);
       if(!cfield) return -1;
     
       if(stun_addr_decode(&public_addr, cfield, stun_attr_get_len(attr), xor_ed, STUN_MAGIC_COOKIE, tid.tsx_id)<0) {
    @@ -1476,7 +1538,7 @@ int stun_attr_get_addr_str(const u08bits *buf, size_t len, stun_attr_ref attr, i
       return 0;
     }
     
    -int stun_attr_get_first_addr_str(const u08bits *buf, size_t len, u16bits attr_type, ioa_addr* ca, const ioa_addr *default_addr) {
    +int stun_attr_get_first_addr_str(const uint8_t *buf, size_t len, uint16_t attr_type, ioa_addr* ca, const ioa_addr *default_addr) {
     
       stun_attr_ref attr=stun_attr_get_first_str(buf,len);
     
    @@ -1492,36 +1554,36 @@ int stun_attr_get_first_addr_str(const u08bits *buf, size_t len, u16bits attr_ty
       return -1;
     }
     
    -int stun_attr_add_channel_number_str(u08bits* buf, size_t *len, u16bits chnumber) {
    +int stun_attr_add_channel_number_str(uint8_t* buf, size_t *len, uint16_t chnumber) {
     
    -  u16bits field[2];
    +  uint16_t field[2];
       field[0]=nswap16(chnumber);
       field[1]=0;
       
    -  return stun_attr_add_str(buf,len,STUN_ATTRIBUTE_CHANNEL_NUMBER,(u08bits*)(field),sizeof(field));
    +  return stun_attr_add_str(buf,len,STUN_ATTRIBUTE_CHANNEL_NUMBER,(uint8_t*)(field),sizeof(field));
     }
     
    -int stun_attr_add_bandwidth_str(u08bits* buf, size_t *len, band_limit_t bps0) {
    +int stun_attr_add_bandwidth_str(uint8_t* buf, size_t *len, band_limit_t bps0) {
     
    -	u32bits bps = (band_limit_t)(bps0 >> 7);
    +	uint32_t bps = (uint32_t)(band_limit_t)(bps0 >> 7);
     
    -	u32bits field=nswap32(bps);
    +	uint32_t field=nswap32(bps);
     
    -	return stun_attr_add_str(buf,len,STUN_ATTRIBUTE_NEW_BANDWIDTH,(u08bits*)(&field),sizeof(field));
    +	return stun_attr_add_str(buf,len,STUN_ATTRIBUTE_NEW_BANDWIDTH,(uint8_t*)(&field),sizeof(field));
     }
     
    -int stun_attr_add_address_error_code(u08bits* buf, size_t *len, int requested_address_family, int error_code)
    +int stun_attr_add_address_error_code(uint8_t* buf, size_t *len, int requested_address_family, int error_code)
     {
    -	const u08bits *reason = get_default_reason(error_code);
    +	const uint8_t *reason = get_default_reason(error_code);
     
    -	u08bits avalue[513];
    -	avalue[0] = (u08bits)requested_address_family;
    +	uint8_t avalue[513];
    +	avalue[0] = (uint8_t)requested_address_family;
     	avalue[1] = 0;
    -	avalue[2] = (u08bits) (error_code / 100);
    -	avalue[3] = (u08bits) (error_code % 100);
    -	strncpy((s08bits*) (avalue + 4), (const s08bits*) reason, sizeof(avalue)-4);
    +	avalue[2] = (uint8_t) (error_code / 100);
    +	avalue[3] = (uint8_t) (error_code % 100);
    +	strncpy((char*) (avalue + 4), (const char*) reason, sizeof(avalue)-4);
     	avalue[sizeof(avalue)-1]=0;
    -	int alen = 4 + strlen((const s08bits*) (avalue+4));
    +	int alen = 4 + (int)strlen((const char*) (avalue+4));
     
     	//"Manual" padding for compatibility with classic old stun:
     	{
    @@ -1531,12 +1593,12 @@ int stun_attr_add_address_error_code(u08bits* buf, size_t *len, int requested_ad
     		}
     	}
     
    -	stun_attr_add_str(buf, len, STUN_ATTRIBUTE_ADDRESS_ERROR_CODE, (u08bits*) avalue, alen);
    +	stun_attr_add_str(buf, len, STUN_ATTRIBUTE_ADDRESS_ERROR_CODE, (uint8_t*) avalue, alen);
     
     	return 0;
     }
     
    -int stun_attr_get_address_error_code(u08bits* buf, size_t len, int *requested_address_family, int *error_code)
    +int stun_attr_get_address_error_code(uint8_t* buf, size_t len, int *requested_address_family, int *error_code)
     {
     	if(requested_address_family) {
     		*requested_address_family = 0;
    @@ -1547,7 +1609,7 @@ int stun_attr_get_address_error_code(u08bits* buf, size_t len, int *requested_ad
     	if(buf && len) {
     		stun_attr_ref sar = stun_attr_get_first_by_type_str(buf, len, STUN_ATTRIBUTE_ADDRESS_ERROR_CODE);
     		if(sar) {
    -			const u08bits* value = stun_attr_get_value(sar);
    +			const uint8_t* value = stun_attr_get_value(sar);
     			if(!value) {
     				return -1;
     			} else {
    @@ -1568,12 +1630,12 @@ int stun_attr_get_address_error_code(u08bits* buf, size_t len, int *requested_ad
     	return 0;
     }
     
    -u16bits stun_attr_get_first_channel_number_str(const u08bits *buf, size_t len) {
    +uint16_t stun_attr_get_first_channel_number_str(const uint8_t *buf, size_t len) {
     
       stun_attr_ref attr=stun_attr_get_first_str(buf,len);
       while(attr) {
         if(stun_attr_get_type(attr) == STUN_ATTRIBUTE_CHANNEL_NUMBER) {
    -      u16bits ret = stun_attr_get_channel_number(attr);
    +      uint16_t ret = stun_attr_get_channel_number(attr);
           if(STUN_VALID_CHANNEL(ret)) {
         	  return ret;
           }
    @@ -1586,21 +1648,21 @@ u16bits stun_attr_get_first_channel_number_str(const u08bits *buf, size_t len) {
     
     ////////////// FINGERPRINT ////////////////////////////
     
    -int stun_attr_add_fingerprint_str(u08bits *buf, size_t *len)
    +int stun_attr_add_fingerprint_str(uint8_t *buf, size_t *len)
     {
    -	u32bits crc32 = 0;
    -	stun_attr_add_str(buf, len, STUN_ATTRIBUTE_FINGERPRINT, (u08bits*)&crc32, 4);
    -	crc32 = ns_crc32(buf,*len-8);
    -	*((u32bits*)(buf+*len-4)) = nswap32(crc32 ^ ((u32bits)0x5354554e));
    +	uint32_t crc32 = 0;
    +	stun_attr_add_str(buf, len, STUN_ATTRIBUTE_FINGERPRINT, (uint8_t*)&crc32, 4);
    +	crc32 = ns_crc32(buf,(int)*len-8);
    +	*((uint32_t*)(buf+*len-4)) = nswap32(crc32 ^ ((uint32_t)0x5354554e));
     	return 0;
     }
     ////////////// CRC ///////////////////////////////////////////////
     
     #define CRC_MASK    0xFFFFFFFFUL
     
    -#define UPDATE_CRC(crc, c)  crc = crctable[(u08bits)crc ^ (u08bits)(c)] ^ (crc >> 8)
    +#define UPDATE_CRC(crc, c)  crc = crctable[(uint8_t)crc ^ (uint8_t)(c)] ^ (crc >> 8)
     
    -static const u32bits crctable[256] = {
    +static const uint32_t crctable[256] = {
       0x00000000, 0x77073096, 0xee0e612c, 0x990951ba,
       0x076dc419, 0x706af48f, 0xe963a535, 0x9e6495a3,
       0x0edb8832, 0x79dcb8a4, 0xe0d5e91e, 0x97d2d988,
    @@ -1676,7 +1738,7 @@ reversed 0x04C11DB7
     static void make_crctable(void)
     {
     	uint i, j;
    -	u32bits r;
    +	uint32_t r;
     
     	for (i = 0; i < 256; ++i) {
     		r = i;
    @@ -1691,9 +1753,9 @@ static void make_crctable(void)
     }
     */
     
    -static u32bits ns_crc32(const u08bits *buffer, u32bits len)
    +static uint32_t ns_crc32(const uint8_t *buffer, uint32_t len)
     {
    -	u32bits crc = CRC_MASK;
    +	uint32_t crc = CRC_MASK;
     	while ( len-- ) UPDATE_CRC( crc, *buffer++ );
     	return (~crc);
     }
    @@ -1702,13 +1764,13 @@ static u32bits ns_crc32(const u08bits *buffer, u32bits len)
     
     /* We support only basic ASCII table */
     
    -int SASLprep(u08bits *s)
    +int SASLprep(uint8_t *s)
     {
     	if(s) {
    -		u08bits *strin = s;
    -		u08bits *strout = s;
    +		uint8_t *strin = s;
    +		uint8_t *strout = s;
     		for(;;) {
    -			u08bits c = *strin;
    +			uint8_t c = *strin;
     			if(!c) {
     				*strout=0;
     				break;
    @@ -1759,14 +1821,14 @@ void print_bin_func(const char *name, size_t len, const void *s, const char *fun
     	printf("<%s>:<%s>:len=%d:[",func,name,(int)len);
     	size_t i;
     	for(i=0;i<len;i++) {
    -		printf("%02x",(int)((const u08bits*)s)[i]);
    +		printf("%02x",(int)((const uint8_t*)s)[i]);
     	}
     	printf("]\n");
     }
     
    -int stun_attr_add_integrity_str(turn_credential_type ct, u08bits *buf, size_t *len, hmackey_t key, password_t pwd, SHATYPE shatype)
    +int stun_attr_add_integrity_str(turn_credential_type ct, uint8_t *buf, size_t *len, hmackey_t key, password_t pwd, SHATYPE shatype)
     {
    -	u08bits hmac[MAXSHASIZE];
    +	uint8_t hmac[MAXSHASIZE];
     
     	unsigned int shasize;
     
    @@ -1798,22 +1860,22 @@ int stun_attr_add_integrity_str(turn_credential_type ct, u08bits *buf, size_t *l
     	return 0;
     }
     
    -int stun_attr_add_integrity_by_key_str(u08bits *buf, size_t *len, u08bits *uname, u08bits *realm, hmackey_t key, u08bits *nonce, SHATYPE shatype)
    +int stun_attr_add_integrity_by_key_str(uint8_t *buf, size_t *len, const uint8_t *uname, const uint8_t *realm, hmackey_t key, const uint8_t *nonce, SHATYPE shatype)
     {
    -	if(stun_attr_add_str(buf, len, STUN_ATTRIBUTE_USERNAME, uname, strlen((s08bits*)uname))<0)
    +	if(stun_attr_add_str(buf, len, STUN_ATTRIBUTE_USERNAME, uname, (int)strlen((const char*)uname))<0)
     			return -1;
     
    -	if(stun_attr_add_str(buf, len, STUN_ATTRIBUTE_NONCE, nonce, strlen((s08bits*)nonce))<0)
    +	if(stun_attr_add_str(buf, len, STUN_ATTRIBUTE_NONCE, nonce, (int)strlen((const char*)nonce))<0)
     		return -1;
     
    -	if(stun_attr_add_str(buf, len, STUN_ATTRIBUTE_REALM, realm, strlen((s08bits*)realm))<0)
    +	if(stun_attr_add_str(buf, len, STUN_ATTRIBUTE_REALM, realm, (int)strlen((const char*)realm))<0)
     			return -1;
     
     	password_t p;
     	return stun_attr_add_integrity_str(TURN_CREDENTIALS_LONG_TERM, buf, len, key, p, shatype);
     }
     
    -int stun_attr_add_integrity_by_user_str(u08bits *buf, size_t *len, u08bits *uname, u08bits *realm, u08bits *upwd, u08bits *nonce, SHATYPE shatype)
    +int stun_attr_add_integrity_by_user_str(uint8_t *buf, size_t *len, const uint8_t *uname, const uint8_t *realm, const uint8_t *upwd, const uint8_t *nonce, SHATYPE shatype)
     {
     	hmackey_t key;
     
    @@ -1823,9 +1885,9 @@ int stun_attr_add_integrity_by_user_str(u08bits *buf, size_t *len, u08bits *unam
     	return stun_attr_add_integrity_by_key_str(buf, len, uname, realm, key, nonce, shatype);
     }
     
    -int stun_attr_add_integrity_by_user_short_term_str(u08bits *buf, size_t *len, u08bits *uname, password_t pwd, SHATYPE shatype)
    +int stun_attr_add_integrity_by_user_short_term_str(uint8_t *buf, size_t *len, const uint8_t *uname, password_t pwd, SHATYPE shatype)
     {
    -	if(stun_attr_add_str(buf, len, STUN_ATTRIBUTE_USERNAME, uname, strlen((s08bits*)uname))<0)
    +	if(stun_attr_add_str(buf, len, STUN_ATTRIBUTE_USERNAME, uname, (int)strlen((const char*)uname))<0)
     			return -1;
     
     	hmackey_t key;
    @@ -1837,20 +1899,20 @@ void print_hmac(const char *name, const void *s, size_t len)
     	printf("%s:len=%d:[",name,(int)len);
     	size_t i;
     	for(i=0;i<len;i++) {
    -		printf("%02x",(int)((const u08bits*)s)[i]);
    +		printf("%02x",(int)((const uint8_t*)s)[i]);
     	}
     	printf("]\n");
     }
     
     /*
      * Return -1 if failure, 0 if the integrity is not correct, 1 if OK
      */
    -int stun_check_message_integrity_by_key_str(turn_credential_type ct, u08bits *buf, size_t len, hmackey_t key, password_t pwd, SHATYPE shatype)
    +int stun_check_message_integrity_by_key_str(turn_credential_type ct, uint8_t *buf, size_t len, hmackey_t key, password_t pwd, SHATYPE shatype)
     {
     	int res = 0;
    -	u08bits new_hmac[MAXSHASIZE];
    +	uint8_t new_hmac[MAXSHASIZE];
     	unsigned int shasize;
    -	const u08bits *old_hmac = NULL;
    +	const uint8_t *old_hmac = NULL;
     
     	stun_attr_ref sar = stun_attr_get_first_by_type_str(buf, len, STUN_ATTRIBUTE_MESSAGE_INTEGRITY);
     	if (!sar)
    @@ -1887,7 +1949,7 @@ int stun_check_message_integrity_by_key_str(turn_credential_type ct, u08bits *bu
     	if (orig_len < 0)
     		return -1;
     
    -	int new_len = ((const u08bits*) sar - buf) + 4 + shasize;
    +	int new_len = (int)((const uint8_t*) sar - buf) + 4 + shasize;
     	if (new_len > orig_len)
     		return -1;
     
    @@ -1917,13 +1979,13 @@ int stun_check_message_integrity_by_key_str(turn_credential_type ct, u08bits *bu
     /*
      * Return -1 if failure, 0 if the integrity is not correct, 1 if OK
      */
    -int stun_check_message_integrity_str(turn_credential_type ct, u08bits *buf, size_t len, u08bits *uname, u08bits *realm, u08bits *upwd, SHATYPE shatype)
    +int stun_check_message_integrity_str(turn_credential_type ct, uint8_t *buf, size_t len, const uint8_t *uname, const uint8_t *realm, const uint8_t *upwd, SHATYPE shatype)
     {
     	hmackey_t key;
     	password_t pwd;
     
     	if(ct == TURN_CREDENTIALS_SHORT_TERM)
    -		strncpy((char*)pwd,(char*)upwd,sizeof(password_t));
    +		strncpy((char*)pwd,(const char*)upwd,sizeof(password_t));
     	else if (stun_produce_integrity_key_str(uname, realm, upwd, key, shatype) < 0)
     		return -1;
     
    @@ -1935,19 +1997,19 @@ int stun_check_message_integrity_str(turn_credential_type ct, u08bits *buf, size
     int stun_attr_get_change_request_str(stun_attr_ref attr, int *change_ip, int *change_port)
     {
     	if(stun_attr_get_len(attr) == 4) {
    -		const u08bits* value = stun_attr_get_value(attr);
    +		const uint8_t* value = stun_attr_get_value(attr);
     		if(value) {
    -			*change_ip = (value[3] & (u08bits)0x04);
    -			*change_port = (value[3] & (u08bits)0x02);
    +			*change_ip = (value[3] & (uint8_t)0x04);
    +			*change_port = (value[3] & (uint8_t)0x02);
     			return 0;
     		}
     	}
     	return -1;
     }
     
    -int stun_attr_add_change_request_str(u08bits *buf, size_t *len, int change_ip, int change_port)
    +int stun_attr_add_change_request_str(uint8_t *buf, size_t *len, int change_ip, int change_port)
     {
    -	u08bits avalue[4]={0,0,0,0};
    +	uint8_t avalue[4]={0,0,0,0};
     
     	if(change_ip) {
     		if(change_port) {
    @@ -1965,18 +2027,18 @@ int stun_attr_add_change_request_str(u08bits *buf, size_t *len, int change_ip, i
     int stun_attr_get_response_port_str(stun_attr_ref attr)
     {
     	if(stun_attr_get_len(attr) >= 2) {
    -		const u08bits* value = stun_attr_get_value(attr);
    +		const uint8_t* value = stun_attr_get_value(attr);
     		if(value) {
    -			return nswap16(((const u16bits*)value)[0]);
    +			return nswap16(((const uint16_t*)value)[0]);
     		}
     	}
     	return -1;
     }
     
    -int stun_attr_add_response_port_str(u08bits *buf, size_t *len, u16bits port)
    +int stun_attr_add_response_port_str(uint8_t *buf, size_t *len, uint16_t port)
     {
    -	u08bits avalue[4]={0,0,0,0};
    -	u16bits *port_ptr = (u16bits*)avalue;
    +	uint8_t avalue[4]={0,0,0,0};
    +	uint16_t *port_ptr = (uint16_t*)avalue;
     
     	*port_ptr = nswap16(port);
     
    @@ -1987,13 +2049,13 @@ int stun_attr_get_padding_len_str(stun_attr_ref attr) {
     	int len = stun_attr_get_len(attr);
     	if(len<0)
     		return -1;
    -	return (u16bits)len;
    +	return (uint16_t)len;
     }
     
    -int stun_attr_add_padding_str(u08bits *buf, size_t *len, u16bits padding_len)
    +int stun_attr_add_padding_str(uint8_t *buf, size_t *len, uint16_t padding_len)
     {
    -	u08bits avalue[0xFFFF];
    -	ns_bzero(avalue,padding_len);
    +	uint8_t avalue[0xFFFF];
    +	bzero(avalue,padding_len);
     
     	return stun_attr_add_str(buf, len, STUN_ATTRIBUTE_PADDING, avalue, padding_len);
     }
    @@ -2081,7 +2143,7 @@ int calculate_key(char *key, size_t key_size,
     {
     	UNUSED_ARG(key_size);
     
    -	ns_bcopy(key,new_key,new_key_size);
    +	bcopy(key,new_key,new_key_size);
     
     	return 0;
     }
    @@ -2091,7 +2153,7 @@ int convert_oauth_key_data(const oauth_key_data *oakd0, oauth_key *key, char *er
     	if(oakd0 && key) {
     
     		oauth_key_data oakd_obj;
    -		ns_bcopy(oakd0,&oakd_obj,sizeof(oauth_key_data));
    +		bcopy(oakd0,&oakd_obj,sizeof(oauth_key_data));
     		oauth_key_data *oakd = &oakd_obj;
     
     		if(!(oakd->ikm_key_size)) {
    @@ -2114,11 +2176,11 @@ int convert_oauth_key_data(const oauth_key_data *oakd0, oauth_key *key, char *er
     			return -1;
     		}
     
    -		ns_bzero(key,sizeof(oauth_key));
    +		bzero(key,sizeof(oauth_key));
     
     		STRCPY(key->kid,oakd->kid);
     
    -		ns_bcopy(oakd->ikm_key,key->ikm_key,sizeof(key->ikm_key));
    +		bcopy(oakd->ikm_key,key->ikm_key,sizeof(key->ikm_key));
     		key->ikm_key_size = oakd->ikm_key_size;
     
     		key->timestamp = oakd->timestamp;
    @@ -2236,8 +2298,8 @@ void print_field(const char* name, const unsigned char* f, size_t len) {
     	printf("\n<<==field %s\n",name);
     }
     
    -int encode_oauth_token_normal(const u08bits *server_name, encoded_oauth_token *etoken, const oauth_key *key, const oauth_token *dtoken);
    -int encode_oauth_token_normal(const u08bits *server_name, encoded_oauth_token *etoken, const oauth_key *key, const oauth_token *dtoken)
    +int encode_oauth_token_normal(const uint8_t *server_name, encoded_oauth_token *etoken, const oauth_key *key, const oauth_token *dtoken);
    +int encode_oauth_token_normal(const uint8_t *server_name, encoded_oauth_token *etoken, const oauth_key *key, const oauth_token *dtoken)
     {
     	UNUSED_ARG(server_name);
     	UNUSED_ARG(etoken);
    @@ -2248,13 +2310,13 @@ int encode_oauth_token_normal(const u08bits *server_name, encoded_oauth_token *e
     	if(server_name && etoken && key && dtoken && (dtoken->enc_block.key_length<=128)) {
     
     		unsigned char orig_field[MAX_ENCODED_OAUTH_TOKEN_SIZE];
    -		ns_bzero(orig_field,sizeof(orig_field));
    +		bzero(orig_field,sizeof(orig_field));
     
     		size_t len = 0;
     		*((uint16_t*)(orig_field+len)) = nswap16(dtoken->enc_block.key_length);
     		len +=2;
     
    -		ns_bcopy(dtoken->enc_block.mac_key,orig_field+len,dtoken->enc_block.key_length);
    +		bcopy(dtoken->enc_block.mac_key,orig_field+len,dtoken->enc_block.key_length);
     		len += dtoken->enc_block.key_length;
     
     		*((uint64_t*)(orig_field+len)) = nswap64(dtoken->enc_block.timestamp);
    @@ -2284,7 +2346,7 @@ int encode_oauth_token_normal(const u08bits *server_name, encoded_oauth_token *e
     		EVP_CIPHER_CTX_cleanup(&ctx);
     
     		size_t sn_len = strlen((const char*)server_name);
    -		ns_bcopy(server_name,encoded_field+outl,sn_len);
    +		bcopy(server_name,encoded_field+outl,sn_len);
     		outl += sn_len;
     
     		const EVP_MD *md = get_auth_type(key->auth_alg);
    @@ -2298,7 +2360,7 @@ int encode_oauth_token_normal(const u08bits *server_name, encoded_oauth_token *e
     
     		update_hmac_len(key->auth_alg, &hmac_len);
     
    -		ns_bcopy(encoded_field + outl, encoded_field + outl - sn_len, hmac_len);
    +		bcopy(encoded_field + outl, encoded_field + outl - sn_len, hmac_len);
     		outl -= sn_len;
     		outl += hmac_len; //encoded+hmac
     
    @@ -2310,8 +2372,8 @@ int encode_oauth_token_normal(const u08bits *server_name, encoded_oauth_token *e
     	return -1;
     }
     
    -int decode_oauth_token_normal(const u08bits *server_name, const encoded_oauth_token *etoken, const oauth_key *key, oauth_token *dtoken);
    -int decode_oauth_token_normal(const u08bits *server_name, const encoded_oauth_token *etoken, const oauth_key *key, oauth_token *dtoken)
    +int decode_oauth_token_normal(const uint8_t *server_name, const encoded_oauth_token *etoken, const oauth_key *key, oauth_token *dtoken);
    +int decode_oauth_token_normal(const uint8_t *server_name, const encoded_oauth_token *etoken, const oauth_key *key, oauth_token *dtoken)
     {
     	UNUSED_ARG(server_name);
     	UNUSED_ARG(etoken);
    @@ -2344,14 +2406,14 @@ int decode_oauth_token_normal(const u08bits *server_name, const encoded_oauth_to
            		}
            		unsigned char efield[MAX_ENCODED_OAUTH_TOKEN_SIZE];
            		unsigned char check_mac[MAXSHASIZE];
    -       		ns_bcopy(encoded_field,efield,encoded_field_size);
    +       		bcopy(encoded_field,efield,encoded_field_size);
            		size_t sn_len = strlen((const char*)server_name);
    -       		ns_bcopy(server_name,efield+encoded_field_size,sn_len);
    +       		bcopy(server_name,efield+encoded_field_size,sn_len);
     		    if (!HMAC(md, key->auth_key, key->auth_key_size, efield, encoded_field_size+sn_len, check_mac, &hmac_len)) {
     		    	return -1;
     		    }
     
    -		    if(ns_bcmp(check_mac,mac,mac_size)) {
    +		    if(bcmp(check_mac,mac,mac_size)) {
     		    	OAUTH_ERROR("%s: token integrity check failed\n",__FUNCTION__);
     		    	return -1;
     		    }
    @@ -2381,7 +2443,7 @@ int decode_oauth_token_normal(const u08bits *server_name, const encoded_oauth_to
     		dtoken->enc_block.key_length = nswap16(*((uint16_t*)(decoded_field+len)));
     		len += 2;
     
    -		ns_bcopy(decoded_field+len,dtoken->enc_block.mac_key,dtoken->enc_block.key_length);
    +		bcopy(decoded_field+len,dtoken->enc_block.mac_key,dtoken->enc_block.key_length);
     		len += dtoken->enc_block.key_length;
     
     		dtoken->enc_block.timestamp = nswap64(*((uint64_t*)(decoded_field+len)));
    @@ -2397,7 +2459,7 @@ int decode_oauth_token_normal(const u08bits *server_name, const encoded_oauth_to
     }
     
     static void generate_random_nonce(unsigned char *nonce, size_t sz) {
    -	if(!RAND_bytes(nonce, sz)) {
    +	if(!RAND_bytes(nonce, (int)sz)) {
     		size_t i;
     		for(i=0;i<sz;++i) {
     			nonce[i] = (unsigned char)random();
    @@ -2407,15 +2469,15 @@ static void generate_random_nonce(unsigned char *nonce, size_t sz) {
     
     #if !defined(TURN_NO_GCM)
     
    -static int encode_oauth_token_gcm(const u08bits *server_name, encoded_oauth_token *etoken, const oauth_key *key, const oauth_token *dtoken, const u08bits* nonce0) {
    +static int encode_oauth_token_gcm(const uint8_t *server_name, encoded_oauth_token *etoken, const oauth_key *key, const oauth_token *dtoken, const uint8_t* nonce0) {
     	if(server_name && etoken && key && dtoken && (dtoken->enc_block.key_length<=MAXSHASIZE)) {
     
     		unsigned char orig_field[MAX_ENCODED_OAUTH_TOKEN_SIZE];
    -		ns_bzero(orig_field,sizeof(orig_field));
    +		bzero(orig_field,sizeof(orig_field));
     
     		unsigned char nonce[OAUTH_GCM_NONCE_SIZE];
     		if(nonce0) {
    -			ns_bcopy(nonce0,nonce,sizeof(nonce));
    +			bcopy(nonce0,nonce,sizeof(nonce));
     		} else {
     			generate_random_nonce(nonce, sizeof(n
    ... [truncated]
    
  • src/client/ns_turn_msg.h+86 86 modified
    @@ -61,9 +61,9 @@ typedef enum {
     /**
      * HMAC key
      */
    -typedef u08bits hmackey_t[64];
    +typedef uint8_t hmackey_t[64];
     
    -typedef u08bits password_t[STUN_MAX_PWD_SIZE+1];
    +typedef uint8_t password_t[STUN_MAX_PWD_SIZE+1];
     typedef unsigned long band_limit_t;
     
     ///////////////////////////////////
    @@ -78,115 +78,115 @@ void stun_tid_generate(stun_tid* id);
     
     ///////////////////////////////////////////////////////////////
     
    -u16bits stun_make_type(u16bits method);
    -u16bits stun_make_request(u16bits method);
    -u16bits stun_make_indication(u16bits method);
    -u16bits stun_make_success_response(u16bits method);
    -u16bits stun_make_error_response(u16bits method);
    +uint16_t stun_make_type(uint16_t method);
    +uint16_t stun_make_request(uint16_t method);
    +uint16_t stun_make_indication(uint16_t method);
    +uint16_t stun_make_success_response(uint16_t method);
    +uint16_t stun_make_error_response(uint16_t method);
     
     ///////////////////////////////////////////////////////////////
     
     turn_time_t stun_adjust_allocate_lifetime(turn_time_t lifetime, turn_time_t max_allowed_lifetime, turn_time_t max_lifetime);
     
     ///////////// STR ////////////////////////////////////////////////
     
    -int stun_method_str(u16bits method, char *smethod);
    -
    -int stun_get_message_len_str(u08bits *buf, size_t len, int padding, size_t *app_len);
    -
    -void stun_init_buffer_str(u08bits *buf, size_t *len);
    -void stun_init_command_str(u16bits message_type, u08bits* buf, size_t *len);
    -void old_stun_init_command_str(u16bits message_type, u08bits* buf, size_t *len, u32bits cookie);
    -void stun_init_request_str(u16bits method, u08bits* buf, size_t *len);
    -void stun_init_indication_str(u16bits method, u08bits* buf, size_t *len);
    -void stun_init_success_response_str(u16bits method, u08bits* buf, size_t *len, stun_tid* id);
    -void old_stun_init_success_response_str(u16bits method, u08bits* buf, size_t *len, stun_tid* id, u32bits cookie);
    -void stun_init_error_response_str(u16bits method, u08bits* buf, size_t *len, u16bits error_code, const u08bits *reason, stun_tid* id);
    -void old_stun_init_error_response_str(u16bits method, u08bits* buf, size_t *len, u16bits error_code, const u08bits *reason, stun_tid* id, u32bits cookie);
    -int stun_init_channel_message_str(u16bits chnumber, u08bits* buf, size_t *len, int length, int do_padding);
    -
    -int stun_is_command_message_str(const u08bits* buf, size_t blen);
    -int old_stun_is_command_message_str(const u08bits* buf, size_t blen, u32bits *cookie);
    -int stun_is_command_message_full_check_str(const u08bits* buf, size_t blen, int must_check_fingerprint, int *fingerprint_present);
    -int stun_is_command_message_offset_str(const u08bits* buf, size_t blen, int offset);
    -int stun_is_request_str(const u08bits* buf, size_t len);
    -int stun_is_success_response_str(const u08bits* buf, size_t len);
    -int stun_is_error_response_str(const u08bits* buf, size_t len, int *err_code, u08bits *err_msg, size_t err_msg_size);
    -int stun_is_challenge_response_str(const u08bits* buf, size_t len, int *err_code, u08bits *err_msg, size_t err_msg_size, u08bits *realm, u08bits *nonce, u08bits *server_name, int *oauth);
    -int stun_is_response_str(const u08bits* buf, size_t len);
    -int stun_is_indication_str(const u08bits* buf, size_t len);
    -u16bits stun_get_method_str(const u08bits *buf, size_t len);
    -u16bits stun_get_msg_type_str(const u08bits *buf, size_t len);
    -int stun_is_channel_message_str(const u08bits *buf, size_t *blen, u16bits* chnumber, int mandatory_padding);
    -int is_channel_msg_str(const u08bits* buf, size_t blen);
    -
    -void stun_set_binding_request_str(u08bits* buf, size_t *len);
    -int stun_set_binding_response_str(u08bits* buf, size_t *len, stun_tid* tid, 
    +int stun_method_str(uint16_t method, char *smethod);
    +
    +int stun_get_message_len_str(uint8_t *buf, size_t len, int padding, size_t *app_len);
    +
    +void stun_init_buffer_str(uint8_t *buf, size_t *len);
    +void stun_init_command_str(uint16_t message_type, uint8_t* buf, size_t *len);
    +void old_stun_init_command_str(uint16_t message_type, uint8_t* buf, size_t *len, uint32_t cookie);
    +void stun_init_request_str(uint16_t method, uint8_t* buf, size_t *len);
    +void stun_init_indication_str(uint16_t method, uint8_t* buf, size_t *len);
    +void stun_init_success_response_str(uint16_t method, uint8_t* buf, size_t *len, stun_tid* id);
    +void old_stun_init_success_response_str(uint16_t method, uint8_t* buf, size_t *len, stun_tid* id, uint32_t cookie);
    +void stun_init_error_response_str(uint16_t method, uint8_t* buf, size_t *len, uint16_t error_code, const uint8_t *reason, stun_tid* id);
    +void old_stun_init_error_response_str(uint16_t method, uint8_t* buf, size_t *len, uint16_t error_code, const uint8_t *reason, stun_tid* id, uint32_t cookie);
    +int stun_init_channel_message_str(uint16_t chnumber, uint8_t* buf, size_t *len, int length, int do_padding);
    +
    +int stun_is_command_message_str(const uint8_t* buf, size_t blen);
    +int old_stun_is_command_message_str(const uint8_t* buf, size_t blen, uint32_t *cookie);
    +int stun_is_command_message_full_check_str(const uint8_t* buf, size_t blen, int must_check_fingerprint, int *fingerprint_present);
    +int stun_is_command_message_offset_str(const uint8_t* buf, size_t blen, int offset);
    +int stun_is_request_str(const uint8_t* buf, size_t len);
    +int stun_is_success_response_str(const uint8_t* buf, size_t len);
    +int stun_is_error_response_str(const uint8_t* buf, size_t len, int *err_code, uint8_t *err_msg, size_t err_msg_size);
    +int stun_is_challenge_response_str(const uint8_t* buf, size_t len, int *err_code, uint8_t *err_msg, size_t err_msg_size, uint8_t *realm, uint8_t *nonce, uint8_t *server_name, int *oauth);
    +int stun_is_response_str(const uint8_t* buf, size_t len);
    +int stun_is_indication_str(const uint8_t* buf, size_t len);
    +uint16_t stun_get_method_str(const uint8_t *buf, size_t len);
    +uint16_t stun_get_msg_type_str(const uint8_t *buf, size_t len);
    +int stun_is_channel_message_str(const uint8_t *buf, size_t *blen, uint16_t* chnumber, int mandatory_padding);
    +int is_channel_msg_str(const uint8_t* buf, size_t blen);
    +
    +void stun_set_binding_request_str(uint8_t* buf, size_t *len);
    +int stun_set_binding_response_str(uint8_t* buf, size_t *len, stun_tid* tid, 
     				  const ioa_addr *reflexive_addr, int error_code,
    -				  const u08bits *reason,
    -				  u32bits cookie, int old_stun);
    -int stun_is_binding_request_str(const u08bits* buf, size_t len, size_t offset);
    -int stun_is_binding_response_str(const u08bits* buf, size_t len);
    +				  const uint8_t *reason,
    +				  uint32_t cookie, int old_stun);
    +int stun_is_binding_request_str(const uint8_t* buf, size_t len, size_t offset);
    +int stun_is_binding_response_str(const uint8_t* buf, size_t len);
     
    -void stun_tid_from_message_str(const u08bits* buf, size_t len, stun_tid* id);
    -void stun_tid_message_cpy(u08bits *buf, const stun_tid* id);
    -void stun_tid_generate_in_message_str(u08bits* buf, stun_tid* id);
    +void stun_tid_from_message_str(const uint8_t* buf, size_t len, stun_tid* id);
    +void stun_tid_message_cpy(uint8_t *buf, const stun_tid* id);
    +void stun_tid_generate_in_message_str(uint8_t* buf, stun_tid* id);
     
    -int stun_get_command_message_len_str(const u08bits* buf, size_t len);
    +int stun_get_command_message_len_str(const uint8_t* buf, size_t len);
     
    -const u08bits* get_default_reason(int error_code);
    +const uint8_t* get_default_reason(int error_code);
     
     int stun_attr_is_addr(stun_attr_ref attr);
     int stun_attr_get_type(stun_attr_ref attr);
     int stun_attr_get_len(stun_attr_ref attr);
    -const u08bits* stun_attr_get_value(stun_attr_ref attr);
    -u16bits stun_attr_get_channel_number(stun_attr_ref attr);
    +const uint8_t* stun_attr_get_value(stun_attr_ref attr);
    +uint16_t stun_attr_get_channel_number(stun_attr_ref attr);
     band_limit_t stun_attr_get_bandwidth(stun_attr_ref attr);
    -u08bits stun_attr_get_even_port(stun_attr_ref attr);
    -u64bits stun_attr_get_reservation_token_value(stun_attr_ref attr);
    -stun_attr_ref stun_attr_get_first_by_type_str(const u08bits* buf, size_t len, u16bits attr_type);
    -stun_attr_ref stun_attr_get_first_str(const u08bits* buf, size_t len);
    -stun_attr_ref stun_attr_get_next_str(const u08bits* buf, size_t len, stun_attr_ref prev);
    -int stun_attr_add_str(u08bits* buf, size_t *len, u16bits attr, const u08bits* avalue, int alen);
    -int stun_attr_add_addr_str(u08bits *buf, size_t *len, u16bits attr_type, const ioa_addr* ca);
    -int stun_attr_get_addr_str(const u08bits *buf, size_t len, stun_attr_ref attr, ioa_addr* ca, const ioa_addr *default_addr);
    -int stun_attr_get_first_addr_str(const u08bits *buf, size_t len, u16bits attr_type, ioa_addr* ca, const ioa_addr *default_addr);
    -int stun_attr_add_channel_number_str(u08bits* buf, size_t *len, u16bits chnumber);
    -int stun_attr_add_bandwidth_str(u08bits* buf, size_t *len, band_limit_t bps);
    -int stun_attr_add_address_error_code(u08bits* buf, size_t *len, int requested_address_family, int error_code);
    +uint8_t stun_attr_get_even_port(stun_attr_ref attr);
    +uint64_t stun_attr_get_reservation_token_value(stun_attr_ref attr);
    +stun_attr_ref stun_attr_get_first_by_type_str(const uint8_t* buf, size_t len, uint16_t attr_type);
    +stun_attr_ref stun_attr_get_first_str(const uint8_t* buf, size_t len);
    +stun_attr_ref stun_attr_get_next_str(const uint8_t* buf, size_t len, stun_attr_ref prev);
    +int stun_attr_add_str(uint8_t* buf, size_t *len, uint16_t attr, const uint8_t* avalue, int alen);
    +int stun_attr_add_addr_str(uint8_t *buf, size_t *len, uint16_t attr_type, const ioa_addr* ca);
    +int stun_attr_get_addr_str(const uint8_t *buf, size_t len, stun_attr_ref attr, ioa_addr* ca, const ioa_addr *default_addr);
    +int stun_attr_get_first_addr_str(const uint8_t *buf, size_t len, uint16_t attr_type, ioa_addr* ca, const ioa_addr *default_addr);
    +int stun_attr_add_channel_number_str(uint8_t* buf, size_t *len, uint16_t chnumber);
    +int stun_attr_add_bandwidth_str(uint8_t* buf, size_t *len, band_limit_t bps);
    +int stun_attr_add_address_error_code(uint8_t* buf, size_t *len, int requested_address_family, int error_code);
     /* return +1 if present, 0 if not, -1 if error: */
    -int stun_attr_get_address_error_code(u08bits* buf, size_t len, int *requested_address_family, int *error_code);
    -u16bits stun_attr_get_first_channel_number_str(const u08bits *buf, size_t len);
    +int stun_attr_get_address_error_code(uint8_t* buf, size_t len, int *requested_address_family, int *error_code);
    +uint16_t stun_attr_get_first_channel_number_str(const uint8_t *buf, size_t len);
     
    -int stun_set_allocate_request_str(u08bits* buf, size_t *len, u32bits lifetime, int af4, int af6, u08bits transport, int mobile, const char* rt, int ep);
    -int stun_set_allocate_response_str(u08bits* buf, size_t *len, stun_tid* tid, 
    +int stun_set_allocate_request_str(uint8_t* buf, size_t *len, uint32_t lifetime, int af4, int af6, uint8_t transport, int mobile, const char* rt, int ep);
    +int stun_set_allocate_response_str(uint8_t* buf, size_t *len, stun_tid* tid, 
     				   const ioa_addr *relayed_addr1, const ioa_addr *relayed_addr2,
     				   const ioa_addr *reflexive_addr,
    -				   u32bits lifetime, u32bits max_lifetime, int error_code, const u08bits *reason,
    -				   u64bits reservation_token, char *mobile_id);
    +				   uint32_t lifetime, uint32_t max_lifetime, int error_code, const uint8_t *reason,
    +				   uint64_t reservation_token, char *mobile_id);
     
    -u16bits stun_set_channel_bind_request_str(u08bits* buf, size_t *len,
    -					  const ioa_addr* peer_addr, u16bits channel_number);
    -void stun_set_channel_bind_response_str(u08bits* buf, size_t *len, stun_tid* tid, int error_code, const u08bits *reason);
    +uint16_t stun_set_channel_bind_request_str(uint8_t* buf, size_t *len,
    +					  const ioa_addr* peer_addr, uint16_t channel_number);
    +void stun_set_channel_bind_response_str(uint8_t* buf, size_t *len, stun_tid* tid, int error_code, const uint8_t *reason);
     
     int stun_get_requested_address_family(stun_attr_ref attr);
     
    -int stun_attr_add_fingerprint_str(u08bits *buf, size_t *len);
    +int stun_attr_add_fingerprint_str(uint8_t *buf, size_t *len);
     
    -int SASLprep(u08bits *s);
    +int SASLprep(uint8_t *s);
     
     #define print_bin(str, len, field) print_bin_func(str,len,field,__FUNCTION__)
     void print_bin_func(const char *name, size_t len, const void *s, const char *func);
     
     /*
      * Return -1 if failure, 0 if the integrity is not correct, 1 if OK
      */
    -int stun_check_message_integrity_by_key_str(turn_credential_type ct, u08bits *buf, size_t len, hmackey_t key, password_t pwd, SHATYPE shatype);
    -int stun_check_message_integrity_str(turn_credential_type ct, u08bits *buf, size_t len, u08bits *uname, u08bits *realm, u08bits *upwd, SHATYPE shatype);
    -int stun_attr_add_integrity_str(turn_credential_type ct, u08bits *buf, size_t *len, hmackey_t key, password_t pwd, SHATYPE shatype);
    -int stun_attr_add_integrity_by_key_str(u08bits *buf, size_t *len, u08bits *uname, u08bits *realm, hmackey_t key, u08bits *nonce, SHATYPE shatype);
    -int stun_attr_add_integrity_by_user_str(u08bits *buf, size_t *len, u08bits *uname, u08bits *realm, u08bits *upwd, u08bits *nonce, SHATYPE shatype);
    -int stun_attr_add_integrity_by_user_short_term_str(u08bits *buf, size_t *len, u08bits *uname, password_t pwd, SHATYPE shatype);
    +int stun_check_message_integrity_by_key_str(turn_credential_type ct, uint8_t *buf, size_t len, hmackey_t key, password_t pwd, SHATYPE shatype);
    +int stun_check_message_integrity_str(turn_credential_type ct, uint8_t *buf, size_t len, const uint8_t *uname, const uint8_t *realm, const uint8_t *upwd, SHATYPE shatype);
    +int stun_attr_add_integrity_str(turn_credential_type ct, uint8_t *buf, size_t *len, hmackey_t key, password_t pwd, SHATYPE shatype);
    +int stun_attr_add_integrity_by_key_str(uint8_t *buf, size_t *len, const uint8_t *uname, const uint8_t *realm, hmackey_t key, const uint8_t *nonce, SHATYPE shatype);
    +int stun_attr_add_integrity_by_user_str(uint8_t *buf, size_t *len, const uint8_t *uname, const uint8_t *realm, const uint8_t *upwd, const uint8_t *nonce, SHATYPE shatype);
    +int stun_attr_add_integrity_by_user_short_term_str(uint8_t *buf, size_t *len, const uint8_t *uname, password_t pwd, SHATYPE shatype);
     size_t get_hmackey_size(SHATYPE shatype);
     
     /*
    @@ -196,24 +196,24 @@ size_t get_hmackey_size(SHATYPE shatype);
     #define TURN_RANDOM_SIZE (sizeof(long))
     long turn_random(void);
     
    -int stun_produce_integrity_key_str(u08bits *uname, u08bits *realm, u08bits *upwd, hmackey_t key, SHATYPE shatype);
    -int stun_calculate_hmac(const u08bits *buf, size_t len, const u08bits *key, size_t sz, u08bits *hmac, unsigned int *hmac_len, SHATYPE shatype);
    +int stun_produce_integrity_key_str(const uint8_t *uname, const uint8_t *realm, const uint8_t *upwd, hmackey_t key, SHATYPE shatype);
    +int stun_calculate_hmac(const uint8_t *buf, size_t len, const uint8_t *key, size_t sz, uint8_t *hmac, unsigned int *hmac_len, SHATYPE shatype);
     
     /* RFC 5780 */
     int stun_attr_get_change_request_str(stun_attr_ref attr, int *change_ip, int *change_port);
    -int stun_attr_add_change_request_str(u08bits *buf, size_t *len, int change_ip, int change_port);
    +int stun_attr_add_change_request_str(uint8_t *buf, size_t *len, int change_ip, int change_port);
     int stun_attr_get_response_port_str(stun_attr_ref attr);
    -int stun_attr_add_response_port_str(u08bits *buf, size_t *len, u16bits port);
    +int stun_attr_add_response_port_str(uint8_t *buf, size_t *len, uint16_t port);
     int stun_attr_get_padding_len_str(stun_attr_ref attr);
    -int stun_attr_add_padding_str(u08bits *buf, size_t *len, u16bits padding_len);
    +int stun_attr_add_padding_str(uint8_t *buf, size_t *len, uint16_t padding_len);
     
     /* HTTP */
     int is_http(const char *s, size_t blen);
     
     /* OAUTH */
     int convert_oauth_key_data(const oauth_key_data *oakd, oauth_key *key, char *err_msg, size_t err_msg_size);
    -int decode_oauth_token(const u08bits *server_name, const encoded_oauth_token *etoken, const oauth_key *key, oauth_token *dtoken);
    -int encode_oauth_token(const u08bits *server_name, encoded_oauth_token *etoken, const oauth_key *key, const oauth_token *dtoken, const u08bits *nonce);
    +int decode_oauth_token(const uint8_t *server_name, const encoded_oauth_token *etoken, const oauth_key *key, oauth_token *dtoken);
    +int encode_oauth_token(const uint8_t *server_name, encoded_oauth_token *etoken, const oauth_key *key, const oauth_token *dtoken, const uint8_t *nonce);
     
     /* Encrypted password */
     void generate_new_enc_password(const char* pwd, char *result);
    
  • src/client++/TurnMsgLib.h+110 110 modified
    @@ -75,7 +75,7 @@ class StunAttrIterator {
     	/**
     	 * Iterator constructor: creates iterator on raw messagebuffer.
     	 */
    -	StunAttrIterator(u08bits *buf, size_t sz) throw (WrongStunBufferFormatException) :
    +	StunAttrIterator(uint8_t *buf, size_t sz) throw (WrongStunBufferFormatException) :
     		_buf(buf), _sz(sz)  {
     		if(!stun_is_command_message_str(_buf, _sz)) {
     			throw WrongStunBufferFormatException();
    @@ -99,7 +99,7 @@ class StunAttrIterator {
     	 * Iterator constructor: creates iterator over raw buffer, starting from first
     	 * location of an attribute of particular type.
     	 */
    -	StunAttrIterator(u08bits *buf, size_t sz, u16bits attr_type) throw (WrongStunBufferFormatException) :
    +	StunAttrIterator(uint8_t *buf, size_t sz, uint16_t attr_type) throw (WrongStunBufferFormatException) :
     			_buf(buf), _sz(sz)  {
     		if(!stun_is_command_message_str(_buf, _sz)) {
     			throw WrongStunBufferFormatException();
    @@ -112,7 +112,7 @@ class StunAttrIterator {
     	 * location of an attribute of particular type.
     	 */
     	template<class T>
    -	StunAttrIterator(T &msg, u16bits attr_type) throw (WrongStunBufferFormatException) :
    +	StunAttrIterator(T &msg, uint16_t attr_type) throw (WrongStunBufferFormatException) :
     			_buf(msg.getRawBuffer()), _sz(msg.getSize())  {
     		if(!stun_is_command_message_str(_buf, _sz)) {
     			throw WrongStunBufferFormatException();
    @@ -167,17 +167,17 @@ class StunAttrIterator {
     	 * Return raw memroy field of the attribute value.
     	 * If the attribute value length is zero (0), then return NULL.
     	 */
    -	const u08bits *getRawBuffer(size_t &sz) const throw(WrongStunAttrFormatException) {
    +	const uint8_t *getRawBuffer(size_t &sz) const throw(WrongStunAttrFormatException) {
     		int len = stun_attr_get_len(_sar);
     		if(len<0)
     			throw WrongStunAttrFormatException();
     		sz = (size_t)len;
    -		const u08bits *value = stun_attr_get_value(_sar);
    +		const uint8_t *value = stun_attr_get_value(_sar);
     		return value;
     	}
     	friend class StunAttr;
     private:
    -	u08bits *_buf;
    +	uint8_t *_buf;
     	size_t _sz;
     	stun_attr_ref _sar;
     };
    @@ -201,60 +201,60 @@ class StunAttr {
     			throw EndOfStunMsgException();
     		}
     		size_t sz = 0;
    -		const u08bits *ptr = iter.getRawBuffer(sz);
    +		const uint8_t *ptr = iter.getRawBuffer(sz);
     		if(sz>=0xFFFF)
     			throw WrongStunAttrFormatException();
     		int at = iter.getType();
     		if(at<0)
     			throw WrongStunAttrFormatException();
    -		_attr_type = (u16bits)at;
    +		_attr_type = (uint16_t)at;
     		_sz = sz;
    -		_value=(u08bits*)turn_malloc(_sz);
    +		_value=(uint8_t*)malloc(_sz);
     		if(ptr)
    -			ns_bcopy(ptr,_value,_sz);
    +			bcopy(ptr,_value,_sz);
     	}
     
     	/**
     	 * Destructor
     	 */
     	virtual ~StunAttr() {
     		if(_value)
    -			turn_free(_value,_sz);
    +			free(_value,_sz);
     	}
     
     	/**
     	 * Return raw data representation of the attribute
     	 */
    -	const u08bits *getRawValue(size_t &sz) const {
    +	const uint8_t *getRawValue(size_t &sz) const {
     		sz=_sz;
     		return _value;
     	}
     
     	/**
     	 * Set raw data value
     	 */
    -	void setRawValue(u08bits *value, size_t sz) throw(WrongStunAttrFormatException) {
    +	void setRawValue(uint8_t *value, size_t sz) throw(WrongStunAttrFormatException) {
     		if(sz>0xFFFF)
     			throw WrongStunAttrFormatException();
     		if(_value)
    -			turn_free(_value,_sz);
    +			free(_value,_sz);
     		_sz = sz;
    -		_value=(u08bits*)turn_malloc(_sz);
    +		_value=(uint8_t*)malloc(_sz);
     		if(value)
    -			ns_bcopy(value,_value,_sz);
    +			bcopy(value,_value,_sz);
     	}
     
     	/**
     	 * Get attribute type
     	 */
    -	u16bits getType() const {
    +	uint16_t getType() const {
     		return _attr_type;
     	}
     
     	/**
     	 * Set attribute type
     	 */
    -	void setType(u16bits at) {
    +	void setType(uint16_t at) {
     		_attr_type = at;
     	}
     
    @@ -265,7 +265,7 @@ class StunAttr {
     	int addToMsg(T &msg) throw(WrongStunAttrFormatException, WrongStunBufferFormatException) {
     		if(!_attr_type)
     			throw WrongStunAttrFormatException();
    -		u08bits *buffer = msg.getRawBuffer();
    +		uint8_t *buffer = msg.getRawBuffer();
     		if(buffer) {
     			size_t sz = msg.getSize();
     			if(addToBuffer(buffer, sz)<0) {
    @@ -281,7 +281,7 @@ class StunAttr {
     	/**
     	 * Virtual function member to add attribute to a raw buffer
     	 */
    -	virtual int addToBuffer(u08bits *buffer, size_t &sz) throw(WrongStunAttrFormatException, WrongStunBufferFormatException) {
    +	virtual int addToBuffer(uint8_t *buffer, size_t &sz) throw(WrongStunAttrFormatException, WrongStunBufferFormatException) {
     		if(buffer) {
     			if(!_value)
     				throw WrongStunAttrFormatException();
    @@ -300,8 +300,8 @@ class StunAttr {
     		return iter._sar;
     	}
     private:
    -	u16bits _attr_type;
    -	u08bits *_value;
    +	uint16_t _attr_type;
    +	uint8_t *_value;
     	size_t _sz;
     };
     
    @@ -324,18 +324,18 @@ class StunAttrChannelNumber : public StunAttr {
     			throw WrongStunAttrFormatException();
     	}
     	virtual ~StunAttrChannelNumber() {}
    -	u16bits getChannelNumber() const {
    +	uint16_t getChannelNumber() const {
     		return _cn;
     	}
    -	void setChannelNumber(u16bits cn) {
    +	void setChannelNumber(uint16_t cn) {
     		_cn = cn;
     	}
     protected:
    -	virtual int addToBuffer(u08bits *buffer, size_t &sz) throw(WrongStunAttrFormatException, WrongStunBufferFormatException) {
    +	virtual int addToBuffer(uint8_t *buffer, size_t &sz) throw(WrongStunAttrFormatException, WrongStunBufferFormatException) {
     		return stun_attr_add_channel_number_str(buffer,&sz,_cn);
     	}
     private:
    -	u16bits _cn;
    +	uint16_t _cn;
     };
     
     /**
    @@ -355,18 +355,18 @@ class StunAttrEvenPort : public StunAttr {
     		_ep = stun_attr_get_even_port(getSar(iter));
     	}
     	virtual ~StunAttrEvenPort() {}
    -	u08bits getEvenPort() const {
    +	uint8_t getEvenPort() const {
     		return _ep;
     	}
    -	void setEvenPort(u08bits ep) {
    +	void setEvenPort(uint8_t ep) {
     		_ep = ep;
     	}
     protected:
    -	virtual int addToBuffer(u08bits *buffer, size_t &sz) throw(WrongStunAttrFormatException, WrongStunBufferFormatException) {
    +	virtual int addToBuffer(uint8_t *buffer, size_t &sz) throw(WrongStunAttrFormatException, WrongStunBufferFormatException) {
     		return stun_attr_add_str(buffer, &sz, STUN_ATTRIBUTE_EVEN_PORT, &_ep, 1);
     	}
     private:
    -	u08bits _ep;
    +	uint8_t _ep;
     };
     
     /**
    @@ -386,27 +386,27 @@ class StunAttrReservationToken : public StunAttr {
     		_rt = stun_attr_get_reservation_token_value(getSar(iter));
     	}
     	virtual ~StunAttrReservationToken() {}
    -	u64bits getReservationToken() const {
    +	uint64_t getReservationToken() const {
     		return _rt;
     	}
    -	void setReservationToken(u64bits rt) {
    +	void setReservationToken(uint64_t rt) {
     		_rt = rt;
     	}
     protected:
    -	virtual int addToBuffer(u08bits *buffer, size_t &sz) throw(WrongStunAttrFormatException, WrongStunBufferFormatException) {
    +	virtual int addToBuffer(uint8_t *buffer, size_t &sz) throw(WrongStunAttrFormatException, WrongStunBufferFormatException) {
     		uint64_t reservation_token = ioa_ntoh64(_rt);
    -		return stun_attr_add_str(buffer, &sz, STUN_ATTRIBUTE_RESERVATION_TOKEN, (u08bits*) (&reservation_token), 8);
    +		return stun_attr_add_str(buffer, &sz, STUN_ATTRIBUTE_RESERVATION_TOKEN, (uint8_t*) (&reservation_token), 8);
     	}
     private:
    -	u64bits _rt;
    +	uint64_t _rt;
     };
     
     /**
      * This attribute class is used for all address attributes
      */
     class StunAttrAddr : public StunAttr {
     public:
    -	StunAttrAddr(u16bits attr_type = 0) {
    +	StunAttrAddr(uint16_t attr_type = 0) {
     		addr_set_any(&_addr);
     		setType(attr_type);
     	}
    @@ -417,7 +417,7 @@ class StunAttrAddr : public StunAttr {
     		if(iter.eof())
     			throw EndOfStunMsgException();
     		size_t sz = 0;
    -		const u08bits *buf = iter.getRawBuffer(sz);
    +		const uint8_t *buf = iter.getRawBuffer(sz);
     		if(stun_attr_get_addr_str(buf,sz,getSar(iter),&_addr,NULL)<0) {
     			throw WrongStunAttrFormatException();
     		}
    @@ -430,7 +430,7 @@ class StunAttrAddr : public StunAttr {
     		addr_cpy(&_addr,&addr);
     	}
     protected:
    -	virtual int addToBuffer(u08bits *buffer, size_t &sz) throw(WrongStunAttrFormatException, WrongStunBufferFormatException) {
    +	virtual int addToBuffer(uint8_t *buffer, size_t &sz) throw(WrongStunAttrFormatException, WrongStunBufferFormatException) {
     		return stun_attr_add_addr_str(buffer, &sz, getType(), &_addr);
     	}
     private:
    @@ -476,7 +476,7 @@ class StunAttrChangeRequest : public StunAttr {
     			_changePort = 0;
     	}
     protected:
    -	virtual int addToBuffer(u08bits *buffer, size_t &sz) throw(WrongStunAttrFormatException, WrongStunBufferFormatException) {
    +	virtual int addToBuffer(uint8_t *buffer, size_t &sz) throw(WrongStunAttrFormatException, WrongStunBufferFormatException) {
     		return stun_attr_add_change_request_str(buffer, &sz, _changeIp, _changePort);
     	}
     private:
    @@ -503,21 +503,21 @@ class StunAttrResponsePort : public StunAttr {
     		if(rp<0) {
     			throw WrongStunAttrFormatException();
     		}
    -		_rp = (u16bits)rp;
    +		_rp = (uint16_t)rp;
     	}
     	virtual ~StunAttrResponsePort() {}
    -	u16bits getResponsePort() const {
    +	uint16_t getResponsePort() const {
     		return _rp;
     	}
    -	void setResponsePort(u16bits p) {
    +	void setResponsePort(uint16_t p) {
     		_rp = p;
     	}
     protected:
    -	virtual int addToBuffer(u08bits *buffer, size_t &sz) throw(WrongStunAttrFormatException, WrongStunBufferFormatException) {
    +	virtual int addToBuffer(uint8_t *buffer, size_t &sz) throw(WrongStunAttrFormatException, WrongStunBufferFormatException) {
     		return stun_attr_add_response_port_str(buffer, &sz, _rp);
     	}
     private:
    -	u16bits _rp;
    +	uint16_t _rp;
     };
     
     /**
    @@ -539,24 +539,24 @@ class StunAttrPadding : public StunAttr {
     		if(p<0) {
     			throw WrongStunAttrFormatException();
     		}
    -		_p = (u16bits)p;
    +		_p = (uint16_t)p;
     	}
     	virtual ~StunAttrPadding() {}
    -	u16bits getPadding() const {
    +	uint16_t getPadding() const {
     		return _p;
     	}
     	/**
     	 * Set length of padding
     	 */
    -	void setPadding(u16bits p) {
    +	void setPadding(uint16_t p) {
     		_p = p;
     	}
     protected:
    -	virtual int addToBuffer(u08bits *buffer, size_t &sz) throw(WrongStunAttrFormatException, WrongStunBufferFormatException) {
    +	virtual int addToBuffer(uint8_t *buffer, size_t &sz) throw(WrongStunAttrFormatException, WrongStunBufferFormatException) {
     		return stun_attr_add_padding_str(buffer, &sz, _p);
     	}
     private:
    -	u16bits _p;
    +	uint16_t _p;
     };
     
     /**
    @@ -569,7 +569,7 @@ class StunMsg {
     	 */
     	StunMsg() {
     		_allocated_sz = 0xFFFF;
    -		_buffer = (u08bits*)turn_malloc(_allocated_sz);
    +		_buffer = (uint8_t*)malloc(_allocated_sz);
     		_deallocate = true;
     		_sz = 0;
     		_constructed = 0;
    @@ -579,7 +579,7 @@ class StunMsg {
     	 * Construct message over raw buffer.
     	 * Parameter "construct" is true if the buffer is initialized.
     	 */
    -	StunMsg(u08bits *buffer, size_t total_sz, size_t sz, bool constructed) :
    +	StunMsg(uint8_t *buffer, size_t total_sz, size_t sz, bool constructed) :
     		_buffer(buffer), _deallocate(false), _allocated_sz(total_sz),
     		_sz(sz), _constructed(constructed) {}
     
    @@ -588,7 +588,7 @@ class StunMsg {
     	 */
     	virtual ~StunMsg() {
     		if(_deallocate && _buffer) {
    -			turn_free(_buffer, _allocated_sz);
    +			free(_buffer, _allocated_sz);
     		}
     	}
     
    @@ -609,7 +609,7 @@ class StunMsg {
     	/**
     	 * get raw buffer
     	 */
    -	u08bits *getRawBuffer() {
    +	uint8_t *getRawBuffer() {
     		return _buffer;
     	}
     
    @@ -632,7 +632,7 @@ class StunMsg {
     	/**
     	 * Check if the raw buffer is a TURN "command" (request, response or indication).
     	 */
    -	static bool isCommand(u08bits *buffer, size_t sz) {
    +	static bool isCommand(uint8_t *buffer, size_t sz) {
     		return stun_is_command_message_str(buffer, sz);
     	}
     
    @@ -643,44 +643,44 @@ class StunMsg {
     		return stun_is_command_message_str(_buffer, _sz);
     	}
     
    -	static bool isIndication(u08bits *buffer, size_t sz) {
    +	static bool isIndication(uint8_t *buffer, size_t sz) {
     		return stun_is_indication_str(buffer, sz);
     	}
     
    -	static bool isRequest(u08bits *buffer, size_t sz) {
    +	static bool isRequest(uint8_t *buffer, size_t sz) {
     		return stun_is_request_str(buffer, sz);
     	}
     
    -	static bool isSuccessResponse(u08bits *buffer, size_t sz) {
    +	static bool isSuccessResponse(uint8_t *buffer, size_t sz) {
     		return stun_is_success_response_str(buffer, sz);
     	}
     
    -	static bool isErrorResponse(u08bits *buffer, size_t sz,
    -					int &err_code, u08bits *err_msg, size_t err_msg_size) {
    +	static bool isErrorResponse(uint8_t *buffer, size_t sz,
    +					int &err_code, uint8_t *err_msg, size_t err_msg_size) {
     		return stun_is_error_response_str(buffer, sz, &err_code, err_msg, err_msg_size);
     	}
     
     	/**
     	 * Check if the raw buffer is a challenge response (the one with 401 error and realm and nonce values).
     	 */
    -	static bool isChallengeResponse(const u08bits* buf, size_t sz,
    -					int &err_code, u08bits *err_msg, size_t err_msg_size,
    -					u08bits *realm, u08bits *nonce,
    -					u08bits *server_name, int *oauth) {
    +	static bool isChallengeResponse(const uint8_t* buf, size_t sz,
    +					int &err_code, uint8_t *err_msg, size_t err_msg_size,
    +					uint8_t *realm, uint8_t *nonce,
    +					uint8_t *server_name, int *oauth) {
     		return stun_is_challenge_response_str(buf, sz, &err_code, err_msg, err_msg_size, realm, nonce, server_name, oauth);
     	}
     
     	/**
     	 * Check if the message is a channel message
     	 */
    -	static bool isChannel(u08bits *buffer, size_t sz) {
    +	static bool isChannel(uint8_t *buffer, size_t sz) {
     		return is_channel_msg_str(buffer, sz);
     	}
     
     	/**
     	 * Check if the fingerprint is present.
     	 */
    -	static bool isFingerprintPresent(u08bits *buffer, size_t sz) {
    +	static bool isFingerprintPresent(uint8_t *buffer, size_t sz) {
     		if(!stun_is_command_message_str(buffer,sz))
     			return false;
     		stun_attr_ref sar = stun_attr_get_first_by_type_str(buffer, sz, STUN_ATTRIBUTE_FINGERPRINT);
    @@ -693,7 +693,7 @@ class StunMsg {
     	/**
     	 * Check the fingerprint
     	 */
    -	static bool checkFingerprint(u08bits *buffer, size_t sz) {
    +	static bool checkFingerprint(uint8_t *buffer, size_t sz) {
     		return stun_is_command_message_full_check_str(buffer, sz, 1, NULL);
     	}
     
    @@ -740,9 +740,9 @@ class StunMsg {
     		throw(WrongStunBufferFormatException) {
     		if(!_constructed || !isCommand())
     			throw WrongStunBufferFormatException();
    -		u08bits *suname=(u08bits*)strdup(uname.c_str());
    -		u08bits *srealm=(u08bits*)strdup(realm.c_str());
    -		u08bits *supwd=(u08bits*)strdup(upwd.c_str());
    +		uint8_t *suname=(uint8_t*)strdup(uname.c_str());
    +		uint8_t *srealm=(uint8_t*)strdup(realm.c_str());
    +		uint8_t *supwd=(uint8_t*)strdup(upwd.c_str());
     		SHATYPE sht = SHATYPE_SHA1;
     		bool ret = (0< stun_check_message_integrity_str(ct,_buffer, _sz, suname, srealm, supwd, sht));
     		free(suname);
    @@ -760,10 +760,10 @@ class StunMsg {
     		if(!_constructed || !isCommand())
     			throw WrongStunBufferFormatException();
     
    -		u08bits *suname=(u08bits*)strdup(uname.c_str());
    -		u08bits *srealm=(u08bits*)strdup(realm.c_str());
    -		u08bits *supwd=(u08bits*)strdup(upwd.c_str());
    -		u08bits *snonce=(u08bits*)strdup(nonce.c_str());
    +		uint8_t *suname=(uint8_t*)strdup(uname.c_str());
    +		uint8_t *srealm=(uint8_t*)strdup(realm.c_str());
    +		uint8_t *supwd=(uint8_t*)strdup(upwd.c_str());
    +		uint8_t *snonce=(uint8_t*)strdup(nonce.c_str());
     
     		stun_attr_add_integrity_by_user_str(_buffer, &_sz, suname, srealm, supwd, snonce, SHATYPE_SHA1);
     
    @@ -782,8 +782,8 @@ class StunMsg {
     		if(!_constructed || !isCommand())
     			throw WrongStunBufferFormatException();
     
    -		u08bits *suname=(u08bits*)strdup(uname.c_str());
    -		u08bits *supwd=(u08bits*)strdup(upwd.c_str());
    +		uint8_t *suname=(uint8_t*)strdup(uname.c_str());
    +		uint8_t *supwd=(uint8_t*)strdup(upwd.c_str());
     
     		stun_attr_add_integrity_by_user_short_term_str(_buffer, &_sz, suname, supwd, SHATYPE_SHA1);
     
    @@ -795,7 +795,7 @@ class StunMsg {
     	virtual void constructBuffer() = 0;
     	virtual bool check() = 0;
     protected:
    -	u08bits *_buffer;
    +	uint8_t *_buffer;
     	bool _deallocate;
     	size_t _allocated_sz;
     	size_t _sz;
    @@ -807,8 +807,8 @@ class StunMsg {
      */
     class StunMsgRequest : public StunMsg {
     public:
    -	StunMsgRequest(u16bits method) : _method(method) {};
    -	StunMsgRequest(u08bits *buffer, size_t total_sz, size_t sz, bool constructed)
    +	StunMsgRequest(uint16_t method) : _method(method) {};
    +	StunMsgRequest(uint8_t *buffer, size_t total_sz, size_t sz, bool constructed)
     		throw(WrongStunBufferFormatException) :
     			StunMsg(buffer,total_sz,sz,constructed),_method(0) {
     
    @@ -824,14 +824,14 @@ class StunMsgRequest : public StunMsg {
     	/**
     	 * Get request method
     	 */
    -	u16bits getMethod() const {
    +	uint16_t getMethod() const {
     		return _method;
     	}
     
     	/**
     	 * Set method
     	 */
    -	void setMethod(u16bits method) {
    +	void setMethod(uint16_t method) {
     		_method = method;
     	}
     
    @@ -849,14 +849,14 @@ class StunMsgRequest : public StunMsg {
     	/**
     	 * Construct allocate request
     	 */
    -	void constructAllocateRequest(u32bits lifetime, int af4, int af6, u08bits transport, int mobile, const char* rt, int ep) {
    +	void constructAllocateRequest(uint32_t lifetime, int af4, int af6, uint8_t transport, int mobile, const char* rt, int ep) {
     		stun_set_allocate_request_str(_buffer, &_sz, lifetime, af4, af6, transport, mobile, rt, ep);
     	}
     
     	/**
     	 * Construct channel bind request
     	 */
    -	void constructChannelBindRequest(const ioa_addr &peer_addr, u16bits channel_number) {
    +	void constructChannelBindRequest(const ioa_addr &peer_addr, uint16_t channel_number) {
     		stun_set_channel_bind_request_str(_buffer, &_sz,
     					&peer_addr, channel_number);
     	}
    @@ -880,26 +880,26 @@ class StunMsgRequest : public StunMsg {
     	}
     
     private:
    -	u16bits _method;
    +	uint16_t _method;
     };
     
     /**
      * Class for STUN/TURN responses
      */
     class StunMsgResponse : public StunMsg {
     public:
    -	StunMsgResponse(u16bits method, stun_tid &tid) : _method(method), _err(0), _reason(""), _tid(tid) {};
    -	StunMsgResponse(u16bits method, int error_code, std::string reason, stun_tid &tid) :
    +	StunMsgResponse(uint16_t method, stun_tid &tid) : _method(method), _err(0), _reason(""), _tid(tid) {};
    +	StunMsgResponse(uint16_t method, int error_code, std::string reason, stun_tid &tid) :
     		_method(method), _err(error_code), _reason(reason), _tid(tid) {
     
     	};
    -	StunMsgResponse(u08bits *buffer, size_t total_sz, size_t sz, bool constructed)
    +	StunMsgResponse(uint8_t *buffer, size_t total_sz, size_t sz, bool constructed)
     		throw(WrongStunBufferFormatException) :
     			StunMsg(buffer,total_sz,sz,constructed),_method(0),_err(0),_reason("") {
     
     		if(constructed) {
     			if(!stun_is_success_response_str(buffer,sz)) {
    -				u08bits errtxt[0xFFFF];
    +				uint8_t errtxt[0xFFFF];
     				if(!stun_is_error_response_str(buffer,sz,&_err,errtxt,sizeof(errtxt))) {
     					throw WrongStunBufferFormatException();
     				}
    @@ -910,11 +910,11 @@ class StunMsgResponse : public StunMsg {
     		}
     	}
     
    -	u16bits getMethod() const {
    +	uint16_t getMethod() const {
     		return _method;
     	}
     
    -	void setMethod(u16bits method) {
    +	void setMethod(uint16_t method) {
     		_method = method;
     	}
     
    @@ -967,10 +967,10 @@ class StunMsgResponse : public StunMsg {
     		bool ret = false;
     		if(_constructed) {
     			int err_code;
    -			u08bits err_msg[1025];
    +			uint8_t err_msg[1025];
     			size_t err_msg_size=sizeof(err_msg);
    -			u08bits srealm[0xFFFF];
    -			u08bits snonce[0xFFFF];
    +			uint8_t srealm[0xFFFF];
    +			uint8_t snonce[0xFFFF];
     			ret = stun_is_challenge_response_str(_buffer, _sz, &err_code, err_msg, err_msg_size, srealm, snonce, NULL, NULL);
     			if(ret) {
     				realm = (char*)srealm;
    @@ -997,7 +997,7 @@ class StunMsgResponse : public StunMsg {
     	 */
     	void constructBindingResponse(stun_tid &tid,
     				const ioa_addr &reflexive_addr, int error_code,
    -				const u08bits *reason) {
    +				const uint8_t *reason) {
     
     		stun_set_binding_response_str(_buffer, &_sz, &tid,
     					&reflexive_addr, error_code,
    @@ -1015,8 +1015,8 @@ class StunMsgResponse : public StunMsg {
     					   const ioa_addr &relayed_addr1,
     					   const ioa_addr &relayed_addr2,
     					   const ioa_addr &reflexive_addr,
    -					   u32bits lifetime, int error_code, const u08bits *reason,
    -					   u64bits reservation_token, char *mobile_id) {
    +					   uint32_t lifetime, int error_code, const uint8_t *reason,
    +					   uint64_t reservation_token, char *mobile_id) {
     
     		stun_set_allocate_response_str(_buffer, &_sz, &tid,
     						   &relayed_addr1, &relayed_addr2,
    @@ -1028,14 +1028,14 @@ class StunMsgResponse : public StunMsg {
     	/**
     	 * Construct channel bind response
     	 */
    -	void constructChannelBindResponse(stun_tid &tid, int error_code, const u08bits *reason) {
    +	void constructChannelBindResponse(stun_tid &tid, int error_code, const uint8_t *reason) {
     		stun_set_channel_bind_response_str(_buffer, &_sz, &tid, error_code, reason);
     	}
     
     protected:
     	virtual void constructBuffer() {
     		if(_err) {
    -			stun_init_error_response_str(_method, _buffer, &_sz, _err, (const u08bits*)_reason.c_str(), &_tid);
    +			stun_init_error_response_str(_method, _buffer, &_sz, _err, (const uint8_t*)_reason.c_str(), &_tid);
     		} else {
     			stun_init_success_response_str(_method, _buffer, &_sz, &_tid);
     		}
    @@ -1046,7 +1046,7 @@ class StunMsgResponse : public StunMsg {
     		if(!_constructed)
     			return false;
     		if(!stun_is_success_response_str(_buffer,_sz)) {
    -			u08bits errtxt[0xFFFF];
    +			uint8_t errtxt[0xFFFF];
     			int cerr=0;
     			if(!stun_is_error_response_str(_buffer,_sz,&cerr,errtxt,sizeof(errtxt))) {
     				throw WrongStunBufferFormatException();
    @@ -1062,7 +1062,7 @@ class StunMsgResponse : public StunMsg {
     	}
     
     private:
    -	u16bits _method;
    +	uint16_t _method;
     	int _err;
     	std::string _reason;
     	stun_tid _tid;
    @@ -1073,8 +1073,8 @@ class StunMsgResponse : public StunMsg {
      */
     class StunMsgIndication : public StunMsg {
     public:
    -	StunMsgIndication(u16bits method) : _method(method) {};
    -	StunMsgIndication(u08bits *buffer, size_t total_sz, size_t sz, bool constructed)
    +	StunMsgIndication(uint16_t method) : _method(method) {};
    +	StunMsgIndication(uint8_t *buffer, size_t total_sz, size_t sz, bool constructed)
     		throw(WrongStunBufferFormatException) :
     			StunMsg(buffer,total_sz,sz,constructed),_method(0) {
     
    @@ -1087,11 +1087,11 @@ class StunMsgIndication : public StunMsg {
     	}
     	virtual ~StunMsgIndication() {}
     
    -	u16bits getMethod() const {
    +	uint16_t getMethod() const {
     		return _method;
     	}
     
    -	void setMethod(u16bits method) {
    +	void setMethod(uint16_t method) {
     		_method = method;
     	}
     
    @@ -1114,16 +1114,16 @@ class StunMsgIndication : public StunMsg {
     	}
     
     private:
    -	u16bits _method;
    +	uint16_t _method;
     };
     
     /**
      * Channel message
      */
     class StunMsgChannel : public StunMsg {
     public:
    -	StunMsgChannel(u16bits cn, int length) : _cn(cn), _len(length) {};
    -	StunMsgChannel(u08bits *buffer, size_t total_sz, size_t sz, bool constructed)
    +	StunMsgChannel(uint16_t cn, int length) : _cn(cn), _len(length) {};
    +	StunMsgChannel(uint8_t *buffer, size_t total_sz, size_t sz, bool constructed)
     		throw(WrongStunBufferFormatException) :
     			StunMsg(buffer,total_sz,sz,constructed),_cn(0) {
     
    @@ -1144,11 +1144,11 @@ class StunMsgChannel : public StunMsg {
     	}
     	virtual ~StunMsgChannel() {}
     
    -	u16bits getChannelNumber() const {
    +	uint16_t getChannelNumber() const {
     		return _cn;
     	}
     
    -	void setChannelNumber(u16bits cn) {
    +	void setChannelNumber(uint16_t cn) {
     		_cn = cn;
     	}
     
    @@ -1175,7 +1175,7 @@ class StunMsgChannel : public StunMsg {
     	virtual bool check() {
     		if(!_constructed)
     			return false;
    -		u16bits cn = 0;
    +		uint16_t cn = 0;
     		if(!stun_is_channel_message_str(_buffer,&_sz,&cn,0)) {
     			return false;
     		}
    @@ -1186,7 +1186,7 @@ class StunMsgChannel : public StunMsg {
     	}
     
     private:
    -	u16bits _cn;
    +	uint16_t _cn;
     	size_t _len;
     };
     
    
  • src/ns_turn_defs.h+9 70 modified
    @@ -31,7 +31,7 @@
     #ifndef __IOADEFS__
     #define __IOADEFS__
     
    -#define TURN_SERVER_VERSION "4.5.1.1"
    +#define TURN_SERVER_VERSION "4.5.1.3"
     #define TURN_SERVER_VERSION_NAME "dan Eider"
     #define TURN_SOFTWARE "Coturn-" TURN_SERVER_VERSION " '" TURN_SERVER_VERSION_NAME "'"
     
    @@ -46,6 +46,7 @@
     #include <arpa/inet.h>
     #include <net/if.h>
     #include <ctype.h>
    +#include <stdint.h>
     #include <stdio.h>
     #include <stdlib.h>
     #include <string.h>
    @@ -60,33 +61,17 @@
     extern "C" {
     #endif
     
    -/* NS types: */
    -
    -#define	s08bits	char
    -#define	s16bits	int16_t
    -#define	s32bits	int32_t
    -#define	s64bits	int64_t
    -
    -#define	u08bits	unsigned char
    -#define	u16bits uint16_t
    -#define	u32bits	uint32_t
    -#define	u64bits	uint64_t
    -
    -#define ns_bcopy(src,dst,sz) bcopy((src),(dst),(sz))
    -#define ns_bzero(ptr,sz) bzero((ptr),(sz))
    -#define ns_bcmp(ptr1,ptr2,sz) bcmp((ptr1),(ptr2),(sz))
    -
     #define nswap16(s) ntohs(s)
     #define nswap32(ul) ntohl(ul)
     #define nswap64(ull) ioa_ntoh64(ull)
     
    -static inline u64bits _ioa_ntoh64(u64bits v)
    +static inline uint64_t _ioa_ntoh64(uint64_t v)
     {
     #if BYTE_ORDER == LITTLE_ENDIAN
    -	u08bits *src = (u08bits*) &v;
    -	u08bits* dst = src + 7;
    +	uint8_t *src = (uint8_t*) &v;
    +	uint8_t* dst = src + 7;
     	while (src < dst) {
    -		u08bits vdst = *dst;
    +		uint8_t vdst = *dst;
     		*(dst--) = *src;
     		*(src++) = vdst;
     	}
    @@ -109,62 +94,16 @@ static inline u64bits _ioa_ntoh64(u64bits v)
     #define ioa_ntoh64 _ioa_ntoh64
     #define ioa_hton64 _ioa_ntoh64
     
    -#if defined(TURN_MEMORY_DEBUG)
    -
    -#if defined(TURN_LOG_FUNC)
    -#undef TURN_LOG_FUNC
    -#endif
    -
    -#define TURN_LOG_FUNC(level, ...) printf (__VA_ARGS__)
    -
    -  void tm_print_func(void);
    -  void *turn_malloc_func(size_t sz, const char* function, int line);
    -  void *turn_realloc_func(void *ptr, size_t old_sz, size_t new_sz, const char* function, int line);
    -  void turn_free_func(void *ptr, size_t sz, const char* function, int line);
    -  void turn_free_simple(void *ptr);
    -  void *turn_calloc_func(size_t number, size_t size, const char* function, int line);
    -  char *turn_strdup_func(const char* s, const char* function, int line);
    -  void* debug_ptr_add_func(void *ptr, const char* function, int line);
    -  void debug_ptr_del_func(void *ptr, const char* function, int line);
    -
    -#define debug_ptr_add(ptr) debug_ptr_add_func((ptr),__FUNCTION__,__LINE__)
    -#define debug_ptr_del(ptr) debug_ptr_del_func((ptr),__FUNCTION__,__LINE__)
    -#define tm_print() tm_print_func()
    -#define turn_malloc(sz) turn_malloc_func((size_t)(sz),__FUNCTION__,__LINE__)
    -#define turn_free(ptr,sz) turn_free_func((ptr),(size_t)(sz),__FUNCTION__,__LINE__)
    -#define turn_realloc(ptr, old_sz, new_sz) turn_realloc_func((ptr),(size_t)(old_sz),(size_t)(new_sz),__FUNCTION__,__LINE__)
    -#define turn_calloc(number, sz) turn_calloc_func((number),(size_t)(sz),__FUNCTION__,__LINE__)
    -#define turn_strdup(s) turn_strdup_func((s),__FUNCTION__,__LINE__)
    -
    -#define SSL_NEW(ctx) ((SSL*)debug_ptr_add(SSL_new(ctx)))
    -
    -#else
    -
    -#define debug_ptr_add(ptr)
    -#define debug_ptr_del(ptr)
    -#define tm_print() 
    -#define turn_malloc(sz) malloc((size_t)(sz))
    -#define turn_free(ptr,sz) free((ptr))
    -#define turn_realloc(ptr, old_sz, new_sz) realloc((ptr),(size_t)(new_sz))
    -#define turn_calloc(number, sz) calloc((number),(size_t)(sz))
    -#define turn_strdup(s) strdup((s))
    -#define turn_free_simple free
    -
    -#define SSL_NEW(ctx) SSL_new(ctx)
    -
    -#endif
    -
    -#define SSL_FREE(ssl) do { debug_ptr_del(ssl); SSL_free(ssl); ssl = NULL; } while(0)
    -#define BUFFEREVENT_FREE(be) do { if(be) { debug_ptr_del(be); bufferevent_flush(be,EV_READ|EV_WRITE,BEV_FLUSH); bufferevent_disable(be,EV_READ|EV_WRITE); bufferevent_free(be); be = NULL;} } while(0)
    +#define BUFFEREVENT_FREE(be) do { if(be) { bufferevent_flush(be,EV_READ|EV_WRITE,BEV_FLUSH); bufferevent_disable(be,EV_READ|EV_WRITE); bufferevent_free(be); be = NULL;} } while(0)
     
     #define turn_time() ((turn_time_t)time(NULL))
     
     typedef int vint;
     typedef vint* vintp;
     
    -typedef u32bits turn_time_t;
    +typedef uint32_t turn_time_t;
     
    -#define turn_time_before(t1,t2) ((((s32bits)(t1))-((s32bits)(t2))) < 0)
    +#define turn_time_before(t1,t2) ((((int32_t)(t1))-((int32_t)(t2))) < 0)
     
     #if !defined(UNUSED_ARG)
     #define UNUSED_ARG(A) do { A=A; } while(0)
    
  • src/server/ns_turn_allocation.c+36 36 modified
    @@ -40,7 +40,7 @@ static turn_permission_info* get_from_turn_permission_hashtable(turn_permission_
     
     void init_allocation(void *owner, allocation* a, ur_map *tcp_connections) {
       if(a) {
    -    ns_bzero(a,sizeof(allocation));
    +    bzero(a,sizeof(allocation));
         a->owner = owner;
         a->tcp_connections = tcp_connections;
         init_turn_permission_hashtable(&(a->addr_to_perm));
    @@ -64,7 +64,7 @@ void clear_allocation(allocation *a)
     					a->tcs.elems[i] = NULL;
     				}
     			}
    -			turn_free(a->tcs.elems,sz*sizeof(tcp_connection*));
    +			free(a->tcs.elems);
     			a->tcs.elems = NULL;
     		}
     		a->tcs.sz = 0;
    @@ -174,7 +174,7 @@ void turn_permission_clean(turn_permission_info* tinfo)
     
     		if(tinfo->verbose) {
     			char s[257]="\0";
    -			addr_to_string(&(tinfo->addr),(u08bits*)s);
    +			addr_to_string(&(tinfo->addr),(uint8_t*)s);
     			TURN_LOG_FUNC(TURN_LOG_LEVEL_INFO, "session %018llu: peer %s deleted\n",tinfo->session_id,s);
     		}
     
    @@ -185,14 +185,14 @@ void turn_permission_clean(turn_permission_info* tinfo)
     		IOA_EVENT_DEL(tinfo->lifetime_ev);
     		lm_map_foreach(&(tinfo->chns), (foreachcb_type) delete_channel_info_from_allocation_map);
     		lm_map_clean(&(tinfo->chns));
    -		ns_bzero(tinfo,sizeof(turn_permission_info));
    +		bzero(tinfo,sizeof(turn_permission_info));
     	}
     }
     
     static void init_turn_permission_hashtable(turn_permission_hashtable *map)
     {
     	if (map)
    -		ns_bzero(map,sizeof(turn_permission_hashtable));
    +		bzero(map,sizeof(turn_permission_hashtable));
     }
     
     static void free_turn_permission_hashtable(turn_permission_hashtable *map)
    @@ -222,10 +222,10 @@ static void free_turn_permission_hashtable(turn_permission_hashtable *map)
     						if(slot->info.allocated) {
     							turn_permission_clean(&(slot->info));
     						}
    -						turn_free(slot,sizeof(turn_permission_slot));
    +						free(slot);
     					}
     				}
    -				turn_free(parray->extra_slots, parray->extra_sz * sizeof(turn_permission_slot*));
    +				free(parray->extra_slots);
     				parray->extra_slots = NULL;
     			}
     			parray->extra_sz = 0;
    @@ -238,7 +238,7 @@ static turn_permission_info* get_from_turn_permission_hashtable(turn_permission_
     	if (!addr || !map)
     		return NULL;
     
    -	u32bits index = addr_hash_no_port(addr) & (TURN_PERMISSION_HASHTABLE_SIZE-1);
    +	uint32_t index = addr_hash_no_port(addr) & (TURN_PERMISSION_HASHTABLE_SIZE-1);
     	turn_permission_array *parray = &(map->table[index]);
     
     	{
    @@ -273,7 +273,7 @@ static void ch_info_clean(ch_info* c) {
     			c->kernel_channel = 0;
     		}
     		IOA_EVENT_DEL(c->lifetime_ev);
    -		ns_bzero(c,sizeof(ch_info));
    +		bzero(c,sizeof(ch_info));
     	}
     }
     
    @@ -300,7 +300,7 @@ void turn_channel_delete(ch_info* chn)
     		int port = addr_get_port(&(chn->peer_addr));
     		if(port<1) {
     			char s[129];
    -			addr_to_string(&(chn->peer_addr),(u08bits*)s);
    +			addr_to_string(&(chn->peer_addr),(uint8_t*)s);
     			TURN_LOG_FUNC(TURN_LOG_LEVEL_ERROR, "!!! %s: strange (1) channel to be cleaned: port is empty: %s\n",__FUNCTION__,s);
     		}
     		{
    @@ -315,7 +315,7 @@ void turn_channel_delete(ch_info* chn)
     	}
     }
     
    -ch_info* allocation_get_new_ch_info(allocation* a, u16bits chnum, ioa_addr* peer_addr)
    +ch_info* allocation_get_new_ch_info(allocation* a, uint16_t chnum, ioa_addr* peer_addr)
     {
     
     	turn_permission_info* tinfo = get_from_turn_permission_hashtable(&(a->addr_to_perm), peer_addr);
    @@ -336,7 +336,7 @@ ch_info* allocation_get_new_ch_info(allocation* a, u16bits chnum, ioa_addr* peer
     	return chn;
     }
     
    -ch_info* allocation_get_ch_info(allocation* a, u16bits chnum) {
    +ch_info* allocation_get_ch_info(allocation* a, uint16_t chnum) {
     	return ch_map_get(&(a->chns), chnum, 0);
     }
     
    @@ -348,7 +348,7 @@ ch_info* allocation_get_ch_info_by_peer_addr(allocation* a, ioa_addr* peer_addr)
     	return NULL;
     }
     
    -u16bits get_turn_channel_number(turn_permission_info* tinfo, ioa_addr *addr)
    +uint16_t get_turn_channel_number(turn_permission_info* tinfo, ioa_addr *addr)
     {
     	if (tinfo) {
     		ur_map_value_type t = 0;
    @@ -388,7 +388,7 @@ turn_permission_info* allocation_add_permission(allocation *a, const ioa_addr* a
     	if (a && addr) {
     
     		turn_permission_hashtable *map = &(a->addr_to_perm);
    -		u32bits hash = addr_hash_no_port(addr);
    +		uint32_t hash = addr_hash_no_port(addr);
     		size_t fds = (size_t) (hash & (TURN_PERMISSION_HASHTABLE_SIZE-1));
     
     		turn_permission_array *parray = &(map->table[fds]);
    @@ -427,16 +427,16 @@ turn_permission_info* allocation_add_permission(allocation *a, const ioa_addr* a
     
     			if(!slot) {
     				size_t old_sz_mem = old_sz * sizeof(turn_permission_slot*);
    -				parray->extra_slots = (turn_permission_slot **) turn_realloc(parray->extra_slots,
    -						old_sz_mem, old_sz_mem + sizeof(turn_permission_slot*));
    +				parray->extra_slots = (turn_permission_slot **) realloc(parray->extra_slots,
    +						old_sz_mem + sizeof(turn_permission_slot*));
     				slots = parray->extra_slots;
     				parray->extra_sz = old_sz + 1;
    -				slots[old_sz] = (turn_permission_slot *)turn_malloc(sizeof(turn_permission_slot));
    +				slots[old_sz] = (turn_permission_slot *)malloc(sizeof(turn_permission_slot));
     				slot = slots[old_sz];
     			}
     		}
     
    -		ns_bzero(slot,sizeof(turn_permission_slot));
    +		bzero(slot,sizeof(turn_permission_slot));
     		slot->info.allocated = 1;
     		turn_permission_info *elem = &(slot->info);
     		addr_cpy(&(elem->addr), addr);
    @@ -448,7 +448,7 @@ turn_permission_info* allocation_add_permission(allocation *a, const ioa_addr* a
     	}
     }
     
    -ch_info *ch_map_get(ch_map* map, u16bits chnum, int new_chn)
    +ch_info *ch_map_get(ch_map* map, uint16_t chnum, int new_chn)
     {
     	ch_info *ret = NULL;
     	if(map) {
    @@ -485,9 +485,9 @@ ch_info *ch_map_get(ch_map* map, u16bits chnum, int new_chn)
     
     		if(new_chn) {
     			size_t old_sz_mem = old_sz * sizeof(ch_info*);
    -			a->extra_chns = (ch_info**)turn_realloc(a->extra_chns,old_sz_mem,old_sz_mem + sizeof(ch_info*));
    -			a->extra_chns[old_sz] = (ch_info*)turn_malloc(sizeof(ch_info));
    -			ns_bzero(a->extra_chns[old_sz],sizeof(ch_info));
    +			a->extra_chns = (ch_info**)realloc(a->extra_chns,old_sz_mem + sizeof(ch_info*));
    +			a->extra_chns[old_sz] = (ch_info*)malloc(sizeof(ch_info));
    +			bzero(a->extra_chns[old_sz],sizeof(ch_info));
     			a->extra_sz += 1;
     
     			return a->extra_chns[old_sz];
    @@ -521,11 +521,11 @@ void ch_map_clean(ch_map* map)
     						if(chi->allocated) {
     							ch_info_clean(chi);
     						}
    -						turn_free(chi,sizeof(ch_info));
    +						free(chi);
     						a->extra_chns[i] = NULL;
     					}
     				}
    -				turn_free(a->extra_chns, sizeof(ch_info*)*sz);
    +				free(a->extra_chns);
     				a->extra_chns = NULL;
     			}
     			a->extra_sz = 0;
    @@ -535,16 +535,16 @@ void ch_map_clean(ch_map* map)
     
     ////////////////// TCP connections ///////////////////////////////
     
    -static void set_new_tc_id(u08bits server_id, tcp_connection *tc) {
    +static void set_new_tc_id(uint8_t server_id, tcp_connection *tc) {
     	allocation *a = (allocation*)(tc->owner);
     	ur_map *map = a->tcp_connections;
    -	u32bits newid;
    -	u32bits sid = server_id;
    +	uint32_t newid;
    +	uint32_t sid = server_id;
     	sid = sid<<24;
     	do {
     		newid = 0;
     		while (!newid) {
    -			newid = (u32bits)turn_random();
    +			newid = (uint32_t)turn_random();
     			if(!newid) {
     				continue;
     			}
    @@ -559,7 +559,7 @@ static void set_new_tc_id(u08bits server_id, tcp_connection *tc) {
     	ur_map_put(map, (ur_map_key_type)newid, (ur_map_value_type)tc);
     }
     
    -tcp_connection *create_tcp_connection(u08bits server_id, allocation *a, stun_tid *tid, ioa_addr *peer_addr, int *err_code)
    +tcp_connection *create_tcp_connection(uint8_t server_id, allocation *a, stun_tid *tid, ioa_addr *peer_addr, int *err_code)
     {
     	tcp_connection_list *tcl = &(a->tcs);
     	if(tcl->elems) {
    @@ -574,11 +574,11 @@ tcp_connection *create_tcp_connection(u08bits server_id, allocation *a, stun_tid
     			}
     		}
     	}
    -	tcp_connection *tc = (tcp_connection*)turn_malloc(sizeof(tcp_connection));
    -	ns_bzero(tc,sizeof(tcp_connection));
    +	tcp_connection *tc = (tcp_connection*)malloc(sizeof(tcp_connection));
    +	bzero(tc,sizeof(tcp_connection));
     	addr_cpy(&(tc->peer_addr),peer_addr);
     	if(tid)
    -		ns_bcopy(tid,&(tc->tid),sizeof(stun_tid));
    +		bcopy(tid,&(tc->tid),sizeof(stun_tid));
     	tc->owner = a;
     
     	int found = 0;
    @@ -596,7 +596,7 @@ tcp_connection *create_tcp_connection(u08bits server_id, allocation *a, stun_tid
     
     	if(!found) {
     		size_t old_sz_mem = a->tcs.sz * sizeof(tcp_connection*);
    -		a->tcs.elems = (tcp_connection**)turn_realloc(a->tcs.elems,old_sz_mem,old_sz_mem+sizeof(tcp_connection*));
    +		a->tcs.elems = (tcp_connection**)realloc(a->tcs.elems,old_sz_mem+sizeof(tcp_connection*));
     		a->tcs.elems[a->tcs.sz] = tc;
     		a->tcs.sz += 1;
     		tcl = &(a->tcs);
    @@ -638,7 +638,7 @@ void delete_tcp_connection(tcp_connection *tc)
     		}
     		IOA_CLOSE_SOCKET(tc->client_s);
     		IOA_CLOSE_SOCKET(tc->peer_s);
    -		turn_free(tc,sizeof(tcp_connection));
    +		free(tc);
     	}
     }
     
    @@ -711,7 +711,7 @@ void clear_unsent_buffer(unsent_buffer *ub)
     					ub->bufs[sz] = NULL;
     				}
     			}
    -			turn_free(ub->bufs,sizeof(ioa_network_buffer_handle) * ub->sz);
    +			free(ub->bufs);
     			ub->bufs = NULL;
     		}
     		ub->sz = 0;
    @@ -723,7 +723,7 @@ void add_unsent_buffer(unsent_buffer *ub, ioa_network_buffer_handle nbh)
     	if(!ub || (ub->sz >= MAX_UNSENT_BUFFER_SIZE)) {
     		ioa_network_buffer_delete(NULL, nbh);
     	} else {
    -		ub->bufs = (ioa_network_buffer_handle*)turn_realloc(ub->bufs, sizeof(ioa_network_buffer_handle) * ub->sz, sizeof(ioa_network_buffer_handle) * (ub->sz+1));
    +		ub->bufs = (ioa_network_buffer_handle*)realloc(ub->bufs, sizeof(ioa_network_buffer_handle) * (ub->sz+1));
     		ub->bufs[ub->sz] = nbh;
     		ub->sz +=1;
     	}
    
  • src/server/ns_turn_allocation.h+8 8 modified
    @@ -75,7 +75,7 @@ enum _TC_STATE {
     
     typedef enum _TC_STATE TC_STATE;
     
    -typedef u32bits tcp_connection_id;
    +typedef uint32_t tcp_connection_id;
     
     typedef struct {
     	size_t sz;
    @@ -110,9 +110,9 @@ typedef struct _tcp_connection_list {
     struct _allocation;
     
     typedef struct _ch_info {
    -  u16bits chnum;
    +  uint16_t chnum;
       int allocated;
    -  u16bits port;
    +  uint16_t port;
       ioa_addr peer_addr;
       turn_time_t expiration_time;
       ioa_timer_handle lifetime_ev;
    @@ -135,7 +135,7 @@ typedef struct _ch_map {
     	ch_map_array table[CH_MAP_HASH_SIZE];
     } ch_map;
     
    -ch_info *ch_map_get(ch_map* map, u16bits chnum, int new_chn);
    +ch_info *ch_map_get(ch_map* map, uint16_t chnum, int new_chn);
     void ch_map_clean(ch_map* map);
     
     ////////////////////////////
    @@ -187,7 +187,7 @@ typedef struct _allocation {
     
     //////////// CHANNELS ////////////////////
     
    -u16bits get_turn_channel_number(turn_permission_info* tinfo, ioa_addr *addr);
    +uint16_t get_turn_channel_number(turn_permission_info* tinfo, ioa_addr *addr);
     ch_info *get_turn_channel(turn_permission_info* tinfo, ioa_addr *addr);
     
     void turn_channel_delete(ch_info* chn);
    @@ -206,8 +206,8 @@ turn_permission_info* allocation_get_permission(allocation* a, const ioa_addr *a
     turn_permission_hashtable* allocation_get_turn_permission_hashtable(allocation *a);
     turn_permission_info* allocation_add_permission(allocation *a, const ioa_addr* addr);
     
    -ch_info* allocation_get_new_ch_info(allocation* a, u16bits chnum, ioa_addr* peer_addr);
    -ch_info* allocation_get_ch_info(allocation* a, u16bits chnum);
    +ch_info* allocation_get_new_ch_info(allocation* a, uint16_t chnum, ioa_addr* peer_addr);
    +ch_info* allocation_get_ch_info(allocation* a, uint16_t chnum);
     ch_info* allocation_get_ch_info_by_peer_addr(allocation* a, ioa_addr* peer_addr);
     
     relay_endpoint_session *get_relay_session(allocation *a, int family);
    @@ -220,7 +220,7 @@ tcp_connection *get_and_clean_tcp_connection_by_id(ur_map *map, tcp_connection_i
     tcp_connection *get_tcp_connection_by_id(ur_map *map, tcp_connection_id id);
     tcp_connection *get_tcp_connection_by_peer(allocation *a, ioa_addr *peer_addr);
     int can_accept_tcp_connection_from_peer(allocation *a, ioa_addr *peer_addr, int server_relay);
    -tcp_connection *create_tcp_connection(u08bits server_id, allocation *a, stun_tid *tid, ioa_addr *peer_addr, int *err_code);
    +tcp_connection *create_tcp_connection(uint8_t server_id, allocation *a, stun_tid *tid, ioa_addr *peer_addr, int *err_code);
     void delete_tcp_connection(tcp_connection *tc);
     
     void clear_unsent_buffer(unsent_buffer *ub);
    
  • src/server/ns_turn_ioalib.h+10 9 modified
    @@ -53,7 +53,7 @@ typedef struct _tcp_connection tcp_connection;
     ////////////// Mutexes /////////////////////
     
     struct _turn_mutex {
    -  u32bits data;
    +  uint32_t data;
       void* mutex;
     };
     
    @@ -90,6 +90,7 @@ enum _SOCKET_TYPE {
     	SCTP_SOCKET=132,
     	TLS_SCTP_SOCKET=133,
     	DTLS_SOCKET=250,
    +	TCP_SOCKET_PROXY=253,
     	TENTATIVE_SCTP_SOCKET=254,
     	TENTATIVE_TCP_SOCKET=255
     };
    @@ -172,14 +173,14 @@ const ip_range_list_t* ioa_get_blacklist(ioa_engine_handle e);
      */
     ioa_network_buffer_handle ioa_network_buffer_allocate(ioa_engine_handle e);
     void ioa_network_buffer_header_init(ioa_network_buffer_handle nbh);
    -u08bits *ioa_network_buffer_data(ioa_network_buffer_handle nbh);
    +uint8_t *ioa_network_buffer_data(ioa_network_buffer_handle nbh);
     size_t ioa_network_buffer_get_size(ioa_network_buffer_handle nbh);
     size_t ioa_network_buffer_get_capacity(ioa_network_buffer_handle nbh);
     size_t ioa_network_buffer_get_capacity_udp(void);
     void ioa_network_buffer_set_size(ioa_network_buffer_handle nbh, size_t len);
    -void ioa_network_buffer_add_offset_size(ioa_network_buffer_handle nbh, u16bits offset, u08bits coffset, size_t len);
    -u16bits ioa_network_buffer_get_offset(ioa_network_buffer_handle nbh);
    -u08bits ioa_network_buffer_get_coffset(ioa_network_buffer_handle nbh);
    +void ioa_network_buffer_add_offset_size(ioa_network_buffer_handle nbh, uint16_t offset, uint8_t coffset, size_t len);
    +uint16_t ioa_network_buffer_get_offset(ioa_network_buffer_handle nbh);
    +uint8_t ioa_network_buffer_get_coffset(ioa_network_buffer_handle nbh);
     void ioa_network_buffer_delete(ioa_engine_handle e, ioa_network_buffer_handle nbh);
     
     /*
    @@ -204,7 +205,7 @@ typedef void (*ioa_timer_event_handler)(ioa_engine_handle e, void *ctx);
     
     /* timers */
     
    -ioa_timer_handle set_ioa_timer(ioa_engine_handle e, int secs, int ms, ioa_timer_event_handler cb, void *ctx, int persist, const s08bits *txt);
    +ioa_timer_handle set_ioa_timer(ioa_engine_handle e, int secs, int ms, ioa_timer_event_handler cb, void *ctx, int persist, const char *txt);
     void stop_ioa_timer(ioa_timer_handle th);
     void delete_ioa_timer(ioa_timer_handle th);
     #define IOA_EVENT_DEL(E) do { if(E) { delete_ioa_timer(E); E = NULL; } } while(0)
    @@ -220,14 +221,14 @@ void inc_ioa_socket_ref_counter(ioa_socket_handle s);
      * even_port == +1: reserve and bind rtcp.
      */
     int create_relay_ioa_sockets(ioa_engine_handle e, ioa_socket_handle client_s,
    -				int address_family, u08bits transport,
    +				int address_family, uint8_t transport,
     				int even_port, ioa_socket_handle *rtp_s, ioa_socket_handle *rtcp_s,
    -				u64bits *out_reservation_token, int *err_code, const u08bits **reason,
    +				uint64_t *out_reservation_token, int *err_code, const uint8_t **reason,
     				accept_cb acb, void *acbarg);
     
     ioa_socket_handle  ioa_create_connecting_tcp_relay_socket(ioa_socket_handle s, ioa_addr *peer_addr, connect_cb cb, void *arg);
     
    -int get_ioa_socket_from_reservation(ioa_engine_handle e, u64bits in_reservation_token, ioa_socket_handle *s);
    +int get_ioa_socket_from_reservation(ioa_engine_handle e, uint64_t in_reservation_token, ioa_socket_handle *s);
     
     int get_ioa_socket_address_family(ioa_socket_handle s);
     int is_stream_socket(int st);
    
  • src/server/ns_turn_khash.h+34 34 modified
    @@ -32,7 +32,7 @@
       An example:
     
     #include "khash.h"
    -KHASH_MAP_INIT_INT(32, s08bits)
    +KHASH_MAP_INIT_INT(32, char)
     int main() {
     	int ret, is_missing;
     	khiter_t k;
    @@ -87,16 +87,16 @@ int main() {
     
     #include "ns_turn_defs.h"
     
    -typedef u32bits khint_t;
    +typedef uint32_t khint_t;
     typedef khint_t khiter_t;
     
     typedef struct _str_chunk_t {
    -    const s08bits *str;
    +    const char *str;
         size_t      len;
     } str_chunk_t;
     
     #define __ac_HASH_PRIME_SIZE 32
    -static const u32bits __ac_prime_list[__ac_HASH_PRIME_SIZE] =
    +static const uint32_t __ac_prime_list[__ac_HASH_PRIME_SIZE] =
     {
       0ul,          3ul,          11ul,         23ul,         53ul,
       97ul,         193ul,        389ul,        769ul,        1543ul,
    @@ -120,25 +120,25 @@ static const double __ac_HASH_UPPER = 0.77;
     #define KHASH_INIT(name, khkey_t, khval_t, kh_is_map, __hash_func, __hash_equal) \
     	typedef struct {													\
     		khint_t n_buckets, size, n_occupied, upper_bound;				\
    -		u32bits *flags;	u32bits flags_size;			\
    -		khkey_t *keys; u32bits keys_size;			\
    -		khval_t *vals; u32bits vals_size; 			\
    +		uint32_t *flags;	uint32_t flags_size;			\
    +		khkey_t *keys; uint32_t keys_size;			\
    +		khval_t *vals; uint32_t vals_size; 			\
     	} kh_##name##_t;													\
     	static inline kh_##name##_t *kh_init_##name(void) {					\
    -		return (kh_##name##_t*)turn_calloc(1, sizeof(kh_##name##_t));		\
    +		return (kh_##name##_t*)calloc(1, sizeof(kh_##name##_t));		\
     	}																	\
     	static inline void kh_destroy_##name(kh_##name##_t *h)				\
     	{																	\
     		if (h) {														\
    -		  turn_free(h->keys,h->keys_size); turn_free(h->flags,h->flags_size); \
    -		  turn_free(h->vals, h->vals_size);					\
    -		  turn_free(h, sizeof(kh_##name##_t));			\
    +		  free(h->keys); free(h->flags); \
    +		  free(h->vals);					\
    +		  free(h);			\
     		}											   \
     	}																	\
     	static inline void kh_clear_##name(kh_##name##_t *h)				\
     	{																	\
     		if (h && h->flags) { \
    -			memset(h->flags, 0xaa, ((h->n_buckets>>4) + 1) * sizeof(u32bits)); \
    +			memset(h->flags, 0xaa, ((h->n_buckets>>4) + 1) * sizeof(uint32_t)); \
     			h->size = h->n_occupied = 0;								\
     		}																\
     	}																	\
    @@ -158,23 +158,23 @@ static const double __ac_HASH_UPPER = 0.77;
     	}																	\
     	static inline void kh_resize_##name(kh_##name##_t *h, khint_t new_n_buckets) \
     	{																	\
    -		u32bits *new_flags = 0;		\
    -		u32bits new_flags_size = 0;	\
    +		uint32_t *new_flags = 0;		\
    +		uint32_t new_flags_size = 0;	\
     		khint_t j = 1;													\
     		{																\
     			khint_t t = __ac_HASH_PRIME_SIZE - 1;						\
     			while (__ac_prime_list[t] > new_n_buckets) --t;				\
     			new_n_buckets = __ac_prime_list[t+1];						\
     			if (h->size >= (khint_t)(new_n_buckets * __ac_HASH_UPPER + 0.5)) j = 0;	\
     			else {			\
    -			  new_flags_size = ((new_n_buckets>>4) + 1) * sizeof(u32bits); \
    -			  new_flags = (u32bits*)turn_malloc(new_flags_size);	\
    +			  new_flags_size = ((new_n_buckets>>4) + 1) * sizeof(uint32_t); \
    +			  new_flags = (uint32_t*)malloc(new_flags_size);	\
     			  memset(new_flags, 0xaa, new_flags_size); \
     			  if (h->n_buckets < new_n_buckets) {		\
    -			    h->keys = (khkey_t*)turn_realloc(h->keys, h->keys_size, new_n_buckets * sizeof(khkey_t)); \
    +			    h->keys = (khkey_t*)realloc(h->keys, new_n_buckets * sizeof(khkey_t)); \
     			    h->keys_size = new_n_buckets * sizeof(khkey_t); \
     			    if (kh_is_map)	{			\
    -			      h->vals = (khval_t*)turn_realloc(h->vals, h->vals_size, new_n_buckets * sizeof(khval_t)); \
    +			      h->vals = (khval_t*)realloc(h->vals, new_n_buckets * sizeof(khval_t)); \
     			      h->vals_size = new_n_buckets * sizeof(khval_t); \
     			    } \
     			  }						\
    @@ -210,14 +210,14 @@ static const double __ac_HASH_UPPER = 0.77;
     				}														\
     			}															\
     			if (h->n_buckets > new_n_buckets) {							\
    -			  h->keys = (khkey_t*)turn_realloc(h->keys, h->keys_size, new_n_buckets * sizeof(khkey_t)); \
    +			  h->keys = (khkey_t*)realloc(h->keys, new_n_buckets * sizeof(khkey_t)); \
     			  h->keys_size = new_n_buckets * sizeof(khkey_t); \
     			  if (kh_is_map)	{			\
    -			    h->vals = (khval_t*)turn_realloc(h->vals, h->vals_size, new_n_buckets * sizeof(khval_t)); \
    +			    h->vals = (khval_t*)realloc(h->vals, new_n_buckets * sizeof(khval_t)); \
     			    h->vals_size = new_n_buckets * sizeof(khval_t); \
     			  } \
     			}															\
    -			turn_free(h->flags, h->flags_size);				\
    +			free(h->flags);				\
     			h->flags = new_flags; \
                             h->flags_size = new_flags_size;						\
     			h->n_buckets = new_n_buckets;								\
    @@ -273,20 +273,20 @@ static const double __ac_HASH_UPPER = 0.77;
     
     /* --- BEGIN OF HASH FUNCTIONS --- */
     
    -#define kh_int_hash_func(key) (u32bits)((key<<3) + nswap32(key>>7))
    +#define kh_int_hash_func(key) (uint32_t)((key<<3) + nswap32(key>>7))
     #define kh_int_hash_equal(a, b) (a == b)
    -#define kh_int64_hash_func(key) (u32bits)((key)>>33^(key)^(key)<<11)
    +#define kh_int64_hash_func(key) (uint32_t)((key)>>33^(key)^(key)<<11)
     #define kh_int64_hash_equal(a, b) (a == b)
     
    -static inline khint_t __ac_X31_hash_string(const s08bits *s)
    +static inline khint_t __ac_X31_hash_string(const char *s)
     {
     	khint_t h = *s;
     	if (h)
     		for (++s; *s; ++s)
     			h = (h << 5) - h + *s;
     	return h;
     }
    -static inline khint_t __ac_X31_hash_cstring(const s08bits *s)
    +static inline khint_t __ac_X31_hash_cstring(const char *s)
     {
     	khint_t h = tolower((int)*s);
     	if (h)
    @@ -349,39 +349,39 @@ static inline khint_t __ac_X31_hash_ncstring(const str_chunk_t *s)
     /* More convenient interfaces */
     
     #define KHASH_SET_INIT_INT(name)										\
    -	KHASH_INIT(name, u32bits, s08bits, 0, kh_int_hash_func, kh_int_hash_equal)
    +	KHASH_INIT(name, uint32_t, char, 0, kh_int_hash_func, kh_int_hash_equal)
     
     #define KHASH_MAP_INIT_INT(name, khval_t)								\
    -	KHASH_INIT(name, u32bits, khval_t, 1, kh_int_hash_func, kh_int_hash_equal)
    +	KHASH_INIT(name, uint32_t, khval_t, 1, kh_int_hash_func, kh_int_hash_equal)
     
     #define KHASH_SET_INIT_INT64(name)										\
    -	KHASH_INIT(name, u64bits, s08bits, 0, kh_int64_hash_func, kh_int64_hash_equal)
    +	KHASH_INIT(name, uint64_t, char, 0, kh_int64_hash_func, kh_int64_hash_equal)
     
     #define KHASH_MAP_INIT_INT64(name, khval_t)								\
    -	KHASH_INIT(name, u64bits, khval_t, 1, kh_int64_hash_func, kh_int64_hash_equal)
    +	KHASH_INIT(name, uint64_t, khval_t, 1, kh_int64_hash_func, kh_int64_hash_equal)
     
    -typedef const s08bits *kh_cstr_t;
    +typedef const char *kh_cstr_t;
     typedef const str_chunk_t *kh_ncstr_t;
     #define KHASH_SET_INIT_STR(name)										\
    -	KHASH_INIT(name, kh_cstr_t, s08bits, 0, kh_str_hash_func, kh_str_hash_equal)
    +	KHASH_INIT(name, kh_cstr_t, char, 0, kh_str_hash_func, kh_str_hash_equal)
     
     #define KHASH_MAP_INIT_STR(name, khval_t)								\
     	KHASH_INIT(name, kh_cstr_t, khval_t, 1, kh_str_hash_func, kh_str_hash_equal)
     
     #define KHASH_SET_INIT_CSTR(name)										\
    -	KHASH_INIT(name, kh_cstr_t, s08bits, 0, kh_cstr_hash_func, kh_cstr_hash_equal)
    +	KHASH_INIT(name, kh_cstr_t, char, 0, kh_cstr_hash_func, kh_cstr_hash_equal)
     
     #define KHASH_MAP_INIT_CSTR(name, khval_t)								\
     	KHASH_INIT(name, kh_cstr_t, khval_t, 1, kh_cstr_hash_func, kh_cstr_hash_equal)
     
     #define KHASH_SET_INIT_NSTR(name)										\
    -	KHASH_INIT(name, kh_ncstr_t, s08bits, 0, kh_nstr_hash_func, kh_nstr_hash_equal)
    +	KHASH_INIT(name, kh_ncstr_t, char, 0, kh_nstr_hash_func, kh_nstr_hash_equal)
     
     #define KHASH_MAP_INIT_NSTR(name, khval_t)								\
     	KHASH_INIT(name, kh_ncstr_t, khval_t, 1, kh_nstr_hash_func, kh_nstr_hash_equal)
     
     #define KHASH_SET_INIT_NCSTR(name)										\
    -	KHASH_INIT(name, kh_ncstr_t, s08bits, 0, kh_ncstr_hash_func, kh_ncstr_hash_equal)
    +	KHASH_INIT(name, kh_ncstr_t, char, 0, kh_ncstr_hash_func, kh_ncstr_hash_equal)
     
     #define KHASH_MAP_INIT_NCSTR(name, khval_t)								\
     	KHASH_INIT(name, kh_ncstr_t, khval_t, 1, kh_ncstr_hash_func, kh_ncstr_hash_equal)
    
  • src/server/ns_turn_maps.c+41 41 modified
    @@ -36,11 +36,11 @@
     
     KHASH_MAP_INIT_INT64(3, ur_map_value_type)
     
    -#define MAGIC_HASH ((u64bits)(0x90ABCDEFL))
    +#define MAGIC_HASH ((uint64_t)(0x90ABCDEFL))
     
     struct _ur_map {
       khash_t(3) *h;
    -  u64bits magic;
    +  uint64_t magic;
       TURN_MUTEX_DECLARE(mutex)
     };
     
    @@ -59,9 +59,9 @@ static int ur_map_init(ur_map* map) {
     #define ur_map_valid(map) ((map) && ((map)->h) && ((map)->magic==MAGIC_HASH))
     
     ur_map* ur_map_create() {
    -  ur_map *map=(ur_map*)turn_malloc(sizeof(ur_map));
    +  ur_map *map=(ur_map*)malloc(sizeof(ur_map));
       if(ur_map_init(map)<0) {
    -    turn_free(map,sizeof(ur_map));
    +    free(map);
         return NULL;
       }
       return map;
    @@ -173,7 +173,7 @@ void ur_map_free(ur_map** map) {
         (*map)->h=NULL;
         (*map)->magic=0;
         TURN_MUTEX_DESTROY(&((*map)->mutex));
    -    turn_free(*map,sizeof(ur_map));
    +    free(*map);
         *map=NULL;
       }
     }
    @@ -239,7 +239,7 @@ int ur_map_unlock(const ur_map* map) {
     void lm_map_init(lm_map *map)
     {
     	if(map) {
    -		ns_bzero(map,sizeof(lm_map));
    +		bzero(map,sizeof(lm_map));
     	}
     }
     
    @@ -292,11 +292,11 @@ int lm_map_put(lm_map* map, ur_map_key_type key, ur_map_value_type value)
     					}
     				} else {
     					if(!(*keyp)) {
    -						a->extra_keys[i] = (ur_map_key_type*)turn_malloc(sizeof(ur_map_key_type));
    +						a->extra_keys[i] = (ur_map_key_type*)malloc(sizeof(ur_map_key_type));
     						keyp = a->extra_keys[i];
     					}
     					if(!(*valuep)) {
    -						a->extra_values[i] = (ur_map_value_type*)turn_malloc(sizeof(ur_map_value_type));
    +						a->extra_values[i] = (ur_map_value_type*)malloc(sizeof(ur_map_value_type));
     						valuep = a->extra_values[i];
     					}
     					*keyp = key;
    @@ -308,13 +308,13 @@ int lm_map_put(lm_map* map, ur_map_key_type key, ur_map_value_type value)
     
     		size_t old_sz = esz;
     		size_t old_sz_mem = esz * sizeof(ur_map_key_type*);
    -		a->extra_keys = (ur_map_key_type**)turn_realloc(a->extra_keys,old_sz_mem,old_sz_mem + sizeof(ur_map_key_type*));
    -		a->extra_keys[old_sz] = (ur_map_key_type*)turn_malloc(sizeof(ur_map_key_type));
    +		a->extra_keys = (ur_map_key_type**)realloc(a->extra_keys,old_sz_mem + sizeof(ur_map_key_type*));
    +		a->extra_keys[old_sz] = (ur_map_key_type*)malloc(sizeof(ur_map_key_type));
     		*(a->extra_keys[old_sz]) = key;
     
     		old_sz_mem = esz * sizeof(ur_map_value_type*);
    -		a->extra_values = (ur_map_value_type**)turn_realloc(a->extra_values,old_sz_mem,old_sz_mem + sizeof(ur_map_value_type*));
    -		a->extra_values[old_sz] = (ur_map_value_type*)turn_malloc(sizeof(ur_map_value_type));
    +		a->extra_values = (ur_map_value_type**)realloc(a->extra_values,old_sz_mem + sizeof(ur_map_value_type*));
    +		a->extra_values[old_sz] = (ur_map_value_type*)malloc(sizeof(ur_map_value_type));
     		*(a->extra_values[old_sz]) = value;
     
     		a->extra_sz += 1;
    @@ -444,21 +444,21 @@ void lm_map_clean(lm_map* map)
     					ur_map_key_type *keyp = a->extra_keys[i];
     					if(keyp) {
     						*keyp = 0;
    -						turn_free(keyp,sizeof(ur_map_key_type));
    +						free(keyp);
     					}
     				}
    -				turn_free(a->extra_keys,esz * sizeof(ur_map_key_type));
    +				free(a->extra_keys);
     				a->extra_keys = NULL;
     			}
     			if(a->extra_values) {
     				for(i=0;i<esz;++i) {
     					ur_map_value_type *valuep = a->extra_values[i];
     					if(valuep) {
     						*valuep = 0;
    -						turn_free(valuep,sizeof(ur_map_value_type));
    +						free(valuep);
     					}
     				}
    -				turn_free(a->extra_values,esz * sizeof(ur_map_value_type));
    +				free(a->extra_values);
     				a->extra_values = NULL;
     			}
     		}
    @@ -588,9 +588,9 @@ int lm_map_foreach_arg(lm_map* map, foreachcb_arg_type func, void* arg)
     static void addr_list_free(addr_list_header* slh) {
       if(slh) {
         if(slh->extra_list) {
    -      turn_free(slh->extra_list,sizeof(addr_elem)*(slh->extra_sz));
    +      free(slh->extra_list);
         }
    -    ns_bzero(slh,sizeof(addr_list_header));
    +    bzero(slh,sizeof(addr_list_header));
       }
     }
         
    @@ -620,7 +620,7 @@ static void addr_list_add(addr_list_header* slh, const ioa_addr* key,  ur_addr_m
       if(!elem) {
     	  size_t old_sz = slh->extra_sz;
     	  size_t old_sz_mem = old_sz * sizeof(addr_elem);
    -	  slh->extra_list = (addr_elem*)turn_realloc(slh->extra_list, old_sz_mem, old_sz_mem + sizeof(addr_elem));
    +	  slh->extra_list = (addr_elem*)realloc(slh->extra_list, old_sz_mem + sizeof(addr_elem));
     	  elem = &(slh->extra_list[old_sz]);
     	  slh->extra_sz += 1;
       }
    @@ -802,18 +802,18 @@ static const addr_elem* addr_list_get_const(const addr_list_header* slh, const i
     
     void ur_addr_map_init(ur_addr_map* map) {
       if(map) {
    -    ns_bzero(map,sizeof(ur_addr_map));
    +    bzero(map,sizeof(ur_addr_map));
         map->magic=MAGIC_HASH;
       }
     }
     
     void ur_addr_map_clean(ur_addr_map* map) {
       if(map && ur_addr_map_valid(map)) {
    -    u32bits i=0;
    +    uint32_t i=0;
         for(i=0;i<ADDR_MAP_SIZE;i++) {
           addr_list_free(&(map->lists[i]));
         }
    -    ns_bzero(map,sizeof(ur_addr_map));
    +    bzero(map,sizeof(ur_addr_map));
       }
     }
     
    @@ -895,7 +895,7 @@ void ur_addr_map_foreach(ur_addr_map* map, ur_addr_map_func func) {
     
       if(ur_addr_map_valid(map)) {
     
    -    u32bits i=0;
    +    uint32_t i=0;
         for(i=0;i<ADDR_MAP_SIZE;i++) {
           
           addr_list_header* slh = &(map->lists[i]);
    @@ -910,7 +910,7 @@ size_t ur_addr_map_num_elements(const ur_addr_map* map) {
     	size_t ret = 0;
     
     	if (ur_addr_map_valid(map)) {
    -		u32bits i = 0;
    +		uint32_t i = 0;
     		for (i = 0; i < ADDR_MAP_SIZE; i++) {
     
     			const addr_list_header* slh = &(map->lists[i]);
    @@ -927,7 +927,7 @@ size_t ur_addr_map_size(const ur_addr_map* map) {
     	size_t ret = 0;
     
     	if (ur_addr_map_valid(map)) {
    -		u32bits i = 0;
    +		uint32_t i = 0;
     		for (i = 0; i < ADDR_MAP_SIZE; i++) {
     
     			const addr_list_header* slh = &(map->lists[i]);
    @@ -948,7 +948,7 @@ typedef struct _string_list {
     typedef struct _string_elem {
       string_list list;
       ur_string_map_key_type key;
    -  u32bits key_size;
    +  uint32_t key_size;
       ur_string_map_value_type value;
     } string_elem;
     
    @@ -967,10 +967,10 @@ static void string_list_free(string_list_header* slh, ur_string_map_func del_val
         while(list) {
           string_elem *elem=(string_elem*)list;
           string_list* tail=elem->list.next;
    -      if(elem->key) turn_free(elem->key,elem->key_size);
    +      if(elem->key) free(elem->key);
           if(del_value_func && elem->value)
     	      del_value_func(elem->value);
    -      turn_free(elem,sizeof(string_elem));
    +      free(elem);
           list=tail;
         }
         slh->list=NULL;
    @@ -979,11 +979,11 @@ static void string_list_free(string_list_header* slh, ur_string_map_func del_val
     
     static string_list* string_list_add(string_list* sl, const ur_string_map_key_type key, ur_string_map_value_type value) {
       if(!key) return sl;
    -  string_elem *elem=(string_elem*)turn_malloc(sizeof(string_elem));
    +  string_elem *elem=(string_elem*)malloc(sizeof(string_elem));
       elem->list.next=sl;
       elem->key_size = strlen(key)+1;
    -  elem->key=(s08bits*)turn_malloc(elem->key_size);
    -  ns_bcopy(key,elem->key,elem->key_size);
    +  elem->key=(char*)malloc(elem->key_size);
    +  bcopy(key,elem->key,elem->key_size);
       elem->value=value;
       return &(elem->list);
     }
    @@ -994,10 +994,10 @@ static string_list* string_list_remove(string_list* sl, const ur_string_map_key_
       string_elem *elem=(string_elem*)sl;
       string_list* tail=elem->list.next;
       if(strcmp(elem->key,key)==0) {
    -    turn_free(elem->key,elem->key_size);
    +    free(elem->key);
         if(del_value_func)
     	    del_value_func(elem->value);
    -    turn_free(elem,sizeof(string_elem));
    +    free(elem);
         if(counter) *counter+=1;
         sl=string_list_remove(tail, key, del_value_func, counter);
       } else {
    @@ -1024,16 +1024,16 @@ static string_elem* string_list_get(string_list* sl, const ur_string_map_key_typ
     
     struct _ur_string_map {
       string_list_header lists[STRING_MAP_SIZE];
    -  u64bits magic;
    +  uint64_t magic;
       ur_string_map_func del_value_func;
       TURN_MUTEX_DECLARE(mutex)
     };
     
    -static u32bits string_hash(const ur_string_map_key_type key) {
    +static uint32_t string_hash(const ur_string_map_key_type key) {
     
    -  u08bits *str=(u08bits*)key;
    +  uint8_t *str=(uint8_t*)key;
     
    -  u32bits hash = 0;
    +  uint32_t hash = 0;
       int c = 0;
     
       while ((c = *str++))
    @@ -1052,7 +1052,7 @@ static string_list_header* get_string_list_header(ur_string_map *map, const ur_s
     
     static int ur_string_map_init(ur_string_map* map) {
       if(map) {
    -    ns_bzero(map,sizeof(ur_string_map));
    +    bzero(map,sizeof(ur_string_map));
         map->magic=MAGIC_HASH;
     
         TURN_MUTEX_INIT_RECURSIVE(&(map->mutex));
    @@ -1067,9 +1067,9 @@ static int ur_string_map_valid(const ur_string_map *map) {
     }
     
     ur_string_map* ur_string_map_create(ur_string_map_func del_value_func) {
    -  ur_string_map *map=(ur_string_map*)turn_malloc(sizeof(ur_string_map));
    +  ur_string_map *map=(ur_string_map*)malloc(sizeof(ur_string_map));
       if(ur_string_map_init(map)<0) {
    -    turn_free(map,sizeof(ur_string_map));
    +    free(map);
         return NULL;
       }
       map->del_value_func = del_value_func;
    @@ -1166,7 +1166,7 @@ void ur_string_map_free(ur_string_map** map) {
         }
         (*map)->magic=0;
         TURN_MUTEX_DESTROY(&((*map)->mutex));
    -    turn_free(*map,sizeof(ur_string_map));
    +    free(*map);
         *map=NULL;
       }
     }
    
  • src/server/ns_turn_maps.h+3 3 modified
    @@ -44,7 +44,7 @@ typedef struct _ur_map ur_map;
     
     //////////////// Common Definitions //////
     
    -typedef u64bits ur_map_key_type;
    +typedef uint64_t ur_map_key_type;
     typedef unsigned long ur_map_value_type;
     
     typedef void (*ur_map_del_func)(ur_map_value_type);
    @@ -176,7 +176,7 @@ typedef struct _addr_list_header {
     
     struct _ur_addr_map {
       addr_list_header lists[ADDR_MAP_SIZE];
    -  u64bits magic;
    +  uint64_t magic;
     };
     
     struct _ur_addr_map;
    @@ -221,7 +221,7 @@ size_t ur_addr_map_size(const ur_addr_map* map);
     
     //////////////// UR STRING MAP //////////////////
     
    -typedef s08bits* ur_string_map_key_type;
    +typedef char* ur_string_map_key_type;
     typedef void* ur_string_map_value_type;
     struct _ur_string_map;
     typedef struct _ur_string_map ur_string_map;
    
  • src/server/ns_turn_maps_rtcp.c+10 10 modified
    @@ -42,7 +42,7 @@
     ////////////////////////////////////////////
     
     struct _rtcp_map {
    -  u32bits magic;
    +  uint32_t magic;
       ur_map *map;
       ioa_timer_handle timer_ev;
       TURN_MUTEX_DECLARE(mutex)
    @@ -90,15 +90,15 @@ static void rtcp_alloc_free(ur_map_value_type value)
     	rtcp_alloc_type *at = (rtcp_alloc_type *)value;
     	if (at) {
     		IOA_CLOSE_SOCKET(at->s);
    -		turn_free(at,sizeof(rtcp_alloc_type));
    +		free(at);
     	}
     }
     
     static void rtcp_alloc_free_savefd(ur_map_value_type value)
     {
     	rtcp_alloc_type *at = (rtcp_alloc_type *) value;
     	if (at) {
    -		turn_free(at,sizeof(rtcp_alloc_type));
    +		free(at);
     	}
     }
     
    @@ -177,10 +177,10 @@ static int rtcp_map_init(rtcp_map* map, ioa_engine_handle e) {
     }
     
     rtcp_map* rtcp_map_create(ioa_engine_handle e) {
    -  rtcp_map *map=(rtcp_map*)turn_malloc(sizeof(rtcp_map));
    -  ns_bzero(map,sizeof(rtcp_map));
    +  rtcp_map *map=(rtcp_map*)malloc(sizeof(rtcp_map));
    +  bzero(map,sizeof(rtcp_map));
       if(rtcp_map_init(map,e)<0) {
    -    turn_free(map,sizeof(rtcp_map));
    +    free(map);
         return NULL;
       }
       return map;
    @@ -194,17 +194,17 @@ rtcp_map* rtcp_map_create(ioa_engine_handle e) {
     int rtcp_map_put(rtcp_map* map, rtcp_token_type token, ioa_socket_handle s) {
       if(!rtcp_map_valid(map)) return -1;
       else {
    -    rtcp_alloc_type *value=(rtcp_alloc_type*)turn_malloc(sizeof(rtcp_alloc_type));
    +    rtcp_alloc_type *value=(rtcp_alloc_type*)malloc(sizeof(rtcp_alloc_type));
         if(!value) return -1;
    -    ns_bzero(value,sizeof(rtcp_alloc_type));
    +    bzero(value,sizeof(rtcp_alloc_type));
         value->s=s;
         value->t=turn_time() + RTCP_TIMEOUT;
         value->token=token;
         TURN_MUTEX_LOCK(&map->mutex);
         int ret = ur_map_put(map->map,token,(ur_map_value_type)value);
         //TURN_LOG_FUNC(TURN_LOG_LEVEL_INFO,"%s: 111.111: ret=%d, token=%llu\n",__FUNCTION__,ret,token);
         TURN_MUTEX_UNLOCK(&map->mutex);
    -    if(ret<0) turn_free(value,sizeof(rtcp_alloc_type));
    +    if(ret<0) free(value);
         return ret;
       }
     }
    @@ -241,7 +241,7 @@ void rtcp_map_free(rtcp_map** map) {
         (*map)->magic=0;
         TURN_MUTEX_UNLOCK(&((*map)->mutex));
         TURN_MUTEX_DESTROY(&((*map)->mutex));
    -    turn_free(*map,sizeof(rtcp_map));
    +    free(*map);
         *map=NULL;
       }
     }
    
  • src/server/ns_turn_server.c+0 0 modified
  • src/server/ns_turn_server.h+8 8 modified
  • src/server/ns_turn_session.h+41 23 modified
  • turndb/schema.stats.redis+8 2 modified

Vulnerability mechanics

Generated by null/stub on May 9, 2026. Inputs: CWE entries + fix-commit diffs from this CVE's patches. Citations validated against bundle.

References

9

News mentions

0

No linked articles in our index yet.