Re-added hamview-receiver
Some checks failed
Test and build / Build receiver (push) Failing after 45s
Test and build / test (push) Successful in 59s
Test and build / Build collector (push) Failing after 1m16s

This commit is contained in:
2026-02-23 21:15:48 +01:00
parent d8715eaaaa
commit 227477d17f
11 changed files with 333 additions and 36 deletions

View File

@@ -24,22 +24,29 @@ jobs:
name: Build collector name: Build collector
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- uses: actions/checkout@v6 - name: Checkout
- uses: actions/setup-go@v6 uses: actions/checkout@v6
- name: Setup Go
uses: actions/setup-go@v6
with: with:
go-version-file: 'go.mod' go-version-file: 'go.mod'
check-latest: false check-latest: false
- name: Download modules - name: Download modules
run: go mod download run: go mod download
- name: Make build directory - name: Make build directory
run: mkdir -p build && readlink -f build run: mkdir -p build
- name: Build - name: Build
run: go build -o build/hamview-collector ./cmd/hamview-collector && ls -al $(readlink -f build/hamview-collector) run: |
- name: Debug env go build -o build/hamview-collector ./cmd/hamview-collector && \
run: env ls -al $(readlink -f build/hamview-collector)
- name: Set up Docker Buildx - name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3 uses: docker/setup-buildx-action@v3
- name: Log into Container Registry - name: Log into Docker Container Registry
uses: docker/login-action@v3
with:
username: ${{ vars.DOCKER_USER }}
password: ${{ secrets.DOCKER_TOKEN }}
- name: Log into Gitea Container Registry
uses: docker/login-action@v3 uses: docker/login-action@v3
with: with:
registry: ${{ vars.REGISTRY }} registry: ${{ vars.REGISTRY }}
@@ -49,7 +56,7 @@ jobs:
uses: docker/build-push-action@v6 uses: docker/build-push-action@v6
with: with:
push: true push: true
tags: ham/hamview:collector tags: ${{ vars.REGISTRY }}/ham/hamview/collector:dev
file: ./cmd/hamview-collector/Dockerfile file: ./cmd/hamview-collector/Dockerfile
context: . context: .
platforms: | platforms: |
@@ -58,40 +65,52 @@ jobs:
build_receiver: build_receiver:
name: Build receiver name: Build receiver
runs-on: ubuntu-latest runs-on: ubuntu-latest
strategy:
matrix:
include:
- goos: linux
goarch: amd64
goarm: ""
- goos: linux
goarch: arm
goarm: "6"
- goos: linux
goarch: arm
goarm: "7"
steps: steps:
- uses: actions/checkout@v6 - name: Checkout
- uses: actions/setup-go@v6 uses: actions/checkout@v6
- name: Setup Go
uses: actions/setup-go@v6
with: with:
go-version-file: 'go.mod' go-version-file: 'go.mod'
check-latest: false check-latest: false
- name: Set target variables
run: |
echo "GOOS=${{ matrix.goos }}" >> $GITHUB_ENV
echo "GOARCH=${{ matrix.goarch }}" >> $GITHUB_ENV
if [ -n "${{ matrix.goarm }}" ]; then
echo "GOARM=${{ matrix.goarm }}" >> $GITHUB_ENV
fi
- name: Download modules - name: Download modules
run: go mod download run: go mod download
- name: Make build directory - name: Make build directory
run: mkdir -p build && readlink -f build run: mkdir -p build && readlink -f build
- name: Build - name: Build amd64
run: go build -o build/hamview-receiver.${{ matrix.goarch }}${{ matrix.goarm }} ./cmd/hamview-receiver && readlink -f build/hamview-receiver.${{ matrix.goarch }}${{ matrix.goarm }} env:
GOOS: linux
GOARCH: amd64
run: |
GOOS=$GOOS GOARCH=$GOARCH \
go build -o build/hamview-receiver-$GOARCH cmd/hamview-receiver && \
readlink -f build/hamview-receiver-$GOARCH
- name: Build arm6
env:
GOOS: linux
GOARCH: arm
GOARM: 6
run: |
GOOS=$GOOS GOARCH=$GOARCH GOARM=$GOARM \
go build -o build/hamview-receiver-$GOARCH$GOARM cmd/hamview-receiver && \
readlink -f build/hamview-receiver-$GOARCH$GOARM
- name: Build arm7
env:
GOOS: linux
GOARCH: arm
GOARM: 7
run: |
GOOS=$GOOS GOARCH=$GOARCH GOARM=$GOARM \
go build -o build/hamview-receiver-$GOARCH$GOARM cmd/hamview-receiver && \
readlink -f build/hamview-receiver-$GOARCH$GOARM
- name: Set up Docker Buildx - name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3 uses: docker/setup-buildx-action@v3
- name: Log into Container Registry - name: Log into Docker Container Registry
uses: docker/login-action@v3
with:
username: ${{ vars.DOCKER_USER }}
password: ${{ secrets.DOCKER_TOKEN }}
- name: Log into Gitea Container Registry
uses: docker/login-action@v3 uses: docker/login-action@v3
with: with:
registry: ${{ vars.REGISTRY }} registry: ${{ vars.REGISTRY }}
@@ -101,7 +120,7 @@ jobs:
uses: docker/build-push-action@v6 uses: docker/build-push-action@v6
with: with:
push: true push: true
tags: ham/hamview:receiver tags: ${{ vars.REGISTRY }}/ham/hamview/receiver:dev
file: ./cmd/hamview-receiver/Dockerfile file: ./cmd/hamview-receiver/Dockerfile
context: . context: .
platforms: | platforms: |

