diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 0000000..9ce32b1 --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,88 @@ +name: RTCAgent Builder + +on: + workflow_dispatch: + release: + types: [created] + + +env: + REGISTRY: ghcr.io + IMAGE_NAME: ${{ github.repository }} + +jobs: + + build: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - name: Set up Go + uses: actions/setup-go@v3 + with: + go-version: 1.19 + - name: Setup Build Env + run: /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com//sipcapture/rtcagent/master/builder/init_env.sh)" + - name: Build RTCAgent + run: make + - name: Compress + run: | + strip bin/rtcagent + upx bin/rtcagent + - name: Check & Run + run: | + ls -alFh bin/rtcagent + ./bin/rtcagent --help + + - name: Patch NFPM Version + run: | + sudo sed -i "s/0.0.0/${{ github.ref_name }}/g" rtcagent.yml + - name: Create deb package + id: nfpm-deb + uses: burningalchemist/nfpm-action@v1 + env: + VERSION: ${{ github.event.release.tag_name }} + with: + packager: deb + config: rtcagent.yml + target: rtcagent_${{ github.ref_name }}_all.deb + - name: Create rpm package + id: nfpm-rpm + uses: burningalchemist/nfpm-action@v1 + env: + VERSION: ${{ github.event.release.tag_name }} + with: + packager: rpm + config: rtcagent.yml + target: rtcagent_${{ github.ref_name }}.amd64.rpm + + - name: Upload Release + if: github.event_name != 'pull_request' + uses: boxpositron/upload-multiple-releases@1.0.7 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + release_config: | + ./bin/rtcagent + ./rtcagent_${{ github.ref_name }}_all.deb + ./rtcagent_${{ github.ref_name }}.amd64.rpm + tag_name: ${{ github.ref_name }} + release_name: rtcagent_${{ github.ref_name }} + draft: false + prerelease: false + overwrite: true + + - name: Log in to the Container registry + uses: docker/login-action@v2.0.0 + with: + registry: ${{ env.REGISTRY }} + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Docker Build and push + uses: docker/build-push-action@v3.0.0 + with: + context: . + push: true + tags: | + ghcr.io/sipcapture/rtcagent:latest + ghcr.io/sipcapture/rtcagent:${{ github.ref_name }} diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..66e0c3a --- /dev/null +++ b/Dockerfile @@ -0,0 +1,9 @@ +FROM alpine as builder +RUN apk add --allow-untrusted --update --no-cache curl ca-certificates +WORKDIR / +RUN curl -fsSL github.com/sipcapture/rtcagent/releases/latest/download/rtcagent -O && chmod +x rtcagent + +FROM scratch +COPY --from=builder /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/ +COPY --from=builder /rtcagent /rtcagent +CMD ["/rtcagent"] diff --git a/README.md b/README.md index 19966c2..bb1f476 100644 --- a/README.md +++ b/README.md @@ -1,52 +1,107 @@ -# RtcAgent + + + -The agent is focusing on VoIP/RTC Applications to make troubleshooting, support and monitoring much easily. +RTCagent is an HEP/eBPF powered observability tool for VoIP/WebRTC Applications. -The Project was inspired by Cilum, Odigos, eCapture. Thank you these projects for nice libraries, implementations and huge job! Without you it will be impossible! +
-> **Note** -> -> Supports Linux/Android kernel versions x86_64 4.18 and above, **aarch64 5.5** and above. -> Does not support Windows and macOS system. ----- +### Made with eBPF +Before proceeding, learn everything you need to know about [eBPF](https://ebpf.io) -# What's eBPF -[eBPF](https://ebpf.io) + + + -# How to compile -Linux Kernel: >= 4.18. +### Download +Download an `amd64/x86` static build of `rtcagent` and use it immediately. +```bash +curl -fsSL github.com/sipcapture/rtcagent/releases/latest/download/rtcagent -O && chmod +x rtcagent +``` + +Prefer using packages? Get the latest [deb and rpm](https://github.com/sipcapture/rtcagent/releases) releases for `amd64/x86` + +### Usage + +``` + +NAME: rtcagent - Capture and debug RTC Projects. +USAGE: rtcagent [flags] + +COMMANDS: + + freeswitch capture SIP messages from freeswitch (libsofia): t_port, su_recv + help Help about any command + kamailio capture SIP messages from kamailio: recv_msg, udp_send, tcp_send. + tcpdrop show tcp drops + +DESCRIPTION: + + RTCAgent is a tool that can capture and trace SIP packets using eBPF hooks and HEP + + Usage: + rtcagent -h -## Tools +OPTIONS: + -d, --debug[=false] enable debug logging + -h, --help[=false] help for rtcagent + -P, --hep-port="9060" hep port - default 9060 + -S, --hep-server="" hep server to duplicate: i.e. 10.0.0.1 + -T, --hep-transport="udp" hep transport default udp. Can be udp, tcp, tls + --hex[=false] print byte strings as hex encoded strings + -l, --log-file="" -l save the packets to file + --nosearch[=false] no lib search + -p, --pid=0 if pid is 0 then we target all pids + -u, --uid=0 if uid is 0 then we target all users + -v, --version[=false] version for rtcagent + +``` + +
+ +### Build + +> Compatible with Linux/Android kernel versions >= **x86_64 4.18**, >= **aarch64 5.5**.
+> Linux only. Does not support Windows and macOS. + +#### Requirements * golang 1.18 or newer * clang 9.0 or newer * cmake 3.18.4 or newer * clang backend: llvm 9.0 or newer * kernel config:CONFIG_DEBUG_INFO_BTF=y -## command +#### Instructions -### ubuntu +##### Ubuntu If you are using Ubuntu 20.04 or later versions, you can use a single command to complete the initialization of the compilation environment. ```shell /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com//sipcapture/rtcagent/master/builder/init_env.sh)" ``` -### other Linux -In addition to the software listed in the 'Toolchain Version' section above, the following software is also required for the compilation environment. Please install it yourself. +##### Any Linux +In addition to the software listed in the 'Toolchain Version' section above, the following software is also required for the compilation environment. Please install before proceeding. + * linux-tools-common * linux-tools-generic * pkgconf * libelf-dev -**Clone the repository code and compile it** +**Clone the repository code and compile** ```shell git clone git@github.com:/sipcapture/rtcagent.git cd rtcagent make bin/rtcagent ``` -## compile without BTF -RtcAgent support BTF disabled with command `make nocore` to compile at 2022/04/17. It can work normally even on Linux systems that do not support BTF. +#### compile without BTF +RTCAgent support BTF disabled with command `make nocore` to compile at 2022/04/17 and can run on Linux systems that do not support BTF. ```shell make nocore bin/rtcagent --help ``` + +
+ +### Credits + +RTCAgent is inspired by Cilum, Odigos, eCapture and the many eBPF guides, libraries and implementations. diff --git a/cli/cmd/freeswitch.go b/cli/cmd/freeswitch.go index b5c6cda..b0627b9 100644 --- a/cli/cmd/freeswitch.go +++ b/cli/cmd/freeswitch.go @@ -42,7 +42,7 @@ var freeswitchConfig = config.NewFreeSwitchConfig() // freeswitchCmd represents the freeswitch command var freeswitchCmd = &cobra.Command{ Use: "freeswitch", - Short: "capture SIP messages from freeswitch: recv_msg, udp_send, tcp_send.", + Short: "capture SIP messages from freeswitch (libsofia): t_port, su_recv.", Long: ` Tested on freeswitch 1.x`, Run: freeswitchCommandFunc, } diff --git a/rtcagent.yml b/rtcagent.yml new file mode 100644 index 0000000..2531523 --- /dev/null +++ b/rtcagent.yml @@ -0,0 +1,19 @@ +name: rtcagent +arch: amd64 +platform: linux +version: 0.0.0 +release: 1 +section: default +priority: extra +replaces: + - rtcagent +provides: + - rtcagent +maintainer: Alexandr Dubovikob +description: RTCagent is a HEP/eBPF sniffer for VoiP/RTC Applications +vendor: sipcapture.org +homepage: http://sipcapture.org +license: AGPLv3 +contents: + - src: ./bin/rtcagent + dst: /usr/bin/rtcagent