Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

2.0.0 #20

Open
wants to merge 16 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ on:
- "master"
tags:
- "v*"
pull_request:
branches:
- "master"
# pull_request:
# branches:
# - "master"
jobs:
build:
runs-on: ubuntu-latest
Expand Down
10 changes: 6 additions & 4 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
*.exe
*.txt
/Release/*
/.idea/*
/bin/*
/pkg/*
Release/
.idea/
bin/
pkg/

/logs/
85 changes: 54 additions & 31 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,18 @@
如果此项目您你有帮助,请给我一个Star,谢谢。
如果您有任何建议,欢迎提出一个issue。

## 关于2.0版本

2.0版本正在开发。请注意:与1.0在配置文件上不兼容

### 二进制发布大小膨胀提示

2.0由于使用了一些库的缘故,二进制大小将和1.0版本有较大差异

release编译模式下,在 Ubuntu 22.04 5.14.0-1059-oem 上,目前amd64编译产物大小为6.1MB

建议具有微小设备运行的用户尝试使用UPX进行压缩,上述平台经过UPX压缩后可降至2.1MB

## Docker 使用说明

docker仓库地址:https://hub.docker.com/r/dextercai/feeyo-adsb-golang
Expand All @@ -14,16 +26,18 @@ docker仓库地址:https://hub.docker.com/r/dextercai/feeyo-adsb-golang
### 使用Docker与文件配置(conf.ini)
```bash
docker run --net host \
-v /YOUR-PATH-OF/conf.ini:/app/conf.ini:rw -d \
dextercai/feeyo-adsb-golang:latest
-v /YOUR-PATH-OF/conf.ini:/app/conf.ini:r -d \
dextercai/feeyo-adsb-golang:latest --conf=/app/conf.ini
```

### 使用Docker与命令行配置
```bash
docker run --net host \
dextercai/feeyo-adsb-golang:latest /app/feeyo-adsb-golang \
-use-file=false -feeyo-url=https://adsb.feeyo.com/adsb/ReceiveCompressADSB.php \
-ip=127.0.0.1 -port=30003 -uuid=YOUR-UUID
--log.path=/tmp --log.rotation_count=1 --log.rotation_size=2 --log.rotation_time=0\
--dump1090.host --dump1090.port=30003 --feeyo.uuid=YOUR-UUID

# 日志会被导向到临时目录中,不占用磁盘。
```

## Binary 使用说明
Expand All @@ -41,11 +55,24 @@ UUID在线生成可访问:https://feeyo-uuid.dextercai.com
你需要在程序**同目录**创建conf.ini文件,内容如下。

```
[config]
UUID=你的UUID(16位)
ip=127.0.0.1
[dump1090]
host=127.0.0.1
port=30003

[log]
level=debug
file=feeyo-adsb-golang.log
path=./logs/
rotation_time=86400 # 单位秒
max_age=604800 # 单位秒
# max_age 与 rotation_count 不可同时配置
rotation_size=32 #单位 MB
rotation_count=0

[feeyo]
uuid=你的UUID(16位)
url=http://adsb.feeyo.com/adsb/ReceiveCompressADSB.php

```

以上展现的是dump1090运行在本机的情况,你也可以按照实际情况进行填写。
Expand All @@ -55,38 +82,34 @@ url=http://adsb.feeyo.com/adsb/ReceiveCompressADSB.php
若对终端操作较为熟悉,可使用该方式。

```
Usage of ./adsb:
-conf string
conf文件位置 (default "./conf.ini")
-feeyo-url string
飞常准接口地址 (default "https://adsb.feeyo.com/adsb/ReceiveCompressADSB.php")
-ip string
dump1090服务IP (default "127.0.0.1")
-port string
dump1090服务端口 (default "30003")
-use-file
是否使用conf文件作为配置来源 (default true)
-uuid string
UUID 16位
Usage of /adsb:
--conf string 配置文件位置 (default "./config.ini")
--dump1090.host string dump1090服务地址 (default "127.0.0.1")
--dump1090.port int dump1090服务端口 (default 30003)
--feeyo.url string 飞常准上传接口 (建议保留默认) (default "http://adsb.feeyo.com/adsb/ReceiveCompressADSB.php")
--feeyo.uuid string 设备UUID
--log.file string 日志存储文件 (default "feeyo-adsb-golang.log")
--log.level string 日志等级 (default "info")
--log.max_age int 日志最大保留时间 单位秒 (default 604800)
--log.path string 日志存储路径 (default "./logs/")
--log.rotation_count uint 日志轮转个数 (max_age 与 rotation_count 不可同时配置)
--log.rotation_size int 日志轮转大小 单位MB (为嵌入式设备设计) (default 10)
--log.rotation_time int 日志轮转时间 单位秒 (default 86400)
```

## TODO
- 统计、集成地图
- 集成部分dump1090功能
- webhook


## 其他

如果使用树莓派加RTL2832为主控的电视棒,建议您前往([飞常准ADSB](https://flightadsb.variflight.com/))

使用官方ADSB脚本,或者前往([FEEYO-Adsb](https://github.com/dextercai/FEEYO-Adsb)),项目内有一份相同的官方脚本。

如果使用其他Linux发行版,可参考下面列出的相关资料,手动移植,或者使用本项目。
## 以下内容不再适用于2.0版本

~~如果使用其他Linux发行版,可参考下面列出的相关资料,手动移植,或者使用本项目。~~

飞常准自建 ADS-B Windows 上传方案
https://blog.dextercai.com/archives/78.html
~~飞常准自建 ADS-B Windows 上传方案~~
~~https://blog.dextercai.com/archives/78.html~~

在 Arch Linux 下安装飞常准上传套件
https://blog.dextercai.com/archives/45.html
~~在 Arch Linux 下安装飞常准上传套件~~
~~https://blog.dextercai.com/archives/45.html~~

120 changes: 0 additions & 120 deletions adsb.go

This file was deleted.

4 changes: 3 additions & 1 deletion ci/makefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,10 @@ GOBUILD=CGO_ENABLED=0 go build -trimpath -ldflags '-X "dextercai.com/feeyo-adsb-
-X "dextercai.com/feeyo-adsb-golang/constant.BuildTime=$(BUILDTIME)" \
-w -s -buildid='

CMD_ADSB_PATH=./cmd/adsb

all: docker # Most used

docker:
$(GOBUILD) -o $(BINDIR)/$(NAME)
$(GOBUILD) -o $(BINDIR)/$(NAME) $(CMD_ADSB_PATH)

59 changes: 59 additions & 0 deletions cmd/adsb/adsb.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
package main

import (
"context"
"dextercai.com/feeyo-adsb-golang/conf"
"dextercai.com/feeyo-adsb-golang/constant"
"dextercai.com/feeyo-adsb-golang/core"
"dextercai.com/feeyo-adsb-golang/log"
"os"
"os/signal"
"sync"
)

func main() {
log.Logger.Warnf("github.com/dextercai/feeyo-adsb-golang")
log.Logger.Warnf("Version: %s, BuildTime: %s", constant.Version, constant.BuildTime)
log.Logger.Warnf("根据《中华人民共和国国家安全法》第七十七条;《中华人民共和国无线电管理条例》第五十五条、七十五条。")
log.Logger.Warnf("任何单位或者个人不得向境外组织或者个人提供涉及国家安全的境内电波参数资料")

conf.InitConfig()
currentConfig := conf.ReadConfig()
log.InitLog(currentConfig.LogLevel, currentConfig.LogPath, currentConfig.LogFile,
currentConfig.LogRotationTime, currentConfig.LogMaxAge, currentConfig.LogRotationSize, currentConfig.LogRotationCount)
log.Logger.Debugf("配置读取: %#v", currentConfig)

log.Logger.Warnf("将使用UUID: %s", currentConfig.FeeyoUUID)

wg := sync.WaitGroup{}
ctx := context.Background()
sender := core.NewFeeyoCompressSender(ctx, log.Logger.WithField("scope", "feeyo-sender"), currentConfig.FeeyoUUID, currentConfig.FeeyoUrl)

wg.Add(1)
go func() {
sender.Run()
wg.Done()
}()

receiver := core.NewDump1090Receiver(ctx, currentConfig.Dump1090Host,
currentConfig.Dump1090Port,
8192,
log.Logger.WithField("scope", "dump1090-receiver"), sender.GetSendChan(),
)
wg.Add(1)
go func() {
receiver.Run()
wg.Done()
}()

quit := make(chan os.Signal)
signal.Notify(quit, os.Kill, os.Interrupt)

sig := <-quit
log.Logger.WithField("scope", "process").Infof("收到信号: %s", sig.String())

receiver.Stop()
sender.Stop()
wg.Wait()
log.Logger.WithField("scope", "process").Info("按预期关闭")
}
Loading