Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: sipcapture/heplify
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 1.45
Choose a base ref
...
head repository: sipcapture/heplify
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: master
Choose a head ref
Loading
Showing with 8,421 additions and 1,579 deletions.
  1. +2 −0 .github/FUNDING.yml
  2. +75 −0 .github/workflows/go.yml
  3. +183 −0 .github/workflows/release-alpine.yml
  4. +73 −0 .github/workflows/release.yml
  5. +3 −0 .gitignore
  6. +21 −0 .travis.yml
  7. +7 −0 Makefile
  8. +228 −34 README.md
  9. +4 −10 build_static.sh
  10. +42 −15 config/config.go
  11. +318 −108 decoder/correlator.go
  12. +177 −0 decoder/correlator_test.go
  13. +951 −134 decoder/decoder.go
  14. +0 −31 decoder/decoder_test.go
  15. +117 −0 decoder/hep.go
  16. +214 −152 decoder/{ → internal}/machine.go
  17. +4 −3 decoder/{ → internal}/machine.rl
  18. +162 −0 decoder/luaengine.go
  19. +443 −0 decoder/luar/luaobject.go
  20. +959 −0 decoder/luar/luar.go
  21. +297 −0 decoder/luar/proxy.go
  22. +202 −0 decoder/luar/proxyfuncs.go
  23. +561 −0 decoder/luar/proxymm.go
  24. +105 −0 decoder/scriptengine.go
  25. +196 −65 decoder/tcpassembly.go
  26. +105 −49 decoder/util.go
  27. +14 −9 docker/heplify/Dockerfile
  28. +11 −3 docker/heplify/docker-compose.yml
  29. +29 −22 sniffer/pcap.go → dump/dump.go
  30. +167 −0 dump/read.go
  31. +104 −0 dump/write.go
  32. +82 −0 example.lua
  33. +2 −3 example/heplify.service
  34. +25 −0 example/heplify.yaml
  35. BIN example/pcap/FAX-Call-t38-CA-TDM-SIP-FB-1.pcap
  36. BIN example/pcap/sip_sctp.pcap
  37. BIN example/pcap/sip_tcp_websocket.pcap
  38. +18 −0 go.mod
  39. +602 −0 go.sum
  40. +14 −16 ip6defrag/defrag.go
  41. +155 −32 main.go
  42. +97 −0 ownlayers/hperm.go
  43. +8 −8 ownlayers/rtp.go
  44. +0 −388 ownlayers/sip.go
  45. +46 −0 ownlayers/vxlan.go
  46. +67 −0 promstats/promestats.go
  47. +1 −1 protos/dns.go
  48. +18 −0 protos/fuzz.go
  49. +38 −35 protos/rtcp.go
  50. +85 −0 protos/rtcp_test.go
  51. +1 −1 protos/rtp.go
  52. +0 −23 protos/sip.go
  53. +116 −0 protos/websocket.go
  54. +9 −7 publish/file.go
  55. +299 −60 publish/hep.go
  56. +248 −154 publish/marshal.go
  57. +25 −19 publish/marshal_test.go
  58. +95 −6 publish/publisher.go
  59. +12 −0 scripts/build_binary.sh
  60. +28 −0 scripts/build_package.sh
  61. +27 −29 sniffer/afpacket_linux.go
  62. +21 −5 sniffer/afpacket_nonlinux.go
  63. +0 −51 sniffer/benchmark.go
  64. +4 −4 sniffer/device.go
  65. +504 −102 sniffer/sniffer.go
2 changes: 2 additions & 0 deletions .github/FUNDING.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
github: [qxip]
custom: ["https://bunq.me/qxip"]
75 changes: 75 additions & 0 deletions .github/workflows/go.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
name: Go CI/CD

on:
push:
branches: [ master, main ]
pull_request:
branches: [ master, main ]

env:
REGISTRY: ghcr.io

jobs:

build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Set up Go
uses: actions/setup-go@v5.0.1
with:
go-version: 1.21

- name: Libraries
run: sudo apt-get install -y libpcap-dev libluajit-5.1-dev

- name: LuaJIT
run: git clone https://luajit.org/git/luajit-2.0.git && cd luajit-2.0 && git checkout v2.1 && make CCOPT="-static -fPIC" BUILDMODE="static" && sudo make install

- name: Build
run: go build -ldflags "-s -w" -o heplify *.go

