diff --git a/Dockerfile b/Dockerfile index df46570..d47d19e 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,16 +1,25 @@ -FROM debian:stretch +FROM debian:bullseye-slim RUN apt-get update \ && apt-get -y --quiet --force-yes upgrade curl iproute2 \ - && apt-get install -y --no-install-recommends ca-certificates gcc g++ make build-essential git iptables-dev libavfilter-dev \ - libevent-dev libpcap-dev libxmlrpc-core-c3-dev markdown \ + && apt-get install -y --no-install-recommends ca-certificates gcc g++ make cmake build-essential git iptables-dev libavfilter-dev \ + libevent-dev libpcap-dev libxmlrpc-core-c3-dev markdown \ libjson-glib-dev default-libmysqlclient-dev libhiredis-dev libssl-dev \ - libcurl4-openssl-dev libavcodec-extra gperf libspandsp-dev libwebsockets-dev\ + libcurl4-openssl-dev libavcodec-extra gperf libspandsp-dev \ && cd /usr/local/src \ - && git clone https://github.com/sipwise/rtpengine.git \ + && git clone https://github.com/BelledonneCommunications/bcg729.git \ + && cd bcg729 \ + && echo "building bcg729" \ + && cmake . -DCMAKE_INSTALL_PREFIX=/usr && make && make install \ + && cd /usr/local/src \ + && git clone https://github.com/warmcat/libwebsockets.git -b v3.2.3 \ + && cd /usr/local/src/libwebsockets \ + && mkdir -p build && cd build && cmake .. -DCMAKE_INSTALL_PREFIX=/usr -DCMAKE_BUILD_TYPE=RelWithDebInfo && make && make install \ + && git clone https://github.com/sipwise/rtpengine.git -b mr11.1.1.1 \ && cd rtpengine/daemon \ - && make && make install \ - && cp /usr/local/src/rtpengine/daemon/rtpengine /usr/local/bin/rtpengine \ + && make with_transcoding=yes \ + && find . -name rtpengine \ + && cp rtpengine /usr/local/bin/rtpengine \ && rm -Rf /usr/local/src/rtpengine \ && apt-get purge -y --quiet --force-yes --auto-remove \ ca-certificates gcc g++ make build-essential git markdown \ @@ -23,12 +32,10 @@ RUN apt-get update \ VOLUME ["/tmp"] -EXPOSE 23000-32768/udp 22222/udp +EXPOSE 40000-60000/udp 22222/udp COPY ./entrypoint.sh /entrypoint.sh -COPY ./rtpengine.conf /etc - ENTRYPOINT ["/entrypoint.sh"] CMD ["rtpengine"] diff --git a/LICENSE b/LICENSE index 96a7461..cee71aa 100644 --- a/LICENSE +++ b/LICENSE @@ -1,6 +1,6 @@ MIT License -Copyright (c) 2017 Dave Horton +Copyright (c) 2017-2022 Dave Horton Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/entrypoint.sh b/entrypoint.sh index 9a4c2cb..d21b2e5 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -7,34 +7,68 @@ case $CLOUD in gcp) LOCAL_IP=$(curl -s -H "Metadata-Flavor: Google" http://metadata.google.internal/computeMetadata/v1/instance/network-interfaces/0/ip) PUBLIC_IP=$(curl -s -H "Metadata-Flavor: Google" http://metadata/computeMetadata/v1/instance/network-interfaces/0/access-configs/0/external-ip) + PRIVATE_INTERFACE="private/${LOCAL_IP}" + PUBLIC_INTERFACE="public/${LOCAL_IP}!${PUBLIC_IP}" ;; aws) - LOCAL_IP=$(curl -s http://169.254.169.254/latest/meta-data/local-ipv4) - PUBLIC_IP=$(curl -s http://169.254.169.254/latest/meta-data/public-ipv4) + if [ -z "$IMDSv2" ]; then + LOCAL_IP=$(curl -s http://169.254.169.254/latest/meta-data/local-ipv4) + PUBLIC_IP=$(curl -s http://169.254.169.254/latest/meta-data/public-ipv4) + else + LOCAL_IP=$(TOKEN=`curl -s -X PUT "http://169.254.169.254/latest/api/token" -H "X-aws-ec2-metadata-token-ttl-seconds: 21600"` && curl -s -H "X-aws-ec2-metadata-token: $TOKEN" http://169.254.169.254/latest/meta-data/local-ipv4) + PUBLIC_IP=$(TOKEN=`curl -s -X PUT "http://169.254.169.254/latest/api/token" -H "X-aws-ec2-metadata-token-ttl-seconds: 21600"` && curl -s -H "X-aws-ec2-metadata-token: $TOKEN" http://169.254.169.254/latest/meta-data/public-ipv4) + fi + PRIVATE_INTERFACE="private/${LOCAL_IP}" + PUBLIC_INTERFACE="public/${LOCAL_IP}!${PUBLIC_IP}" ;; digitalocean) LOCAL_IP=$(curl -s http://169.254.169.254/metadata/v1/interfaces/private/0/ipv4/address) PUBLIC_IP=$(curl -s http://169.254.169.254/metadata/v1/interfaces/public/0/ipv4/address) + PRIVATE_INTERFACE="private/${LOCAL_IP}" + PUBLIC_INTERFACE="public/${PUBLIC_IP}" ;; azure) LOCAL_IP=$(curl -H Metadata:true "http://169.254.169.254/metadata/instance/network/interface/0/ipv4/ipAddress/0/privateIpAddress?api-version=2017-08-01&format=text") PUBLIC_IP=$(curl -H Metadata:true "http://169.254.169.254/metadata/instance/network/interface/0/ipv4/ipAddress/0/publicIpAddress?api-version=2017-08-01&format=text") + PRIVATE_INTERFACE="private/${LOCAL_IP}" + PUBLIC_INTERFACE="public/${LOCAL_IP}!${PUBLIC_IP}" ;; *) ;; esac -if [ -n "$PUBLIC_IP" ]; then - MY_IP="$LOCAL_IP"!"$PUBLIC_IP" -else - MY_IP=`ip addr | grep 'state UP' -A2 | tail -n1 | awk '{print $2}' | cut -f1 -d'/'` +if [ -z "$PUBLIC_IP" ]; then + LOCAL_IP=`ip addr | grep 'state UP' -A2 | tail -n1 | awk '{print $2}' | cut -f1 -d'/'` + PUBLIC_IP=`ip addr | grep 'state UP' -A2 | tail -n1 | awk '{print $2}' | cut -f1 -d'/'` + PRIVATE_INTERFACE="private/${LOCAL_IP}" + PUBLIC_INTERFACE="public/${LOCAL_IP}!${PUBLIC_IP}" fi -sed -i -e "s/MY_IP/$MY_IP/g" /etc/rtpengine.conf +if [ -z "$RTP_START_PORT" ]; then + RTP_START_PORT=40000 +fi +if [ -z "$RTP_END_PORT" ]; then + RTP_END_PORT=60000 +fi +if [ -z "$LOGLEVEL" ]; then + LOGLEVEL=5 +fi if [ "$1" = 'rtpengine' ]; then shift - exec rtpengine --config-file /etc/rtpengine.conf "$@" + exec rtpengine \ + --interface ${PRIVATE_INTERFACE} --interface ${PUBLIC_INTERFACE} \ + --port-min ${RTP_START_PORT} --port-max ${RTP_END_PORT} \ + --log-level ${LOGLEVEL} --port-min ${RTP_START_PORT} --port-max ${RTP_END_PORT} \ + --listen-ng=22222 --listen-http=8080 --listen-udp=12222 \ + --dtmf-log-dest=127.0.0.1:22223 \ + --listen-cli=127.0.0.1:9900 \ + --pidfile /var/run/rtpengine.pid \ + --recording-dir /tmp --recording-method pcap --recording-format eth \ + --delete-delay 0 \ + --log-stderr \ + --foreground \ + $@ +else + exec "$@" fi - -exec "$@" \ No newline at end of file diff --git a/rtpengine.conf b/rtpengine.conf deleted file mode 100644 index bab109a..0000000 --- a/rtpengine.conf +++ /dev/null @@ -1,12 +0,0 @@ -[rtpengine] -interface=MY_IP -foreground=true -log-stderr=true -listen-ng=MY_IP:22222 -port-min=23000 -port-max=32768 -recording-dir=/tmp -recording-method=pcap -recording-format=eth -log-level=6 -delete-delay=0