23
.gitignore vendored
View File

@@ -1,3 +1,26 @@
# Binaries for programs and plugins
*.exe
*.exe~
*.dll
*.so
*.dylib
# Test binary, built with `go test -c`
*.test
# Output of the go coverage tool, specifically when used with LiteIDE
*.out
# Dependency directories (remove the comment below to include it)
# vendor/
# Go workspace file
go.work
go.work.sum
# env file
.env
# Build artifacts # Build artifacts
build/ build/

18
LICENSE Normal file
View File

@@ -0,0 +1,18 @@
MIT License
Copyright (c) 2026 ham
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and
associated documentation files (the "Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the
following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial
portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT
LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO
EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
USE OR OTHER DEALINGS IN THE SOFTWARE.

3
README.md Normal file
View File

@@ -0,0 +1,3 @@
# hamview
HAMView radio receiver

View File

@@ -0,0 +1,12 @@
FROM alpine:3
RUN apk add --no-cache dumb-init=1.2.5-r3
WORKDIR /app
ARG TARGETARCH
ARG TARGETVARIANT
COPY ./etc /app/config
COPY ./build/hamview-receiver-${TARGETARCH}${TARGETVARIANT#v} /app/hamview-receiver
COPY ./entrypoint.sh /entrypoint.sh
ENTRYPOINT ["dumb-init", "/entrypoint.sh"]

View File

@@ -0,0 +1,17 @@
#!/bin/sh
run() {
case "${PROTOCOL}" in
"") exec "/app/hamview-receiver" help ;;
*) exec "/app/hamview-receiver" --config "/app/config/hamview-${PROTOCOL}.yaml" "${PROTOCOL}" ;;
esac
}
case "$@" in
"")
run
;;
*)
exec "/bin/sh" -c "$@"
;;
esac

View File

@@ -0,0 +1,49 @@
package main
import (
"context"
"fmt"
"log"
"os"
"github.com/sirupsen/logrus"
"github.com/urfave/cli/v3"
"git.maze.io/ham/hamview/cmd"
)
var logger *logrus.Logger
func main() {
cmd := &cli.Command{
Name: "hamview-receiver",
Usage: "Receiver for HAM radio protocols",
Action: func(context.Context, *cli.Command) error {
fmt.Println("boom! I say!")
return nil
},
Flags: cmd.AllFlags("hamview-receiver.yaml"),
Commands: []*cli.Command{
{
Name: "aprsis",
Usage: "Start an APRS-IS proxy",
Before: cmd.ConfigureLogging(&logger),
Action: runAPRSIS,
},
{
Name: "meshcore",
Usage: "Start a MeshCore receiver",
Before: cmd.ConfigureLogging(&logger),
Action: runMeshCore,
},
},
}
if err := cmd.Run(context.Background(), os.Args); err != nil {
log.Fatal(err)
}
}
func waitForInterrupt() error {
return cmd.WaitForInterrupt(logger, "receiver")
}

View File