docker-push:
if: github.event_name != 'pull_request'
runs-on: ubuntu-latest
needs: build
permissions:
packages: write
contents: read

steps:
- uses: actions/checkout@v4
- id: tag_bump
name: Bump version and push tag
uses: anothrNick/github-tag-action@1.67.0
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
DEFAULT_BUMP: none
BRANCH: master

- name: Log in to the Container registry
uses: docker/login-action@v3.2.0
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Docker meta
id: meta
uses: docker/metadata-action@v5.5.1
with:
images: |
ghcr.io/${{ github.repository }}
tags: |
latest
${{ steps.tag_bump.outputs.tag }}
- name: Build and push
uses: docker/build-push-action@v5.4.0
with:
context: .
file: ./docker/heplify/Dockerfile
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
183 changes: 183 additions & 0 deletions .github/workflows/release-alpine.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,183 @@
name: Release Binary/Images (alpine)

on:
workflow_dispatch:
release:
types: [created]

env:
REGISTRY: ghcr.io
CROSS_SYSROOT: /mnt/alpine

jobs:

build:
runs-on: ubuntu-latest
strategy:
matrix:
arch: [x86_64, aarch64]
steps:
- uses: actions/checkout@v4
- name: Set up Alpine Linux for x86_64 (build arch)
uses: jirutka/setup-alpine@v1
with:
arch: ${{ matrix.arch }}
id: alpine-root
packages: >
build-base
pkgconf
linux-headers
musl-dev
gcc
libpcap-dev
ca-certificates
git
go
sudo
- name: Install LuaJit 2.1 ${{ matrix.arch }}
run: |
git clone https://luajit.org/git/luajit-2.0.git \
&& cd luajit-2.0 \
&& git checkout v2.1 \
&& make CCOPT="-static -fPIC" BUILDMODE="static" && sudo make install
shell: alpine.sh {0}

- name: Build ${{ matrix.arch }}
run: CGO_ENABLED=1 GOOS=linux go build -a --ldflags '-linkmode external -extldflags "-static -s -w"' -o heplify${{ matrix.arch == 'aarch64' && '-arm64' || '' }} .
shell: alpine.sh {0}

- name: Try to run the binary ${{ matrix.arch }}
run: ./heplify${{ matrix.arch == 'aarch64' && '-arm64' || '' }} -h
shell: alpine.sh {0}

- name: Package for ${{ matrix.arch }}
if: ${{ matrix.arch != 'aarch64' }}
run: ./scripts/build_package.sh
env:
ARCH: ${{ matrix.arch == 'aarch64' && 'arm64' || 'amd64' }}

- name: Upload Artifacts for ${{ matrix.arch }}
if: ${{ github.event_name != 'workflow_dispatch' }}
uses: skx/github-action-publish-binaries@master
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
args: 'heplify*'

- name: Check PACKAGECLOUD secret presence
id: checkpackagecloud
shell: bash
run: |
if [ "$SECRET" == "" ]; then
echo "secretspresent=false" >> $GITHUB_OUTPUT
else
echo "secretspresent=true" >> $GITHUB_OUTPUT
fi
env:
SECRET: ${{ secrets.PACKAGECLOUD_TOKEN }}

- name: upload deb packagecloud
if: ${{ matrix.arch != 'aarch64' && steps.checkpackagecloud.outputs.secretspresent == 'true' }}
uses: danielmundi/upload-packagecloud@v1
with:
PACKAGE-NAME: heplify-*-amd64.deb
PACKAGECLOUD-REPO: sipcapture
PACKAGECLOUD-DISTRIB: any/any
PACKAGECLOUD-USERNAME: qxip
PACKAGECLOUD-TOKEN: ${{ secrets.PACKAGECLOUD_TOKEN }}

- name: upload rpm packagecloud
if: ${{ matrix.arch != 'aarch64' && steps.checkpackagecloud.outputs.secretspresent == 'true' }}
uses: danielmundi/upload-packagecloud@v1
with:
PACKAGE-NAME: heplify-*-amd64.rpm
PACKAGECLOUD-REPO: sipcapture
PACKAGECLOUD-DISTRIB: rpm_any/rpm_any
PACKAGECLOUD-USERNAME: qxip
PACKAGECLOUD-TOKEN: ${{ secrets.PACKAGECLOUD_TOKEN }}

docker-ghcr-push:
if: ${{ github.event_name != 'workflow_dispatch' }}
runs-on: ubuntu-latest
needs: build
permissions:
packages: write
contents: read

