Merge branch 'develop' of gitee.com:w1ndyb0y/tele-recv into develop
This commit is contained in:
+6
-4
@@ -14,7 +14,7 @@ clone:
|
|||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: build
|
- name: build
|
||||||
image: reg.int.it2000.com.cn/library/golang:1.15.6-buster
|
image: reg.int.it2000.com.cn/library/golang-cross:1.15.6-buster
|
||||||
volumes:
|
volumes:
|
||||||
- name: deps
|
- name: deps
|
||||||
path: /go
|
path: /go
|
||||||
@@ -22,7 +22,9 @@ steps:
|
|||||||
GO111MODULE: on
|
GO111MODULE: on
|
||||||
GOPROXY: https://goproxy.io
|
GOPROXY: https://goproxy.io
|
||||||
commands:
|
commands:
|
||||||
- go build -o tele-recv-linux
|
- OOS=linux GOARCH=amd64 CGO_ENABLED=1 go build -o tele-recv-linux
|
||||||
|
- GOOS=windows GOARCH=amd64 CGO_ENABLED=1 CXX=x86_64-w64-mingw32-g++ CC=x86_64-w64-mingw32-gcc go build -o tele-recv-win64.exe
|
||||||
|
- tar cvzf tele-recv-0.0.9.tar.gz tele-recv-linux tele-recv-win64.exe telegram.yaml
|
||||||
|
|
||||||
- name: release
|
- name: release
|
||||||
image: plugins/gitea-release
|
image: plugins/gitea-release
|
||||||
@@ -32,9 +34,9 @@ steps:
|
|||||||
settings:
|
settings:
|
||||||
api_key: fe1e1a8dd77de7452a3f473984c7ac6fe6c5abaf
|
api_key: fe1e1a8dd77de7452a3f473984c7ac6fe6c5abaf
|
||||||
base_url: https://gitea.int.it2000.com.cn
|
base_url: https://gitea.int.it2000.com.cn
|
||||||
title: 0.0.1
|
title: 0.0.9
|
||||||
files:
|
files:
|
||||||
- tele-recv-linux
|
- tele-recv-0.0.8.tar.gz
|
||||||
checksum:
|
checksum:
|
||||||
- sha256
|
- sha256
|
||||||
when:
|
when:
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
tty*
|
tty*
|
||||||
telegram.db
|
telegram.db
|
||||||
.idea
|
.idea
|
||||||
|
log_*
|
||||||
@@ -1 +1,64 @@
|
|||||||
### 电报接收
|
# 电报接收
|
||||||
|
[](http://d2.int.it2000.com.cn/airport/tele-recv)
|
||||||
|
|
||||||
|
机场串口电报数据缓存程序。从串口读取电报,保存,等待处理程序处理
|
||||||
|
|
||||||
|
## 下载
|
||||||
|
|
||||||
|
下载发布版本 [release](https://gitea.int.it2000.com.cn/airport/tele-recv/releases)
|
||||||
|
|
||||||
|
## 安装
|
||||||
|
|
||||||
|
解压下载文件 tele-recv-XXX.tag.gz
|
||||||
|
|
||||||
|
如果是linux
|
||||||
|
|
||||||
|
```Shell
|
||||||
|
tar xzvf tele-recv-XXX.tar.gz
|
||||||
|
```
|
||||||
|
|
||||||
|
文件包中包含两个可执行文件和一个.yaml的配置文件
|
||||||
|
|
||||||
|
tele-recv-linux: linux 可执行文件
|
||||||
|
tele-recv-win64.exe: windows 64位可执行文件
|
||||||
|
|
||||||
|
### 配置
|
||||||
|
|
||||||
|
| 选项 | 含义 | 取值 | 例子 |
|
||||||
|
|------- |---------------------|-----------------|------------------------|
|
||||||
|
|device | 串口设备名称 | ttyS1 | win: COM1 linux: ttyS1 |
|
||||||
|
|baudrate| 波特率 | 9600 | 19200,38400 .... |
|
||||||
|
|lograw | 是否向控制台输出通讯内容| ture | true/false |
|
||||||
|
|file | sqlite 文件名 | telegram.db | tele.db |
|
||||||
|
|init | 是否新建电报数据库 | true | true/false |
|
||||||
|
|address | 本地处理监听端口 | 127.0.0.1:6000 | |
|
||||||
|
|
||||||
|
### 测试环境
|
||||||
|
|
||||||
|
linux:
|
||||||
|
```Shell
|
||||||
|
./tele-recv-linux test
|
||||||
|
```
|
||||||
|
|
||||||
|
windows:
|
||||||
|
```Shell
|
||||||
|
tele-recv-win64.exe test
|
||||||
|
```
|
||||||
|
|
||||||
|
测试运行的环境是否能正确开始串口设备,以及初始化数据库
|
||||||
|
|
||||||
|
### 开始接收电报
|
||||||
|
|
||||||
|
linux:
|
||||||
|
```Shell
|
||||||
|
./tele-recv-linux start
|
||||||
|
```
|
||||||
|
|
||||||
|
windows:
|
||||||
|
```Shell
|
||||||
|
tele-recv-win64.exe start
|
||||||
|
```
|
||||||
|
|
||||||
|
开始从串口设备读取数据,并开启TCP服务等待处理程序连接。
|
||||||
|
如果没有处理程序,电报则保存在本地数据库中。
|
||||||
|
等到处理程序连上端口,则把未处理电报以此发送给处理程序。
|
||||||
+60
-11
@@ -17,17 +17,24 @@ package cmd
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"github.com/spf13/cobra"
|
|
||||||
"os"
|
"os"
|
||||||
|
"time"
|
||||||
|
|
||||||
|
rotatelogs "github.com/lestrrat-go/file-rotatelogs"
|
||||||
|
"github.com/spf13/cobra"
|
||||||
|
"go.uber.org/zap"
|
||||||
|
"go.uber.org/zap/zapcore"
|
||||||
|
|
||||||
"github.com/spf13/viper"
|
"github.com/spf13/viper"
|
||||||
|
"it2000.com.cn/tele-recv/utils"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
const ModeName = "TELEGRAM_MODE"
|
||||||
|
|
||||||
var (
|
var (
|
||||||
cfgFile string
|
cfgFile string
|
||||||
device string
|
device string
|
||||||
baudrate int
|
baudrate int
|
||||||
bytesize byte
|
|
||||||
lograw bool
|
lograw bool
|
||||||
|
|
||||||
dbFile string
|
dbFile string
|
||||||
@@ -45,6 +52,10 @@ Read the telegram from `,
|
|||||||
// has an action associated with it:
|
// has an action associated with it:
|
||||||
// Run: func(cmd *cobra.Command, args []string) { },
|
// Run: func(cmd *cobra.Command, args []string) { },
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Mode = os.Getenv(ModeName)
|
||||||
|
|
||||||
|
logger *zap.Logger
|
||||||
)
|
)
|
||||||
|
|
||||||
// Execute adds all child commands to the root command and sets flags appropriately.
|
// Execute adds all child commands to the root command and sets flags appropriately.
|
||||||
@@ -67,6 +78,12 @@ func init() {
|
|||||||
// Cobra also supports local flags, which will only run
|
// Cobra also supports local flags, which will only run
|
||||||
// when this action is called directly.
|
// when this action is called directly.
|
||||||
rootCmd.Flags().BoolP("toggle", "t", false, "Help message for toggle")
|
rootCmd.Flags().BoolP("toggle", "t", false, "Help message for toggle")
|
||||||
|
|
||||||
|
initLog()
|
||||||
|
defer logger.Sync()
|
||||||
|
// l = logger.Sugar()
|
||||||
|
utils.Log = logger
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// initConfig reads in config file and ENV variables if set.
|
// initConfig reads in config file and ENV variables if set.
|
||||||
@@ -75,13 +92,6 @@ func initConfig() {
|
|||||||
// Use config file from the flag.
|
// Use config file from the flag.
|
||||||
viper.SetConfigFile(cfgFile)
|
viper.SetConfigFile(cfgFile)
|
||||||
} else {
|
} else {
|
||||||
// Find home directory.
|
|
||||||
//home, err := os.Open(".")
|
|
||||||
//if err != nil {
|
|
||||||
// fmt.Println(err)
|
|
||||||
// os.Exit(1)
|
|
||||||
//}
|
|
||||||
|
|
||||||
// Search config in home directory with name ".tele-recv" (without extension).
|
// Search config in home directory with name ".tele-recv" (without extension).
|
||||||
viper.AddConfigPath(".")
|
viper.AddConfigPath(".")
|
||||||
viper.SetConfigName("telegram")
|
viper.SetConfigName("telegram")
|
||||||
@@ -91,13 +101,52 @@ func initConfig() {
|
|||||||
|
|
||||||
// If a config file is found, read it in.
|
// If a config file is found, read it in.
|
||||||
if err := viper.ReadInConfig(); err == nil {
|
if err := viper.ReadInConfig(); err == nil {
|
||||||
fmt.Println("Using config file:", viper.ConfigFileUsed())
|
// fmt.Println("Using config file:", viper.ConfigFileUsed())
|
||||||
|
logger.Info("Using config file ", zap.String("path", viper.ConfigFileUsed()))
|
||||||
device = viper.GetString("serial.device")
|
device = viper.GetString("serial.device")
|
||||||
baudrate = viper.GetInt("serial.baudrate")
|
baudrate = viper.GetInt("serial.baudrate")
|
||||||
bytesize = byte(viper.GetInt("serial.bytesize"))
|
|
||||||
lograw = viper.GetBool("serial.lograw")
|
lograw = viper.GetBool("serial.lograw")
|
||||||
dbFile = viper.GetString("sqlite.file")
|
dbFile = viper.GetString("sqlite.file")
|
||||||
dbInit = viper.GetBool("sqlite.init")
|
dbInit = viper.GetBool("sqlite.init")
|
||||||
socketAddress = viper.GetString("socket.address")
|
socketAddress = viper.GetString("socket.address")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
func initLog() {
|
||||||
|
logFile := "./logs/telegram-%Y-%m-%d-%H.log"
|
||||||
|
rotator, err := rotatelogs.New(
|
||||||
|
logFile,
|
||||||
|
rotatelogs.WithMaxAge(60*24*time.Hour),
|
||||||
|
rotatelogs.WithRotationTime(time.Hour))
|
||||||
|
if err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
rawFile := "./logs/raw-%Y-%m-%d-%H.txt"
|
||||||
|
utils.RawLog, err = rotatelogs.New(
|
||||||
|
rawFile,
|
||||||
|
rotatelogs.WithMaxAge(60*24*time.Hour),
|
||||||
|
rotatelogs.WithRotationTime(time.Hour))
|
||||||
|
if err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
filePriority := zap.LevelEnablerFunc(func(lvl zapcore.Level) bool {
|
||||||
|
return lvl >= zapcore.DebugLevel
|
||||||
|
})
|
||||||
|
|
||||||
|
stdoutPriority := zap.LevelEnablerFunc(func(lvl zapcore.Level) bool {
|
||||||
|
return lvl >= zapcore.InfoLevel
|
||||||
|
})
|
||||||
|
|
||||||
|
encoder := zapcore.NewConsoleEncoder(zap.NewDevelopmentEncoderConfig())
|
||||||
|
|
||||||
|
core := zapcore.NewTee(
|
||||||
|
zapcore.NewCore(encoder, zapcore.Lock(os.Stdout), stdoutPriority),
|
||||||
|
zapcore.NewCore(encoder, zapcore.AddSync(rotator), filePriority),
|
||||||
|
)
|
||||||
|
|
||||||
|
logger = zap.New(core)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
+15
-14
@@ -17,11 +17,11 @@ package cmd
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"log"
|
|
||||||
"os"
|
"os"
|
||||||
"os/signal"
|
"os/signal"
|
||||||
"syscall"
|
"syscall"
|
||||||
|
|
||||||
|
"go.uber.org/zap"
|
||||||
"it2000.com.cn/tele-recv/utils"
|
"it2000.com.cn/tele-recv/utils"
|
||||||
|
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
@@ -70,8 +70,7 @@ func start() {
|
|||||||
// and then notify the program that it can finish.
|
// and then notify the program that it can finish.
|
||||||
go func() {
|
go func() {
|
||||||
sig := <-sigs
|
sig := <-sigs
|
||||||
fmt.Println()
|
logger.Info("got ", zap.Any("signal", sig))
|
||||||
fmt.Println(sig)
|
|
||||||
utils.ServerRunning = false
|
utils.ServerRunning = false
|
||||||
utils.StopSocketServer()
|
utils.StopSocketServer()
|
||||||
done <- true
|
done <- true
|
||||||
@@ -80,27 +79,29 @@ func start() {
|
|||||||
// The program will wait here until it gets the
|
// The program will wait here until it gets the
|
||||||
// expected signal (as indicated by the goroutine
|
// expected signal (as indicated by the goroutine
|
||||||
// above sending a value on `done`) and then exit.
|
// above sending a value on `done`) and then exit.
|
||||||
fmt.Println("awaiting signal")
|
logger.Info("awaiting signal")
|
||||||
_ = utils.InitDb(dbFile, dbInit)
|
_ = utils.InitDb(dbFile, dbInit)
|
||||||
go utils.Listen(socketAddress)
|
go utils.Listen(socketAddress)
|
||||||
for utils.ServerRunning {
|
for utils.ServerRunning {
|
||||||
if !utils.IsPortOpen() {
|
if !utils.IsPortOpen() {
|
||||||
log.Println("try to open port")
|
logger.Info("try to open port")
|
||||||
err := utils.OpenPort(device, baudrate, bytesize)
|
err := utils.OpenPort(device, baudrate)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatal("error in open serial port ", err)
|
logger.Fatal("error in open serial port ", zap.Error(err))
|
||||||
}
|
}
|
||||||
log.Println("starting read")
|
logger.Info("starting read")
|
||||||
}
|
}
|
||||||
buffer, count := utils.ReadPort()
|
buffer, err := utils.ReadPort()
|
||||||
if count > 0 {
|
if err == nil {
|
||||||
if lograw {
|
if lograw && len(buffer) > 0 {
|
||||||
log.Print(string(buffer))
|
fmt.Println(buffer)
|
||||||
|
}
|
||||||
|
if utils.Append(buffer) {
|
||||||
|
fmt.Println()
|
||||||
}
|
}
|
||||||
utils.Append(buffer)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
<-done
|
<-done
|
||||||
fmt.Println("exiting")
|
logger.Info("exiting")
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
+2
-3
@@ -18,7 +18,6 @@ package cmd
|
|||||||
import (
|
import (
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
"it2000.com.cn/tele-recv/utils"
|
"it2000.com.cn/tele-recv/utils"
|
||||||
"log"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// testCmd represents the test command
|
// testCmd represents the test command
|
||||||
@@ -34,8 +33,8 @@ Test load sqlite database and init table`,
|
|||||||
}
|
}
|
||||||
|
|
||||||
func test() {
|
func test() {
|
||||||
log.Println("Testing environment")
|
logger.Info("Testing environment")
|
||||||
_ = utils.OpenPort(device, baudrate, bytesize)
|
_ = utils.OpenPort(device, baudrate)
|
||||||
|
|
||||||
err := utils.InitDb(dbFile, dbInit)
|
err := utils.InitDb(dbFile, dbInit)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|||||||
@@ -3,7 +3,12 @@ module it2000.com.cn/tele-recv
|
|||||||
go 1.15
|
go 1.15
|
||||||
|
|
||||||
require (
|
require (
|
||||||
|
github.com/argandas/serial v0.0.0-20160316175758-889a5ad85462
|
||||||
|
github.com/fastly/go-utils v0.0.0-20180712184237-d95a45783239 // indirect
|
||||||
github.com/fsnotify/fsnotify v1.4.9 // indirect
|
github.com/fsnotify/fsnotify v1.4.9 // indirect
|
||||||
|
github.com/jehiah/go-strftime v0.0.0-20171201141054-1d33003b3869 // indirect
|
||||||
|
github.com/lestrrat-go/file-rotatelogs v2.4.0+incompatible
|
||||||
|
github.com/lestrrat-go/strftime v1.0.3 // indirect
|
||||||
github.com/magiconair/properties v1.8.4 // indirect
|
github.com/magiconair/properties v1.8.4 // indirect
|
||||||
github.com/mattn/go-sqlite3 v1.14.5
|
github.com/mattn/go-sqlite3 v1.14.5
|
||||||
github.com/mitchellh/mapstructure v1.4.0 // indirect
|
github.com/mitchellh/mapstructure v1.4.0 // indirect
|
||||||
@@ -13,7 +18,9 @@ require (
|
|||||||
github.com/spf13/cobra v1.1.1
|
github.com/spf13/cobra v1.1.1
|
||||||
github.com/spf13/jwalterweatherman v1.1.0 // indirect
|
github.com/spf13/jwalterweatherman v1.1.0 // indirect
|
||||||
github.com/spf13/viper v1.7.1
|
github.com/spf13/viper v1.7.1
|
||||||
github.com/tarm/serial v0.0.0-20180830185346-98f6abe2eb07
|
github.com/tebeka/strftime v0.1.5 // indirect
|
||||||
|
go.uber.org/multierr v1.6.0 // indirect
|
||||||
|
go.uber.org/zap v1.16.0
|
||||||
golang.org/x/sys v0.0.0-20201214210602-f9fddec55a1e // indirect
|
golang.org/x/sys v0.0.0-20201214210602-f9fddec55a1e // indirect
|
||||||
golang.org/x/text v0.3.4 // indirect
|
golang.org/x/text v0.3.4 // indirect
|
||||||
gopkg.in/ini.v1 v1.62.0 // indirect
|
gopkg.in/ini.v1 v1.62.0 // indirect
|
||||||
|
|||||||
@@ -11,11 +11,14 @@ cloud.google.com/go/firestore v1.1.0/go.mod h1:ulACoGHTpvq5r8rxGJ4ddJZBZqakUQqCl
|
|||||||
cloud.google.com/go/pubsub v1.0.1/go.mod h1:R0Gpsv3s54REJCy4fxDixWD93lHJMoZTyQ2kNxGRt3I=
|
cloud.google.com/go/pubsub v1.0.1/go.mod h1:R0Gpsv3s54REJCy4fxDixWD93lHJMoZTyQ2kNxGRt3I=
|
||||||
cloud.google.com/go/storage v1.0.0/go.mod h1:IhtSnM/ZTZV8YYJWCY8RULGVqBDmpoyjwiyrjsg+URw=
|
cloud.google.com/go/storage v1.0.0/go.mod h1:IhtSnM/ZTZV8YYJWCY8RULGVqBDmpoyjwiyrjsg+URw=
|
||||||
dmitri.shuralyov.com/gpu/mtl v0.0.0-20190408044501-666a987793e9/go.mod h1:H6x//7gZCb22OMCxBHrMx7a5I7Hp++hsVxbQ4BYO7hU=
|
dmitri.shuralyov.com/gpu/mtl v0.0.0-20190408044501-666a987793e9/go.mod h1:H6x//7gZCb22OMCxBHrMx7a5I7Hp++hsVxbQ4BYO7hU=
|
||||||
|
github.com/BurntSushi/toml v0.3.1 h1:WXkYYl6Yr3qBf1K79EBnL4mak0OimBfB0XUf9Vl28OQ=
|
||||||
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
|
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
|
||||||
github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo=
|
github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo=
|
||||||
github.com/OneOfOne/xxhash v1.2.2/go.mod h1:HSdplMjZKSmBqAxg5vPj2TmRDmfkzw+cTzAElWljhcU=
|
github.com/OneOfOne/xxhash v1.2.2/go.mod h1:HSdplMjZKSmBqAxg5vPj2TmRDmfkzw+cTzAElWljhcU=
|
||||||
github.com/alecthomas/template v0.0.0-20160405071501-a0175ee3bccc/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc=
|
github.com/alecthomas/template v0.0.0-20160405071501-a0175ee3bccc/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc=
|
||||||
github.com/alecthomas/units v0.0.0-20151022065526-2efee857e7cf/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0=
|
github.com/alecthomas/units v0.0.0-20151022065526-2efee857e7cf/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0=
|
||||||
|
github.com/argandas/serial v0.0.0-20160316175758-889a5ad85462 h1:Hl0NBpA4cJvqHyrm3mhAb+g9bzimPr6pmb9JhfV5PhA=
|
||||||
|
github.com/argandas/serial v0.0.0-20160316175758-889a5ad85462/go.mod h1:IPXZreh+vkWR8Dr8jwAZJo/L9Kpsw9zSkwYFEJ7eVro=
|
||||||
github.com/armon/circbuf v0.0.0-20150827004946-bbbad097214e/go.mod h1:3U/XgcO3hCbHZ8TKRvWD2dDTCfh9M9ya+I9JpbB7O8o=
|
github.com/armon/circbuf v0.0.0-20150827004946-bbbad097214e/go.mod h1:3U/XgcO3hCbHZ8TKRvWD2dDTCfh9M9ya+I9JpbB7O8o=
|
||||||
github.com/armon/go-metrics v0.0.0-20180917152333-f0300d1749da/go.mod h1:Q73ZrmVTwzkszR9V5SSuryQ31EELlFMUz1kKyl939pY=
|
github.com/armon/go-metrics v0.0.0-20180917152333-f0300d1749da/go.mod h1:Q73ZrmVTwzkszR9V5SSuryQ31EELlFMUz1kKyl939pY=
|
||||||
github.com/armon/go-radix v0.0.0-20180808171621-7fddfc383310/go.mod h1:ufUuZ+zHj4x4TnLV4JWEpy2hxWSpsRywHrMgIH9cCH8=
|
github.com/armon/go-radix v0.0.0-20180808171621-7fddfc383310/go.mod h1:ufUuZ+zHj4x4TnLV4JWEpy2hxWSpsRywHrMgIH9cCH8=
|
||||||
@@ -36,6 +39,8 @@ github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c
|
|||||||
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||||
github.com/dgrijalva/jwt-go v3.2.0+incompatible/go.mod h1:E3ru+11k8xSBh+hMPgOLZmtrrCbhqsmaPHjLKYnJCaQ=
|
github.com/dgrijalva/jwt-go v3.2.0+incompatible/go.mod h1:E3ru+11k8xSBh+hMPgOLZmtrrCbhqsmaPHjLKYnJCaQ=
|
||||||
github.com/dgryski/go-sip13 v0.0.0-20181026042036-e10d5fee7954/go.mod h1:vAd38F8PWV+bWy6jNmig1y/TA+kYO4g3RSRF0IAv0no=
|
github.com/dgryski/go-sip13 v0.0.0-20181026042036-e10d5fee7954/go.mod h1:vAd38F8PWV+bWy6jNmig1y/TA+kYO4g3RSRF0IAv0no=
|
||||||
|
github.com/fastly/go-utils v0.0.0-20180712184237-d95a45783239 h1:Ghm4eQYC0nEPnSJdVkTrXpu9KtoVCSo1hg7mtI7G9KU=
|
||||||
|
github.com/fastly/go-utils v0.0.0-20180712184237-d95a45783239/go.mod h1:Gdwt2ce0yfBxPvZrHkprdPPTTS3N5rwmLE8T22KBXlw=
|
||||||
github.com/fatih/color v1.7.0/go.mod h1:Zm6kSWBoL9eyXnKyktHP6abPY2pDugNf5KwzbycvMj4=
|
github.com/fatih/color v1.7.0/go.mod h1:Zm6kSWBoL9eyXnKyktHP6abPY2pDugNf5KwzbycvMj4=
|
||||||
github.com/fsnotify/fsnotify v1.4.7 h1:IXs+QLmnXW2CcXuY+8Mzv/fWEsPGWxqefPtCP5CnV9I=
|
github.com/fsnotify/fsnotify v1.4.7 h1:IXs+QLmnXW2CcXuY+8Mzv/fWEsPGWxqefPtCP5CnV9I=
|
||||||
github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo=
|
github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo=
|
||||||
@@ -96,6 +101,9 @@ github.com/hashicorp/memberlist v0.1.3/go.mod h1:ajVTdAv/9Im8oMAAj5G31PhhMCZJV2p
|
|||||||
github.com/hashicorp/serf v0.8.2/go.mod h1:6hOLApaqBFA1NXqRQAsxw9QxuDEvNxSQRwA/JwenrHc=
|
github.com/hashicorp/serf v0.8.2/go.mod h1:6hOLApaqBFA1NXqRQAsxw9QxuDEvNxSQRwA/JwenrHc=
|
||||||
github.com/inconshreveable/mousetrap v1.0.0 h1:Z8tu5sraLXCXIcARxBp/8cbvlwVa7Z1NHg9XEKhtSvM=
|
github.com/inconshreveable/mousetrap v1.0.0 h1:Z8tu5sraLXCXIcARxBp/8cbvlwVa7Z1NHg9XEKhtSvM=
|
||||||
github.com/inconshreveable/mousetrap v1.0.0/go.mod h1:PxqpIevigyE2G7u3NXJIT2ANytuPF1OarO4DADm73n8=
|
github.com/inconshreveable/mousetrap v1.0.0/go.mod h1:PxqpIevigyE2G7u3NXJIT2ANytuPF1OarO4DADm73n8=
|
||||||
|
github.com/jehiah/go-strftime v0.0.0-20171201141054-1d33003b3869 h1:IPJ3dvxmJ4uczJe5YQdrYB16oTJlGSC/OyZDqUk9xX4=
|
||||||
|
github.com/jehiah/go-strftime v0.0.0-20171201141054-1d33003b3869/go.mod h1:cJ6Cj7dQo+O6GJNiMx+Pa94qKj+TG8ONdKHgMNIyyag=
|
||||||
|
github.com/jonboulle/clockwork v0.1.0 h1:VKV+ZcuP6l3yW9doeqz6ziZGgcynBVQO+obU0+0hcPo=
|
||||||
github.com/jonboulle/clockwork v0.1.0/go.mod h1:Ii8DK3G1RaLaWxj9trq07+26W01tbo22gdxWY5EU2bo=
|
github.com/jonboulle/clockwork v0.1.0/go.mod h1:Ii8DK3G1RaLaWxj9trq07+26W01tbo22gdxWY5EU2bo=
|
||||||
github.com/json-iterator/go v1.1.6/go.mod h1:+SdeFBvtyEkXs7REEP0seUULqWtbJapLOCVDaaPEHmU=
|
github.com/json-iterator/go v1.1.6/go.mod h1:+SdeFBvtyEkXs7REEP0seUULqWtbJapLOCVDaaPEHmU=
|
||||||
github.com/jstemmer/go-junit-report v0.0.0-20190106144839-af01ea7f8024/go.mod h1:6v2b51hI/fHJwM22ozAgKL4VKDeJcHhJFhtBdhmNjmU=
|
github.com/jstemmer/go-junit-report v0.0.0-20190106144839-af01ea7f8024/go.mod h1:6v2b51hI/fHJwM22ozAgKL4VKDeJcHhJFhtBdhmNjmU=
|
||||||
@@ -112,6 +120,12 @@ github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORN
|
|||||||
github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
|
github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
|
||||||
github.com/kr/text v0.1.0 h1:45sCR5RtlFHMR4UwH9sdQ5TC8v0qDQCHnXt+kaKSTVE=
|
github.com/kr/text v0.1.0 h1:45sCR5RtlFHMR4UwH9sdQ5TC8v0qDQCHnXt+kaKSTVE=
|
||||||
github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
|
github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
|
||||||
|
github.com/lestrrat-go/envload v0.0.0-20180220234015-a3eb8ddeffcc h1:RKf14vYWi2ttpEmkA4aQ3j4u9dStX2t4M8UM6qqNsG8=
|
||||||
|
github.com/lestrrat-go/envload v0.0.0-20180220234015-a3eb8ddeffcc/go.mod h1:kopuH9ugFRkIXf3YoqHKyrJ9YfUFsckUU9S7B+XP+is=
|
||||||
|
github.com/lestrrat-go/file-rotatelogs v2.4.0+incompatible h1:Y6sqxHMyB1D2YSzWkLibYKgg+SwmyFU9dF2hn6MdTj4=
|
||||||
|
github.com/lestrrat-go/file-rotatelogs v2.4.0+incompatible/go.mod h1:ZQnN8lSECaebrkQytbHj4xNgtg8CR7RYXnPok8e0EHA=
|
||||||
|
github.com/lestrrat-go/strftime v1.0.3 h1:qqOPU7y+TM8Y803I8fG9c/DyKG3xH/xkng6keC1015Q=
|
||||||
|
github.com/lestrrat-go/strftime v1.0.3/go.mod h1:E1nN3pCbtMSu1yjSVeyuRFVm/U0xoR76fd03sz+Qz4g=
|
||||||
github.com/magiconair/properties v1.8.1 h1:ZC2Vc7/ZFkGmsVC9KvOjumD+G5lXy2RtTKyzRKO2BQ4=
|
github.com/magiconair/properties v1.8.1 h1:ZC2Vc7/ZFkGmsVC9KvOjumD+G5lXy2RtTKyzRKO2BQ4=
|
||||||
github.com/magiconair/properties v1.8.1/go.mod h1:PppfXfuXeibc/6YijjN8zIbojt8czPbwD3XqdrwzmxQ=
|
github.com/magiconair/properties v1.8.1/go.mod h1:PppfXfuXeibc/6YijjN8zIbojt8czPbwD3XqdrwzmxQ=
|
||||||
github.com/magiconair/properties v1.8.4 h1:8KGKTcQQGm0Kv7vEbKFErAoAOFyyacLStRtQSeYtvkY=
|
github.com/magiconair/properties v1.8.4 h1:8KGKTcQQGm0Kv7vEbKFErAoAOFyyacLStRtQSeYtvkY=
|
||||||
@@ -144,6 +158,7 @@ github.com/pelletier/go-toml v1.2.0/go.mod h1:5z9KED0ma1S8pY6P1sdut58dfprrGBbd/9
|
|||||||
github.com/pelletier/go-toml v1.8.1 h1:1Nf83orprkJyknT6h7zbuEGUEjcyVlCxSUGTENmNCRM=
|
github.com/pelletier/go-toml v1.8.1 h1:1Nf83orprkJyknT6h7zbuEGUEjcyVlCxSUGTENmNCRM=
|
||||||
github.com/pelletier/go-toml v1.8.1/go.mod h1:T2/BmBdy8dvIRq1a/8aqjN41wvWlN4lrapLU/GW4pbc=
|
github.com/pelletier/go-toml v1.8.1/go.mod h1:T2/BmBdy8dvIRq1a/8aqjN41wvWlN4lrapLU/GW4pbc=
|
||||||
github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
|
github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
|
||||||
|
github.com/pkg/errors v0.8.1 h1:iURUrRGxPUNPdy5/HRSm+Yj6okJ6UtLINN0Q9M4+h3I=
|
||||||
github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
|
github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
|
||||||
github.com/pkg/sftp v1.10.1/go.mod h1:lYOWFsE0bwd1+KfKJaKeuokY15vzFx25BLbzYYoAxZI=
|
github.com/pkg/sftp v1.10.1/go.mod h1:lYOWFsE0bwd1+KfKJaKeuokY15vzFx25BLbzYYoAxZI=
|
||||||
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
|
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
|
||||||
@@ -201,16 +216,27 @@ github.com/stretchr/testify v1.4.0 h1:2E4SXV/wtOkTonXsotYi4li6zVWxYlZuYNCXe9XRJy
|
|||||||
github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4=
|
github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4=
|
||||||
github.com/subosito/gotenv v1.2.0 h1:Slr1R9HxAlEKefgq5jn9U+DnETlIUa6HfgEzj0g5d7s=
|
github.com/subosito/gotenv v1.2.0 h1:Slr1R9HxAlEKefgq5jn9U+DnETlIUa6HfgEzj0g5d7s=
|
||||||
github.com/subosito/gotenv v1.2.0/go.mod h1:N0PQaV/YGNqwC0u51sEeR/aUtSLEXKX9iv69rRypqCw=
|
github.com/subosito/gotenv v1.2.0/go.mod h1:N0PQaV/YGNqwC0u51sEeR/aUtSLEXKX9iv69rRypqCw=
|
||||||
github.com/tarm/serial v0.0.0-20180830185346-98f6abe2eb07 h1:UyzmZLoiDWMRywV4DUYb9Fbt8uiOSooupjTq10vpvnU=
|
github.com/tebeka/strftime v0.1.5 h1:1NQKN1NiQgkqd/2moD6ySP/5CoZQsKa1d3ZhJ44Jpmg=
|
||||||
github.com/tarm/serial v0.0.0-20180830185346-98f6abe2eb07/go.mod h1:kDXzergiv9cbyO7IOYJZWg1U88JhDg3PB6klq9Hg2pA=
|
github.com/tebeka/strftime v0.1.5/go.mod h1:29/OidkoWHdEKZqzyDLUyC+LmgDgdHo4WAFCDT7D/Ig=
|
||||||
github.com/tmc/grpc-websocket-proxy v0.0.0-20190109142713-0ad062ec5ee5/go.mod h1:ncp9v5uamzpCO7NfCPTXjqaC+bZgJeR0sMTm6dMHP7U=
|
github.com/tmc/grpc-websocket-proxy v0.0.0-20190109142713-0ad062ec5ee5/go.mod h1:ncp9v5uamzpCO7NfCPTXjqaC+bZgJeR0sMTm6dMHP7U=
|
||||||
github.com/xiang90/probing v0.0.0-20190116061207-43a291ad63a2/go.mod h1:UETIi67q53MR2AWcXfiuqkDkRtnGDLqkBTpCHuJHxtU=
|
github.com/xiang90/probing v0.0.0-20190116061207-43a291ad63a2/go.mod h1:UETIi67q53MR2AWcXfiuqkDkRtnGDLqkBTpCHuJHxtU=
|
||||||
go.etcd.io/bbolt v1.3.2/go.mod h1:IbVyRI1SCnLcuJnV2u8VeU0CEYM7e686BmAb1XKL+uU=
|
go.etcd.io/bbolt v1.3.2/go.mod h1:IbVyRI1SCnLcuJnV2u8VeU0CEYM7e686BmAb1XKL+uU=
|
||||||
go.opencensus.io v0.21.0/go.mod h1:mSImk1erAIZhrmZN+AvHh14ztQfjbGwt4TtuofqLduU=
|
go.opencensus.io v0.21.0/go.mod h1:mSImk1erAIZhrmZN+AvHh14ztQfjbGwt4TtuofqLduU=
|
||||||
go.opencensus.io v0.22.0/go.mod h1:+kGneAE2xo2IficOXnaByMWTGM9T73dGwxeWcUqIpI8=
|
go.opencensus.io v0.22.0/go.mod h1:+kGneAE2xo2IficOXnaByMWTGM9T73dGwxeWcUqIpI8=
|
||||||
go.uber.org/atomic v1.4.0/go.mod h1:gD2HeocX3+yG+ygLZcrzQJaqmWj9AIm7n08wl/qW/PE=
|
go.uber.org/atomic v1.4.0/go.mod h1:gD2HeocX3+yG+ygLZcrzQJaqmWj9AIm7n08wl/qW/PE=
|
||||||
|
go.uber.org/atomic v1.6.0 h1:Ezj3JGmsOnG1MoRWQkPBsKLe9DwWD9QeXzTRzzldNVk=
|
||||||
|
go.uber.org/atomic v1.6.0/go.mod h1:sABNBOSYdrvTF6hTgEIbc7YasKWGhgEQZyfxyTvoXHQ=
|
||||||
|
go.uber.org/atomic v1.7.0 h1:ADUqmZGgLDDfbSL9ZmPxKTybcoEYHgpYfELNoN+7hsw=
|
||||||
|
go.uber.org/atomic v1.7.0/go.mod h1:fEN4uk6kAWBTFdckzkM89CLk9XfWZrxpCo0nPH17wJc=
|
||||||
go.uber.org/multierr v1.1.0/go.mod h1:wR5kodmAFQ0UK8QlbwjlSNy0Z68gJhDJUG5sjR94q/0=
|
go.uber.org/multierr v1.1.0/go.mod h1:wR5kodmAFQ0UK8QlbwjlSNy0Z68gJhDJUG5sjR94q/0=
|
||||||
|
go.uber.org/multierr v1.5.0 h1:KCa4XfM8CWFCpxXRGok+Q0SS/0XBhMDbHHGABQLvD2A=
|
||||||
|
go.uber.org/multierr v1.5.0/go.mod h1:FeouvMocqHpRaaGuG9EjoKcStLC43Zu/fmqdUMPcKYU=
|
||||||
|
go.uber.org/multierr v1.6.0 h1:y6IPFStTAIT5Ytl7/XYmHvzXQ7S3g/IeZW9hyZ5thw4=
|
||||||
|
go.uber.org/multierr v1.6.0/go.mod h1:cdWPpRnG4AhwMwsgIHip0KRBQjJy5kYEpYjJxpXp9iU=
|
||||||
|
go.uber.org/tools v0.0.0-20190618225709-2cfd321de3ee/go.mod h1:vJERXedbb3MVM5f9Ejo0C68/HhF8uaILCdgjnY+goOA=
|
||||||
go.uber.org/zap v1.10.0/go.mod h1:vwi/ZaCAaUcBkycHslxD9B2zi4UTXhF60s6SWpuDF0Q=
|
go.uber.org/zap v1.10.0/go.mod h1:vwi/ZaCAaUcBkycHslxD9B2zi4UTXhF60s6SWpuDF0Q=
|
||||||
|
go.uber.org/zap v1.16.0 h1:uFRZXykJGK9lLY4HtgSw44DnIcAM+kRBP7x5m+NpAOM=
|
||||||
|
go.uber.org/zap v1.16.0/go.mod h1:MA8QOfq0BHJwdXa996Y4dYkAqRKB8/1K1QMMZVaNZjQ=
|
||||||
golang.org/x/crypto v0.0.0-20180904163835-0709b304e793/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4=
|
golang.org/x/crypto v0.0.0-20180904163835-0709b304e793/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4=
|
||||||
golang.org/x/crypto v0.0.0-20181029021203-45a5f77698d3/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4=
|
golang.org/x/crypto v0.0.0-20181029021203-45a5f77698d3/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4=
|
||||||
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
|
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
|
||||||
@@ -230,6 +256,7 @@ golang.org/x/lint v0.0.0-20190301231843-5614ed5bae6f/go.mod h1:UVdnD1Gm6xHRNCYTk
|
|||||||
golang.org/x/lint v0.0.0-20190313153728-d0100b6bd8b3/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc=
|
golang.org/x/lint v0.0.0-20190313153728-d0100b6bd8b3/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc=
|
||||||
golang.org/x/lint v0.0.0-20190409202823-959b441ac422/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc=
|
golang.org/x/lint v0.0.0-20190409202823-959b441ac422/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc=
|
||||||
golang.org/x/lint v0.0.0-20190909230951-414d861bb4ac/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc=
|
golang.org/x/lint v0.0.0-20190909230951-414d861bb4ac/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc=
|
||||||
|
golang.org/x/lint v0.0.0-20190930215403-16217165b5de h1:5hukYrvBGR8/eNkX5mdUezrA6JiaEZDtJb9Ei+1LlBs=
|
||||||
golang.org/x/lint v0.0.0-20190930215403-16217165b5de/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc=
|
golang.org/x/lint v0.0.0-20190930215403-16217165b5de/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc=
|
||||||
golang.org/x/mobile v0.0.0-20190312151609-d3739f865fa6/go.mod h1:z+o9i4GpDbdi3rU15maQ/Ox0txvL9dWGYEHz965HBQE=
|
golang.org/x/mobile v0.0.0-20190312151609-d3739f865fa6/go.mod h1:z+o9i4GpDbdi3rU15maQ/Ox0txvL9dWGYEHz965HBQE=
|
||||||
golang.org/x/mobile v0.0.0-20190719004257-d2bd2a29d028/go.mod h1:E/iHnbuqvinMTCcRqshq8CkpyQDoeVncDDYHnLhea+o=
|
golang.org/x/mobile v0.0.0-20190719004257-d2bd2a29d028/go.mod h1:E/iHnbuqvinMTCcRqshq8CkpyQDoeVncDDYHnLhea+o=
|
||||||
@@ -299,6 +326,9 @@ golang.org/x/tools v0.0.0-20190628153133-6cdbf07be9d0/go.mod h1:/rFqwRUd4F7ZHNgw
|
|||||||
golang.org/x/tools v0.0.0-20190816200558-6889da9d5479/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
|
golang.org/x/tools v0.0.0-20190816200558-6889da9d5479/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
|
||||||
golang.org/x/tools v0.0.0-20190911174233-4f2ddba30aff/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
|
golang.org/x/tools v0.0.0-20190911174233-4f2ddba30aff/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
|
||||||
golang.org/x/tools v0.0.0-20191012152004-8de300cfc20a/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
|
golang.org/x/tools v0.0.0-20191012152004-8de300cfc20a/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
|
||||||
|
golang.org/x/tools v0.0.0-20191029041327-9cc4af7d6b2c/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
|
||||||
|
golang.org/x/tools v0.0.0-20191029190741-b9c20aec41a5/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
|
||||||
|
golang.org/x/tools v0.0.0-20191112195655-aa38f8e97acc h1:NCy3Ohtk6Iny5V/reW2Ktypo4zIpWBdRJ1uFMjBxdg8=
|
||||||
golang.org/x/tools v0.0.0-20191112195655-aa38f8e97acc/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
|
golang.org/x/tools v0.0.0-20191112195655-aa38f8e97acc/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
|
||||||
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||||
google.golang.org/api v0.4.0/go.mod h1:8k5glujaEP+g9n7WNsDg8QP6cUVNI86fCNMcbazEtwE=
|
google.golang.org/api v0.4.0/go.mod h1:8k5glujaEP+g9n7WNsDg8QP6cUVNI86fCNMcbazEtwE=
|
||||||
@@ -343,5 +373,6 @@ gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ=
|
|||||||
honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
|
honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
|
||||||
honnef.co/go/tools v0.0.0-20190106161140-3f1c8253044a/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
|
honnef.co/go/tools v0.0.0-20190106161140-3f1c8253044a/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
|
||||||
honnef.co/go/tools v0.0.0-20190418001031-e561f6794a2a/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
|
honnef.co/go/tools v0.0.0-20190418001031-e561f6794a2a/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
|
||||||
|
honnef.co/go/tools v0.0.1-2019.2.3 h1:3JgtbtFHMiCmsznwGVTUWbgGov+pVqnlf1dEJTNAXeM=
|
||||||
honnef.co/go/tools v0.0.1-2019.2.3/go.mod h1:a3bituU0lyd329TUQxRnasdCoJDkEUEAqEt0JzvZhAg=
|
honnef.co/go/tools v0.0.1-2019.2.3/go.mod h1:a3bituU0lyd329TUQxRnasdCoJDkEUEAqEt0JzvZhAg=
|
||||||
rsc.io/binaryregexp v0.2.0/go.mod h1:qTv7/COck+e2FymRvadv62gMdZztPaShugOCi3I+8D8=
|
rsc.io/binaryregexp v0.2.0/go.mod h1:qTv7/COck+e2FymRvadv62gMdZztPaShugOCi3I+8D8=
|
||||||
|
|||||||
+3
-1
@@ -1,7 +1,9 @@
|
|||||||
serial:
|
serial:
|
||||||
device: ttyS1
|
device: ttyS1
|
||||||
baudrate: 9600
|
baudrate: 9600
|
||||||
bytesize: 7
|
#bytesize: 8
|
||||||
|
# 1, 2, 15
|
||||||
|
#stopbits: 1
|
||||||
lograw: true
|
lograw: true
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
+29
-27
@@ -1,48 +1,50 @@
|
|||||||
package utils
|
package utils
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"io"
|
|
||||||
"log"
|
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/tarm/serial"
|
"github.com/argandas/serial"
|
||||||
|
"go.uber.org/zap"
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
device string
|
device string
|
||||||
baudrate int
|
baudrate int
|
||||||
bytesize byte
|
// port *serial.Port
|
||||||
port *serial.Port
|
sp *serial.SerialPort
|
||||||
portOpened = false
|
portOpened = false
|
||||||
|
Log *zap.Logger
|
||||||
)
|
)
|
||||||
|
|
||||||
func OpenPort(device string, baudrate int, bytesize byte) error {
|
const readDuration = 500 * time.Millisecond
|
||||||
log.Println("opening port device:", device, ", baudrate=", baudrate, ", bytesize=", bytesize)
|
|
||||||
config := &serial.Config{Name: device, Baud: baudrate, Size: bytesize, ReadTimeout: time.Second * 1}
|
// OpenPort open serial port
|
||||||
var err error
|
func OpenPort(device string, baudrate int) error {
|
||||||
port, err = serial.OpenPort(config)
|
Log.Info("opening serial device ",
|
||||||
if err != nil {
|
zap.String("port", device),
|
||||||
log.Fatalln("error in open serial port ", err)
|
zap.Int("baudrate", baudrate))
|
||||||
return err
|
sp = serial.New()
|
||||||
}
|
sp.EOL('\r')
|
||||||
log.Println("opened port ", port)
|
sp.Verbose = false
|
||||||
|
err := sp.Open(device, baudrate, time.Second*3)
|
||||||
|
Log.Info("open ", zap.String("device", device), zap.Error(err))
|
||||||
|
if err == nil {
|
||||||
portOpened = true
|
portOpened = true
|
||||||
return nil
|
}
|
||||||
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
func ReadPort() ([]byte, int) {
|
//ReadPort read byte array from port
|
||||||
buffer := make([]byte, 256)
|
func ReadPort() (string, error) {
|
||||||
if !ServerRunning {
|
// buffer := make([]byte, 1)
|
||||||
return buffer, 0
|
// if !ServerRunning {
|
||||||
}
|
// return buffer, 0
|
||||||
count, err := port.Read(buffer)
|
// }
|
||||||
if err != nil && err != io.EOF {
|
|
||||||
log.Println("error in read port ", err)
|
return sp.ReadLine()
|
||||||
//TODO: 3 time fail try to
|
|
||||||
}
|
|
||||||
return buffer, count
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//IsPortOpen check serial port status
|
||||||
func IsPortOpen() bool {
|
func IsPortOpen() bool {
|
||||||
return portOpened
|
return portOpened
|
||||||
}
|
}
|
||||||
|
|||||||
+14
-11
@@ -2,9 +2,10 @@ package utils
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"io"
|
"io"
|
||||||
"log"
|
|
||||||
"net"
|
"net"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"go.uber.org/zap"
|
||||||
)
|
)
|
||||||
|
|
||||||
const ServerType = "tcp"
|
const ServerType = "tcp"
|
||||||
@@ -18,26 +19,25 @@ func Listen(address string) {
|
|||||||
var err error
|
var err error
|
||||||
server, err = net.Listen(ServerType, address)
|
server, err = net.Listen(ServerType, address)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatal("error in create server ", err)
|
Log.Fatal("error in create server ", zap.Error(err))
|
||||||
}
|
}
|
||||||
defer server.Close()
|
defer server.Close()
|
||||||
log.Println("listen on ", address)
|
Log.Info("listen on ", zap.String("address", address))
|
||||||
for ServerRunning {
|
for ServerRunning {
|
||||||
conn, err := server.Accept()
|
conn, err := server.Accept()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
ServerRunning = false
|
ServerRunning = false
|
||||||
log.Fatalln("error in create connection ", err)
|
Log.Error("error in create connection ", zap.Error(err))
|
||||||
}
|
}
|
||||||
if client == nil {
|
if client == nil {
|
||||||
client = conn
|
client = conn
|
||||||
ClientReady = false
|
ClientReady = false
|
||||||
log.Println("client connected ", client.RemoteAddr())
|
Log.Info("client connected on ", zap.Any("address", client.RemoteAddr()))
|
||||||
LoadUnprocessed()
|
LoadUnprocessed()
|
||||||
} else {
|
} else {
|
||||||
log.Println("client already connected, close")
|
Log.Info("remove old client")
|
||||||
client.Close()
|
closeClient()
|
||||||
client = nil
|
client = conn
|
||||||
conn.Close()
|
|
||||||
}
|
}
|
||||||
if IsClientConnected() {
|
if IsClientConnected() {
|
||||||
connCheck()
|
connCheck()
|
||||||
@@ -47,19 +47,22 @@ func Listen(address string) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func WriteToClient(data string) error {
|
func WriteToClient(data string) error {
|
||||||
|
if client != nil {
|
||||||
_, err := client.Write([]byte(data + "\r\n"))
|
_, err := client.Write([]byte(data + "\r\n"))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Println("error in write data to client socket ", err)
|
Log.Error("error in write data to client socket ", zap.Error(err))
|
||||||
closeClient()
|
closeClient()
|
||||||
}
|
}
|
||||||
return err
|
return err
|
||||||
|
}
|
||||||
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func connCheck() bool {
|
func connCheck() bool {
|
||||||
_, err := client.Read(make([]byte, 0))
|
_, err := client.Read(make([]byte, 0))
|
||||||
if err != nil && err != io.EOF {
|
if err != nil && err != io.EOF {
|
||||||
// this connection is invalid
|
// this connection is invalid
|
||||||
log.Println("conn closed....", err)
|
Log.Error("conn closed....", zap.Error(err))
|
||||||
client = nil
|
client = nil
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|||||||
+18
-17
@@ -2,11 +2,11 @@ package utils
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"database/sql"
|
"database/sql"
|
||||||
"log"
|
|
||||||
"os"
|
"os"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
_ "github.com/mattn/go-sqlite3"
|
_ "github.com/mattn/go-sqlite3"
|
||||||
|
"go.uber.org/zap"
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
@@ -42,12 +42,12 @@ var (
|
|||||||
func getDb() *sql.DB {
|
func getDb() *sql.DB {
|
||||||
//log.Println("init database ", initTable)
|
//log.Println("init database ", initTable)
|
||||||
if initTable && !initialized {
|
if initTable && !initialized {
|
||||||
log.Println("remove database file", dbFile)
|
Log.Info("remove database ", zap.String("file", dbFile))
|
||||||
os.Remove(dbFile)
|
os.Remove(dbFile)
|
||||||
}
|
}
|
||||||
db, err := sql.Open(DbDriver, dbFile)
|
db, err := sql.Open(DbDriver, dbFile)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatal("error in open database ", err)
|
Log.Fatal("error in open database ", zap.Error(err))
|
||||||
}
|
}
|
||||||
return db
|
return db
|
||||||
}
|
}
|
||||||
@@ -60,7 +60,7 @@ func InitDb(file string, init bool) error {
|
|||||||
defer db.Close()
|
defer db.Close()
|
||||||
_, dbErr = db.Exec(TableCreate)
|
_, dbErr = db.Exec(TableCreate)
|
||||||
checkDbErr(dbErr, "error in create table")
|
checkDbErr(dbErr, "error in create table")
|
||||||
log.Println("database ", db, " initialized")
|
Log.Info("database initialized")
|
||||||
initialized = true
|
initialized = true
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
@@ -83,14 +83,14 @@ func InsertTelegram(teleString string) {
|
|||||||
checkDbErr(err, "error in insert telegram ")
|
checkDbErr(err, "error in insert telegram ")
|
||||||
isWriting = false
|
isWriting = false
|
||||||
if insertSQL == InsertOld {
|
if insertSQL == InsertOld {
|
||||||
log.Println("telegram processed ", id)
|
Log.Info("telegram processed ", zap.Int64("id", id))
|
||||||
} else {
|
} else {
|
||||||
log.Println("telegram saved ", id)
|
Log.Info("telegram saved ", zap.Int64("id", id))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func LoadUnprocessed() {
|
func LoadUnprocessed() {
|
||||||
log.Println("loading telegram")
|
Log.Info("loading telegram")
|
||||||
db := getDb()
|
db := getDb()
|
||||||
defer db.Close()
|
defer db.Close()
|
||||||
for {
|
for {
|
||||||
@@ -100,22 +100,23 @@ func LoadUnprocessed() {
|
|||||||
}
|
}
|
||||||
for _, t := range telegrams {
|
for _, t := range telegrams {
|
||||||
if WriteToClient(t.text) == nil {
|
if WriteToClient(t.text) == nil {
|
||||||
|
time.Sleep(500 * time.Millisecond)
|
||||||
processed(db, t)
|
processed(db, t)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ClientReady = true
|
ClientReady = true
|
||||||
log.Println("client is ready for new telegram")
|
Log.Info("client is ready for new telegram")
|
||||||
}
|
}
|
||||||
|
|
||||||
func getTelegram(db *sql.DB) []telegram {
|
func getTelegram(db *sql.DB) []telegram {
|
||||||
var telegrams []telegram
|
var telegrams []telegram
|
||||||
num := countTelegram()
|
num := countTelegram()
|
||||||
log.Println("unprocessed : ", num)
|
Log.Info("telegram ", zap.Int64("unprocessed", num))
|
||||||
if num < 1 {
|
if num < 1 {
|
||||||
return telegrams
|
return telegrams
|
||||||
}
|
}
|
||||||
log.Println("try to load unprocessed telegram ", num)
|
Log.Info("try to load unprocessed telegram ")
|
||||||
rows, err := db.Query(load)
|
rows, err := db.Query(load)
|
||||||
checkDbErr(err, "error in query telegram")
|
checkDbErr(err, "error in query telegram")
|
||||||
defer rows.Close()
|
defer rows.Close()
|
||||||
@@ -137,10 +138,10 @@ func processed(db *sql.DB, t telegram) {
|
|||||||
checkDbErr(err, "error in create update statement")
|
checkDbErr(err, "error in create update statement")
|
||||||
result, err := stmt.Exec(t.id)
|
result, err := stmt.Exec(t.id)
|
||||||
checkDbErr(err, "error in update telegram status")
|
checkDbErr(err, "error in update telegram status")
|
||||||
id, _ := result.RowsAffected()
|
rows, _ := result.RowsAffected()
|
||||||
log.Println(t.id, " telegram update : ", id > 0)
|
Log.Info("telegram update ", zap.Int64("id", t.id), zap.Bool("result", rows > 0))
|
||||||
isWriting = false
|
isWriting = false
|
||||||
log.Println("release lock")
|
Log.Debug("release lock")
|
||||||
tx.Commit()
|
tx.Commit()
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -157,20 +158,20 @@ func countTelegram() int64 {
|
|||||||
|
|
||||||
func getWriteLock() {
|
func getWriteLock() {
|
||||||
count := 0
|
count := 0
|
||||||
log.Println("write lock :", isWriting)
|
Log.Debug("with ", zap.Bool("lock", isWriting))
|
||||||
for isWriting && count < 10 {
|
for isWriting && count < 10 {
|
||||||
log.Println("waiting for write ")
|
Log.Info("waiting for write ")
|
||||||
time.Sleep(5 * time.Second)
|
time.Sleep(5 * time.Second)
|
||||||
count++
|
count++
|
||||||
}
|
}
|
||||||
if count >= 10 {
|
if count >= 10 {
|
||||||
log.Fatalln("database locked")
|
Log.Fatal("database locked")
|
||||||
}
|
}
|
||||||
isWriting = true
|
isWriting = true
|
||||||
}
|
}
|
||||||
|
|
||||||
func checkDbErr(err error, msg string) {
|
func checkDbErr(err error, msg string) {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatalln(msg, err)
|
Log.Fatal(msg, zap.Error(err))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+21
-15
@@ -1,9 +1,10 @@
|
|||||||
package utils
|
package utils
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"log"
|
|
||||||
"regexp"
|
"regexp"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
|
rotatelogs "github.com/lestrrat-go/file-rotatelogs"
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
@@ -11,27 +12,32 @@ const (
|
|||||||
Expression = "(?s)ZCZC.*NNNN"
|
Expression = "(?s)ZCZC.*NNNN"
|
||||||
)
|
)
|
||||||
|
|
||||||
var buffer []byte
|
var buffer string
|
||||||
|
var exp, _ = regexp.Compile(Expression)
|
||||||
|
var RawLog *rotatelogs.RotateLogs
|
||||||
|
|
||||||
func Append(data []byte) {
|
func Append(data string) bool {
|
||||||
buffer = append(buffer, data...)
|
buffer += (data + "\n")
|
||||||
if buffer[len(buffer)-1] == '\r' {
|
return check()
|
||||||
buffer = append(buffer, '\n')
|
|
||||||
}
|
|
||||||
check()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func check() {
|
func check() bool {
|
||||||
teleString := string(buffer)
|
teleString := buffer
|
||||||
if strings.Index(teleString, EndTag) > 0 {
|
if strings.Index(teleString, EndTag) > 0 {
|
||||||
exp, _ := regexp.Compile(Expression)
|
telegram := exp.FindString(teleString)
|
||||||
telegram := exp.FindString(string(buffer))
|
|
||||||
|
|
||||||
if len(telegram) > 0 {
|
if len(telegram) > 0 {
|
||||||
log.Println("telegram : ", telegram)
|
// Log.Info("telegram ", zap.String("text", telegram))
|
||||||
buffer = nil
|
telegram = removeEmpty(telegram) + "\n\n"
|
||||||
|
telegram += "\n"
|
||||||
|
RawLog.Write([]byte(telegram + "\n"))
|
||||||
|
buffer = ""
|
||||||
InsertTelegram(telegram)
|
InsertTelegram(telegram)
|
||||||
|
return true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
func removeEmpty(s string) string {
|
||||||
|
return regexp.MustCompile(`[\t\r\n]+`).ReplaceAllString(strings.TrimSpace(s), "\n")
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user