@@ -0,0 +1,77 @@
package main
import (
"context"
"github.com/urfave/cli/v3"
"git.maze.io/go/ham/protocol/aprs/aprsis"
"git.maze.io/ham/hamview"
"git.maze.io/ham/hamview/cmd"
)
type aprsisConfig struct {
Broker hamview.BrokerConfig `yaml:"broker"`
Receiver hamview.APRSISConfig `yaml:"receiver"`
Include []string `yaml:"include"`
}
func (config *aprsisConfig) Includes() []string {
includes := config.Include
config.Include = nil
return includes
}
func runAPRSIS(ctx context.Context, command *cli.Command) error {
var config = aprsisConfig{
Receiver: hamview.APRSISConfig{
Listen: hamview.DefaultAPRSISListen,
Server: hamview.DefaultAPRSISServer,
},
}
if err := cmd.Load(logger, command.String(cmd.FlagConfig), &config); err != nil {
return err
}
logger.Infof("receiver: starting APRS-IS proxy on tcp://%s to tcp://%s",
config.Receiver.Listen,
config.Receiver.Server)
proxy, err := aprsis.NewProxy(config.Receiver.Listen, config.Receiver.Server)
if err != nil {
return err
}
proxy.OnClient = func(callsign string, client *aprsis.ProxyClient) {
go receiveAPRSIS(&config.Broker, callsign, client)
}
return waitForInterrupt()
}
func receiveAPRSIS(config *hamview.BrokerConfig, callsign string, client *aprsis.ProxyClient) {
defer func() { _ = client.Close() }()
broker, err := hamview.NewBroker(config)
if err != nil {
logger.Errorf("receiver: can't setup to broker: %v", err)
return
}
defer func() { _ = broker.Close() }()
info := client.Info() // TODO: enrich info from config?
if err = broker.StartRadio("aprs", info); err != nil {
logger.Fatalf("receiver: can't start broker: %v", err)
return
}
logger.Infof("receiver: start receiving packets from station: %s", callsign)
for packet := range client.RawPackets() {
logger.Debugf("aprs packet: %#+v", packet)
if err := broker.PublishPacket("aprs/packet", packet); err != nil {
logger.Error(err)
}
}
logger.Infof("receiver: stopped receiving packets from station: %s", callsign)
}

View File

@@ -0,0 +1,79 @@
package main
import (
"context"
"github.com/urfave/cli/v3"
"git.maze.io/go/ham/protocol"
"git.maze.io/go/ham/protocol/meshcore"
"git.maze.io/ham/hamview"
"git.maze.io/ham/hamview/cmd"
)
type meshCoreConfig struct {
Broker hamview.BrokerConfig `yaml:"broker"`
Receiver hamview.MeshCoreConfig `yaml:"receiver"`
Include []string `yaml:"include"`
}
func (config *meshCoreConfig) Includes() []string {
includes := config.Include
config.Include = nil
return includes
}
func runMeshCore(ctx context.Context, command *cli.Command) error {
var config meshCoreConfig
if err := cmd.Load(logger, command.String(cmd.FlagConfig), &config); err != nil {
return err
}
broker, err := hamview.NewBroker(&config.Broker)
if err != nil {
return err
}
defer func() { _ = broker.Close() }()
receiver, err := hamview.NewMeshCoreReceiver(&config.Receiver)
if err != nil {
return err
}
defer func() { _ = receiver.Close() }()
info := receiver.Info() // TODO: enrich info from config?
if err = broker.StartRadio(protocol.MeshCore, info); err != nil {
logger.Fatalf("receiver: can't start broker: %v", err)
return err
}
// Trace scheduler
//go receiver.RunTraces()
// Packet decoder
go func() {
logger.Info("receiver: start receiving packets")
for packet := range receiver.RawPackets() {
if len(packet.Raw) >= 1 {
var (
header = packet.Raw[0]
version = (header >> 6) & 0x03
routeType = meshcore.RouteType(header & 0x03)
payloadType = meshcore.PayloadType((header >> 2) & 0x0F)
)
logger.Debugf("meshcore packet: %d %s %s: %d bytes",
version,
routeType,
payloadType,
len(packet.Raw))
}
if err = broker.PublishPacket("meshcore/packet", packet); err != nil {
logger.Errorf("receiver: failed to publish packet: %v", err)
}
}
logger.Warn("receiver: closing")
}()
return waitForInterrupt()
}

