From 025ed2a17c7f5865d3d206a976d30ea930bf4036 Mon Sep 17 00:00:00 2001 From: Nick Knight Date: Tue, 13 Dec 2022 10:39:16 +0000 Subject: [PATCH 1/6] parse arg before add --- entrypoint.sh | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/entrypoint.sh b/entrypoint.sh index cd6ab79dc8..810dc62fca 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -54,7 +54,9 @@ if [ "$1" = 'drachtio' ]; then ;; *) - MYARGS+=($1) + thisarg="${1//PUBLIC_IP/"$PUBLIC_IP"}" + thisarg="${thisarg//LOCAL_IP/"$LOCAL_IP"}" + MYARGS+=($thisarg) ;; esac From 7d1540e348a12ccc0acf3e396dc0c881ff39c589 Mon Sep 17 00:00:00 2001 From: Nick Knight Date: Mon, 2 Oct 2023 14:56:47 +0100 Subject: [PATCH 2/6] Add local ip by route detection --- Dockerfile | 2 +- entrypoint.sh | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 389da56012..fdf0329629 100644 --- a/Dockerfile +++ b/Dockerfile @@ -2,7 +2,7 @@ FROM debian:bullseye-slim RUN apt-get update \ && apt-get -y --quiet --force-yes upgrade \ - && apt-get install -y --no-install-recommends ca-certificates gcc g++ make build-essential cmake git autoconf automake curl libtool libtool-bin libssl-dev libcurl4-openssl-dev zlib1g-dev libgoogle-perftools-dev \ + && apt-get install -y --no-install-recommends ca-certificates gcc g++ make build-essential cmake git autoconf automake curl libtool libtool-bin libssl-dev libcurl4-openssl-dev zlib1g-dev libgoogle-perftools-dev iproute2 \ && git clone --depth=50 --branch=main https://github.com/drachtio/drachtio-server.git /usr/local/src/drachtio-server \ && cd /usr/local/src/drachtio-server \ && git submodule update --init --recursive \ diff --git a/entrypoint.sh b/entrypoint.sh index 810dc62fca..c836d55569 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -29,6 +29,11 @@ case $CLOUD in ;; esac +if [ -f "/proc/1/cgroup" ]; then + # Docker container + LOCAL_IP=$(ip route get 1.1.1.1 | grep -oP 'src \K\S+') +fi + if [ "$1" = 'drachtio' ]; then shift From a4597c8fe57a771a820862227e9895a8015df5d5 Mon Sep 17 00:00:00 2001 From: Nick Knight Date: Wed, 29 Nov 2023 09:17:36 +0000 Subject: [PATCH 3/6] detect tcp connection and check outgoing transport --- src/sip-dialog-controller.cpp | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/sip-dialog-controller.cpp b/src/sip-dialog-controller.cpp index 97f1ad506a..f635541d66 100644 --- a/src/sip-dialog-controller.cpp +++ b/src/sip-dialog-controller.cpp @@ -462,7 +462,17 @@ namespace drachtio { string port = tpn->tpn_port ; string proto = tpn->tpn_proto ; - contact = ""; + if( "tcp" == proto ) { + pSelectedTransport = SipTransport::findAppropriateTransport( useOutboundProxy ? sipOutboundProxy.c_str() : requestUri.c_str()) ; + if (pSelectedTransport) { + pSelectedTransport->getDescription( desc ) ; + pSelectedTransport->getContactUri( contact, true ) ; + contact = "<" + contact + ">" ; + DR_LOG(log_debug) << "SipDialogController::doSendRequestOutsideDialog - modifying contact " << std::hex << (void*)tp << ": " << desc << " for request-uri " << requestUri << " to " << contact ; + } + } else { + contact = ""; + } } } if( NULL == tp ) { From 9b5b0b71ce2861fd8f4665cf50c8837df335744b Mon Sep 17 00:00:00 2001 From: Nick Knight Date: Mon, 11 Dec 2023 10:05:15 +0000 Subject: [PATCH 4/6] revert Dockerfile --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index fdf0329629..389da56012 100644 --- a/Dockerfile +++ b/Dockerfile @@ -2,7 +2,7 @@ FROM debian:bullseye-slim RUN apt-get update \ && apt-get -y --quiet --force-yes upgrade \ - && apt-get install -y --no-install-recommends ca-certificates gcc g++ make build-essential cmake git autoconf automake curl libtool libtool-bin libssl-dev libcurl4-openssl-dev zlib1g-dev libgoogle-perftools-dev iproute2 \ + && apt-get install -y --no-install-recommends ca-certificates gcc g++ make build-essential cmake git autoconf automake curl libtool libtool-bin libssl-dev libcurl4-openssl-dev zlib1g-dev libgoogle-perftools-dev \ && git clone --depth=50 --branch=main https://github.com/drachtio/drachtio-server.git /usr/local/src/drachtio-server \ && cd /usr/local/src/drachtio-server \ && git submodule update --init --recursive \ From 50ad4d85725df1d5f88a5c05336e6132cc5fac15 Mon Sep 17 00:00:00 2001 From: Nick Knight Date: Mon, 11 Dec 2023 10:05:52 +0000 Subject: [PATCH 5/6] revert entrypoint.sh --- entrypoint.sh | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/entrypoint.sh b/entrypoint.sh index 0ff6617a15..823728af57 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -33,11 +33,6 @@ case $CLOUD in ;; esac -if [ -f "/proc/1/cgroup" ]; then - # Docker container - LOCAL_IP=$(ip route get 1.1.1.1 | grep -oP 'src \K\S+') -fi - if [ "$1" = 'drachtio' ]; then shift @@ -63,9 +58,7 @@ if [ "$1" = 'drachtio' ]; then ;; *) - thisarg="${1//PUBLIC_IP/"$PUBLIC_IP"}" - thisarg="${thisarg//LOCAL_IP/"$LOCAL_IP"}" - MYARGS+=($thisarg) + MYARGS+=($1) ;; esac From 3846b98aa1d5a3b3f3d94139e7098820f23aee25 Mon Sep 17 00:00:00 2001 From: Nick Knight Date: Mon, 11 Dec 2023 10:21:37 +0000 Subject: [PATCH 6/6] Update sip-dialog-controller.cpp --- src/sip-dialog-controller.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/sip-dialog-controller.cpp b/src/sip-dialog-controller.cpp index f635541d66..738738bfaf 100644 --- a/src/sip-dialog-controller.cpp +++ b/src/sip-dialog-controller.cpp @@ -462,6 +462,7 @@ namespace drachtio { string port = tpn->tpn_port ; string proto = tpn->tpn_proto ; + contact = ""; if( "tcp" == proto ) { pSelectedTransport = SipTransport::findAppropriateTransport( useOutboundProxy ? sipOutboundProxy.c_str() : requestUri.c_str()) ; if (pSelectedTransport) { @@ -470,8 +471,6 @@ namespace drachtio { contact = "<" + contact + ">" ; DR_LOG(log_debug) << "SipDialogController::doSendRequestOutsideDialog - modifying contact " << std::hex << (void*)tp << ": " << desc << " for request-uri " << requestUri << " to " << contact ; } - } else { - contact = ""; } } }