steps:
- uses: actions/checkout@v4
- name: Log in to the Container registry
uses: docker/login-action@v3.2.0
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Docker meta
id: meta
uses: docker/metadata-action@v5.5.1
with:
images: |
ghcr.io/${{ github.repository }}
tags: |
latest
${{ github.ref_name }}
- name: Build and push
uses: docker/build-push-action@v5.4.0
with:
context: .
file: ./docker/heplify/Dockerfile
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}

docker-dockerhub-push:
if: ${{ github.event_name != 'workflow_dispatch' }}
runs-on: ubuntu-latest
needs: build
permissions:
packages: write
contents: read

steps:
- name: Check Docker secret presence
id: checkdocker
shell: bash
run: |
if [ "$SECRET" == "" ] || [ "$USERNAME" == "" ]; then
echo "secretspresent=false" >> $GITHUB_OUTPUT
else
echo "secretspresent=true" >> $GITHUB_OUTPUT
fi
env:
SECRET: ${{ secrets.DOCKERHUB_TOKEN }}
USERNAME: ${{ secrets.DOCKERHUB_USERNAME }}

- uses: actions/checkout@v4
- name: Login to DockerHub
if: ${{ steps.checkdocker.outputs.secretspresent == 'true' }}
uses: docker/login-action@v3.2.0
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}

- name: Docker meta
id: meta
uses: docker/metadata-action@v5.5.1
with:
images: |
qxip/heplify
tags: |
latest
${{ github.ref_name }}
- name: Build and push
uses: docker/build-push-action@v5.4.0
with:
context: .
file: ./docker/heplify/Dockerfile
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
73 changes: 73 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
name: Release Binary/Images (old)

on:
workflow_dispatch:
# release:
# types: [created, published]

env:
REGISTRY: ghcr.io

jobs:

build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Set up Go
uses: actions/setup-go@v5.0.1
with:
go-version: 1.21

- name: Libraries
run: sudo apt-get install -y libpcap-dev libluajit-5.1-dev

- name: LuaJIT
run: git clone https://luajit.org/git/luajit-2.0.git && cd luajit-2.0 && git checkout v2.1 && make CCOPT="-static -fPIC" BUILDMODE="static" && sudo make install && sudo ldconfig

- name: Build
run: CGO_ENABLED=1 GOOS=linux go build -a --ldflags '-linkmode external -extldflags "-static -s -w"' -o heplify .
# run: CGO_ENABLED=1 GOOS=linux CGO_LDFLAGS="-lm -ldl" go build -a -ldflags '-extldflags "-static"' -tags netgo -installsuffix netgo -o heplify *.go

- name: Upload
uses: skx/github-action-publish-binaries@master
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
args: 'heplify'

docker-push:
runs-on: ubuntu-latest
needs: build
permissions:
packages: write
contents: read

steps:
- uses: actions/checkout@v4
- name: Log in to the Container registry
uses: docker/login-action@v3.2.0
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Docker meta
id: meta
uses: docker/metadata-action@v5.5.1
with:
images: |
ghcr.io/${{ github.repository }}
tags: |
latest
${{ github.ref_name }}
- name: Build and push
uses: docker/build-push-action@v5.4.0
with:
context: .
file: ./docker/heplify/Dockerfile
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
heplify
heplify.log*
vendor/
21 changes: 21 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
language: go
sudo: true

go:
- "1.11.x"
- "tip"

env:
- GO111MODULE=on

before_script:
- sudo apt-get install -y libpcap-dev

matrix:
allow_failures:
- go: tip

script:
- make test
- make
- find example/pcap -name "*.pcap" \( -exec echo -e "\n Running {} \n" \; -exec ./heplify -rf {} -rs -e -hs "" \; -o -quit \)
7 changes: 7 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,11 +1,18 @@
NAME?=heplify
#export CGO_LDFLAGS += -Wl,-static -L/usr/lib/x86_64-linux-gnu/libpcap.a -lpcap -Wl,-Bdynamic

PKGLIST=$(shell go list ./... | grep -Ev '/vendor|decoder/internal')

all:
go build -ldflags "-s -w" -o $(NAME) *.go

debug:
go build -o $(NAME) *.go

test:
go vet $(PKGLIST)
go test $(PKGLIST) -race

.PHONY: clean
clean:
rm -fr $(NAME)
Loading