2
go.mod
View File

@@ -3,7 +3,7 @@ module git.maze.io/ham/hamview
go 1.25.6 go 1.25.6
require ( require (
git.maze.io/go/ham v0.1.0 git.maze.io/go/ham v0.1.1-0.20260223201507-65f3fe39a98b
github.com/Vaniog/go-postgis v0.0.0-20240619200434-9c2eb8ed621e github.com/Vaniog/go-postgis v0.0.0-20240619200434-9c2eb8ed621e
github.com/cemkiy/echo-logrus v0.0.0-20200218141616-06f9cd1dae34 github.com/cemkiy/echo-logrus v0.0.0-20200218141616-06f9cd1dae34
github.com/cridenour/go-postgis v1.0.1 github.com/cridenour/go-postgis v1.0.1

4
go.sum
View File

@@ -1,9 +1,9 @@
filippo.io/edwards25519 v1.1.0 h1:FNf4tywRC1HmFuKW5xopWpigGjJKiJSV0Cqo0cJWDaA= filippo.io/edwards25519 v1.1.0 h1:FNf4tywRC1HmFuKW5xopWpigGjJKiJSV0Cqo0cJWDaA=
filippo.io/edwards25519 v1.1.0/go.mod h1:BxyFTGdWcka3PhytdK4V28tE5sGfRvvvRV7EaN4VDT4= filippo.io/edwards25519 v1.1.0/go.mod h1:BxyFTGdWcka3PhytdK4V28tE5sGfRvvvRV7EaN4VDT4=
git.maze.io/go/ham v0.0.0-20260222201625-824bde5d5525 h1:No1WgUBujHY8tSMfIFuvcAJ5qe9RK6o2WgmZROp5+JM=
git.maze.io/go/ham v0.0.0-20260222201625-824bde5d5525/go.mod h1:+WuiawzNBqlWgklVoodUAJc0cV+NDW6RR8Tn+AW8hsU=
git.maze.io/go/ham v0.1.0 h1:ytqqkGux4E6h3QbCB3zJy/Ngc+fEqodyMpepbp9o/ts= git.maze.io/go/ham v0.1.0 h1:ytqqkGux4E6h3QbCB3zJy/Ngc+fEqodyMpepbp9o/ts=
git.maze.io/go/ham v0.1.0/go.mod h1:+WuiawzNBqlWgklVoodUAJc0cV+NDW6RR8Tn+AW8hsU= git.maze.io/go/ham v0.1.0/go.mod h1:+WuiawzNBqlWgklVoodUAJc0cV+NDW6RR8Tn+AW8hsU=
git.maze.io/go/ham v0.1.1-0.20260223201507-65f3fe39a98b h1:Wzt2uXbqW9h/159KeXY95CrDoLN0m3HCxPC6jPLO6ws=
git.maze.io/go/ham v0.1.1-0.20260223201507-65f3fe39a98b/go.mod h1:+WuiawzNBqlWgklVoodUAJc0cV+NDW6RR8Tn+AW8hsU=
github.com/Vaniog/go-postgis v0.0.0-20240619200434-9c2eb8ed621e h1:Ck+0lNRr62RM/LNKkkD0R1aJ2DvgELqmmuNvyyHL75E= github.com/Vaniog/go-postgis v0.0.0-20240619200434-9c2eb8ed621e h1:Ck+0lNRr62RM/LNKkkD0R1aJ2DvgELqmmuNvyyHL75E=
github.com/Vaniog/go-postgis v0.0.0-20240619200434-9c2eb8ed621e/go.mod h1:o3MIxN5drWoGBTtBGtLqFZlr7RjfdQKnfwYXoUU77vU= github.com/Vaniog/go-postgis v0.0.0-20240619200434-9c2eb8ed621e/go.mod h1:o3MIxN5drWoGBTtBGtLqFZlr7RjfdQKnfwYXoUU77vU=
github.com/cemkiy/echo-logrus v0.0.0-20200218141616-06f9cd1dae34 h1:cGxEwqDl+PiqPtJpQNoiJIXcrVEkkSMuMQtb+PPAHL4= github.com/cemkiy/echo-logrus v0.0.0-20200218141616-06f9cd1dae34 h1:cGxEwqDl+PiqPtJpQNoiJIXcrVEkkSMuMQtb+PPAHL4=