diff --git a/README.md b/README.md index a804d90..0d78f25 100644 --- a/README.md +++ b/README.md @@ -10,10 +10,16 @@ Your SIP PBX should be comaptible with `L16@48000` or `OPUS@48000` voice codec. ## Usage -1. Download prebuild versions for supported OS from CI or compile it yourself. -[Ubuntu 18.04 Bionic](https://ci.appveyor.com/api/projects/Infactum/tg2sip/artifacts/tg2sip_bionic.zip?branch=master&job=Environment%3A%20target_name%3DUbuntu%20Bionic%2C%20docker_tag%3Dbionic) -[CentOS 7](https://ci.appveyor.com/api/projects/Infactum/tg2sip/artifacts/tg2sip_centos7.zip?branch=master&job=Environment%3A%20target_name%3DCentOS%207%2C%20docker_tag%3Dcentos7) -Prebuild binaries requires OPUS libraries (`libopus0` for Ubuntu, `opus` for CentOS, etc). +1. Obtain binaries in one of convenient ways for you. + * Build them from source. + Requires C++17 supported comiler, which may be a trouble for old linux distros. + * Download prebuild native binaries for one of supported distros. + [Ubuntu 18.04 Bionic](https://ci.appveyor.com/api/projects/Infactum/tg2sip/artifacts/tg2sip_bionic.zip?branch=master&job=Environment%3A%20target_name%3DUbuntu%20Bionic%2C%20docker_tag%3Dbionic) + [CentOS 7](https://ci.appveyor.com/api/projects/Infactum/tg2sip/artifacts/tg2sip_centos7.zip?branch=master&job=Environment%3A%20target_name%3DCentOS%207%2C%20docker_tag%3Dcentos7) + Prebuild binaries requires OPUS libraries (`libopus0` for Ubuntu, `opus` for CentOS, etc). + * [Download](https://ci.appveyor.com/api/projects/Infactum/tg2sip/artifacts/tg2sip.zip?branch=master&job=Environment%3A%20target_name%3DAppImage%2C%20docker_tag%3Dcentos6) universal AppImage package. + More information of what is AppImage can be found here https://appimage.org/ + 2. Obtain `api_id` and `api_hash` tokens from [this](https://my.telegram.org) page and put them in `settings.ini` file. 3. Login into telegram with `gen_db` app 4. Set SIP server settings in `settings.ini` @@ -25,6 +31,9 @@ SIP->Telegram calls can be done using 3 extension types: 2. `\+[\d]+` for calls by phone number 3. `[\d]+` for calls by telegram ID. Only known IDs allowed by telegram API. +All Telegram->SIP calls will be redirected to `callback_uri` SIP-URI that can be set in from `settings.ini` file. +Extra information about caller Telegram account will be added into `X-TG-*` SIP tags. + ## Donate [![paypal](https://www.paypalobjects.com/en_US/i/btn/btn_donateCC_LG.gif)](https://www.paypal.com/cgi-bin/webscr?cmd=_donations&business=755FZWPRC9YGL&lc=US&item_name=TG2SIP¤cy_code=USD&bn=PP%2dDonationsBF%3abtn_donateCC_LG%2egif%3aNonHosted) diff --git a/appveyor.yml b/appveyor.yml index ab4a627..72ce178 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -24,6 +24,9 @@ environment: - target_name: CentOS 7 docker_tag: centos7 + - target_name: AppImage + docker_tag: centos6 + init: - sh: | docker login -u "$docker_login" -p "$docker_password" @@ -34,17 +37,47 @@ install: build_script: - sh: >- + if [ "$target_name" != "AppImage" ] ; then mkdir build; docker run --rm -v "$(pwd)":/src "$docker_image":"$docker_tag" /bin/bash -c " mkdir build && cd build; - export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig && cmake -DCMAKE_BUILD_TYPE=Release /src + export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig && cmake -DCMAKE_BUILD_TYPE=Release /src; cmake --build .; chmod +x tg2sip; chmod +x gen_db; cp tg2sip /src/build; - cp gen_db /src/build;" + cp gen_db /src/build;" 7z a tg2sip.zip ./build/tg2sip ./build/gen_db ./settings.ini; + fi; + + - sh: >- + if [ "$target_name" = "AppImage" ] ; then + mkdir build; + docker run --rm -v "$(pwd)":/src "$docker_image":"$docker_tag" /bin/bash -c " + mkdir build && cd build; + export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig && cmake -DCMAKE_BUILD_TYPE=Release /src; + cmake --build .; + chmod +x tg2sip; + chmod +x gen_db; + linuxdeploy --appdir /src/build/tg2sip -e tg2sip; + linuxdeploy --appdir /src/build/gen_db -e gen_db;" + wget https://github.com/AppImage/AppImageKit/releases/download/continuous/appimagetool-x86_64.AppImage -O appimagetool.AppImage; + chmod +x appimagetool.AppImage; + wget https://github.com/linuxdeploy/linuxdeploy/releases/download/continuous/linuxdeploy-x86_64.AppImage -O linuxdeploy.AppImage; + chmod +x linuxdeploy.AppImage; + sudo chown -R "$(id -u)":"$(id -g)" ./build; + ./linuxdeploy.AppImage --appdir ./build/tg2sip -d ./buildenv/tg2sip.desktop -i ./buildenv/icon.svg; + ./linuxdeploy.AppImage --appdir ./build/gen_db -d ./buildenv/gen_db.desktop -i ./buildenv/icon.svg; + ./appimagetool.AppImage ./build/tg2sip; + ./appimagetool.AppImage ./build/gen_db; + 7z a tg2sip.zip ./tg2sip-x86_64.AppImage ./gen_db-x86_64.AppImage ./settings.ini; + fi; after_build: - sh: docker push "$docker_image":"$docker_tag" - - sh: appveyor PushArtifact tg2sip.zip -FileName tg2sip_"$docker_tag".zip -DeploymentName "TG2SIP $target_name" \ No newline at end of file + - sh: >- + if [ "$target_name" != "AppImage" ] ; then + appveyor PushArtifact tg2sip.zip -FileName tg2sip_"$docker_tag".zip -DeploymentName "TG2SIP $target_name" + else + appveyor PushArtifact tg2sip.zip -FileName tg2sip.zip -DeploymentName "TG2SIP AppImage" + fi \ No newline at end of file diff --git a/buildenv/Dockerfile.centos6 b/buildenv/Dockerfile.centos6 new file mode 100644 index 0000000..7f29128 --- /dev/null +++ b/buildenv/Dockerfile.centos6 @@ -0,0 +1,73 @@ +FROM centos:6 as builder + +# https://www.softwarecollections.org/en/scls/rhscl/devtoolset-7/ +RUN yum -y install centos-release-scl yum-utils \ + && yum-config-manager --enable rhel-server-rhscl-7-rpms \ + && yum install -y devtoolset-7-gcc devtoolset-7-gcc-c++ + +RUN set -xe \ + && yum install -y \ + make \ + git wget \ + zlib-devel openssl-devel gperf \ + pkgconfig ccache gperf unzip \ + libpng-devel libjpeg-devel \ + epel-release \ + && yum install -y opus-devel patchelf + +RUN wget https://cmake.org/files/v3.9/cmake-3.9.6-Linux-x86_64.sh \ + && sh cmake-3.9.6-Linux-x86_64.sh --prefix=/usr --exclude-subdir + +COPY tdlib_header.patch / +COPY tdlib_threadname.patch / + +RUN source /opt/rh/devtoolset-7/enable \ + && git clone https://github.com/tdlib/td.git \ + && cd td \ + && git reset --hard v1.2.0 \ + && git apply /tdlib_header.patch \ + && git apply /tdlib_threadname.patch \ + && mkdir build \ + && cd build \ + && cmake -DCMAKE_BUILD_TYPE=Release .. \ + && cmake --build . --target install \ + && cd / \ + && rm -rf td + +COPY config_site.h / + +RUN source /opt/rh/devtoolset-7/enable \ + && git clone https://github.com/Infactum/pjproject.git \ + && cd pjproject \ + && cp /config_site.h pjlib/include/pj \ + && ./configure --disable-sound CFLAGS="-O3 -DNDEBUG" \ + && make dep && make && make install \ + && cd / \ + && rm -rf pjproject + +RUN source /opt/rh/devtoolset-7/enable \ + && git clone -n https://github.com/gabime/spdlog.git \ + && cd spdlog \ + && git checkout tags/v0.17.0 \ + && mkdir build \ + && cd build \ + && cmake -DCMAKE_BUILD_TYPE=Release -DSPDLOG_BUILD_EXAMPLES=OFF -DSPDLOG_BUILD_TESTING=OFF .. \ + && cmake --build . --target install \ + && cd / \ + && rm -rf spdlog + +RUN source /opt/rh/devtoolset-7/enable \ + && git clone --recursive https://github.com/linuxdeploy/linuxdeploy.git \ + && cd linuxdeploy \ + && git checkout f9fc51a832185158d3e0e64858c83a941047871f \ + && mkdir build \ + && cd build \ + && export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig && cmake -DCMAKE_BUILD_TYPE=Release -DUSE_SYSTEM_CIMG=0 .. \ + && cmake --build . \ + && cp bin/linuxdeploy /usr/local/bin \ + && cd / \ + && rm -rf linuxdeploy + +COPY centos_entrypoint.sh / + +ENTRYPOINT ["/centos_entrypoint.sh"] diff --git a/buildenv/gen_db.desktop b/buildenv/gen_db.desktop new file mode 100644 index 0000000..8e5c3aa --- /dev/null +++ b/buildenv/gen_db.desktop @@ -0,0 +1,8 @@ +[Desktop Entry] +Name=gen_db +Exec=gen_db +Comment=TG2SIP DB generator +Terminal=true +Type=Application +Icon=icon +Categories=AudioVideo; \ No newline at end of file diff --git a/buildenv/icon.svg b/buildenv/icon.svg new file mode 100644 index 0000000..83ac565 --- /dev/null +++ b/buildenv/icon.svg @@ -0,0 +1,320 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + image/svg+xml + + + + + + + + + + + + + + + + + + + + + + diff --git a/buildenv/tg2sip.desktop b/buildenv/tg2sip.desktop new file mode 100644 index 0000000..f9ac64f --- /dev/null +++ b/buildenv/tg2sip.desktop @@ -0,0 +1,8 @@ +[Desktop Entry] +Name=tg2sip +Exec=tg2sip +Comment=TG2SIP Voice Gateway +Terminal=true +Type=Application +Icon=icon +Categories=AudioVideo; \ No newline at end of file diff --git a/libtgvoip/CMakeLists.txt b/libtgvoip/CMakeLists.txt index 67ae01f..a9658fb 100644 --- a/libtgvoip/CMakeLists.txt +++ b/libtgvoip/CMakeLists.txt @@ -657,6 +657,7 @@ target_include_directories(libtgvoip PRIVATE ${PJSIP_INCLUDE_DIRS}) target_compile_definitions(libtgvoip PRIVATE + __STDC_FORMAT_MACROS WEBRTC_APM_DEBUG_DUMP=0 WEBRTC_POSIX WEBRTC_LINUX