forked from Elara6331/itd
Compare commits
52 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 552f19676b | |||
| 9d58ea0ae7 | |||
| 76875db7ea | |||
| be5bdc625b | |||
| 0d0db949af | |||
| 0d164aef3d | |||
| 28610d9ebb | |||
| dff34b484d | |||
| 2ea9f99db6 | |||
| 44dc5f8e47 | |||
| 4d35912466 | |||
| ef29b9bee4 | |||
| e198b769f9 | |||
| ef4bad94b5 | |||
| 8cf2b47733 | |||
| f20fdcb161 | |||
| eeba9b2964 | |||
| d7057e3f9c | |||
| 80a5867d6b | |||
| f001dd6079 | |||
| b87586ef15 | |||
| 295892c8a8 | |||
| 1492db7566 | |||
| e7de7bd7bb | |||
| 7b849a3fc7 | |||
| 21d4964207 | |||
| 604ea57c5f | |||
| b15cbb6349 | |||
| 843e369bab | |||
| eec7a3db48 | |||
| c23201e18c | |||
| 4bc6eb9d41 | |||
| 2a59e74a2c | |||
| df743cca96 | |||
| 01bf493c77 | |||
| b6e9ad6160 | |||
| c56c0ae198 | |||
| 6b94030b83 | |||
| 2bbd722ecd | |||
| 73f16fcfef | |||
| 9df6531023 | |||
| 1db2ca3395 | |||
| 419b2f5a79 | |||
| 44607ba9e2 | |||
| f4d2f4e6eb | |||
| 0721b7f9d4 | |||
| b7bd385c43 | |||
| cbcefb149e | |||
| cb8d207249 | |||
| 7786ea1d58 | |||
| 6e16aa7a7a | |||
| 91f7132d5e |
1
.gitignore
vendored
1
.gitignore
vendored
@@ -1,2 +1,3 @@
|
||||
/itctl
|
||||
/itd
|
||||
/itgui
|
||||
71
README.md
71
README.md
@@ -12,8 +12,10 @@
|
||||
### Features
|
||||
|
||||
- Notification relay
|
||||
- Notification transliteration
|
||||
- Call Notifications (ModemManager)
|
||||
- Music control
|
||||
- Get info from watch (HRM, Battery level, Firmware version)
|
||||
- Get info from watch (HRM, Battery level, Firmware version, Motion)
|
||||
- Set current time
|
||||
- Control socket
|
||||
- Firmware upgrades
|
||||
@@ -27,7 +29,7 @@ This daemon creates a UNIX socket at `/tmp/itd/socket`. It allows you to directl
|
||||
The socket accepts JSON requests. For example, sending a notification looks like this:
|
||||
|
||||
```json
|
||||
{"type": "notify", "data": {"title": "title1", "body": "body1"}}
|
||||
{"type": 5, "data": {"title": "title1", "body": "body1"}}
|
||||
```
|
||||
|
||||
It will return a JSON response. A response can have 3 fields: `error`, `msg`, and `value`. Error is a boolean that signals whether an error was returned. If error is true, the msg field will contain the error. Value can contain any data and depends on what the request was.
|
||||
@@ -36,6 +38,42 @@ The various request types and their data requirements can be seen in `internal/t
|
||||
|
||||
---
|
||||
|
||||
### Transliteration
|
||||
|
||||
Since the PineTime does not have enough space to store all unicode glyphs, it only stores the ASCII space and Cyrillic. Therefore, this daemon can transliterate unsupported characters into supported ones. Since some languages have different transliterations, the transliterators to be used must be specified in the config. Here are the available transliterators:
|
||||
|
||||
- eASCII
|
||||
- Scandinavian
|
||||
- German
|
||||
- Hebrew
|
||||
- Greek
|
||||
- Russian
|
||||
- Ukranian
|
||||
- Arabic
|
||||
- Farsi
|
||||
- Polish
|
||||
- Lithuanian
|
||||
- Estonian
|
||||
- Icelandic
|
||||
- Czeck
|
||||
- French
|
||||
- Armenian
|
||||
- Korean
|
||||
- Chinese
|
||||
- Emoji
|
||||
|
||||
Place the desired map names in an array as `notifs.translit.use`. They will be evaluated in order. You can also put custom transliterations in `notifs.translit.custom`. These take priority over any other maps. The `notifs.translit` config section should look like this:
|
||||
|
||||
```toml
|
||||
[notifs.translit]
|
||||
use = ["eASCII", "Russian", "Emoji"]
|
||||
custom = [
|
||||
"test", "replaced"
|
||||
]
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
### `itctl`
|
||||
|
||||
This daemon comes with a binary called `itctl` which uses the socket to control the daemon from the command line. As such, it can be scripted using bash.
|
||||
@@ -45,10 +83,10 @@ This is the `itctl` usage screen:
|
||||
Control the itd daemon for InfiniTime smartwatches
|
||||
|
||||
Usage:
|
||||
itctl [flags]
|
||||
itctl [command]
|
||||
|
||||
Available Commands:
|
||||
completion generate the autocompletion script for the specified shell
|
||||
firmware Manage InfiniTime firmware
|
||||
get Get information from InfiniTime
|
||||
help Help about any command
|
||||
@@ -56,11 +94,36 @@ Available Commands:
|
||||
set Set information on InfiniTime
|
||||
|
||||
Flags:
|
||||
-h, --help help for itctl
|
||||
-h, --help help for itctl
|
||||
-s, --socket-path string Path to itd socket
|
||||
|
||||
Use "itctl [command] --help" for more information about a command.
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
### `itgui`
|
||||
|
||||
In `cmd/itgui`, there is a gui frontend to the socket of `itd`. It uses the [fyne library](https://fyne.io/) for Go. It can be compiled by running:
|
||||
|
||||
```shell
|
||||
go build ./cmd/itgui
|
||||
```
|
||||
|
||||
#### Screenshots
|
||||
|
||||

|
||||
|
||||

|
||||
|
||||

|
||||
|
||||

|
||||
|
||||

|
||||
|
||||
---
|
||||
|
||||
#### Interactive mode
|
||||
|
||||
Running `itctl` by itself will open interactive mode. It's essentially a shell where you can enter commands. For example:
|
||||
|
||||
133
api/client.go
Normal file
133
api/client.go
Normal file
@@ -0,0 +1,133 @@
|
||||
package api
|
||||
|
||||
import (
|
||||
"bufio"
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"net"
|
||||
|
||||
"github.com/mitchellh/mapstructure"
|
||||
"go.arsenm.dev/infinitime"
|
||||
"go.arsenm.dev/itd/internal/types"
|
||||
)
|
||||
|
||||
// Default socket address
|
||||
const DefaultAddr = "/tmp/itd/socket"
|
||||
|
||||
// Client is the socket API client
|
||||
type Client struct {
|
||||
conn net.Conn
|
||||
respCh chan types.Response
|
||||
heartRateCh chan types.Response
|
||||
battLevelCh chan types.Response
|
||||
stepCountCh chan types.Response
|
||||
motionCh chan types.Response
|
||||
dfuProgressCh chan types.Response
|
||||
}
|
||||
|
||||
// New creates a new client and sets it up
|
||||
func New(addr string) (*Client, error) {
|
||||
conn, err := net.Dial("unix", addr)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
out := &Client{
|
||||
conn: conn,
|
||||
respCh: make(chan types.Response, 5),
|
||||
}
|
||||
|
||||
go func() {
|
||||
scanner := bufio.NewScanner(conn)
|
||||
for scanner.Scan() {
|
||||
var res types.Response
|
||||
err = json.Unmarshal(scanner.Bytes(), &res)
|
||||
if err != nil {
|
||||
continue
|
||||
}
|
||||
out.handleResp(res)
|
||||
}
|
||||
}()
|
||||
return out, err
|
||||
}
|
||||
|
||||
func (c *Client) Close() error {
|
||||
err := c.conn.Close()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
close(c.respCh)
|
||||
return nil
|
||||
}
|
||||
|
||||
// request sends a request to itd and waits for and returns the response
|
||||
func (c *Client) request(req types.Request) (types.Response, error) {
|
||||
// Encode request into connection
|
||||
err := json.NewEncoder(c.conn).Encode(req)
|
||||
if err != nil {
|
||||
return types.Response{}, err
|
||||
}
|
||||
|
||||
res := <-c.respCh
|
||||
|
||||
if res.Error {
|
||||
return res, errors.New(res.Message)
|
||||
}
|
||||
|
||||
return res, nil
|
||||
}
|
||||
|
||||
// requestNoRes sends a request to itd and does not wait for the response
|
||||
func (c *Client) requestNoRes(req types.Request) error {
|
||||
// Encode request into connection
|
||||
err := json.NewEncoder(c.conn).Encode(req)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// handleResp handles the received response as needed
|
||||
func (c *Client) handleResp(res types.Response) error {
|
||||
switch res.Type {
|
||||
case types.ReqTypeWatchHeartRate:
|
||||
c.heartRateCh <- res
|
||||
case types.ReqTypeWatchBattLevel:
|
||||
c.battLevelCh <- res
|
||||
case types.ReqTypeWatchStepCount:
|
||||
c.stepCountCh <- res
|
||||
case types.ReqTypeWatchMotion:
|
||||
c.motionCh <- res
|
||||
case types.ReqTypeFwUpgrade:
|
||||
c.dfuProgressCh <- res
|
||||
default:
|
||||
c.respCh <- res
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func decodeUint8(val interface{}) uint8 {
|
||||
return uint8(val.(float64))
|
||||
}
|
||||
|
||||
func decodeUint32(val interface{}) uint32 {
|
||||
return uint32(val.(float64))
|
||||
}
|
||||
|
||||
func decodeMotion(val interface{}) (infinitime.MotionValues, error) {
|
||||
out := infinitime.MotionValues{}
|
||||
err := mapstructure.Decode(val, &out)
|
||||
if err != nil {
|
||||
return out, err
|
||||
}
|
||||
return out, nil
|
||||
}
|
||||
|
||||
func decodeDFUProgress(val interface{}) (DFUProgress, error) {
|
||||
out := DFUProgress{}
|
||||
err := mapstructure.Decode(val, &out)
|
||||
if err != nil {
|
||||
return out, err
|
||||
}
|
||||
return out, nil
|
||||
}
|
||||
209
api/info.go
Normal file
209
api/info.go
Normal file
@@ -0,0 +1,209 @@
|
||||
package api
|
||||
|
||||
import (
|
||||
"github.com/mitchellh/mapstructure"
|
||||
"go.arsenm.dev/infinitime"
|
||||
"go.arsenm.dev/itd/internal/types"
|
||||
)
|
||||
|
||||
// Address gets the bluetooth address of the connected device
|
||||
func (c *Client) Address() (string, error) {
|
||||
res, err := c.request(types.Request{
|
||||
Type: types.ReqTypeBtAddress,
|
||||
})
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
return res.Value.(string), nil
|
||||
}
|
||||
|
||||
// Version gets the firmware version of the connected device
|
||||
func (c *Client) Version() (string, error) {
|
||||
res, err := c.request(types.Request{
|
||||
Type: types.ReqTypeFwVersion,
|
||||
})
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
return res.Value.(string), nil
|
||||
}
|
||||
|
||||
// BatteryLevel gets the battery level of the connected device
|
||||
func (c *Client) BatteryLevel() (uint8, error) {
|
||||
res, err := c.request(types.Request{
|
||||
Type: types.ReqTypeBattLevel,
|
||||
})
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
|
||||
return uint8(res.Value.(float64)), nil
|
||||
}
|
||||
|
||||
// WatchBatteryLevel returns a channel which will contain
|
||||
// new battery level values as they update. Do not use after
|
||||
// calling cancellation function
|
||||
func (c *Client) WatchBatteryLevel() (<-chan uint8, func(), error) {
|
||||
c.battLevelCh = make(chan types.Response, 2)
|
||||
err := c.requestNoRes(types.Request{
|
||||
Type: types.ReqTypeWatchBattLevel,
|
||||
})
|
||||
if err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
res := <-c.battLevelCh
|
||||
done, cancel := c.cancelFn(res.ID, c.battLevelCh)
|
||||
out := make(chan uint8, 2)
|
||||
go func() {
|
||||
for res := range c.battLevelCh {
|
||||
select {
|
||||
case <-done:
|
||||
return
|
||||
default:
|
||||
out <- decodeUint8(res.Value)
|
||||
}
|
||||
}
|
||||
}()
|
||||
return out, cancel, nil
|
||||
}
|
||||
|
||||
// HeartRate gets the heart rate from the connected device
|
||||
func (c *Client) HeartRate() (uint8, error) {
|
||||
res, err := c.request(types.Request{
|
||||
Type: types.ReqTypeHeartRate,
|
||||
})
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
|
||||
return decodeUint8(res.Value), nil
|
||||
}
|
||||
|
||||
// WatchHeartRate returns a channel which will contain
|
||||
// new heart rate values as they update. Do not use after
|
||||
// calling cancellation function
|
||||
func (c *Client) WatchHeartRate() (<-chan uint8, func(), error) {
|
||||
c.heartRateCh = make(chan types.Response, 2)
|
||||
err := c.requestNoRes(types.Request{
|
||||
Type: types.ReqTypeWatchHeartRate,
|
||||
})
|
||||
if err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
res := <-c.heartRateCh
|
||||
done, cancel := c.cancelFn(res.ID, c.heartRateCh)
|
||||
out := make(chan uint8, 2)
|
||||
go func() {
|
||||
for res := range c.heartRateCh {
|
||||
select {
|
||||
case <-done:
|
||||
return
|
||||
default:
|
||||
out <- decodeUint8(res.Value)
|
||||
}
|
||||
}
|
||||
}()
|
||||
return out, cancel, nil
|
||||
}
|
||||
|
||||
// cancelFn generates a cancellation function for the given
|
||||
// request type and channel
|
||||
func (c *Client) cancelFn(reqID string, ch chan types.Response) (chan struct{}, func()) {
|
||||
done := make(chan struct{}, 1)
|
||||
return done, func() {
|
||||
done <- struct{}{}
|
||||
close(ch)
|
||||
c.requestNoRes(types.Request{
|
||||
Type: types.ReqTypeCancel,
|
||||
Data: reqID,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
// StepCount gets the step count from the connected device
|
||||
func (c *Client) StepCount() (uint32, error) {
|
||||
res, err := c.request(types.Request{
|
||||
Type: types.ReqTypeStepCount,
|
||||
})
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
|
||||
return uint32(res.Value.(float64)), nil
|
||||
}
|
||||
|
||||
// WatchStepCount returns a channel which will contain
|
||||
// new step count values as they update. Do not use after
|
||||
// calling cancellation function
|
||||
func (c *Client) WatchStepCount() (<-chan uint32, func(), error) {
|
||||
c.stepCountCh = make(chan types.Response, 2)
|
||||
err := c.requestNoRes(types.Request{
|
||||
Type: types.ReqTypeWatchStepCount,
|
||||
})
|
||||
if err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
res := <-c.stepCountCh
|
||||
done, cancel := c.cancelFn(res.ID, c.stepCountCh)
|
||||
out := make(chan uint32, 2)
|
||||
go func() {
|
||||
for res := range c.stepCountCh {
|
||||
select {
|
||||
case <-done:
|
||||
return
|
||||
default:
|
||||
out <- decodeUint32(res.Value)
|
||||
}
|
||||
}
|
||||
}()
|
||||
return out, cancel, nil
|
||||
}
|
||||
|
||||
// Motion gets the motion values from the connected device
|
||||
func (c *Client) Motion() (infinitime.MotionValues, error) {
|
||||
out := infinitime.MotionValues{}
|
||||
res, err := c.request(types.Request{
|
||||
Type: types.ReqTypeMotion,
|
||||
})
|
||||
if err != nil {
|
||||
return out, err
|
||||
}
|
||||
err = mapstructure.Decode(res.Value, &out)
|
||||
if err != nil {
|
||||
return out, err
|
||||
}
|
||||
return out, nil
|
||||
}
|
||||
|
||||
// WatchMotion returns a channel which will contain
|
||||
// new motion values as they update. Do not use after
|
||||
// calling cancellation function
|
||||
func (c *Client) WatchMotion() (<-chan infinitime.MotionValues, func(), error) {
|
||||
c.motionCh = make(chan types.Response, 5)
|
||||
err := c.requestNoRes(types.Request{
|
||||
Type: types.ReqTypeWatchMotion,
|
||||
})
|
||||
if err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
res := <-c.motionCh
|
||||
done, cancel := c.cancelFn(res.ID, c.motionCh)
|
||||
out := make(chan infinitime.MotionValues, 5)
|
||||
go func() {
|
||||
for res := range c.motionCh {
|
||||
select {
|
||||
case <-done:
|
||||
return
|
||||
default:
|
||||
motion, err := decodeMotion(res.Value)
|
||||
if err != nil {
|
||||
continue
|
||||
}
|
||||
out <- motion
|
||||
}
|
||||
}
|
||||
}()
|
||||
return out, cancel, nil
|
||||
}
|
||||
14
api/notify.go
Normal file
14
api/notify.go
Normal file
@@ -0,0 +1,14 @@
|
||||
package api
|
||||
|
||||
import "go.arsenm.dev/itd/internal/types"
|
||||
|
||||
func (c *Client) Notify(title string, body string) error {
|
||||
_, err := c.request(types.Request{
|
||||
Type: types.ReqTypeNotify,
|
||||
Data: types.ReqDataNotify{
|
||||
Title: title,
|
||||
Body: body,
|
||||
},
|
||||
})
|
||||
return err
|
||||
}
|
||||
33
api/time.go
Normal file
33
api/time.go
Normal file
@@ -0,0 +1,33 @@
|
||||
package api
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
"go.arsenm.dev/itd/internal/types"
|
||||
)
|
||||
|
||||
// SetTime sets the given time on the connected device
|
||||
func (c *Client) SetTime(t time.Time) error {
|
||||
_, err := c.request(types.Request{
|
||||
Type: types.ReqTypeSetTime,
|
||||
Data: t.Format(time.RFC3339),
|
||||
})
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// SetTimeNow sets the time on the connected device to
|
||||
// the current time. This is more accurate than
|
||||
// SetTime(time.Now()) due to RFC3339 formatting
|
||||
func (c *Client) SetTimeNow() error {
|
||||
_, err := c.request(types.Request{
|
||||
Type: types.ReqTypeSetTime,
|
||||
Data: "now",
|
||||
})
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
48
api/upgrade.go
Normal file
48
api/upgrade.go
Normal file
@@ -0,0 +1,48 @@
|
||||
package api
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
|
||||
"go.arsenm.dev/itd/internal/types"
|
||||
)
|
||||
|
||||
// DFUProgress stores the progress of a DFU upfate
|
||||
type DFUProgress types.DFUProgress
|
||||
|
||||
// UpgradeType indicates the type of upgrade to be performed
|
||||
type UpgradeType uint8
|
||||
|
||||
// Type of DFU upgrade
|
||||
const (
|
||||
UpgradeTypeArchive UpgradeType = iota
|
||||
UpgradeTypeFiles
|
||||
)
|
||||
|
||||
// FirmwareUpgrade initiates a DFU update and returns the progress channel
|
||||
func (c *Client) FirmwareUpgrade(upgType UpgradeType, files ...string) (<-chan DFUProgress, error) {
|
||||
err := json.NewEncoder(c.conn).Encode(types.Request{
|
||||
Type: types.ReqTypeFwUpgrade,
|
||||
Data: types.ReqDataFwUpgrade{
|
||||
Type: int(upgType),
|
||||
Files: files,
|
||||
},
|
||||
})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
c.dfuProgressCh = make(chan types.Response, 5)
|
||||
|
||||
out := make(chan DFUProgress, 5)
|
||||
go func() {
|
||||
for res := range c.dfuProgressCh {
|
||||
progress, err := decodeDFUProgress(res.Value)
|
||||
if err != nil {
|
||||
continue
|
||||
}
|
||||
out <- progress
|
||||
}
|
||||
}()
|
||||
|
||||
return out, nil
|
||||
}
|
||||
176
calls.go
Normal file
176
calls.go
Normal file
@@ -0,0 +1,176 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"bufio"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"os/exec"
|
||||
"strconv"
|
||||
"strings"
|
||||
|
||||
"github.com/rs/zerolog/log"
|
||||
"go.arsenm.dev/infinitime"
|
||||
)
|
||||
|
||||
func initCallNotifs(dev *infinitime.Device) error {
|
||||
// Define rule to filter dbus messages
|
||||
rule := "type='signal',sender='org.freedesktop.ModemManager1',interface='org.freedesktop.ModemManager1.Modem.Voice',member='CallAdded'"
|
||||
|
||||
// Use dbus-monitor command with profiling output as a workaround
|
||||
// because go-bluetooth seems to monopolize the system bus connection
|
||||
// which makes monitoring show only bluez-related messages.
|
||||
cmd := exec.Command("dbus-monitor", "--system", "--profile", rule)
|
||||
// Get command output pipe
|
||||
stdout, err := cmd.StdoutPipe()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
// Run command asynchronously
|
||||
err = cmd.Start()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// Create new scanner for command output
|
||||
scanner := bufio.NewScanner(stdout)
|
||||
go func() {
|
||||
// For each line in output
|
||||
for scanner.Scan() {
|
||||
// Get line as string
|
||||
text := scanner.Text()
|
||||
|
||||
// If line starts with "#", it is part of
|
||||
// the field format, skip it.
|
||||
if strings.HasPrefix(text, "#") {
|
||||
continue
|
||||
}
|
||||
|
||||
// Split line into fields. The order is as follows:
|
||||
// type timestamp serial sender destination path interface member
|
||||
fields := strings.Fields(text)
|
||||
// Field 7 is Member. Make sure it is "CallAdded".
|
||||
if fields[7] == "CallAdded" {
|
||||
// Get Modem ID from modem path
|
||||
modemID := parseModemID(fields[5])
|
||||
// Get call ID of current call
|
||||
callID, err := getCurrentCallID(modemID)
|
||||
if err != nil {
|
||||
continue
|
||||
}
|
||||
// Get phone number of current call
|
||||
phoneNum, err := getPhoneNum(callID)
|
||||
if err != nil {
|
||||
continue
|
||||
}
|
||||
// Send call notification to PineTime
|
||||
resCh, err := dev.NotifyCall(phoneNum)
|
||||
if err != nil {
|
||||
continue
|
||||
}
|
||||
go func() {
|
||||
// Wait for PineTime response
|
||||
res := <-resCh
|
||||
switch res {
|
||||
case infinitime.CallStatusAccepted:
|
||||
// Attempt to accept call
|
||||
err = acceptCall(callID)
|
||||
if err != nil {
|
||||
log.Warn().Err(err).Msg("Error accepting call")
|
||||
}
|
||||
case infinitime.CallStatusDeclined:
|
||||
// Attempt to decline call
|
||||
err = declineCall(callID)
|
||||
if err != nil {
|
||||
log.Warn().Err(err).Msg("Error declining call")
|
||||
}
|
||||
case infinitime.CallStatusMuted:
|
||||
// Warn about unimplemented muting
|
||||
log.Warn().Msg("Muting calls is not implemented")
|
||||
}
|
||||
}()
|
||||
}
|
||||
}
|
||||
}()
|
||||
return nil
|
||||
}
|
||||
|
||||
func parseModemID(modemPath string) int {
|
||||
// Split path by "/"
|
||||
splitPath := strings.Split(modemPath, "/")
|
||||
// Get last element and convert to integer
|
||||
id, _ := strconv.Atoi(splitPath[len(splitPath)-1])
|
||||
return id
|
||||
}
|
||||
|
||||
func getCurrentCallID(modemID int) (int, error) {
|
||||
// Create mmcli command
|
||||
cmd := exec.Command("mmcli", "--voice-list-calls", "-m", fmt.Sprint(modemID), "-J")
|
||||
// Run command and get output
|
||||
data, err := cmd.Output()
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
var calls map[string][]string
|
||||
// Decode JSON from command output
|
||||
err = json.Unmarshal(data, &calls)
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
// Get first call in output
|
||||
firstCall := calls["modem.voice.call"][0]
|
||||
// Split path by "/"
|
||||
splitCall := strings.Split(firstCall, "/")
|
||||
// Return last element converted to integer
|
||||
return strconv.Atoi(splitCall[len(splitCall)-1])
|
||||
}
|
||||
|
||||
func getPhoneNum(callID int) (string, error) {
|
||||
// Create dbus-send command
|
||||
cmd := exec.Command("dbus-send",
|
||||
"--dest=org.freedesktop.ModemManager1",
|
||||
"--system",
|
||||
"--print-reply=literal",
|
||||
"--type=method_call",
|
||||
fmt.Sprintf("/org/freedesktop/ModemManager1/Call/%d", callID),
|
||||
"org.freedesktop.DBus.Properties.Get",
|
||||
"string:org.freedesktop.ModemManager1.Call",
|
||||
"string:Number",
|
||||
)
|
||||
// Run command and get output
|
||||
numData, err := cmd.Output()
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
// Split output into fields
|
||||
num := strings.Fields(string(numData))
|
||||
// Return last field
|
||||
return num[len(num)-1], nil
|
||||
}
|
||||
|
||||
func acceptCall(callID int) error {
|
||||
// Create dbus-send command
|
||||
cmd := exec.Command("dbus-send",
|
||||
"--dest=org.freedesktop.ModemManager1",
|
||||
"--print-reply",
|
||||
"--system",
|
||||
"--type=method_call",
|
||||
fmt.Sprintf("/org/freedesktop/ModemManager1/Call/%d", callID),
|
||||
"org.freedesktop.ModemManager1.Call.Accept",
|
||||
)
|
||||
// Run command and return errpr
|
||||
return cmd.Run()
|
||||
}
|
||||
|
||||
func declineCall(callID int) error {
|
||||
// Create dbus-send command
|
||||
cmd := exec.Command("dbus-send",
|
||||
"--dest=org.freedesktop.ModemManager1",
|
||||
"--print-reply",
|
||||
"--system",
|
||||
"--type=method_call",
|
||||
fmt.Sprintf("/org/freedesktop/ModemManager1/Call/%d", callID),
|
||||
"org.freedesktop.ModemManager1.Call.Hangup",
|
||||
)
|
||||
// Run command and return errpr
|
||||
return cmd.Run()
|
||||
}
|
||||
@@ -16,10 +16,11 @@
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package cmd
|
||||
package firmware
|
||||
|
||||
import (
|
||||
"github.com/spf13/cobra"
|
||||
"go.arsenm.dev/itd/cmd/itctl/root"
|
||||
)
|
||||
|
||||
// firmwareCmd represents the firmware command
|
||||
@@ -30,5 +31,5 @@ var firmwareCmd = &cobra.Command{
|
||||
}
|
||||
|
||||
func init() {
|
||||
rootCmd.AddCommand(firmwareCmd)
|
||||
root.RootCmd.AddCommand(firmwareCmd)
|
||||
}
|
||||
@@ -16,61 +16,50 @@
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package cmd
|
||||
package firmware
|
||||
|
||||
import (
|
||||
"bufio"
|
||||
"encoding/json"
|
||||
"net"
|
||||
|
||||
"github.com/cheggaaa/pb/v3"
|
||||
"github.com/mitchellh/mapstructure"
|
||||
"github.com/rs/zerolog/log"
|
||||
"github.com/spf13/cobra"
|
||||
"github.com/spf13/viper"
|
||||
"go.arsenm.dev/itd/api"
|
||||
"go.arsenm.dev/itd/internal/types"
|
||||
)
|
||||
|
||||
type DFUProgress struct {
|
||||
Received int64 `mapstructure:"recvd"`
|
||||
Total int64 `mapstructure:"total"`
|
||||
}
|
||||
|
||||
// upgradeCmd represents the upgrade command
|
||||
var upgradeCmd = &cobra.Command{
|
||||
Use: "upgrade",
|
||||
Short: "Upgrade InfiniTime firmware using files or archive",
|
||||
Aliases: []string{"upg"},
|
||||
Run: func(cmd *cobra.Command, args []string) {
|
||||
// Connect to itd UNIX socket
|
||||
conn, err := net.Dial("unix", SockPath)
|
||||
if err != nil {
|
||||
log.Fatal().Err(err).Msg("Error dialing socket. Is itd running?")
|
||||
}
|
||||
defer conn.Close()
|
||||
client := viper.Get("client").(*api.Client)
|
||||
|
||||
var data types.ReqDataFwUpgrade
|
||||
var upgType api.UpgradeType
|
||||
var files []string
|
||||
// Get relevant data struct
|
||||
if viper.GetString("archive") != "" {
|
||||
// Get archive data struct
|
||||
data = types.ReqDataFwUpgrade{
|
||||
Type: UpgradeTypeArchive,
|
||||
Files: []string{viper.GetString("archive")},
|
||||
}
|
||||
upgType = types.UpgradeTypeArchive
|
||||
files = []string{viper.GetString("archive")}
|
||||
} else if viper.GetString("initPkt") != "" && viper.GetString("firmware") != "" {
|
||||
// Get files data struct
|
||||
data = types.ReqDataFwUpgrade{
|
||||
Type: UpgradeTypeFiles,
|
||||
Files: []string{viper.GetString("initPkt"), viper.GetString("firmware")},
|
||||
}
|
||||
upgType = types.UpgradeTypeFiles
|
||||
files = []string{viper.GetString("initPkt"), viper.GetString("firmware")}
|
||||
} else {
|
||||
cmd.Usage()
|
||||
log.Warn().Msg("Upgrade command requires either archive or init packet and firmware.")
|
||||
return
|
||||
}
|
||||
|
||||
// Encode response into connection
|
||||
err = json.NewEncoder(conn).Encode(types.Request{
|
||||
Type: ReqTypeFwUpgrade,
|
||||
Data: data,
|
||||
})
|
||||
progress, err := client.FirmwareUpgrade(upgType, files...)
|
||||
if err != nil {
|
||||
log.Fatal().Err(err).Msg("Error making request")
|
||||
log.Fatal().Err(err).Msg("Error initiating DFU")
|
||||
}
|
||||
|
||||
// Create progress bar template
|
||||
@@ -78,37 +67,18 @@ var upgradeCmd = &cobra.Command{
|
||||
// Start full bar at 0 total
|
||||
bar := pb.ProgressBarTemplate(barTmpl).Start(0)
|
||||
// Create new scanner of connection
|
||||
scanner := bufio.NewScanner(conn)
|
||||
for scanner.Scan() {
|
||||
var res types.Response
|
||||
// Decode scanned line into response struct
|
||||
err = json.Unmarshal(scanner.Bytes(), &res)
|
||||
if err != nil {
|
||||
log.Fatal().Err(err).Msg("Error decoding JSON response")
|
||||
}
|
||||
if res.Error {
|
||||
log.Fatal().Msg(res.Message)
|
||||
}
|
||||
var event DFUProgress
|
||||
// Decode response data into progress struct
|
||||
err = mapstructure.Decode(res.Value, &event)
|
||||
if err != nil {
|
||||
log.Fatal().Err(err).Msg("Error decoding response data")
|
||||
}
|
||||
// If transfer finished, break
|
||||
if event.Received == event.Total {
|
||||
break
|
||||
}
|
||||
for event := range progress {
|
||||
// Set total bytes in progress bar
|
||||
bar.SetTotal(event.Total)
|
||||
// Set amount of bytes received in progress bar
|
||||
bar.SetCurrent(event.Received)
|
||||
// If transfer finished, break
|
||||
if event.Sent == event.Total {
|
||||
break
|
||||
}
|
||||
}
|
||||
// Finish progress bar
|
||||
bar.Finish()
|
||||
if scanner.Err() != nil {
|
||||
log.Fatal().Err(scanner.Err()).Msg("Error while scanning output")
|
||||
}
|
||||
},
|
||||
}
|
||||
|
||||
@@ -16,17 +16,15 @@
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package cmd
|
||||
package firmware
|
||||
|
||||
import (
|
||||
"bufio"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"net"
|
||||
|
||||
"github.com/rs/zerolog/log"
|
||||
"github.com/spf13/cobra"
|
||||
"go.arsenm.dev/itd/internal/types"
|
||||
"github.com/spf13/viper"
|
||||
"go.arsenm.dev/itd/api"
|
||||
)
|
||||
|
||||
// versionCmd represents the version command
|
||||
@@ -35,40 +33,14 @@ var versionCmd = &cobra.Command{
|
||||
Aliases: []string{"ver"},
|
||||
Short: "Get firmware version of InfiniTime",
|
||||
Run: func(cmd *cobra.Command, args []string) {
|
||||
// Connect to itd UNIX socket
|
||||
conn, err := net.Dial("unix", SockPath)
|
||||
client := viper.Get("client").(*api.Client)
|
||||
|
||||
version, err := client.Version()
|
||||
if err != nil {
|
||||
log.Fatal().Err(err).Msg("Error dialing socket. Is itd running?")
|
||||
}
|
||||
defer conn.Close()
|
||||
|
||||
// Encode request into connection
|
||||
err = json.NewEncoder(conn).Encode(types.Request{
|
||||
Type: ReqTypeFwVersion,
|
||||
})
|
||||
if err != nil {
|
||||
log.Fatal().Err(err).Msg("Error making request")
|
||||
log.Fatal().Err(err).Msg("Error getting firmware version")
|
||||
}
|
||||
|
||||
// Read one line from connection
|
||||
line, _, err := bufio.NewReader(conn).ReadLine()
|
||||
if err != nil {
|
||||
log.Fatal().Err(err).Msg("Error reading line from connection")
|
||||
}
|
||||
|
||||
var res types.Response
|
||||
// Decode line into response
|
||||
err = json.Unmarshal(line, &res)
|
||||
if err != nil {
|
||||
log.Fatal().Err(err).Msg("Error decoding JSON data")
|
||||
}
|
||||
|
||||
if res.Error {
|
||||
log.Fatal().Msg(res.Message)
|
||||
}
|
||||
|
||||
// Print returned value
|
||||
fmt.Println(res.Value)
|
||||
fmt.Println(version)
|
||||
},
|
||||
}
|
||||
|
||||
@@ -16,17 +16,15 @@
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package cmd
|
||||
package get
|
||||
|
||||
import (
|
||||
"bufio"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"net"
|
||||
|
||||
"github.com/rs/zerolog/log"
|
||||
"github.com/spf13/cobra"
|
||||
"go.arsenm.dev/itd/internal/types"
|
||||
"github.com/spf13/viper"
|
||||
"go.arsenm.dev/itd/api"
|
||||
)
|
||||
|
||||
// addressCmd represents the address command
|
||||
@@ -35,40 +33,14 @@ var addressCmd = &cobra.Command{
|
||||
Aliases: []string{"addr"},
|
||||
Short: "Get InfiniTime's bluetooth address",
|
||||
Run: func(cmd *cobra.Command, args []string) {
|
||||
// Connect to itd UNIX socket
|
||||
conn, err := net.Dial("unix", SockPath)
|
||||
client := viper.Get("client").(*api.Client)
|
||||
|
||||
address, err := client.Address()
|
||||
if err != nil {
|
||||
log.Fatal().Err(err).Msg("Error dialing socket. Is itd running?")
|
||||
}
|
||||
defer conn.Close()
|
||||
|
||||
// Encode request into connection
|
||||
err = json.NewEncoder(conn).Encode(types.Request{
|
||||
Type: ReqTypeBtAddress,
|
||||
})
|
||||
if err != nil {
|
||||
log.Fatal().Err(err).Msg("Error making request")
|
||||
log.Fatal().Err(err).Msg("Error getting bluetooth address")
|
||||
}
|
||||
|
||||
// Read one line from connection
|
||||
line, _, err := bufio.NewReader(conn).ReadLine()
|
||||
if err != nil {
|
||||
log.Fatal().Err(err).Msg("Error reading line from connection")
|
||||
}
|
||||
|
||||
var res types.Response
|
||||
// Decode line into response
|
||||
err = json.Unmarshal(line, &res)
|
||||
if err != nil {
|
||||
log.Fatal().Err(err).Msg("Error decoding JSON data")
|
||||
}
|
||||
|
||||
if res.Error {
|
||||
log.Fatal().Msg(res.Message)
|
||||
}
|
||||
|
||||
// Print returned value
|
||||
fmt.Println(res.Value)
|
||||
fmt.Println(address)
|
||||
},
|
||||
}
|
||||
|
||||
@@ -16,17 +16,15 @@
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package cmd
|
||||
package get
|
||||
|
||||
import (
|
||||
"bufio"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"net"
|
||||
|
||||
"github.com/rs/zerolog/log"
|
||||
"github.com/spf13/cobra"
|
||||
"go.arsenm.dev/itd/internal/types"
|
||||
"github.com/spf13/viper"
|
||||
"go.arsenm.dev/itd/api"
|
||||
)
|
||||
|
||||
// batteryCmd represents the batt command
|
||||
@@ -35,40 +33,15 @@ var batteryCmd = &cobra.Command{
|
||||
Aliases: []string{"batt"},
|
||||
Short: "Get battery level from InfiniTime",
|
||||
Run: func(cmd *cobra.Command, args []string) {
|
||||
// Connect to itd UNIX socket
|
||||
conn, err := net.Dial("unix", SockPath)
|
||||
if err != nil {
|
||||
log.Fatal().Err(err).Msg("Error dialing socket. Is itd running?")
|
||||
}
|
||||
defer conn.Close()
|
||||
client := viper.Get("client").(*api.Client)
|
||||
|
||||
// Encode request into connection
|
||||
err = json.NewEncoder(conn).Encode(types.Request{
|
||||
Type: ReqTypeBattLevel,
|
||||
})
|
||||
battLevel, err := client.BatteryLevel()
|
||||
if err != nil {
|
||||
log.Fatal().Err(err).Msg("Error making request")
|
||||
}
|
||||
|
||||
// Read one line from connection
|
||||
line, _, err := bufio.NewReader(conn).ReadLine()
|
||||
if err != nil {
|
||||
log.Fatal().Err(err).Msg("Error reading line from connection")
|
||||
}
|
||||
|
||||
var res types.Response
|
||||
// Deocde line into response
|
||||
err = json.Unmarshal(line, &res)
|
||||
if err != nil {
|
||||
log.Fatal().Err(err).Msg("Error decoding JSON data")
|
||||
}
|
||||
|
||||
if res.Error {
|
||||
log.Fatal().Msg(res.Message)
|
||||
log.Fatal().Err(err).Msg("Error getting battery level")
|
||||
}
|
||||
|
||||
// Print returned percentage
|
||||
fmt.Printf("%d%%\n", int(res.Value.(float64)))
|
||||
fmt.Printf("%d%%\n", battLevel)
|
||||
},
|
||||
}
|
||||
|
||||
@@ -16,10 +16,11 @@
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package cmd
|
||||
package get
|
||||
|
||||
import (
|
||||
"github.com/spf13/cobra"
|
||||
"go.arsenm.dev/itd/cmd/itctl/root"
|
||||
)
|
||||
|
||||
// getCmd represents the get command
|
||||
@@ -29,5 +30,5 @@ var getCmd = &cobra.Command{
|
||||
}
|
||||
|
||||
func init() {
|
||||
rootCmd.AddCommand(getCmd)
|
||||
root.RootCmd.AddCommand(getCmd)
|
||||
}
|
||||
@@ -16,17 +16,15 @@
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package cmd
|
||||
package get
|
||||
|
||||
import (
|
||||
"bufio"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"net"
|
||||
|
||||
"github.com/rs/zerolog/log"
|
||||
"github.com/spf13/cobra"
|
||||
"go.arsenm.dev/itd/internal/types"
|
||||
"github.com/spf13/viper"
|
||||
"go.arsenm.dev/itd/api"
|
||||
)
|
||||
|
||||
// heartCmd represents the heart command
|
||||
@@ -34,40 +32,15 @@ var heartCmd = &cobra.Command{
|
||||
Use: "heart",
|
||||
Short: "Get heart rate from InfiniTime",
|
||||
Run: func(cmd *cobra.Command, args []string) {
|
||||
// Connect to itd UNIX socket
|
||||
conn, err := net.Dial("unix", SockPath)
|
||||
if err != nil {
|
||||
log.Fatal().Err(err).Msg("Error dialing socket. Is itd running?")
|
||||
}
|
||||
defer conn.Close()
|
||||
client := viper.Get("client").(*api.Client)
|
||||
|
||||
// Encode request into connection
|
||||
err = json.NewEncoder(conn).Encode(types.Request{
|
||||
Type: ReqTypeHeartRate,
|
||||
})
|
||||
heartRate, err := client.HeartRate()
|
||||
if err != nil {
|
||||
log.Fatal().Err(err).Msg("Error making request")
|
||||
}
|
||||
|
||||
// Read one line from connection
|
||||
line, _, err := bufio.NewReader(conn).ReadLine()
|
||||
if err != nil {
|
||||
log.Fatal().Err(err).Msg("Error reading line from connection")
|
||||
}
|
||||
|
||||
var res types.Response
|
||||
// Decode line into response
|
||||
err = json.Unmarshal(line, &res)
|
||||
if err != nil {
|
||||
log.Fatal().Err(err).Msg("Error decoding JSON data")
|
||||
}
|
||||
|
||||
if res.Error {
|
||||
log.Fatal().Msg(res.Message)
|
||||
log.Fatal().Err(err).Msg("Error getting heart rate")
|
||||
}
|
||||
|
||||
// Print returned BPM
|
||||
fmt.Printf("%d BPM\n", int(res.Value.(float64)))
|
||||
fmt.Printf("%d BPM\n", heartRate)
|
||||
},
|
||||
}
|
||||
|
||||
68
cmd/itctl/get/motion.go
Normal file
68
cmd/itctl/get/motion.go
Normal file
@@ -0,0 +1,68 @@
|
||||
/*
|
||||
* itd uses bluetooth low energy to communicate with InfiniTime devices
|
||||
* Copyright (C) 2021 Arsen Musayelyan
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package get
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/rs/zerolog/log"
|
||||
"github.com/spf13/cobra"
|
||||
"github.com/spf13/viper"
|
||||
"go.arsenm.dev/itd/api"
|
||||
)
|
||||
|
||||
// steps.goCmd represents the steps.go command
|
||||
var motionCmd = &cobra.Command{
|
||||
Use: "motion",
|
||||
Short: "Get motion values from InfiniTime",
|
||||
Run: func(cmd *cobra.Command, args []string) {
|
||||
client := viper.Get("client").(*api.Client)
|
||||
|
||||
motionVals, err := client.Motion()
|
||||
if err != nil {
|
||||
log.Fatal().Err(err).Msg("Error getting motion values")
|
||||
}
|
||||
|
||||
if viper.GetBool("shell") {
|
||||
fmt.Printf(
|
||||
"X=%d\nY=%d\nZ=%d",
|
||||
motionVals.X,
|
||||
motionVals.Y,
|
||||
motionVals.Z,
|
||||
)
|
||||
} else {
|
||||
fmt.Printf("%+v\n", motionVals)
|
||||
}
|
||||
},
|
||||
}
|
||||
|
||||
func init() {
|
||||
getCmd.AddCommand(motionCmd)
|
||||
|
||||
// Here you will define your flags and configuration settings.
|
||||
|
||||
// Cobra supports Persistent Flags which will work for this command
|
||||
// and all subcommands, e.g.:
|
||||
// steps.goCmd.PersistentFlags().String("foo", "", "A help for foo")
|
||||
|
||||
// Cobra supports local flags which will only run when this command
|
||||
// is called directly, e.g.:
|
||||
motionCmd.Flags().BoolP("shell", "s", false, "Output data in shell-compatible format")
|
||||
viper.BindPFlag("shell", motionCmd.Flags().Lookup("shell"))
|
||||
}
|
||||
59
cmd/itctl/get/steps.go
Normal file
59
cmd/itctl/get/steps.go
Normal file
@@ -0,0 +1,59 @@
|
||||
/*
|
||||
* itd uses bluetooth low energy to communicate with InfiniTime devices
|
||||
* Copyright (C) 2021 Arsen Musayelyan
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package get
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/rs/zerolog/log"
|
||||
"github.com/spf13/cobra"
|
||||
"github.com/spf13/viper"
|
||||
"go.arsenm.dev/itd/api"
|
||||
)
|
||||
|
||||
// steps.goCmd represents the steps.go command
|
||||
var stepsCmd = &cobra.Command{
|
||||
Use: "steps",
|
||||
Short: "Get step count from InfiniTime",
|
||||
Run: func(cmd *cobra.Command, args []string) {
|
||||
client := viper.Get("client").(*api.Client)
|
||||
|
||||
stepCount, err := client.StepCount()
|
||||
if err != nil {
|
||||
log.Fatal().Err(err).Msg("Error getting step count")
|
||||
}
|
||||
|
||||
// Print returned BPM
|
||||
fmt.Printf("%d Steps\n", stepCount)
|
||||
},
|
||||
}
|
||||
|
||||
func init() {
|
||||
getCmd.AddCommand(stepsCmd)
|
||||
|
||||
// Here you will define your flags and configuration settings.
|
||||
|
||||
// Cobra supports Persistent Flags which will work for this command
|
||||
// and all subcommands, e.g.:
|
||||
// steps.goCmd.PersistentFlags().String("foo", "", "A help for foo")
|
||||
|
||||
// Cobra supports local flags which will only run when this command
|
||||
// is called directly, e.g.:
|
||||
// steps.goCmd.Flags().BoolP("toggle", "t", false, "Help message for toggle")
|
||||
}
|
||||
@@ -19,9 +19,14 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"os"
|
||||
_ "go.arsenm.dev/itd/cmd/itctl/firmware"
|
||||
_ "go.arsenm.dev/itd/cmd/itctl/get"
|
||||
_ "go.arsenm.dev/itd/cmd/itctl/notify"
|
||||
"go.arsenm.dev/itd/cmd/itctl/root"
|
||||
_ "go.arsenm.dev/itd/cmd/itctl/set"
|
||||
_ "go.arsenm.dev/itd/cmd/itctl/watch"
|
||||
|
||||
"go.arsenm.dev/itd/cmd/itctl/cmd"
|
||||
"os"
|
||||
|
||||
"github.com/rs/zerolog"
|
||||
"github.com/rs/zerolog/log"
|
||||
@@ -32,5 +37,5 @@ func init() {
|
||||
}
|
||||
|
||||
func main() {
|
||||
cmd.Execute()
|
||||
root.Execute()
|
||||
}
|
||||
|
||||
@@ -16,16 +16,14 @@
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package cmd
|
||||
package notify
|
||||
|
||||
import (
|
||||
"bufio"
|
||||
"encoding/json"
|
||||
"net"
|
||||
|
||||
"github.com/rs/zerolog/log"
|
||||
"github.com/spf13/cobra"
|
||||
"go.arsenm.dev/itd/internal/types"
|
||||
"github.com/spf13/viper"
|
||||
"go.arsenm.dev/itd/api"
|
||||
"go.arsenm.dev/itd/cmd/itctl/root"
|
||||
)
|
||||
|
||||
// notifyCmd represents the notify command
|
||||
@@ -39,44 +37,15 @@ var notifyCmd = &cobra.Command{
|
||||
log.Fatal().Msg("Command notify requires two arguments")
|
||||
}
|
||||
|
||||
// Connect to itd UNIX socket
|
||||
conn, err := net.Dial("unix", SockPath)
|
||||
if err != nil {
|
||||
log.Fatal().Err(err).Msg("Error dialing socket. Is itd running?")
|
||||
}
|
||||
defer conn.Close()
|
||||
client := viper.Get("client").(*api.Client)
|
||||
|
||||
// Encode request into connection
|
||||
err = json.NewEncoder(conn).Encode(types.Request{
|
||||
Type: ReqTypeNotify,
|
||||
Data: types.ReqDataNotify{
|
||||
Title: args[0],
|
||||
Body: args[1],
|
||||
},
|
||||
})
|
||||
err := client.Notify(args[0], args[1])
|
||||
if err != nil {
|
||||
log.Fatal().Err(err).Msg("Error making request")
|
||||
}
|
||||
|
||||
// Read one line from connection
|
||||
line, _, err := bufio.NewReader(conn).ReadLine()
|
||||
if err != nil {
|
||||
log.Fatal().Err(err).Msg("Error reading line from connection")
|
||||
}
|
||||
|
||||
var res types.Response
|
||||
// Decode line into response
|
||||
err = json.Unmarshal(line, &res)
|
||||
if err != nil {
|
||||
log.Fatal().Err(err).Msg("Error decoding JSON data")
|
||||
}
|
||||
|
||||
if res.Error {
|
||||
log.Fatal().Msg(res.Message)
|
||||
log.Fatal().Err(err).Msg("Error sending notification")
|
||||
}
|
||||
},
|
||||
}
|
||||
|
||||
func init() {
|
||||
rootCmd.AddCommand(notifyCmd)
|
||||
root.RootCmd.AddCommand(notifyCmd)
|
||||
}
|
||||
@@ -16,15 +16,18 @@
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package cmd
|
||||
package root
|
||||
|
||||
import (
|
||||
"github.com/abiosoft/ishell"
|
||||
"github.com/rs/zerolog/log"
|
||||
"github.com/spf13/cobra"
|
||||
"github.com/spf13/viper"
|
||||
"go.arsenm.dev/itd/api"
|
||||
)
|
||||
|
||||
// rootCmd represents the base command when called without any subcommands
|
||||
var rootCmd = &cobra.Command{
|
||||
// RootCmd represents the base command when called without any subcommands
|
||||
var RootCmd = &cobra.Command{
|
||||
Use: "itctl",
|
||||
Short: "Control the itd daemon for InfiniTime smartwatches",
|
||||
Run: func(cmd *cobra.Command, args []string) {
|
||||
@@ -60,6 +63,25 @@ var rootCmd = &cobra.Command{
|
||||
// Execute adds all child commands to the root command and sets flags appropriately.
|
||||
// This is called by main.main(). It only needs to happen once to the rootCmd.
|
||||
func Execute() {
|
||||
rootCmd.CompletionOptions.DisableDefaultCmd = true
|
||||
cobra.CheckErr(rootCmd.Execute())
|
||||
client, err := api.New(viper.GetString("sockPath"))
|
||||
if err != nil {
|
||||
log.Fatal().Err(err).Msg("Error connecting to socket. Is itd running?")
|
||||
}
|
||||
defer client.Close()
|
||||
viper.Set("client", client)
|
||||
RootCmd.CompletionOptions.DisableDefaultCmd = true
|
||||
cobra.CheckErr(RootCmd.Execute())
|
||||
|
||||
}
|
||||
|
||||
func init() {
|
||||
// Register flag for socket path
|
||||
RootCmd.Flags().StringP("socket-path", "s", api.DefaultAddr, "Path to itd socket")
|
||||
|
||||
// Bind flag and environment variable to viper key
|
||||
viper.BindPFlag("sockPath", RootCmd.Flags().Lookup("socket-path"))
|
||||
viper.BindEnv("sockPath", "ITCTL_SOCKET_PATH")
|
||||
|
||||
// Set default value for socket path
|
||||
viper.SetDefault("sockPath", api.DefaultAddr)
|
||||
}
|
||||
@@ -16,10 +16,11 @@
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package cmd
|
||||
package set
|
||||
|
||||
import (
|
||||
"github.com/spf13/cobra"
|
||||
"go.arsenm.dev/itd/cmd/itctl/root"
|
||||
)
|
||||
|
||||
// setCmd represents the set command
|
||||
@@ -29,5 +30,5 @@ var setCmd = &cobra.Command{
|
||||
}
|
||||
|
||||
func init() {
|
||||
rootCmd.AddCommand(setCmd)
|
||||
root.RootCmd.AddCommand(setCmd)
|
||||
}
|
||||
@@ -16,7 +16,7 @@
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package cmd
|
||||
package set
|
||||
|
||||
import (
|
||||
"bufio"
|
||||
@@ -25,6 +25,7 @@ import (
|
||||
|
||||
"github.com/rs/zerolog/log"
|
||||
"github.com/spf13/cobra"
|
||||
"github.com/spf13/viper"
|
||||
"go.arsenm.dev/itd/internal/types"
|
||||
)
|
||||
|
||||
@@ -41,7 +42,7 @@ var timeCmd = &cobra.Command{
|
||||
}
|
||||
|
||||
// Connect to itd UNIX socket
|
||||
conn, err := net.Dial("unix", SockPath)
|
||||
conn, err := net.Dial("unix", viper.GetString("sockPath"))
|
||||
if err != nil {
|
||||
log.Fatal().Err(err).Msg("Error dialing socket. Is itd running?")
|
||||
}
|
||||
@@ -49,7 +50,7 @@ var timeCmd = &cobra.Command{
|
||||
|
||||
// Encode request into connection
|
||||
err = json.NewEncoder(conn).Encode(types.Request{
|
||||
Type: ReqTypeSetTime,
|
||||
Type: types.ReqTypeSetTime,
|
||||
Data: args[0],
|
||||
})
|
||||
if err != nil {
|
||||
76
cmd/itctl/watch/battery.go
Normal file
76
cmd/itctl/watch/battery.go
Normal file
@@ -0,0 +1,76 @@
|
||||
/*
|
||||
* itd uses bluetooth low energy to communicate with InfiniTime devices
|
||||
* Copyright (C) 2021 Arsen Musayelyan
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package watch
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
"os/signal"
|
||||
"syscall"
|
||||
|
||||
"github.com/rs/zerolog/log"
|
||||
"github.com/spf13/cobra"
|
||||
"github.com/spf13/viper"
|
||||
"go.arsenm.dev/itd/api"
|
||||
)
|
||||
|
||||
// heartCmd represents the address command
|
||||
var batteryCmd = &cobra.Command{
|
||||
Use: "battery",
|
||||
Aliases: []string{"batt"},
|
||||
Short: "Watch InfiniTime's battery level for changes",
|
||||
Run: func(cmd *cobra.Command, args []string) {
|
||||
client := viper.Get("client").(*api.Client)
|
||||
|
||||
battLevelCh, cancel, err := client.WatchBatteryLevel()
|
||||
if err != nil {
|
||||
log.Fatal().Err(err).Msg("Error getting battery level channel")
|
||||
}
|
||||
defer cancel()
|
||||
|
||||
signalCh := make(chan os.Signal, 1)
|
||||
go func() {
|
||||
<-signalCh
|
||||
cancel()
|
||||
os.Exit(0)
|
||||
}()
|
||||
signal.Notify(signalCh,
|
||||
syscall.SIGINT,
|
||||
syscall.SIGTERM,
|
||||
)
|
||||
|
||||
for battlevel := range battLevelCh {
|
||||
fmt.Printf("%d%%\n", battlevel)
|
||||
}
|
||||
},
|
||||
}
|
||||
|
||||
func init() {
|
||||
watchCmd.AddCommand(batteryCmd)
|
||||
|
||||
// Here you will define your flags and configuration settings.
|
||||
|
||||
// Cobra supports Persistent Flags which will work for this command
|
||||
// and all subcommands, e.g.:
|
||||
// addressCmd.PersistentFlags().String("foo", "", "A help for foo")
|
||||
|
||||
// Cobra supports local flags which will only run when this command
|
||||
// is called directly, e.g.:
|
||||
// addressCmd.Flags().BoolP("toggle", "t", false, "Help message for toggle")
|
||||
}
|
||||
75
cmd/itctl/watch/heart.go
Normal file
75
cmd/itctl/watch/heart.go
Normal file
@@ -0,0 +1,75 @@
|
||||
/*
|
||||
* itd uses bluetooth low energy to communicate with InfiniTime devices
|
||||
* Copyright (C) 2021 Arsen Musayelyan
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package watch
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
"os/signal"
|
||||
"syscall"
|
||||
|
||||
"github.com/rs/zerolog/log"
|
||||
"github.com/spf13/cobra"
|
||||
"github.com/spf13/viper"
|
||||
"go.arsenm.dev/itd/api"
|
||||
)
|
||||
|
||||
// heartCmd represents the address command
|
||||
var heartCmd = &cobra.Command{
|
||||
Use: "heart",
|
||||
Short: "Watch InfiniTime's heart rate for changes",
|
||||
Run: func(cmd *cobra.Command, args []string) {
|
||||
client := viper.Get("client").(*api.Client)
|
||||
|
||||
heartRateCh, cancel, err := client.WatchHeartRate()
|
||||
if err != nil {
|
||||
log.Fatal().Err(err).Msg("Error getting heart rate channel")
|
||||
}
|
||||
defer cancel()
|
||||
|
||||
signalCh := make(chan os.Signal, 1)
|
||||
go func() {
|
||||
<-signalCh
|
||||
cancel()
|
||||
os.Exit(0)
|
||||
}()
|
||||
signal.Notify(signalCh,
|
||||
syscall.SIGINT,
|
||||
syscall.SIGTERM,
|
||||
)
|
||||
|
||||
for heartRate := range heartRateCh {
|
||||
fmt.Println(heartRate, "BPM")
|
||||
}
|
||||
},
|
||||
}
|
||||
|
||||
func init() {
|
||||
watchCmd.AddCommand(heartCmd)
|
||||
|
||||
// Here you will define your flags and configuration settings.
|
||||
|
||||
// Cobra supports Persistent Flags which will work for this command
|
||||
// and all subcommands, e.g.:
|
||||
// addressCmd.PersistentFlags().String("foo", "", "A help for foo")
|
||||
|
||||
// Cobra supports local flags which will only run when this command
|
||||
// is called directly, e.g.:
|
||||
// addressCmd.Flags().BoolP("toggle", "t", false, "Help message for toggle")
|
||||
}
|
||||
86
cmd/itctl/watch/motion.go
Normal file
86
cmd/itctl/watch/motion.go
Normal file
@@ -0,0 +1,86 @@
|
||||
/*
|
||||
* itd uses bluetooth low energy to communicate with InfiniTime devices
|
||||
* Copyright (C) 2021 Arsen Musayelyan
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package watch
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
"os/signal"
|
||||
"syscall"
|
||||
|
||||
"github.com/rs/zerolog/log"
|
||||
"github.com/spf13/cobra"
|
||||
"github.com/spf13/viper"
|
||||
"go.arsenm.dev/itd/api"
|
||||
)
|
||||
|
||||
// heartCmd represents the address command
|
||||
var motionCmd = &cobra.Command{
|
||||
Use: "motion",
|
||||
Short: "Watch InfiniTime's motion values for changes",
|
||||
Run: func(cmd *cobra.Command, args []string) {
|
||||
client := viper.Get("client").(*api.Client)
|
||||
|
||||
motionValCh, cancel, err := client.WatchMotion()
|
||||
if err != nil {
|
||||
log.Fatal().Err(err).Msg("Error getting motion value channel")
|
||||
}
|
||||
defer cancel()
|
||||
|
||||
signalCh := make(chan os.Signal, 1)
|
||||
go func() {
|
||||
<-signalCh
|
||||
cancel()
|
||||
os.Exit(0)
|
||||
}()
|
||||
signal.Notify(signalCh,
|
||||
syscall.SIGINT,
|
||||
syscall.SIGTERM,
|
||||
)
|
||||
|
||||
for motionVals := range motionValCh {
|
||||
if viper.GetBool("shell") {
|
||||
fmt.Printf(
|
||||
"X=%d\nY=%d\nZ=%d\n",
|
||||
motionVals.X,
|
||||
motionVals.Y,
|
||||
motionVals.Z,
|
||||
)
|
||||
} else {
|
||||
fmt.Printf("%+v\n", motionVals)
|
||||
}
|
||||
}
|
||||
},
|
||||
}
|
||||
|
||||
func init() {
|
||||
watchCmd.AddCommand(motionCmd)
|
||||
|
||||
// Here you will define your flags and configuration settings.
|
||||
|
||||
// Cobra supports Persistent Flags which will work for this command
|
||||
// and all subcommands, e.g.:
|
||||
// addressCmd.PersistentFlags().String("foo", "", "A help for foo")
|
||||
|
||||
// Cobra supports local flags which will only run when this command
|
||||
// is called directly, e.g.:
|
||||
// addressCmd.Flags().BoolP("toggle", "t", false, "Help message for toggle")
|
||||
motionCmd.Flags().BoolP("shell", "s", false, "Output data in shell-compatible format")
|
||||
viper.BindPFlag("shell", motionCmd.Flags().Lookup("shell"))
|
||||
}
|
||||
75
cmd/itctl/watch/steps.go
Normal file
75
cmd/itctl/watch/steps.go
Normal file
@@ -0,0 +1,75 @@
|
||||
/*
|
||||
* itd uses bluetooth low energy to communicate with InfiniTime devices
|
||||
* Copyright (C) 2021 Arsen Musayelyan
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package watch
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
"os/signal"
|
||||
"syscall"
|
||||
|
||||
"github.com/rs/zerolog/log"
|
||||
"github.com/spf13/cobra"
|
||||
"github.com/spf13/viper"
|
||||
"go.arsenm.dev/itd/api"
|
||||
)
|
||||
|
||||
// heartCmd represents the address command
|
||||
var stepsCmd = &cobra.Command{
|
||||
Use: "steps",
|
||||
Short: "Watch InfiniTime's step count for changes",
|
||||
Run: func(cmd *cobra.Command, args []string) {
|
||||
client := viper.Get("client").(*api.Client)
|
||||
|
||||
stepCountCh, cancel, err := client.WatchStepCount()
|
||||
if err != nil {
|
||||
log.Fatal().Err(err).Msg("Error getting step count channel")
|
||||
}
|
||||
defer cancel()
|
||||
|
||||
signalCh := make(chan os.Signal, 1)
|
||||
go func() {
|
||||
<-signalCh
|
||||
cancel()
|
||||
os.Exit(0)
|
||||
}()
|
||||
signal.Notify(signalCh,
|
||||
syscall.SIGINT,
|
||||
syscall.SIGTERM,
|
||||
)
|
||||
|
||||
for stepCount := range stepCountCh {
|
||||
fmt.Println(stepCount, "Steps")
|
||||
}
|
||||
},
|
||||
}
|
||||
|
||||
func init() {
|
||||
watchCmd.AddCommand(stepsCmd)
|
||||
|
||||
// Here you will define your flags and configuration settings.
|
||||
|
||||
// Cobra supports Persistent Flags which will work for this command
|
||||
// and all subcommands, e.g.:
|
||||
// addressCmd.PersistentFlags().String("foo", "", "A help for foo")
|
||||
|
||||
// Cobra supports local flags which will only run when this command
|
||||
// is called directly, e.g.:
|
||||
// addressCmd.Flags().BoolP("toggle", "t", false, "Help message for toggle")
|
||||
}
|
||||
@@ -16,26 +16,19 @@
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package cmd
|
||||
package watch
|
||||
|
||||
const SockPath = "/tmp/itd/socket"
|
||||
|
||||
const (
|
||||
ReqTypeHeartRate = "hrt"
|
||||
ReqTypeBattLevel = "battlvl"
|
||||
ReqTypeFwVersion = "fwver"
|
||||
ReqTypeFwUpgrade = "fwupg"
|
||||
ReqTypeBtAddress = "btaddr"
|
||||
ReqTypeNotify = "notify"
|
||||
ReqTypeSetTime = "settime"
|
||||
import (
|
||||
"github.com/spf13/cobra"
|
||||
"go.arsenm.dev/itd/cmd/itctl/root"
|
||||
)
|
||||
|
||||
const (
|
||||
UpgradeTypeArchive = iota
|
||||
UpgradeTypeFiles
|
||||
)
|
||||
|
||||
type DFUProgress struct {
|
||||
Received int64 `mapstructure:"recvd"`
|
||||
Total int64 `mapstructure:"total"`
|
||||
// watchCmd represents the watch command
|
||||
var watchCmd = &cobra.Command{
|
||||
Use: "watch",
|
||||
Short: "Watch values from InfiniTime for changes",
|
||||
}
|
||||
|
||||
func init() {
|
||||
root.RootCmd.AddCommand(watchCmd)
|
||||
}
|
||||
53
cmd/itgui/error.go
Normal file
53
cmd/itgui/error.go
Normal file
@@ -0,0 +1,53 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"image/color"
|
||||
"os"
|
||||
|
||||
"fyne.io/fyne/v2"
|
||||
"fyne.io/fyne/v2/canvas"
|
||||
"fyne.io/fyne/v2/container"
|
||||
"fyne.io/fyne/v2/dialog"
|
||||
"fyne.io/fyne/v2/widget"
|
||||
)
|
||||
|
||||
func guiErr(err error, msg string, fatal bool, parent fyne.Window) {
|
||||
// Create new label containing message
|
||||
msgLbl := widget.NewLabel(msg)
|
||||
// Text formatting settings
|
||||
msgLbl.Wrapping = fyne.TextWrapWord
|
||||
msgLbl.Alignment = fyne.TextAlignCenter
|
||||
// Create new rectangle to set the size of the dialog
|
||||
rect := canvas.NewRectangle(color.Transparent)
|
||||
// Set minimum size of rectangle to 350x0
|
||||
rect.SetMinSize(fyne.NewSize(350, 0))
|
||||
// Create new container containing message and rectangle
|
||||
content := container.NewVBox(
|
||||
msgLbl,
|
||||
rect,
|
||||
)
|
||||
if err != nil {
|
||||
// Create new label containing error text
|
||||
errLbl := widget.NewLabel(err.Error())
|
||||
// Create new dropdown containing error label
|
||||
content.Add(widget.NewAccordion(
|
||||
widget.NewAccordionItem("More Details", errLbl),
|
||||
))
|
||||
}
|
||||
if fatal {
|
||||
// Create new error dialog
|
||||
errDlg := dialog.NewCustom("Error", "Close", content, parent)
|
||||
// On close, exit with code 1
|
||||
errDlg.SetOnClosed(func() {
|
||||
os.Exit(1)
|
||||
})
|
||||
// Show dialog
|
||||
errDlg.Show()
|
||||
// Run app prematurely to stop further execution
|
||||
parent.ShowAndRun()
|
||||
} else {
|
||||
// Show error dialog
|
||||
dialog.NewCustom("Error", "Ok", content, parent).Show()
|
||||
}
|
||||
|
||||
}
|
||||
123
cmd/itgui/info.go
Normal file
123
cmd/itgui/info.go
Normal file
@@ -0,0 +1,123 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"image/color"
|
||||
|
||||
"fyne.io/fyne/v2"
|
||||
"fyne.io/fyne/v2/canvas"
|
||||
"fyne.io/fyne/v2/container"
|
||||
"fyne.io/fyne/v2/theme"
|
||||
"go.arsenm.dev/itd/api"
|
||||
)
|
||||
|
||||
func infoTab(parent fyne.Window, client *api.Client) *fyne.Container {
|
||||
infoLayout := container.NewVBox(
|
||||
// Add rectangle for a bit of padding
|
||||
canvas.NewRectangle(color.Transparent),
|
||||
)
|
||||
|
||||
// Create label for heart rate
|
||||
heartRateLbl := newText("0 BPM", 24)
|
||||
// Creae container to store heart rate section
|
||||
heartRateSect := container.NewVBox(
|
||||
newText("Heart Rate", 12),
|
||||
heartRateLbl,
|
||||
canvas.NewLine(theme.ShadowColor()),
|
||||
)
|
||||
infoLayout.Add(heartRateSect)
|
||||
|
||||
heartRateCh, cancel, err := client.WatchHeartRate()
|
||||
if err != nil {
|
||||
guiErr(err, "Error getting heart rate channel", true, parent)
|
||||
}
|
||||
onClose = append(onClose, cancel)
|
||||
go func() {
|
||||
for heartRate := range heartRateCh {
|
||||
// Change text of heart rate label
|
||||
heartRateLbl.Text = fmt.Sprintf("%d BPM", heartRate)
|
||||
// Refresh label
|
||||
heartRateLbl.Refresh()
|
||||
}
|
||||
}()
|
||||
|
||||
// Create label for heart rate
|
||||
stepCountLbl := newText("0 Steps", 24)
|
||||
// Creae container to store heart rate section
|
||||
stepCountSect := container.NewVBox(
|
||||
newText("Step Count", 12),
|
||||
stepCountLbl,
|
||||
canvas.NewLine(theme.ShadowColor()),
|
||||
)
|
||||
infoLayout.Add(stepCountSect)
|
||||
|
||||
stepCountCh, cancel, err := client.WatchStepCount()
|
||||
if err != nil {
|
||||
guiErr(err, "Error getting step count channel", true, parent)
|
||||
}
|
||||
onClose = append(onClose, cancel)
|
||||
go func() {
|
||||
for stepCount := range stepCountCh {
|
||||
// Change text of heart rate label
|
||||
stepCountLbl.Text = fmt.Sprintf("%d Steps", stepCount)
|
||||
// Refresh label
|
||||
stepCountLbl.Refresh()
|
||||
}
|
||||
}()
|
||||
|
||||
// Create label for battery level
|
||||
battLevelLbl := newText("0%", 24)
|
||||
// Create container to store battery level section
|
||||
battLevel := container.NewVBox(
|
||||
newText("Battery Level", 12),
|
||||
battLevelLbl,
|
||||
canvas.NewLine(theme.ShadowColor()),
|
||||
)
|
||||
infoLayout.Add(battLevel)
|
||||
|
||||
battLevelCh, cancel, err := client.WatchBatteryLevel()
|
||||
if err != nil {
|
||||
guiErr(err, "Error getting battery level channel", true, parent)
|
||||
}
|
||||
onClose = append(onClose, cancel)
|
||||
go func() {
|
||||
for battLevel := range battLevelCh {
|
||||
// Change text of battery level label
|
||||
battLevelLbl.Text = fmt.Sprintf("%d%%", battLevel)
|
||||
// Refresh label
|
||||
battLevelLbl.Refresh()
|
||||
}
|
||||
}()
|
||||
|
||||
fwVerString, err := client.Version()
|
||||
if err != nil {
|
||||
guiErr(err, "Error getting firmware string", true, parent)
|
||||
}
|
||||
|
||||
fwVer := container.NewVBox(
|
||||
newText("Firmware Version", 12),
|
||||
newText(fwVerString, 24),
|
||||
canvas.NewLine(theme.ShadowColor()),
|
||||
)
|
||||
infoLayout.Add(fwVer)
|
||||
|
||||
btAddrString, err := client.Address()
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
btAddr := container.NewVBox(
|
||||
newText("Bluetooth Address", 12),
|
||||
newText(btAddrString, 24),
|
||||
canvas.NewLine(theme.ShadowColor()),
|
||||
)
|
||||
infoLayout.Add(btAddr)
|
||||
|
||||
return infoLayout
|
||||
}
|
||||
|
||||
func newText(t string, size float32) *canvas.Text {
|
||||
text := canvas.NewText(t, theme.ForegroundColor())
|
||||
text.TextSize = size
|
||||
return text
|
||||
}
|
||||
43
cmd/itgui/main.go
Normal file
43
cmd/itgui/main.go
Normal file
@@ -0,0 +1,43 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"fyne.io/fyne/v2/app"
|
||||
"fyne.io/fyne/v2/container"
|
||||
"go.arsenm.dev/itd/api"
|
||||
)
|
||||
|
||||
var onClose []func()
|
||||
|
||||
func main() {
|
||||
// Create new app
|
||||
a := app.New()
|
||||
// Create new window with title "itgui"
|
||||
window := a.NewWindow("itgui")
|
||||
window.SetOnClosed(func() {
|
||||
for _, closeFn := range onClose {
|
||||
closeFn()
|
||||
}
|
||||
})
|
||||
|
||||
client, err := api.New(api.DefaultAddr)
|
||||
if err != nil {
|
||||
guiErr(err, "Error connecting to itd", true, window)
|
||||
}
|
||||
onClose = append(onClose, func() {
|
||||
client.Close()
|
||||
})
|
||||
|
||||
// Create new app tabs container
|
||||
tabs := container.NewAppTabs(
|
||||
container.NewTabItem("Info", infoTab(window, client)),
|
||||
container.NewTabItem("Motion", motionTab(window, client)),
|
||||
container.NewTabItem("Notify", notifyTab(window, client)),
|
||||
container.NewTabItem("Set Time", timeTab(window, client)),
|
||||
container.NewTabItem("Upgrade", upgradeTab(window, client)),
|
||||
)
|
||||
|
||||
// Set tabs as window content
|
||||
window.SetContent(tabs)
|
||||
// Show window and run app
|
||||
window.ShowAndRun()
|
||||
}
|
||||
105
cmd/itgui/motion.go
Normal file
105
cmd/itgui/motion.go
Normal file
@@ -0,0 +1,105 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"image/color"
|
||||
"strconv"
|
||||
|
||||
"fyne.io/fyne/v2"
|
||||
"fyne.io/fyne/v2/canvas"
|
||||
"fyne.io/fyne/v2/container"
|
||||
"fyne.io/fyne/v2/theme"
|
||||
"fyne.io/fyne/v2/widget"
|
||||
"go.arsenm.dev/itd/api"
|
||||
)
|
||||
|
||||
func motionTab(parent fyne.Window, client *api.Client) *fyne.Container {
|
||||
// Create label for heart rate
|
||||
xCoordLbl := newText("0", 24)
|
||||
// Creae container to store heart rate section
|
||||
xCoordSect := container.NewVBox(
|
||||
newText("X Coordinate", 12),
|
||||
xCoordLbl,
|
||||
canvas.NewLine(theme.ShadowColor()),
|
||||
)
|
||||
|
||||
// Create label for heart rate
|
||||
yCoordLbl := newText("0", 24)
|
||||
// Creae container to store heart rate section
|
||||
yCoordSect := container.NewVBox(
|
||||
newText("Y Coordinate", 12),
|
||||
yCoordLbl,
|
||||
canvas.NewLine(theme.ShadowColor()),
|
||||
)
|
||||
// Create label for heart rate
|
||||
zCoordLbl := newText("0", 24)
|
||||
// Creae container to store heart rate section
|
||||
zCoordSect := container.NewVBox(
|
||||
newText("Z Coordinate", 12),
|
||||
zCoordLbl,
|
||||
canvas.NewLine(theme.ShadowColor()),
|
||||
)
|
||||
|
||||
// Create variable to keep track of whether motion started
|
||||
started := false
|
||||
|
||||
// Create button to stop motion
|
||||
stopBtn := widget.NewButton("Stop", nil)
|
||||
// Create button to start motion
|
||||
startBtn := widget.NewButton("Start", func() {
|
||||
// if motion is started
|
||||
if started {
|
||||
// Do nothing
|
||||
return
|
||||
}
|
||||
// Set motion started
|
||||
started = true
|
||||
// Watch motion values
|
||||
motionCh, cancel, err := client.WatchMotion()
|
||||
if err != nil {
|
||||
guiErr(err, "Error getting heart rate channel", true, parent)
|
||||
}
|
||||
// Create done channel
|
||||
done := make(chan struct{}, 1)
|
||||
go func() {
|
||||
for {
|
||||
select {
|
||||
case <-done:
|
||||
return
|
||||
case motion := <-motionCh:
|
||||
// Set labels to new values
|
||||
xCoordLbl.Text = strconv.Itoa(int(motion.X))
|
||||
yCoordLbl.Text = strconv.Itoa(int(motion.Y))
|
||||
zCoordLbl.Text = strconv.Itoa(int(motion.Z))
|
||||
// Refresh labels to display new values
|
||||
xCoordLbl.Refresh()
|
||||
yCoordLbl.Refresh()
|
||||
zCoordLbl.Refresh()
|
||||
}
|
||||
}
|
||||
}()
|
||||
// Create stop function
|
||||
stopBtn.OnTapped = func() {
|
||||
done <- struct{}{}
|
||||
started = false
|
||||
cancel()
|
||||
}
|
||||
|
||||
})
|
||||
// Run stop button function on close if possible
|
||||
onClose = append(onClose, func() {
|
||||
if stopBtn.OnTapped != nil {
|
||||
stopBtn.OnTapped()
|
||||
}
|
||||
})
|
||||
|
||||
// Return new container containing all elements
|
||||
return container.NewVBox(
|
||||
// Add rectangle for a bit of padding
|
||||
canvas.NewRectangle(color.Transparent),
|
||||
startBtn,
|
||||
stopBtn,
|
||||
xCoordSect,
|
||||
yCoordSect,
|
||||
zCoordSect,
|
||||
)
|
||||
}
|
||||
37
cmd/itgui/notify.go
Normal file
37
cmd/itgui/notify.go
Normal file
@@ -0,0 +1,37 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"fyne.io/fyne/v2"
|
||||
"fyne.io/fyne/v2/container"
|
||||
"fyne.io/fyne/v2/layout"
|
||||
"fyne.io/fyne/v2/widget"
|
||||
"go.arsenm.dev/itd/api"
|
||||
)
|
||||
|
||||
func notifyTab(parent fyne.Window, client *api.Client) *fyne.Container {
|
||||
// Create new entry for notification title
|
||||
titleEntry := widget.NewEntry()
|
||||
titleEntry.SetPlaceHolder("Title")
|
||||
|
||||
// Create multiline entry for notification body
|
||||
bodyEntry := widget.NewMultiLineEntry()
|
||||
bodyEntry.SetPlaceHolder("Body")
|
||||
|
||||
// Create new button to send notification
|
||||
sendBtn := widget.NewButton("Send", func() {
|
||||
err := client.Notify(titleEntry.Text, bodyEntry.Text)
|
||||
if err != nil {
|
||||
guiErr(err, "Error sending notification", false, parent)
|
||||
return
|
||||
}
|
||||
})
|
||||
|
||||
// Return new container containing all elements
|
||||
return container.NewVBox(
|
||||
layout.NewSpacer(),
|
||||
titleEntry,
|
||||
bodyEntry,
|
||||
sendBtn,
|
||||
layout.NewSpacer(),
|
||||
)
|
||||
}
|
||||
60
cmd/itgui/time.go
Normal file
60
cmd/itgui/time.go
Normal file
@@ -0,0 +1,60 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
"fyne.io/fyne/v2"
|
||||
"fyne.io/fyne/v2/container"
|
||||
"fyne.io/fyne/v2/layout"
|
||||
"fyne.io/fyne/v2/widget"
|
||||
"go.arsenm.dev/itd/api"
|
||||
)
|
||||
|
||||
func timeTab(parent fyne.Window, client *api.Client) *fyne.Container {
|
||||
// Create new entry for time string
|
||||
timeEntry := widget.NewEntry()
|
||||
// Set text to current time formatter properly
|
||||
timeEntry.SetText(time.Now().Format(time.RFC1123))
|
||||
|
||||
// Create button to set current time
|
||||
currentBtn := widget.NewButton("Set Current", func() {
|
||||
timeEntry.SetText(time.Now().Format(time.RFC1123))
|
||||
setTime(client, true)
|
||||
})
|
||||
|
||||
// Create button to set time inside entry
|
||||
timeBtn := widget.NewButton("Set", func() {
|
||||
// Parse time as RFC1123 string
|
||||
parsedTime, err := time.Parse(time.RFC1123, timeEntry.Text)
|
||||
if err != nil {
|
||||
guiErr(err, "Error parsing time string", false, parent)
|
||||
return
|
||||
}
|
||||
// Set time to parsed time
|
||||
setTime(client, false, parsedTime)
|
||||
})
|
||||
|
||||
// Return new container with all elements centered
|
||||
return container.NewVBox(
|
||||
layout.NewSpacer(),
|
||||
timeEntry,
|
||||
currentBtn,
|
||||
timeBtn,
|
||||
layout.NewSpacer(),
|
||||
)
|
||||
}
|
||||
|
||||
// setTime sets the first element in the variadic parameter
|
||||
// if current is false, otherwise, it sets the current time.
|
||||
func setTime(client *api.Client, current bool, t ...time.Time) error {
|
||||
var err error
|
||||
if current {
|
||||
err = client.SetTimeNow()
|
||||
} else {
|
||||
err = client.SetTime(t[0])
|
||||
}
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
165
cmd/itgui/upgrade.go
Normal file
165
cmd/itgui/upgrade.go
Normal file
@@ -0,0 +1,165 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"path/filepath"
|
||||
|
||||
"fyne.io/fyne/v2"
|
||||
"fyne.io/fyne/v2/container"
|
||||
"fyne.io/fyne/v2/dialog"
|
||||
"fyne.io/fyne/v2/layout"
|
||||
"fyne.io/fyne/v2/storage"
|
||||
"fyne.io/fyne/v2/widget"
|
||||
"go.arsenm.dev/itd/api"
|
||||
"go.arsenm.dev/itd/internal/types"
|
||||
)
|
||||
|
||||
func upgradeTab(parent fyne.Window, client *api.Client) *fyne.Container {
|
||||
var (
|
||||
archivePath string
|
||||
firmwarePath string
|
||||
initPktPath string
|
||||
)
|
||||
|
||||
var archiveBtn *widget.Button
|
||||
// Create archive selection dialog
|
||||
archiveDialog := dialog.NewFileOpen(func(uc fyne.URIReadCloser, e error) {
|
||||
if e != nil || uc == nil {
|
||||
return
|
||||
}
|
||||
uc.Close()
|
||||
archivePath = uc.URI().Path()
|
||||
archiveBtn.SetText(fmt.Sprintf("Select archive (.zip) [%s]", filepath.Base(archivePath)))
|
||||
}, parent)
|
||||
// Limit dialog to .zip files
|
||||
archiveDialog.SetFilter(storage.NewExtensionFileFilter([]string{".zip"}))
|
||||
// Create button to show dialog
|
||||
archiveBtn = widget.NewButton("Select archive (.zip)", archiveDialog.Show)
|
||||
|
||||
var firmwareBtn *widget.Button
|
||||
// Create firmware selection dialog
|
||||
firmwareDialog := dialog.NewFileOpen(func(uc fyne.URIReadCloser, e error) {
|
||||
if e != nil || uc == nil {
|
||||
return
|
||||
}
|
||||
uc.Close()
|
||||
firmwarePath = uc.URI().Path()
|
||||
firmwareBtn.SetText(fmt.Sprintf("Select firmware (.bin) [%s]", filepath.Base(firmwarePath)))
|
||||
}, parent)
|
||||
// Limit dialog to .bin files
|
||||
firmwareDialog.SetFilter(storage.NewExtensionFileFilter([]string{".bin"}))
|
||||
// Create button to show dialog
|
||||
firmwareBtn = widget.NewButton("Select firmware (.bin)", firmwareDialog.Show)
|
||||
|
||||
var initPktBtn *widget.Button
|
||||
// Create init packet selection dialog
|
||||
initPktDialog := dialog.NewFileOpen(func(uc fyne.URIReadCloser, e error) {
|
||||
if e != nil || uc == nil {
|
||||
return
|
||||
}
|
||||
uc.Close()
|
||||
initPktPath = uc.URI().Path()
|
||||
initPktBtn.SetText(fmt.Sprintf("Select init packet (.dat) [%s]", filepath.Base(initPktPath)))
|
||||
}, parent)
|
||||
// Limit dialog to .dat files
|
||||
initPktDialog.SetFilter(storage.NewExtensionFileFilter([]string{".dat"}))
|
||||
// Create button to show dialog
|
||||
initPktBtn = widget.NewButton("Select init packet (.dat)", initPktDialog.Show)
|
||||
|
||||
// Hide init packet and firmware buttons
|
||||
initPktBtn.Hide()
|
||||
firmwareBtn.Hide()
|
||||
|
||||
// Create dropdown to select upgrade type
|
||||
upgradeTypeSelect := widget.NewSelect([]string{
|
||||
"Archive",
|
||||
"Files",
|
||||
}, func(s string) {
|
||||
// Hide all buttons
|
||||
archiveBtn.Hide()
|
||||
initPktBtn.Hide()
|
||||
firmwareBtn.Hide()
|
||||
// Unhide appropriate button(s)
|
||||
switch s {
|
||||
case "Archive":
|
||||
archiveBtn.Show()
|
||||
case "Files":
|
||||
initPktBtn.Show()
|
||||
firmwareBtn.Show()
|
||||
}
|
||||
})
|
||||
// Select first elemetn
|
||||
upgradeTypeSelect.SetSelectedIndex(0)
|
||||
|
||||
// Create new button to start DFU
|
||||
startBtn := widget.NewButton("Start", func() {
|
||||
// If archive path does not exist and both init packet and firmware paths
|
||||
// also do not exist, return error
|
||||
if archivePath == "" && (initPktPath == "" && firmwarePath == "") {
|
||||
guiErr(nil, "Upgrade requires archive or files selected", false, parent)
|
||||
return
|
||||
}
|
||||
|
||||
// Create new label for byte progress
|
||||
progressLbl := widget.NewLabelWithStyle("0 / 0 B", fyne.TextAlignCenter, fyne.TextStyle{})
|
||||
// Create new progress bar
|
||||
progressBar := widget.NewProgressBar()
|
||||
// Create modal dialog containing label and progress bar
|
||||
progressDlg := widget.NewModalPopUp(container.NewVBox(
|
||||
layout.NewSpacer(),
|
||||
progressLbl,
|
||||
progressBar,
|
||||
layout.NewSpacer(),
|
||||
), parent.Canvas())
|
||||
// Resize modal to 300x100
|
||||
progressDlg.Resize(fyne.NewSize(300, 100))
|
||||
|
||||
var fwUpgType api.UpgradeType
|
||||
var files []string
|
||||
// Get appropriate upgrade type and file paths
|
||||
switch upgradeTypeSelect.Selected {
|
||||
case "Archive":
|
||||
fwUpgType = types.UpgradeTypeArchive
|
||||
files = append(files, archivePath)
|
||||
case "Files":
|
||||
fwUpgType = types.UpgradeTypeFiles
|
||||
files = append(files, initPktPath, firmwarePath)
|
||||
}
|
||||
|
||||
progress, err := client.FirmwareUpgrade(fwUpgType, files...)
|
||||
if err != nil {
|
||||
guiErr(err, "Error initiating DFU", false, parent)
|
||||
return
|
||||
}
|
||||
|
||||
// Show progress dialog
|
||||
progressDlg.Show()
|
||||
// Hide progress dialog after completion
|
||||
defer progressDlg.Hide()
|
||||
|
||||
for event := range progress {
|
||||
// Set label text to received / total B
|
||||
progressLbl.SetText(fmt.Sprintf("%d / %d B", event.Received, event.Total))
|
||||
// Set progress bar values
|
||||
progressBar.Max = float64(event.Total)
|
||||
progressBar.Value = float64(event.Received)
|
||||
// Refresh progress bar
|
||||
progressBar.Refresh()
|
||||
// If transfer finished, break
|
||||
if event.Sent == event.Total {
|
||||
break
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
// Return container containing all elements
|
||||
return container.NewVBox(
|
||||
layout.NewSpacer(),
|
||||
upgradeTypeSelect,
|
||||
archiveBtn,
|
||||
firmwareBtn,
|
||||
initPktBtn,
|
||||
startBtn,
|
||||
layout.NewSpacer(),
|
||||
)
|
||||
}
|
||||
47
config.go
Normal file
47
config.go
Normal file
@@ -0,0 +1,47 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"os"
|
||||
"strings"
|
||||
|
||||
"github.com/rs/zerolog"
|
||||
"github.com/rs/zerolog/log"
|
||||
"github.com/spf13/viper"
|
||||
)
|
||||
|
||||
func init() {
|
||||
// Set up logger
|
||||
log.Logger = log.Output(zerolog.ConsoleWriter{Out: os.Stderr})
|
||||
|
||||
// Set config settings
|
||||
setCfgDefaults()
|
||||
viper.AddConfigPath("$HOME/.config")
|
||||
viper.AddConfigPath("/etc")
|
||||
viper.SetConfigName("itd")
|
||||
viper.SetConfigType("toml")
|
||||
viper.WatchConfig()
|
||||
viper.SetEnvKeyReplacer(strings.NewReplacer(".", "_"))
|
||||
viper.SetEnvPrefix("itd")
|
||||
// Ignore error because defaults set
|
||||
viper.ReadInConfig()
|
||||
viper.AutomaticEnv()
|
||||
}
|
||||
|
||||
func setCfgDefaults() {
|
||||
viper.SetDefault("cfg.version", 2)
|
||||
|
||||
viper.SetDefault("socket.path", "/tmp/itd/socket")
|
||||
|
||||
viper.SetDefault("conn.reconnect", true)
|
||||
|
||||
viper.SetDefault("on.connect.notify", true)
|
||||
|
||||
viper.SetDefault("on.reconnect.notify", true)
|
||||
viper.SetDefault("on.reconnect.setTime", true)
|
||||
|
||||
viper.SetDefault("notifs.ignore.sender", []string{})
|
||||
viper.SetDefault("notifs.ignore.summary", []string{"InfiniTime"})
|
||||
viper.SetDefault("notifs.ignore.body", []string{})
|
||||
|
||||
viper.SetDefault("music.vol.interval", 5)
|
||||
}
|
||||
30
go.mod
30
go.mod
@@ -3,23 +3,31 @@ module go.arsenm.dev/itd
|
||||
go 1.16
|
||||
|
||||
require (
|
||||
fyne.io/fyne/v2 v2.1.0
|
||||
github.com/VividCortex/ewma v1.2.0 // indirect
|
||||
github.com/abiosoft/ishell v2.0.0+incompatible
|
||||
github.com/abiosoft/readline v0.0.0-20180607040430-155bce2042db // indirect
|
||||
github.com/cheggaaa/pb/v3 v3.0.8
|
||||
github.com/fatih/color v1.12.0 // indirect
|
||||
github.com/fatih/color v1.13.0 // indirect
|
||||
github.com/flynn-archive/go-shlex v0.0.0-20150515145356-3f9db97f8568 // indirect
|
||||
github.com/fsnotify/fsnotify v1.5.0 // indirect
|
||||
github.com/godbus/dbus/v5 v5.0.4
|
||||
github.com/mattn/go-isatty v0.0.13 // indirect
|
||||
github.com/go-gl/gl v0.0.0-20210905235341-f7a045908259 // indirect
|
||||
github.com/go-gl/glfw/v3.3/glfw v0.0.0-20210727001814-0db043d8d5be // indirect
|
||||
github.com/godbus/dbus/v5 v5.0.5
|
||||
github.com/google/uuid v1.1.2
|
||||
github.com/mattn/go-colorable v0.1.11 // indirect
|
||||
github.com/mattn/go-runewidth v0.0.13 // indirect
|
||||
github.com/mitchellh/mapstructure v1.4.1
|
||||
github.com/rs/zerolog v1.23.0
|
||||
github.com/mitchellh/mapstructure v1.4.2
|
||||
github.com/mozillazg/go-pinyin v0.18.0
|
||||
github.com/rs/zerolog v1.25.0
|
||||
github.com/sirupsen/logrus v1.8.1 // indirect
|
||||
github.com/spf13/cast v1.4.1 // indirect
|
||||
github.com/spf13/cobra v1.2.1
|
||||
github.com/spf13/viper v1.8.1
|
||||
go.arsenm.dev/infinitime v0.0.0-20210822201216-955384489609
|
||||
golang.org/x/sys v0.0.0-20210820121016-41cdb8703e55 // indirect
|
||||
golang.org/x/text v0.3.7 // indirect
|
||||
github.com/spf13/viper v1.9.0
|
||||
github.com/srwiley/oksvg v0.0.0-20210519022825-9fc0c575d5fe // indirect
|
||||
github.com/srwiley/rasterx v0.0.0-20210519020934-456a8d69b780 // indirect
|
||||
github.com/yuin/goldmark v1.4.1 // indirect
|
||||
go.arsenm.dev/infinitime v0.0.0-20211023042633-53aa6f8a0c72
|
||||
golang.org/x/image v0.0.0-20210628002857-a66eb6448b8d // indirect
|
||||
golang.org/x/net v0.0.0-20211011170408-caeb26a5c8c0 // indirect
|
||||
golang.org/x/sys v0.0.0-20211007075335-d3039528d8ac // indirect
|
||||
golang.org/x/text v0.3.7
|
||||
)
|
||||
|
||||
186
go.sum
186
go.sum
@@ -18,6 +18,11 @@ cloud.google.com/go v0.74.0/go.mod h1:VV1xSbzvo+9QJOxLDaJfTjx5e+MePCpCWwvftOeQmW
|
||||
cloud.google.com/go v0.78.0/go.mod h1:QjdrLG0uq+YwhjoVOLsS1t7TW8fs36kLs4XO5R5ECHg=
|
||||
cloud.google.com/go v0.79.0/go.mod h1:3bzgcEeQlzbuEAYu4mrWhKqWjmpprinYgKJLgKHnbb8=
|
||||
cloud.google.com/go v0.81.0/go.mod h1:mk/AM35KwGk/Nm2YSeZbxXdrNK3KZOYHmLkOqC2V6E0=
|
||||
cloud.google.com/go v0.83.0/go.mod h1:Z7MJUsANfY0pYPdw0lbnivPx4/vhy/e2FEkSkF7vAVY=
|
||||
cloud.google.com/go v0.84.0/go.mod h1:RazrYuxIK6Kb7YrzzhPoLmCVzl7Sup4NrbKPg8KHSUM=
|
||||
cloud.google.com/go v0.87.0/go.mod h1:TpDYlFy7vuLzZMMZ+B6iRiELaY7z/gJPaqbMx6mlWcY=
|
||||
cloud.google.com/go v0.90.0/go.mod h1:kRX0mNRHe0e2rC6oNakvwQqzyDmg57xJ+SZU1eT2aDQ=
|
||||
cloud.google.com/go v0.93.3/go.mod h1:8utlLll2EF5XMAV15woO4lSbWQlk8rer9aLOfLh7+YI=
|
||||
cloud.google.com/go/bigquery v1.0.1/go.mod h1:i/xbL2UlR5RvWAURpBYZTtm/cXjCha9lbfbpx4poX+o=
|
||||
cloud.google.com/go/bigquery v1.3.0/go.mod h1:PjpwJnslEMmckchkHFfq+HTD2DmtT67aNFKH1/VBDHE=
|
||||
cloud.google.com/go/bigquery v1.4.0/go.mod h1:S8dzgnTigyfTmLBfrtrhyYhwRxG72rYxvftPBK2Dvzc=
|
||||
@@ -27,6 +32,7 @@ cloud.google.com/go/bigquery v1.8.0/go.mod h1:J5hqkt3O0uAFnINi6JXValWIb1v0goeZM7
|
||||
cloud.google.com/go/datastore v1.0.0/go.mod h1:LXYbyblFSglQ5pkeyhO+Qmw7ukd3C+pD7TKLgZqpHYE=
|
||||
cloud.google.com/go/datastore v1.1.0/go.mod h1:umbIZjpQpHh4hmRpGhH4tLFup+FVzqBi1b3c64qFpCk=
|
||||
cloud.google.com/go/firestore v1.1.0/go.mod h1:ulACoGHTpvq5r8rxGJ4ddJZBZqakUQqClKRT5SZwBmk=
|
||||
cloud.google.com/go/firestore v1.6.0/go.mod h1:afJwI0vaXwAG54kI7A//lP/lSPDkQORQuMkv56TxEPU=
|
||||
cloud.google.com/go/pubsub v1.0.1/go.mod h1:R0Gpsv3s54REJCy4fxDixWD93lHJMoZTyQ2kNxGRt3I=
|
||||
cloud.google.com/go/pubsub v1.1.0/go.mod h1:EwwdRX2sKPjnvnqCa270oGRyludottCI76h+R3AArQw=
|
||||
cloud.google.com/go/pubsub v1.2.0/go.mod h1:jhfEVHT8odbXTkndysNHCcx0awwzvfOlguIAii9o8iA=
|
||||
@@ -37,8 +43,13 @@ cloud.google.com/go/storage v1.6.0/go.mod h1:N7U0C8pVQ/+NIKOBQyamJIeKQKkZ+mxpohl
|
||||
cloud.google.com/go/storage v1.8.0/go.mod h1:Wv1Oy7z6Yz3DshWRJFhqM/UCfaWIRTdp0RXyy7KQOVs=
|
||||
cloud.google.com/go/storage v1.10.0/go.mod h1:FLPqc6j+Ki4BU591ie1oL6qBQGu2Bl/tZ9ullr3+Kg0=
|
||||
dmitri.shuralyov.com/gpu/mtl v0.0.0-20190408044501-666a987793e9/go.mod h1:H6x//7gZCb22OMCxBHrMx7a5I7Hp++hsVxbQ4BYO7hU=
|
||||
fyne.io/fyne/v2 v2.1.0 h1:qzdkaXL/UpmMtG4FlsX9xMZ0Q93CRzLxkoiSXyplP/I=
|
||||
fyne.io/fyne/v2 v2.1.0/go.mod h1:c1vwI38Ebd0dAdxVa6H1Pj6/+cK1xtDy61+I31g+s14=
|
||||
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
|
||||
github.com/BurntSushi/toml v0.4.1/go.mod h1:CxXYINrC8qIiEnFrOxCa7Jy5BFHlXnUU2pbicEuybxQ=
|
||||
github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo=
|
||||
github.com/Kodeworks/golang-image-ico v0.0.0-20141118225523-73f0f4cfade9/go.mod h1:7uhhqiBaR4CpN0k9rMjOtjpcfGd6DG2m04zQxKnWQ0I=
|
||||
github.com/OneOfOne/xxhash v1.2.2/go.mod h1:HSdplMjZKSmBqAxg5vPj2TmRDmfkzw+cTzAElWljhcU=
|
||||
github.com/VividCortex/ewma v1.1.1/go.mod h1:2Tkkvm3sRDVXaiyucHiACn4cqf7DpdyLvmxzcbUokwA=
|
||||
github.com/VividCortex/ewma v1.2.0 h1:f58SaIzcDXrSy3kWaHNvuJgJ3Nmz59Zji6XoJR/q1ow=
|
||||
github.com/VividCortex/ewma v1.2.0/go.mod h1:nz4BbCtbLyFDeC9SUHbtcT5644juEuWfUAUnGx7j5l4=
|
||||
@@ -46,13 +57,16 @@ github.com/abiosoft/ishell v2.0.0+incompatible h1:zpwIuEHc37EzrsIYah3cpevrIc8Oma
|
||||
github.com/abiosoft/ishell v2.0.0+incompatible/go.mod h1:HQR9AqF2R3P4XXpMpI0NAzgHf/aS6+zVXRj14cVk9qg=
|
||||
github.com/abiosoft/readline v0.0.0-20180607040430-155bce2042db h1:CjPUSXOiYptLbTdr1RceuZgSFDQ7U15ITERUGrUORx8=
|
||||
github.com/abiosoft/readline v0.0.0-20180607040430-155bce2042db/go.mod h1:rB3B4rKii8V21ydCbIzH5hZiCQE7f5E9SzUb/ZZx530=
|
||||
github.com/akavel/rsrc v0.8.0/go.mod h1:uLoCtb9J+EyAqh+26kdrTgmzRBFPGOolLWKpdxkKq+c=
|
||||
github.com/antihax/optional v1.0.0/go.mod h1:uupD/76wgC+ih3iEmQUL+0Ugr19nfwCT1kdvxnR2qWY=
|
||||
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-radix v0.0.0-20180808171621-7fddfc383310/go.mod h1:ufUuZ+zHj4x4TnLV4JWEpy2hxWSpsRywHrMgIH9cCH8=
|
||||
github.com/armon/go-radix v1.0.0/go.mod h1:ufUuZ+zHj4x4TnLV4JWEpy2hxWSpsRywHrMgIH9cCH8=
|
||||
github.com/bgentry/speakeasy v0.1.0/go.mod h1:+zsyZBPWlz7T6j88CTgSN5bM796AkVf0kBD4zp0CCIs=
|
||||
github.com/bketelsen/crypt v0.0.4/go.mod h1:aI6NrJ0pMGgvZKL1iVgXLnfIFJtfV+bKCoqOes/6LfM=
|
||||
github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU=
|
||||
github.com/cespare/xxhash v1.1.0/go.mod h1:XrSqR1VqqWfGrhpAt58auRo0WTKS1nRRg3ghfAqPWnc=
|
||||
github.com/cheggaaa/pb/v3 v3.0.8 h1:bC8oemdChbke2FHIIGy9mn4DPJ2caZYQnfbRqwmdCoA=
|
||||
github.com/cheggaaa/pb/v3 v3.0.8/go.mod h1:UICbiLec/XO6Hw6k+BHEtHeQFzzBH4i2/qk/ow1EJTA=
|
||||
github.com/chzyer/logex v1.1.10 h1:Swpa1K6QvQznwJRcfTfQJmTE72DqScAa40E+fbHEXEE=
|
||||
@@ -64,8 +78,10 @@ github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDk
|
||||
github.com/cncf/udpa/go v0.0.0-20191209042840-269d4d468f6f/go.mod h1:M8M6+tZqaGXZJjfX53e64911xZQV5JYwmTeXPW+k8Sc=
|
||||
github.com/cncf/udpa/go v0.0.0-20200629203442-efcf912fb354/go.mod h1:WmhPx2Nbnhtbo57+VJT5O0JRkEi1Wbu0z5j0R8u5Hbk=
|
||||
github.com/cncf/udpa/go v0.0.0-20201120205902-5459f2c99403/go.mod h1:WmhPx2Nbnhtbo57+VJT5O0JRkEi1Wbu0z5j0R8u5Hbk=
|
||||
github.com/cncf/xds/go v0.0.0-20210312221358-fbca930ec8ed/go.mod h1:eXthEFrGJvWHgFFCl3hGmgk+/aYT6PnTQLykKQRLhEs=
|
||||
github.com/coreos/go-semver v0.3.0/go.mod h1:nnelYz7RCh+5ahJtPPxZlU+153eP4D4r3EedlOD2RNk=
|
||||
github.com/coreos/go-systemd/v22 v22.3.2/go.mod h1:Y58oyj3AT4RCenI/lSvhwexgC+NSVTIJ3seZv2GcEnc=
|
||||
github.com/cpuguy83/go-md2man/v2 v2.0.0-20190314233015-f79a8a8ca69d/go.mod h1:maD7wRr/U5Z6m/iR4s+kqSMx2CaBsrgA7czyZG/E6dU=
|
||||
github.com/cpuguy83/go-md2man/v2 v2.0.0/go.mod h1:maD7wRr/U5Z6m/iR4s+kqSMx2CaBsrgA7czyZG/E6dU=
|
||||
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
|
||||
@@ -76,26 +92,41 @@ github.com/envoyproxy/go-control-plane v0.9.4/go.mod h1:6rpuAdCZL397s3pYoYcLgu1m
|
||||
github.com/envoyproxy/go-control-plane v0.9.7/go.mod h1:cwu0lG7PUMfa9snN8LXBig5ynNVH9qI8YYLbd1fK2po=
|
||||
github.com/envoyproxy/go-control-plane v0.9.9-0.20201210154907-fd9021fe5dad/go.mod h1:cXg6YxExXjJnVBQHBLXeUAgxn2UodCpnH306RInaBQk=
|
||||
github.com/envoyproxy/go-control-plane v0.9.9-0.20210217033140-668b12f5399d/go.mod h1:cXg6YxExXjJnVBQHBLXeUAgxn2UodCpnH306RInaBQk=
|
||||
github.com/envoyproxy/go-control-plane v0.9.9-0.20210512163311-63b5d3c536b0/go.mod h1:hliV/p42l8fGbc6Y9bQ70uLwIvmJyVE5k4iMKlh8wCQ=
|
||||
github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c=
|
||||
github.com/fatih/color v1.7.0/go.mod h1:Zm6kSWBoL9eyXnKyktHP6abPY2pDugNf5KwzbycvMj4=
|
||||
github.com/fatih/color v1.9.0/go.mod h1:eQcE1qtQxscV5RaZvpXrrb8Drkc3/DdQ+uUYCNjL+zU=
|
||||
github.com/fatih/color v1.10.0/go.mod h1:ELkj/draVOlAH/xkhN6mQ50Qd0MPOk5AAr3maGEBuJM=
|
||||
github.com/fatih/color v1.12.0 h1:mRhaKNwANqRgUBGKmnI5ZxEk7QXmjQeCcuYFMX2bfcc=
|
||||
github.com/fatih/color v1.12.0/go.mod h1:ELkj/draVOlAH/xkhN6mQ50Qd0MPOk5AAr3maGEBuJM=
|
||||
github.com/fatih/color v1.13.0 h1:8LOYc1KYPPmyKMuN8QV2DNRWNbLo6LZ0iLs8+mlH53w=
|
||||
github.com/fatih/color v1.13.0/go.mod h1:kLAiJbzzSOZDVNGyDpeOxJ47H46qBXwg5ILebYFFOfk=
|
||||
github.com/fatih/structs v1.1.0 h1:Q7juDM0QtcnhCpeyLGQKyg4TOIghuNXrkL32pHAUMxo=
|
||||
github.com/fatih/structs v1.1.0/go.mod h1:9NiDSp5zOcgEDl+j00MP/WkGVPOlPRLejGD8Ga6PJ7M=
|
||||
github.com/flynn-archive/go-shlex v0.0.0-20150515145356-3f9db97f8568 h1:BMXYYRWTLOJKlh+lOBt6nUQgXAfB7oVIQt5cNreqSLI=
|
||||
github.com/flynn-archive/go-shlex v0.0.0-20150515145356-3f9db97f8568/go.mod h1:rZfgFAXFS/z/lEd6LJmf9HVZ1LkgYiHx5pHhV5DR16M=
|
||||
github.com/fredbi/uri v0.0.0-20181227131451-3dcfdacbaaf3 h1:FDqhDm7pcsLhhWl1QtD8vlzI4mm59llRvNzrFg6/LAA=
|
||||
github.com/fredbi/uri v0.0.0-20181227131451-3dcfdacbaaf3/go.mod h1:CzM2G82Q9BDUvMTGHnXf/6OExw/Dz2ivDj48nVg7Lg8=
|
||||
github.com/fsnotify/fsnotify v1.4.9/go.mod h1:znqG4EE+3YCdAaPaxE2ZRY/06pZUdp0tY4IgpuI1SZQ=
|
||||
github.com/fsnotify/fsnotify v1.5.0 h1:NO5hkcB+srp1x6QmwvNZLeaOgbM8cmBTN32THzjvu2k=
|
||||
github.com/fsnotify/fsnotify v1.5.0/go.mod h1:BX0DCEr5pT4jm2CnQdVP1lFV521fcCNcyEeNp4DQQDk=
|
||||
github.com/fsnotify/fsnotify v1.5.1 h1:mZcQUHVQUQWoPXXtuf9yuEXKudkV2sx1E06UadKWpgI=
|
||||
github.com/fsnotify/fsnotify v1.5.1/go.mod h1:T3375wBYaZdLLcVNkcVbzGHY7f1l/uK5T5Ai1i3InKU=
|
||||
github.com/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04=
|
||||
github.com/go-gl/gl v0.0.0-20210813123233-e4099ee2221f/go.mod h1:wjpnOv6ONl2SuJSxqCPVaPZibGFdSci9HFocT9qtVYM=
|
||||
github.com/go-gl/gl v0.0.0-20210905235341-f7a045908259 h1:8q7+xl2D2qHPLTII1t4vSMNP2VKwDcn+Avf2WXvdB1A=
|
||||
github.com/go-gl/gl v0.0.0-20210905235341-f7a045908259/go.mod h1:wjpnOv6ONl2SuJSxqCPVaPZibGFdSci9HFocT9qtVYM=
|
||||
github.com/go-gl/glfw v0.0.0-20190409004039-e6da0acd62b1 h1:QbL/5oDUmRBzO9/Z7Seo6zf912W/a6Sr4Eu0G/3Jho0=
|
||||
github.com/go-gl/glfw v0.0.0-20190409004039-e6da0acd62b1/go.mod h1:vR7hzQXu2zJy9AVAgeJqvqgH9Q5CA+iKCZ2gyEVpxRU=
|
||||
github.com/go-gl/glfw/v3.3/glfw v0.0.0-20191125211704-12ad95a8df72/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8=
|
||||
github.com/go-gl/glfw/v3.3/glfw v0.0.0-20200222043503-6f7a984d4dc4/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8=
|
||||
github.com/go-gl/glfw/v3.3/glfw v0.0.0-20210410170116-ea3d685f79fb/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8=
|
||||
github.com/go-gl/glfw/v3.3/glfw v0.0.0-20210727001814-0db043d8d5be h1:vEIVIuBApEBQTEJt19GfhoU+zFSV+sNTa9E9FdnRYfk=
|
||||
github.com/go-gl/glfw/v3.3/glfw v0.0.0-20210727001814-0db043d8d5be/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8=
|
||||
github.com/go-ole/go-ole v1.2.5/go.mod h1:pprOEPIfldk/42T2oK7lQ4v4JSDwmV0As9GaiUsvbm0=
|
||||
github.com/godbus/dbus/v5 v5.0.3/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA=
|
||||
github.com/godbus/dbus/v5 v5.0.4 h1:9349emZab16e7zQvpmsbtjc18ykshndd8y2PG3sgJbA=
|
||||
github.com/godbus/dbus/v5 v5.0.4/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA=
|
||||
github.com/godbus/dbus/v5 v5.0.5 h1:9Eg0XUhQxtkV8ykTMKtMMYY72g4NgxtRq4jgh4Ih5YM=
|
||||
github.com/godbus/dbus/v5 v5.0.5/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA=
|
||||
github.com/gogo/protobuf v1.3.2/go.mod h1:P1XiOD3dCwIKUDQYPy72D8LYyHL2YPYrpS2s69NZV8Q=
|
||||
github.com/goki/freetype v0.0.0-20181231101311-fa8a33aabaff h1:W71vTCKoxtdXgnm1ECDFkfQnpdqAO00zzGXLA5yaEX8=
|
||||
github.com/goki/freetype v0.0.0-20181231101311-fa8a33aabaff/go.mod h1:wfqRWLHRBsRgkp5dmbG56SA0DmVtwrF5N3oPdI8t+Aw=
|
||||
github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q=
|
||||
github.com/golang/groupcache v0.0.0-20190702054246-869f871628b6/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc=
|
||||
github.com/golang/groupcache v0.0.0-20191227052852-215e87163ea7/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc=
|
||||
@@ -108,6 +139,7 @@ github.com/golang/mock v1.4.1/go.mod h1:UOMv5ysSaYNkG+OFQykRIcU/QvvxJf3p21QfJ2Bt
|
||||
github.com/golang/mock v1.4.3/go.mod h1:UOMv5ysSaYNkG+OFQykRIcU/QvvxJf3p21QfJ2Bt3cw=
|
||||
github.com/golang/mock v1.4.4/go.mod h1:l3mdAwkq5BuhzHwde/uurv3sEJeZMXNpwsxVWU71h+4=
|
||||
github.com/golang/mock v1.5.0/go.mod h1:CWnOUgYIOo4TcNZ0wHX3YZCqsaM1I1Jvs6v3mP3KVu8=
|
||||
github.com/golang/mock v1.6.0/go.mod h1:p6yTPP+5HYm5mzsMV8JkE6ZKdX+/wYM6Hr+LicevLPs=
|
||||
github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
|
||||
github.com/golang/protobuf v1.3.1/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
|
||||
github.com/golang/protobuf v1.3.2/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
|
||||
@@ -125,6 +157,7 @@ github.com/golang/protobuf v1.4.3/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw
|
||||
github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk=
|
||||
github.com/golang/protobuf v1.5.1/go.mod h1:DopwsBzvsk0Fs44TXzsVbJyPhcCPeIwnvohx4u74HPM=
|
||||
github.com/golang/protobuf v1.5.2/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY=
|
||||
github.com/golang/snappy v0.0.3/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q=
|
||||
github.com/google/btree v0.0.0-20180813153112-4030bb1f1f0c/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ=
|
||||
github.com/google/btree v1.0.0/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ=
|
||||
github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M=
|
||||
@@ -138,10 +171,12 @@ github.com/google/go-cmp v0.5.2/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/
|
||||
github.com/google/go-cmp v0.5.3/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
|
||||
github.com/google/go-cmp v0.5.4/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
|
||||
github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
|
||||
github.com/google/go-cmp v0.5.6/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
|
||||
github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg=
|
||||
github.com/google/martian v2.1.0+incompatible/go.mod h1:9I4somxYTbIHy5NJKHRl3wXiIaQGbYVAs8BPL6v8lEs=
|
||||
github.com/google/martian/v3 v3.0.0/go.mod h1:y5Zk1BBys9G+gd6Jrk0W3cC1+ELVxBWuIGO+w/tUAp0=
|
||||
github.com/google/martian/v3 v3.1.0/go.mod h1:y5Zk1BBys9G+gd6Jrk0W3cC1+ELVxBWuIGO+w/tUAp0=
|
||||
github.com/google/martian/v3 v3.2.1/go.mod h1:oBOf6HBosgwRXnUGWUB05QECsc6uvmMiJ3+6W4l/CUk=
|
||||
github.com/google/pprof v0.0.0-20181206194817-3ea8567a2e57/go.mod h1:zfwlbNMJ+OItoe0UupaVj+oy1omPYYDuagoSzA8v9mc=
|
||||
github.com/google/pprof v0.0.0-20190515194954-54271f7e092f/go.mod h1:zfwlbNMJ+OItoe0UupaVj+oy1omPYYDuagoSzA8v9mc=
|
||||
github.com/google/pprof v0.0.0-20191218002539-d4f498aebedc/go.mod h1:ZgVRPoUq/hfqzAqh7sHMqb3I9Rq5C59dIz2SbBwJ4eM=
|
||||
@@ -153,22 +188,31 @@ github.com/google/pprof v0.0.0-20201023163331-3e6fc7fc9c4c/go.mod h1:kpwsk12EmLe
|
||||
github.com/google/pprof v0.0.0-20201203190320-1bf35d6f28c2/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE=
|
||||
github.com/google/pprof v0.0.0-20210122040257-d980be63207e/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE=
|
||||
github.com/google/pprof v0.0.0-20210226084205-cbba55b83ad5/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE=
|
||||
github.com/google/pprof v0.0.0-20210601050228-01bbb1931b22/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE=
|
||||
github.com/google/pprof v0.0.0-20210609004039-a478d1d731e9/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE=
|
||||
github.com/google/pprof v0.0.0-20210720184732-4bb14d4b1be1/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE=
|
||||
github.com/google/renameio v0.1.0/go.mod h1:KWCgfxg9yswjAJkECMjeO8J8rahYeXnNhOm40UhjYkI=
|
||||
github.com/google/uuid v1.1.1/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
|
||||
github.com/google/uuid v1.1.2 h1:EVhdT+1Kseyi1/pUmXKaFxYsDNy9RQYkMWRH68J/W7Y=
|
||||
github.com/google/uuid v1.1.2/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
|
||||
github.com/googleapis/gax-go/v2 v2.0.4/go.mod h1:0Wqv26UfaUD9n4G6kQubkQ+KchISgw+vpHVxEJEs9eg=
|
||||
github.com/googleapis/gax-go/v2 v2.0.5/go.mod h1:DWXyrwAJ9X0FpwwEdw+IPEYBICEFu5mhpdKc/us6bOk=
|
||||
github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1 h1:EGx4pi6eqNxGaHF6qqu48+N2wcFQ5qg5FXgOdqsJ5d8=
|
||||
github.com/googleapis/gax-go/v2 v2.1.0/go.mod h1:Q3nei7sK6ybPYH7twZdmQpAd1MKb7pfu6SK+H1/DsU0=
|
||||
github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1/go.mod h1:wJfORRmW1u3UXTncJ5qlYoELFm8eSnnEO6hX4iZ3EWY=
|
||||
github.com/grpc-ecosystem/grpc-gateway v1.16.0/go.mod h1:BDjrQk3hbvj6Nolgz8mAMFbcEtjT1g+wF4CSlocrBnw=
|
||||
github.com/hashicorp/consul/api v1.1.0/go.mod h1:VmuI/Lkw1nC05EYQWNKwWGbkg+FbDBtguAZLlVdkD9Q=
|
||||
github.com/hashicorp/consul/api v1.10.1/go.mod h1:XjsvQN+RJGWI2TWy1/kqaE16HrR2J/FWgkYjdZQsX9M=
|
||||
github.com/hashicorp/consul/sdk v0.1.1/go.mod h1:VKf9jXwCTEY1QZP2MOLRhb5i/I/ssyNV1vwHyQBF0x8=
|
||||
github.com/hashicorp/consul/sdk v0.8.0/go.mod h1:GBvyrGALthsZObzUGsfgHZQDXjg4lOjagTIwIR1vPms=
|
||||
github.com/hashicorp/errwrap v1.0.0/go.mod h1:YH+1FKiLXxHSkmPseP+kNlulaMuP3n2brvKWEqk/Jc4=
|
||||
github.com/hashicorp/go-cleanhttp v0.5.1/go.mod h1:JpRdi6/HCYpAwUzNwuwqhbovhLtngrth3wmdIIUrZ80=
|
||||
github.com/hashicorp/go-hclog v0.12.0/go.mod h1:whpDNt7SSdeAju8AWKIWsul05p54N/39EeqMAyrmvFQ=
|
||||
github.com/hashicorp/go-immutable-radix v1.0.0/go.mod h1:0y9vanUI8NX6FsYoO3zeMjhV/C5i9g4Q3DwcSNZ4P60=
|
||||
github.com/hashicorp/go-msgpack v0.5.3/go.mod h1:ahLV/dePpqEmjfWmKiqvPkv/twdG7iPBM1vqhUKIvfM=
|
||||
github.com/hashicorp/go-multierror v1.0.0/go.mod h1:dHtQlpGsu+cZNNAkkCN/P3hoUDHhCYQXV3UM06sGGrk=
|
||||
github.com/hashicorp/go-multierror v1.1.0/go.mod h1:spPvp8C1qA32ftKqdAHm4hHTbPw+vmowP0z+KUhOZdA=
|
||||
github.com/hashicorp/go-rootcerts v1.0.0/go.mod h1:K6zTfqpRlCUIjkwsN4Z+hiSfzSTQa6eBIzfwKfwNnHU=
|
||||
github.com/hashicorp/go-rootcerts v1.0.2/go.mod h1:pqUvnprVnM5bf7AOirdbb01K4ccR319Vf4pU3K5EGc8=
|
||||
github.com/hashicorp/go-sockaddr v1.0.0/go.mod h1:7Xibr9yA9JjQq1JpNB2Vw7kxv8xerXegt+ozgdvDeDU=
|
||||
github.com/hashicorp/go-syslog v1.0.0/go.mod h1:qPfqrKkXGihmCqbJM2mZgkZGvKG1dFdvsLplgctolz4=
|
||||
github.com/hashicorp/go-uuid v1.0.0/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/bN7x4byOro=
|
||||
@@ -180,84 +224,108 @@ github.com/hashicorp/hcl v1.0.0 h1:0Anlzjpi4vEasTeNFn2mLJgTSwt0+6sfsiTG8qcWGx4=
|
||||
github.com/hashicorp/hcl v1.0.0/go.mod h1:E5yfLk+7swimpb2L/Alb/PJmXilQ/rhwaUYs4T20WEQ=
|
||||
github.com/hashicorp/logutils v1.0.0/go.mod h1:QIAnNjmIWmVIIkWDTG1z5v++HQmx9WQRO+LraFDTW64=
|
||||
github.com/hashicorp/mdns v1.0.0/go.mod h1:tL+uN++7HEJ6SQLQ2/p+z2pH24WQKWjBPkE0mNTz8vQ=
|
||||
github.com/hashicorp/mdns v1.0.1/go.mod h1:4gW7WsVCke5TE7EPeYliwHlRUyBtfCwuFwuMg2DmyNY=
|
||||
github.com/hashicorp/memberlist v0.1.3/go.mod h1:ajVTdAv/9Im8oMAAj5G31PhhMCZJV2pPBoIllUwCN7I=
|
||||
github.com/hashicorp/memberlist v0.2.2/go.mod h1:MS2lj3INKhZjWNqd3N0m3J+Jxf3DAOnAH9VT3Sh9MUE=
|
||||
github.com/hashicorp/serf v0.8.2/go.mod h1:6hOLApaqBFA1NXqRQAsxw9QxuDEvNxSQRwA/JwenrHc=
|
||||
github.com/hashicorp/serf v0.9.5/go.mod h1:UWDWwZeL5cuWDJdl0C6wrvrUwEqtQ4ZKBKKENpqIUyk=
|
||||
github.com/ianlancetaylor/demangle v0.0.0-20181102032728-5e5cf60278f6/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc=
|
||||
github.com/ianlancetaylor/demangle v0.0.0-20200824232613-28f6c0f3b639/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc=
|
||||
github.com/inconshreveable/mousetrap v1.0.0 h1:Z8tu5sraLXCXIcARxBp/8cbvlwVa7Z1NHg9XEKhtSvM=
|
||||
github.com/inconshreveable/mousetrap v1.0.0/go.mod h1:PxqpIevigyE2G7u3NXJIT2ANytuPF1OarO4DADm73n8=
|
||||
github.com/jackmordaunt/icns v0.0.0-20181231085925-4f16af745526/go.mod h1:UQkeMHVoNcyXYq9otUupF7/h/2tmHlhrS2zw7ZVvUqc=
|
||||
github.com/josephspurrier/goversioninfo v0.0.0-20200309025242-14b0ab84c6ca/go.mod h1:eJTEwMjXb7kZ633hO3Ln9mBUCOjX2+FlTljvpl9SYdE=
|
||||
github.com/json-iterator/go v1.1.11/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4=
|
||||
github.com/jstemmer/go-junit-report v0.0.0-20190106144839-af01ea7f8024/go.mod h1:6v2b51hI/fHJwM22ozAgKL4VKDeJcHhJFhtBdhmNjmU=
|
||||
github.com/jstemmer/go-junit-report v0.9.1/go.mod h1:Brl9GWCQeLvo8nXZwPNNblvFj/XSXhF0NWZEnDohbsk=
|
||||
github.com/jtolds/gls v4.20.0+incompatible h1:xdiiI2gbIgH/gLH7ADydsJ1uDOEzR8yvV7C0MuV77Wo=
|
||||
github.com/jtolds/gls v4.20.0+incompatible/go.mod h1:QJZ7F/aHp+rZTRtaJ1ow/lLfFfVYBRgL+9YlvaHOwJU=
|
||||
github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI2bnpBCr8=
|
||||
github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck=
|
||||
github.com/konsorten/go-windows-terminal-sequences v1.0.3/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ=
|
||||
github.com/kr/fs v0.1.0/go.mod h1:FFnZGqtBN9Gxj7eW1uZ42v5BccTP0vu6NEaFoC2HwRg=
|
||||
github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo=
|
||||
github.com/kr/pretty v0.2.0/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI=
|
||||
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/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
|
||||
github.com/lucor/goinfo v0.0.0-20210802170112-c078a2b0f08b/go.mod h1:PRq09yoB+Q2OJReAmwzKivcYyremnibWGbK7WfftHzc=
|
||||
github.com/magiconair/properties v1.8.5 h1:b6kJs+EmPFMYGkow9GiUyCyOvIwYetYJ3fSaWak/Gls=
|
||||
github.com/magiconair/properties v1.8.5/go.mod h1:y3VJvCyxH9uVvJTWEGAELF3aiYNyPKd5NZ3oSwXrF60=
|
||||
github.com/mattn/go-colorable v0.0.9/go.mod h1:9vuHe8Xs5qXnSaW/c/ABM9alt+Vo+STaOChaDxuIBZU=
|
||||
github.com/mattn/go-colorable v0.1.8 h1:c1ghPdyEDarC70ftn0y+A/Ee++9zz8ljHG1b13eJ0s8=
|
||||
github.com/mattn/go-colorable v0.1.4/go.mod h1:U0ppj6V5qS13XJ6of8GYAs25YV2eR4EVcfRqFIhoBtE=
|
||||
github.com/mattn/go-colorable v0.1.6/go.mod h1:u6P/XSegPjTcexA+o6vUJrdnUu04hMope9wVRipJSqc=
|
||||
github.com/mattn/go-colorable v0.1.8/go.mod h1:u6P/XSegPjTcexA+o6vUJrdnUu04hMope9wVRipJSqc=
|
||||
github.com/mattn/go-colorable v0.1.9/go.mod h1:u6P/XSegPjTcexA+o6vUJrdnUu04hMope9wVRipJSqc=
|
||||
github.com/mattn/go-colorable v0.1.11 h1:nQ+aFkoE2TMGc0b68U2OKSexC+eq46+XwZzWXHRmPYs=
|
||||
github.com/mattn/go-colorable v0.1.11/go.mod h1:u5H1YNBxpqRaxsYJYSkiCWKzEfiAb1Gb520KVy5xxl4=
|
||||
github.com/mattn/go-isatty v0.0.3/go.mod h1:M+lRXTBqGeGNdLjl/ufCoiOlB5xdOkqRJdNxMWT7Zi4=
|
||||
github.com/mattn/go-isatty v0.0.8/go.mod h1:Iq45c/XA43vh69/j3iqttzPXn0bhXyGjM0Hdxcsrc5s=
|
||||
github.com/mattn/go-isatty v0.0.10/go.mod h1:qgIWMr58cqv1PHHyhnkY9lrL7etaEgOFcMEpPG5Rm84=
|
||||
github.com/mattn/go-isatty v0.0.11/go.mod h1:PhnuNfih5lzO57/f3n+odYbM4JtupLOxQOAqxQCu2WE=
|
||||
github.com/mattn/go-isatty v0.0.12/go.mod h1:cbi8OIDigv2wuxKPP5vlRcQ1OAZbq2CE4Kysco4FUpU=
|
||||
github.com/mattn/go-isatty v0.0.13 h1:qdl+GuBjcsKKDco5BsxPJlId98mSWNKqYA+Co0SC1yA=
|
||||
github.com/mattn/go-isatty v0.0.13/go.mod h1:cbi8OIDigv2wuxKPP5vlRcQ1OAZbq2CE4Kysco4FUpU=
|
||||
github.com/mattn/go-isatty v0.0.14 h1:yVuAays6BHfxijgZPzw+3Zlu5yQgKGP2/hcQbHb7S9Y=
|
||||
github.com/mattn/go-isatty v0.0.14/go.mod h1:7GGIvUiUoEMVVmxf/4nioHXj79iQHKdU27kJ6hsGG94=
|
||||
github.com/mattn/go-runewidth v0.0.12/go.mod h1:RAqKPSqVFrSLVXbA8x7dzmKdmGzieGRCM46jaSJTDAk=
|
||||
github.com/mattn/go-runewidth v0.0.13 h1:lTGmDsbAYt5DmK6OnoV7EuIF1wEIFAcxld6ypU4OSgU=
|
||||
github.com/mattn/go-runewidth v0.0.13/go.mod h1:Jdepj2loyihRzMpdS35Xk/zdY8IAYHsh153qUoGf23w=
|
||||
github.com/miekg/dns v1.0.14/go.mod h1:W1PPwlIAgtquWBMBEV9nkV9Cazfe8ScdGz/Lj7v3Nrg=
|
||||
github.com/miekg/dns v1.1.26/go.mod h1:bPDLeHnStXmXAq1m/Ch/hvfNHr14JKNPMBo3VZKjuso=
|
||||
github.com/mitchellh/cli v1.0.0/go.mod h1:hNIlj7HEI86fIcpObd7a0FcrxTWetlwJDGcceTlRvqc=
|
||||
github.com/mitchellh/cli v1.1.0/go.mod h1:xcISNoH86gajksDmfB23e/pu+B+GeFRMYmoHXxx3xhI=
|
||||
github.com/mitchellh/go-homedir v1.0.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0=
|
||||
github.com/mitchellh/go-homedir v1.1.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0=
|
||||
github.com/mitchellh/go-testing-interface v1.0.0/go.mod h1:kRemZodwjscx+RGhAo8eIhFbs2+BFgRtFPeD/KE+zxI=
|
||||
github.com/mitchellh/gox v0.4.0/go.mod h1:Sd9lOJ0+aimLBi73mGofS1ycjY8lL3uZM3JPS42BGNg=
|
||||
github.com/mitchellh/iochan v1.0.0/go.mod h1:JwYml1nuB7xOzsp52dPpHFffvOCDupsG0QubkSMEySY=
|
||||
github.com/mitchellh/mapstructure v0.0.0-20160808181253-ca63d7c062ee/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y=
|
||||
github.com/mitchellh/mapstructure v1.1.2/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y=
|
||||
github.com/mitchellh/mapstructure v1.4.1 h1:CpVNEelQCZBooIPDn+AR3NpivK/TIKU8bDxdASFVQag=
|
||||
github.com/mitchellh/mapstructure v1.4.1/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo=
|
||||
github.com/mitchellh/mapstructure v1.4.2 h1:6h7AQ0yhTcIsmFmnAwQls75jp2Gzs4iB8W7pjMO+rqo=
|
||||
github.com/mitchellh/mapstructure v1.4.2/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo=
|
||||
github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
|
||||
github.com/modern-go/reflect2 v0.0.0-20180701023420-4b7aa43c6742/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0=
|
||||
github.com/modern-go/reflect2 v1.0.1/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0=
|
||||
github.com/mozillazg/go-pinyin v0.18.0 h1:hQompXO23/0ohH8YNjvfsAITnCQImCiR/Fny8EhIeW0=
|
||||
github.com/mozillazg/go-pinyin v0.18.0/go.mod h1:iR4EnMMRXkfpFVV5FMi4FNB6wGq9NV6uDWbUuPhP4Yc=
|
||||
github.com/muka/go-bluetooth v0.0.0-20210812063148-b6c83362e27d h1:EG/xyWjHT19rkUpwsWSkyiCCmyqNwFovr9m10rhyOxU=
|
||||
github.com/muka/go-bluetooth v0.0.0-20210812063148-b6c83362e27d/go.mod h1:dMCjicU6vRBk34dqOmIZm0aod6gUwZXOXzBROqGous0=
|
||||
github.com/nfnt/resize v0.0.0-20180221191011-83c6a9932646/go.mod h1:jpp1/29i3P1S/RLdc7JQKbRpFeM1dOBd8T9ki5s+AY8=
|
||||
github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e h1:fD57ERR4JtEqsWbfPhv4DMiApHyliiK5xCTNVSPiaAs=
|
||||
github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e/go.mod h1:zD1mROLANZcx1PVRCS0qkT7pwLkGfwJo4zjcN/Tysno=
|
||||
github.com/pascaldekloe/goe v0.0.0-20180627143212-57f6aae5913c/go.mod h1:lzWF7FIEvWOWxwDKqyGYQf6ZUaNfKdP144TG7ZOy1lc=
|
||||
github.com/paypal/gatt v0.0.0-20151011220935-4ae819d591cf/go.mod h1:+AwQL2mK3Pd3S+TUwg0tYQjid0q1txyNUJuuSmz8Kdk=
|
||||
github.com/pelletier/go-toml v1.9.3 h1:zeC5b1GviRUyKYd6OJPvBU/mcVDVoL1OhT17FCt5dSQ=
|
||||
github.com/pelletier/go-toml v1.9.3/go.mod h1:u1nR/EPcESfeI/szUZKdtJ0xRNbUoANCkoOuaOx1Y+c=
|
||||
github.com/pelletier/go-toml v1.9.4 h1:tjENF6MfZAg8e4ZmZTeWaWiT2vXtsoO6+iuOjFhECwM=
|
||||
github.com/pelletier/go-toml v1.9.4/go.mod h1:u1nR/EPcESfeI/szUZKdtJ0xRNbUoANCkoOuaOx1Y+c=
|
||||
github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
|
||||
github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
|
||||
github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
|
||||
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/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
|
||||
github.com/posener/complete v1.1.1/go.mod h1:em0nMJCgc9GFtwrmVmEMR/ZL6WyhyjMBndrE9hABlRI=
|
||||
github.com/posener/complete v1.2.3/go.mod h1:WZIdtGGp+qx0sLrYKtIRAruyNpv6hFCicSgv7Sy7s/s=
|
||||
github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA=
|
||||
github.com/rivo/uniseg v0.1.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc=
|
||||
github.com/rivo/uniseg v0.2.0 h1:S1pD9weZBuJdFmowNwbpi7BJ8TNftyUImj/0WQi72jY=
|
||||
github.com/rivo/uniseg v0.2.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc=
|
||||
github.com/rogpeppe/fastuuid v1.2.0/go.mod h1:jVj6XXZzXRy/MSR5jhDC/2q6DgLz+nrA6LYCDYWNEvQ=
|
||||
github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4=
|
||||
github.com/rs/xid v1.2.1/go.mod h1:+uKXf+4Djp6Md1KODXJxgGQPKngRmWyn10oCKFzNHOQ=
|
||||
github.com/rs/zerolog v1.23.0 h1:UskrK+saS9P9Y789yNNulYKdARjPZuS35B8gJF2x60g=
|
||||
github.com/rs/zerolog v1.23.0/go.mod h1:6c7hFfxPOy7TacJc4Fcdi24/J0NKYGzjG8FWRI916Qo=
|
||||
github.com/rs/xid v1.3.0/go.mod h1:trrq9SKmegXys3aeAKXMUTdJsYXVwGY3RLcfgqegfbg=
|
||||
github.com/rs/zerolog v1.25.0 h1:Rj7XygbUHKUlDPcVdoLyR91fJBsduXj5fRxyqIQj/II=
|
||||
github.com/rs/zerolog v1.25.0/go.mod h1:7KHcEGe0QZPOm2IE4Kpb5rTh6n1h2hIgS5OOnu1rUaI=
|
||||
github.com/russross/blackfriday/v2 v2.0.1/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
|
||||
github.com/ryanuber/columnize v0.0.0-20160712163229-9b3edd62028f/go.mod h1:sm1tb6uqfes/u+d4ooFouqFdy9/2g9QGwK3SQygK0Ts=
|
||||
github.com/sagikazarmark/crypt v0.1.0/go.mod h1:B/mN0msZuINBtQ1zZLEQcegFJJf9vnYIR88KRMEuODE=
|
||||
github.com/sean-/seed v0.0.0-20170313163322-e2103e2c3529/go.mod h1:DxrIzT+xaE7yg65j358z/aeFdxmN0P9QXhEzd20vsDc=
|
||||
github.com/shurcooL/sanitized_anchor_name v1.0.0/go.mod h1:1NzhyTcUVG4SuEtjjoZeVRXNmyL/1OwPU0+IJeTBvfc=
|
||||
github.com/sirupsen/logrus v1.6.0/go.mod h1:7uNnSEd1DgxDLC74fIahvMZmmYsHGZGEOFrfsX/uA88=
|
||||
github.com/sirupsen/logrus v1.8.1 h1:dJKuHgqk1NNQlqoA6BTlM1Wf9DOH3NBjQyu0h9+AZZE=
|
||||
github.com/sirupsen/logrus v1.8.1/go.mod h1:yWOB1SBYBC5VeMP7gHvWumXLIWorT60ONWic61uBYv0=
|
||||
github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d h1:zE9ykElWQ6/NYmHa3jpm/yHnI4xSofP+UP6SpjHcSeM=
|
||||
github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d/go.mod h1:OnSkiWE9lh6wB0YB77sQom3nweQdgAjqCqsofrRNTgc=
|
||||
github.com/smartystreets/goconvey v1.6.4 h1:fv0U8FUIMPNf1L9lnHLvLhgicrIVChEkdzIKYqbNC9s=
|
||||
github.com/smartystreets/goconvey v1.6.4/go.mod h1:syvi0/a8iFYH4r/RixwvyeAJjdLS9QV7WQ/tjFTllLA=
|
||||
github.com/spaolacci/murmur3 v0.0.0-20180118202830-f09979ecbc72/go.mod h1:JwIasOWyU6f++ZhiEuf87xNszmSA2myDM2Kzu9HwQUA=
|
||||
github.com/spf13/afero v1.1.2/go.mod h1:j4pytiNVoe2o6bmDsKpLACNPDBIoEAkihy7loJ1B0CQ=
|
||||
github.com/spf13/afero v1.6.0 h1:xoax2sJ2DT8S8xA2paPFjDCScCNeWsg75VG0DLRreiY=
|
||||
github.com/spf13/afero v1.6.0/go.mod h1:Ai8FlHk4v/PARR026UzYexafAt9roJ7LcLMAmO6Z93I=
|
||||
github.com/spf13/cast v1.3.1/go.mod h1:Qx5cxh0v+4UWYiBimWS+eyWzqEqokIECu5etghLkUJE=
|
||||
@@ -267,10 +335,18 @@ github.com/spf13/cobra v1.2.1 h1:+KmjbUw1hriSNMF55oPrkZcb27aECyrj8V2ytv7kWDw=
|
||||
github.com/spf13/cobra v1.2.1/go.mod h1:ExllRjgxM/piMAM+3tAZvg8fsklGAf3tPfi+i8t68Nk=
|
||||
github.com/spf13/jwalterweatherman v1.1.0 h1:ue6voC5bR5F8YxI5S67j9i582FU4Qvo2bmqnqMYADFk=
|
||||
github.com/spf13/jwalterweatherman v1.1.0/go.mod h1:aNWZUN0dPAAO/Ljvb5BEdw96iTZ0EXowPYD95IqWIGo=
|
||||
github.com/spf13/pflag v1.0.3/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnInEg4=
|
||||
github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA=
|
||||
github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg=
|
||||
github.com/spf13/viper v1.8.1 h1:Kq1fyeebqsBfbjZj4EL7gj2IO0mMaiyjYUWcUsl2O44=
|
||||
github.com/spf13/viper v1.8.1/go.mod h1:o0Pch8wJ9BVSWGQMbra6iw0oQ5oktSIBaujf1rJH9Ns=
|
||||
github.com/spf13/viper v1.9.0 h1:yR6EXjTp0y0cLN8OZg1CRZmOBdI88UcGkhgyJhu6nZk=
|
||||
github.com/spf13/viper v1.9.0/go.mod h1:+i6ajR7OX2XaiBkrcZJFK21htRk7eDeLg7+O6bhUPP4=
|
||||
github.com/srwiley/oksvg v0.0.0-20200311192757-870daf9aa564/go.mod h1:afMbS0qvv1m5tfENCwnOdZGOF8RGR/FsZ7bvBxQGZG4=
|
||||
github.com/srwiley/oksvg v0.0.0-20210519022825-9fc0c575d5fe h1:J5Ga/gb+4/WgJBupg9Fp8F6JQnUT3UF+asoTweLi9Jc=
|
||||
github.com/srwiley/oksvg v0.0.0-20210519022825-9fc0c575d5fe/go.mod h1:afMbS0qvv1m5tfENCwnOdZGOF8RGR/FsZ7bvBxQGZG4=
|
||||
github.com/srwiley/rasterx v0.0.0-20200120212402-85cb7272f5e9/go.mod h1:mvWM0+15UqyrFKqdRjY6LuAVJR0HOVhJlEgZ5JWtSWU=
|
||||
github.com/srwiley/rasterx v0.0.0-20210519020934-456a8d69b780 h1:oDMiXaTMyBEuZMU53atpxqYsSB3U1CHkeAu2zr6wTeY=
|
||||
github.com/srwiley/rasterx v0.0.0-20210519020934-456a8d69b780/go.mod h1:mvWM0+15UqyrFKqdRjY6LuAVJR0HOVhJlEgZ5JWtSWU=
|
||||
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
|
||||
github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
|
||||
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
|
||||
@@ -282,13 +358,17 @@ github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/
|
||||
github.com/suapapa/go_eddystone v1.3.1/go.mod h1:bXC11TfJOS+3g3q/Uzd7FKd5g62STQEfeEIhcKe4Qy8=
|
||||
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/urfave/cli/v2 v2.3.0/go.mod h1:LJmUH05zAU44vOAcrfzZQKsZbVcdbOG8rtL3/XcUArI=
|
||||
github.com/yuin/goldmark v1.1.25/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
|
||||
github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
|
||||
github.com/yuin/goldmark v1.1.32/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
|
||||
github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
|
||||
github.com/yuin/goldmark v1.3.5/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k=
|
||||
go.arsenm.dev/infinitime v0.0.0-20210822201216-955384489609 h1:QH7hsVjulEs1OP8lcQ7EfVy2UO/rtwRsxUo3ylde83E=
|
||||
go.arsenm.dev/infinitime v0.0.0-20210822201216-955384489609/go.mod h1:gaepaueUz4J5FfxuV19B4w5pi+V3mD0LTef50ryxr/Q=
|
||||
github.com/yuin/goldmark v1.3.8/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k=
|
||||
github.com/yuin/goldmark v1.4.1 h1:/vn0k+RBvwlxEmP5E7SZMqNxPhfMVFEJiykr15/0XKM=
|
||||
github.com/yuin/goldmark v1.4.1/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k=
|
||||
go.arsenm.dev/infinitime v0.0.0-20211023042633-53aa6f8a0c72 h1:e8kOuL6Jj8ZjJzkGwJ3xqpGG9EhUzfvZk9AlSsm3X1U=
|
||||
go.arsenm.dev/infinitime v0.0.0-20211023042633-53aa6f8a0c72/go.mod h1:gaepaueUz4J5FfxuV19B4w5pi+V3mD0LTef50ryxr/Q=
|
||||
go.etcd.io/etcd/api/v3 v3.5.0/go.mod h1:cbVKeC6lCfl7j/8jBhAK6aIYO9XOjdptoxU/nLQcPvs=
|
||||
go.etcd.io/etcd/client/pkg/v3 v3.5.0/go.mod h1:IJHfcCEKxYu1Os13ZdwCwIUTUVGYTSAM3YSwc9/Ac1g=
|
||||
go.etcd.io/etcd/client/v2 v2.305.0/go.mod h1:h9puh54ZTgAKtEbut2oe9P4L/oqKCVB6xsXlzd7alYQ=
|
||||
@@ -299,6 +379,7 @@ go.opencensus.io v0.22.3/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw=
|
||||
go.opencensus.io v0.22.4/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw=
|
||||
go.opencensus.io v0.22.5/go.mod h1:5pWMHQbX5EPX2/62yrJeAkowc+lfs/XD7Uxpq3pI6kk=
|
||||
go.opencensus.io v0.23.0/go.mod h1:XItmlyltB5F7CS4xOC1DcqMoFqwtC6OG2xF7mCv7P7E=
|
||||
go.opentelemetry.io/proto/otlp v0.7.0/go.mod h1:PqfVotwruBrMGOCsRd/89rSnXhoiJIqeYNgFYFoEGnI=
|
||||
go.uber.org/atomic v1.7.0/go.mod h1:fEN4uk6kAWBTFdckzkM89CLk9XfWZrxpCo0nPH17wJc=
|
||||
go.uber.org/multierr v1.6.0/go.mod h1:cdWPpRnG4AhwMwsgIHip0KRBQjJy5kYEpYjJxpXp9iU=
|
||||
go.uber.org/zap v1.17.0/go.mod h1:MXVU+bhUf/A7Xi2HNOnopQOrmycQ5Ih87HtOu4q5SSo=
|
||||
@@ -307,8 +388,10 @@ golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACk
|
||||
golang.org/x/crypto v0.0.0-20190510104115-cbcb75029529/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
|
||||
golang.org/x/crypto v0.0.0-20190605123033-f99c8df09eb5/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
|
||||
golang.org/x/crypto v0.0.0-20190820162420-60c769a6c586/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
|
||||
golang.org/x/crypto v0.0.0-20190923035154-9ee001bba392/go.mod h1:/lpIB1dKB+9EgE3H3cr1v9wB50oz8l4C4h62xy7jSTY=
|
||||
golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
|
||||
golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
|
||||
golang.org/x/crypto v0.0.0-20210817164053-32db794688a5/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
|
||||
golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
|
||||
golang.org/x/exp v0.0.0-20190306152737-a1d7652674e8/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
|
||||
golang.org/x/exp v0.0.0-20190510132918-efd6b22b2522/go.mod h1:ZjyILWgesfNpC6sMxTJOJm9Kp84zZh5NQWvqDGG3Qr8=
|
||||
@@ -321,6 +404,9 @@ golang.org/x/exp v0.0.0-20200207192155-f17229e696bd/go.mod h1:J/WKrq2StrnmMY6+EH
|
||||
golang.org/x/exp v0.0.0-20200224162631-6cc2880d07d6/go.mod h1:3jZMyOhIsHpP37uCMkUooju7aAi5cS1Q23tOzKc+0MU=
|
||||
golang.org/x/image v0.0.0-20190227222117-0694c2d4d067/go.mod h1:kZ7UVZpmo3dzQBMxlp+ypCbDeSB+sBbTgSJuh5dn5js=
|
||||
golang.org/x/image v0.0.0-20190802002840-cff245a6509b/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0=
|
||||
golang.org/x/image v0.0.0-20200430140353-33d19683fad8/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0=
|
||||
golang.org/x/image v0.0.0-20210628002857-a66eb6448b8d h1:RNPAfi2nHY7C2srAV8A49jpsYr0ADedCk1wq6fTMTvs=
|
||||
golang.org/x/image v0.0.0-20210628002857-a66eb6448b8d/go.mod h1:023OzeP/+EPmXeapQh35lcL3II3LrY8Ic+EFFKVhULM=
|
||||
golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE=
|
||||
golang.org/x/lint v0.0.0-20190227174305-5b3e6a55c961/go.mod h1:wehouNa3lNwaWXcvxsM5YxQ5yQlVC4a0KAMCusXpPoU=
|
||||
golang.org/x/lint v0.0.0-20190301231843-5614ed5bae6f/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE=
|
||||
@@ -358,6 +444,7 @@ golang.org/x/net v0.0.0-20190603091049-60506f45cf65/go.mod h1:HSz+uSET+XFnRR8LxR
|
||||
golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
|
||||
golang.org/x/net v0.0.0-20190628185345-da137c7871d7/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
|
||||
golang.org/x/net v0.0.0-20190724013045-ca1201d0de80/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
|
||||
golang.org/x/net v0.0.0-20190923162816-aa69164e4478/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
|
||||
golang.org/x/net v0.0.0-20191209160850-c0dbc17a3553/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
|
||||
golang.org/x/net v0.0.0-20200114155413-6afb5195e5aa/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
|
||||
golang.org/x/net v0.0.0-20200202094626-16171245cfb2/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
|
||||
@@ -380,6 +467,9 @@ golang.org/x/net v0.0.0-20210119194325-5f4716e94777/go.mod h1:m0MpNAwzfU5UDzcl9v
|
||||
golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg=
|
||||
golang.org/x/net v0.0.0-20210316092652-d523dce5a7f4/go.mod h1:RBQZq4jEuRlivfhVLdyRGr576XBO4/greRjx4P4O3yc=
|
||||
golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4/go.mod h1:p54w0d4576C0XHj96bSt6lcn1PtDYWL6XObtHCRCNQM=
|
||||
golang.org/x/net v0.0.0-20210503060351-7fd8e65b6420/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
|
||||
golang.org/x/net v0.0.0-20211011170408-caeb26a5c8c0 h1:qOfNqBm5gk93LjGZo1MJaKY6Bph39zOKz1Hz2ogHj1w=
|
||||
golang.org/x/net v0.0.0-20211011170408-caeb26a5c8c0/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
|
||||
golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=
|
||||
golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw=
|
||||
golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw=
|
||||
@@ -392,6 +482,10 @@ golang.org/x/oauth2 v0.0.0-20210218202405-ba52d332ba99/go.mod h1:KelEdhl1UZF7XfJ
|
||||
golang.org/x/oauth2 v0.0.0-20210220000619-9bb904979d93/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A=
|
||||
golang.org/x/oauth2 v0.0.0-20210313182246-cd4f82c27b84/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A=
|
||||
golang.org/x/oauth2 v0.0.0-20210402161424-2e8d93401602/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A=
|
||||
golang.org/x/oauth2 v0.0.0-20210514164344-f6687ab2804c/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A=
|
||||
golang.org/x/oauth2 v0.0.0-20210628180205-a41e5a781914/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A=
|
||||
golang.org/x/oauth2 v0.0.0-20210805134026-6f1e6394065a/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A=
|
||||
golang.org/x/oauth2 v0.0.0-20210819190943-2bc19b11175f/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A=
|
||||
golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
@@ -407,6 +501,7 @@ golang.org/x/sys v0.0.0-20180823144017-11551d06cbcc/go.mod h1:STP8DvDyc/dI5b8T5h
|
||||
golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||
golang.org/x/sys v0.0.0-20181026203630-95b1ffbd15a5/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||
golang.org/x/sys v0.0.0-20190222072716-a9d3bda3a223/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||
golang.org/x/sys v0.0.0-20190312061237-fead79001313/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20190422165155-953cdadca894/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
@@ -415,14 +510,19 @@ golang.org/x/sys v0.0.0-20190507160741-ecd444e8653b/go.mod h1:h1NjWce9XRLGQEsW7w
|
||||
golang.org/x/sys v0.0.0-20190606165138-5da285871e9c/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20190624142023-c5567b49c5d0/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20190726091711-fc99dfbffb4e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20190916202348-b4ddaad3f8a3/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20190922100055-0a153f010e69/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20190924154521-2837fb4f24fe/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20191001151750-bb3f8db39f24/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20191005200804-aed5e4c7ecf9/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20191008105621-543471e840be/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20191026070338-33540a1f6037/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20191204072324-ce4227a45e2e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20191228213918-04cbcbbfeed8/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20200113162924-86b910548bc1/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20200116001909-b77594299b42/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20200122134326-e047566fdf82/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20200124204421-9fbb57f87de9/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20200202164722-d101bd2416d5/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20200212091648-12a6c2dcc1e4/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20200223170610-d5e6a3e2c0ae/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
@@ -447,10 +547,18 @@ golang.org/x/sys v0.0.0-20210315160823-c6e025ad8005/go.mod h1:h1NjWce9XRLGQEsW7w
|
||||
golang.org/x/sys v0.0.0-20210320140829-1e4c9ba3b0c4/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20210330210617-4fbd30eecc44/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20210403161142-5e06dd20ab57/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20210510120138-977fb7262007/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.0.0-20210514084401-e8d321eab015/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.0.0-20210603125802-9665404d3644/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.0.0-20210616094352-59db8d763f22/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.0.0-20210820121016-41cdb8703e55 h1:rw6UNGRMfarCepjI8qOepea/SXwIBVfTKjztZ5gBbq4=
|
||||
golang.org/x/sys v0.0.0-20210820121016-41cdb8703e55/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.0.0-20210806184541-e5e7981a1069/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.0.0-20210823070655-63515b42dcdf/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.0.0-20210927094055-39ccf1dd6fa6/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.0.0-20211007075335-d3039528d8ac h1:oN6lz7iLW/YC7un8pq+9bOLyXrprv2+DKfkJY+2LJJw=
|
||||
golang.org/x/sys v0.0.0-20211007075335-d3039528d8ac/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
|
||||
golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
||||
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
||||
@@ -459,6 +567,7 @@ golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk=
|
||||
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
|
||||
golang.org/x/text v0.3.4/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
|
||||
golang.org/x/text v0.3.5/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
|
||||
golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
|
||||
golang.org/x/text v0.3.7 h1:olpwvP2KacW1ZWvsR7uQhoyTYvKAupfQrRGBFM352Gk=
|
||||
golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ=
|
||||
golang.org/x/time v0.0.0-20181108054448-85acf8d2951c/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
|
||||
@@ -478,6 +587,7 @@ golang.org/x/tools v0.0.0-20190606124116-d0a3d012864b/go.mod h1:/rFqwRUd4F7ZHNgw
|
||||
golang.org/x/tools v0.0.0-20190621195816-6e04913cbbac/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc=
|
||||
golang.org/x/tools v0.0.0-20190628153133-6cdbf07be9d0/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc=
|
||||
golang.org/x/tools v0.0.0-20190816200558-6889da9d5479/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
|
||||
golang.org/x/tools v0.0.0-20190907020128-2ca718005c18/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-20191112195655-aa38f8e97acc/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
|
||||
@@ -515,7 +625,11 @@ golang.org/x/tools v0.0.0-20201208233053-a543418bbed2/go.mod h1:emZCQorbCU4vsT4f
|
||||
golang.org/x/tools v0.0.0-20210105154028-b0ab187a4818/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA=
|
||||
golang.org/x/tools v0.0.0-20210106214847-113979e3529a/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA=
|
||||
golang.org/x/tools v0.1.0/go.mod h1:xkSsbof2nBLbhDlRMhhhyNLN/zl3eTqcnHD5viDpcZ0=
|
||||
golang.org/x/tools v0.1.1/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk=
|
||||
golang.org/x/tools v0.1.2/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk=
|
||||
golang.org/x/tools v0.1.3/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk=
|
||||
golang.org/x/tools v0.1.4/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk=
|
||||
golang.org/x/tools v0.1.5/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk=
|
||||
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||
golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||
@@ -542,6 +656,12 @@ google.golang.org/api v0.40.0/go.mod h1:fYKFpnQN0DsDSKRVRcQSDQNtqWPfM9i+zNPxepjR
|
||||
google.golang.org/api v0.41.0/go.mod h1:RkxM5lITDfTzmyKFPt+wGrCJbVfniCr2ool8kTBzRTU=
|
||||
google.golang.org/api v0.43.0/go.mod h1:nQsDGjRXMo4lvh5hP0TKqF244gqhGcr/YSIykhUk/94=
|
||||
google.golang.org/api v0.44.0/go.mod h1:EBOGZqzyhtvMDoxwS97ctnh0zUmYY6CxqXsc1AvkYD8=
|
||||
google.golang.org/api v0.47.0/go.mod h1:Wbvgpq1HddcWVtzsVLyfLp8lDg6AA241LmgIL59tHXo=
|
||||
google.golang.org/api v0.48.0/go.mod h1:71Pr1vy+TAZRPkPs/xlCf5SsU8WjuAWv1Pfjbtukyy4=
|
||||
google.golang.org/api v0.50.0/go.mod h1:4bNT5pAuq5ji4SRZm+5QIkjny9JAyVD/3gaSihNefaw=
|
||||
google.golang.org/api v0.51.0/go.mod h1:t4HdrdoNgyN5cbEfm7Lum0lcLDLiise1F8qDKX00sOU=
|
||||
google.golang.org/api v0.54.0/go.mod h1:7C4bFFOvVDGXjfDTAsgGwDgAxRDeQ4X8NvUedIt6z3k=
|
||||
google.golang.org/api v0.56.0/go.mod h1:38yMfeP1kfjsl8isn0tliTjIb1rJXcQi4UXlbqivdVE=
|
||||
google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM=
|
||||
google.golang.org/appengine v1.4.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4=
|
||||
google.golang.org/appengine v1.5.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4=
|
||||
@@ -589,7 +709,18 @@ google.golang.org/genproto v0.0.0-20210303154014-9728d6b83eeb/go.mod h1:FWY/as6D
|
||||
google.golang.org/genproto v0.0.0-20210310155132-4ce2db91004e/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no=
|
||||
google.golang.org/genproto v0.0.0-20210319143718-93e7006c17a6/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no=
|
||||
google.golang.org/genproto v0.0.0-20210402141018-6c239bbf2bb1/go.mod h1:9lPAdzaEmUacj36I+k7YKbEc5CXzPIeORRgDAUOu28A=
|
||||
google.golang.org/genproto v0.0.0-20210513213006-bf773b8c8384/go.mod h1:P3QM42oQyzQSnHPnZ/vqoCdDmzH28fzWByN9asMeM8A=
|
||||
google.golang.org/genproto v0.0.0-20210602131652-f16073e35f0c/go.mod h1:UODoCrxHCcBojKKwX1terBiRUaqAsFqJiF615XL43r0=
|
||||
google.golang.org/genproto v0.0.0-20210604141403-392c879c8b08/go.mod h1:UODoCrxHCcBojKKwX1terBiRUaqAsFqJiF615XL43r0=
|
||||
google.golang.org/genproto v0.0.0-20210608205507-b6d2f5bf0d7d/go.mod h1:UODoCrxHCcBojKKwX1terBiRUaqAsFqJiF615XL43r0=
|
||||
google.golang.org/genproto v0.0.0-20210624195500-8bfb893ecb84/go.mod h1:SzzZ/N+nwJDaO1kznhnlzqS8ocJICar6hYhVyhi++24=
|
||||
google.golang.org/genproto v0.0.0-20210713002101-d411969a0d9a/go.mod h1:AxrInvYm1dci+enl5hChSFPOmmUF1+uAa/UsgNRWd7k=
|
||||
google.golang.org/genproto v0.0.0-20210716133855-ce7ef5c701ea/go.mod h1:AxrInvYm1dci+enl5hChSFPOmmUF1+uAa/UsgNRWd7k=
|
||||
google.golang.org/genproto v0.0.0-20210728212813-7823e685a01f/go.mod h1:ob2IJxKrgPT52GcgX759i1sleT07tiKowYBGbczaW48=
|
||||
google.golang.org/genproto v0.0.0-20210805201207-89edb61ffb67/go.mod h1:ob2IJxKrgPT52GcgX759i1sleT07tiKowYBGbczaW48=
|
||||
google.golang.org/genproto v0.0.0-20210813162853-db860fec028c/go.mod h1:cFeNkxwySK631ADgubI+/XFU/xp8FD5KIVV4rj8UC5w=
|
||||
google.golang.org/genproto v0.0.0-20210821163610-241b8fcbd6c8/go.mod h1:eFjDcFEctNawg4eG61bRv87N7iHBWyVhJu7u1kqDUXY=
|
||||
google.golang.org/genproto v0.0.0-20210828152312-66f60bf46e71/go.mod h1:eFjDcFEctNawg4eG61bRv87N7iHBWyVhJu7u1kqDUXY=
|
||||
google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c=
|
||||
google.golang.org/grpc v1.20.1/go.mod h1:10oTOabMzJvdu6/UiuZezV6QK5dSlG84ov/aaiqXj38=
|
||||
google.golang.org/grpc v1.21.1/go.mod h1:oYelfM1adQP15Ek0mdvEgi9Df8B9CZIaU1084ijfRaM=
|
||||
@@ -609,7 +740,13 @@ google.golang.org/grpc v1.34.0/go.mod h1:WotjhfgOW/POjDeRt8vscBtXq+2VjORFy659qA5
|
||||
google.golang.org/grpc v1.35.0/go.mod h1:qjiiYl8FncCW8feJPdyg3v6XW24KsRHe+dy9BAGRRjU=
|
||||
google.golang.org/grpc v1.36.0/go.mod h1:qjiiYl8FncCW8feJPdyg3v6XW24KsRHe+dy9BAGRRjU=
|
||||
google.golang.org/grpc v1.36.1/go.mod h1:qjiiYl8FncCW8feJPdyg3v6XW24KsRHe+dy9BAGRRjU=
|
||||
google.golang.org/grpc v1.37.0/go.mod h1:NREThFqKR1f3iQ6oBuvc5LadQuXVGo9rkm5ZGrQdJfM=
|
||||
google.golang.org/grpc v1.37.1/go.mod h1:NREThFqKR1f3iQ6oBuvc5LadQuXVGo9rkm5ZGrQdJfM=
|
||||
google.golang.org/grpc v1.38.0/go.mod h1:NREThFqKR1f3iQ6oBuvc5LadQuXVGo9rkm5ZGrQdJfM=
|
||||
google.golang.org/grpc v1.39.0/go.mod h1:PImNr+rS9TWYb2O4/emRugxiyHZ5JyHW5F+RPnDzfrE=
|
||||
google.golang.org/grpc v1.39.1/go.mod h1:PImNr+rS9TWYb2O4/emRugxiyHZ5JyHW5F+RPnDzfrE=
|
||||
google.golang.org/grpc v1.40.0/go.mod h1:ogyxbiOoUXAkP+4+xa6PZSE9DZgIHtSpzjDTB9KAK34=
|
||||
google.golang.org/grpc/cmd/protoc-gen-go-grpc v1.1.0/go.mod h1:6Kw0yEErY5E/yWrBtf03jp27GLLJujG4z/JK95pnjjw=
|
||||
google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8=
|
||||
google.golang.org/protobuf v0.0.0-20200221191635-4d8936d0db64/go.mod h1:kwYJMbMJ01Woi6D6+Kah6886xMZcty6N08ah7+eCXa0=
|
||||
google.golang.org/protobuf v0.0.0-20200228230310-ab0ca4ff8a60/go.mod h1:cfTl7dwQJ+fmap5saPgwCLgHXTUD7jkjRqWcaiX5VyM=
|
||||
@@ -622,13 +759,16 @@ google.golang.org/protobuf v1.24.0/go.mod h1:r/3tXBNzIEhYS9I1OUVjXDlt8tc493IdKGj
|
||||
google.golang.org/protobuf v1.25.0/go.mod h1:9JNX74DMeImyA3h4bdi1ymwjUzf21/xIlbajtzgsN7c=
|
||||
google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw=
|
||||
google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc=
|
||||
google.golang.org/protobuf v1.27.1/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc=
|
||||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||
gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||
gopkg.in/check.v1 v1.0.0-20200227125254-8fa46927fb4f h1:BLraFXnmrev5lT+xlilqcH8XK9/i0At2xKjWk4p6zsU=
|
||||
gopkg.in/check.v1 v1.0.0-20200227125254-8fa46927fb4f/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||
gopkg.in/errgo.v2 v2.1.0/go.mod h1:hNsd1EY+bozCKY1Ytp96fpM3vjJbqLJn88ws8XvfDNI=
|
||||
gopkg.in/ini.v1 v1.62.0 h1:duBzk771uxoUuOlyRLkHsygud9+5lrlGjdFBb4mSKDU=
|
||||
gopkg.in/ini.v1 v1.62.0/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k=
|
||||
gopkg.in/ini.v1 v1.63.2 h1:tGK/CyBg7SMzb60vP1M03vNZ3VDu3wGQJwn7Sxi9r3c=
|
||||
gopkg.in/ini.v1 v1.63.2/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k=
|
||||
gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
||||
gopkg.in/yaml.v2 v2.2.3/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
||||
gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
||||
|
||||
@@ -1,18 +1,42 @@
|
||||
package types
|
||||
|
||||
const (
|
||||
ReqTypeHeartRate = iota
|
||||
ReqTypeBattLevel
|
||||
ReqTypeFwVersion
|
||||
ReqTypeFwUpgrade
|
||||
ReqTypeBtAddress
|
||||
ReqTypeNotify
|
||||
ReqTypeSetTime
|
||||
ReqTypeWatchHeartRate
|
||||
ReqTypeWatchBattLevel
|
||||
ReqTypeMotion
|
||||
ReqTypeWatchMotion
|
||||
ReqTypeStepCount
|
||||
ReqTypeWatchStepCount
|
||||
ReqTypeCancel
|
||||
)
|
||||
|
||||
const (
|
||||
UpgradeTypeArchive = iota
|
||||
UpgradeTypeFiles
|
||||
)
|
||||
|
||||
type ReqDataFwUpgrade struct {
|
||||
Type int
|
||||
Files []string
|
||||
}
|
||||
|
||||
type Response struct {
|
||||
Type int `json:"type"`
|
||||
Value interface{} `json:"value,omitempty"`
|
||||
Message string `json:"msg,omitempty"`
|
||||
ID string `json:"id,omitempty"`
|
||||
Error bool `json:"error"`
|
||||
}
|
||||
|
||||
type Request struct {
|
||||
Type string `json:"type"`
|
||||
Type int `json:"type"`
|
||||
Data interface{} `json:"data,omitempty"`
|
||||
}
|
||||
|
||||
@@ -20,3 +44,15 @@ type ReqDataNotify struct {
|
||||
Title string
|
||||
Body string
|
||||
}
|
||||
|
||||
type DFUProgress struct {
|
||||
Received int64 `mapstructure:"recvd"`
|
||||
Total int64 `mapstructure:"total"`
|
||||
Sent int64 `mapstructure:"sent"`
|
||||
}
|
||||
|
||||
type MotionValues struct {
|
||||
X int16
|
||||
Y int16
|
||||
Z int16
|
||||
}
|
||||
|
||||
24
itd.toml
24
itd.toml
@@ -1,14 +1,28 @@
|
||||
# This is temporary, it is to show a notice
|
||||
# to people still using the old config
|
||||
cfg.version = 2
|
||||
|
||||
[socket]
|
||||
path = "/tmp/itd/socket"
|
||||
|
||||
[conn]
|
||||
reconnect = true
|
||||
|
||||
[notify]
|
||||
onConnect = true
|
||||
onReconnect = true
|
||||
[on.connect]
|
||||
notify = true
|
||||
|
||||
[notifications.ignore]
|
||||
[on.reconnect]
|
||||
notify = true
|
||||
setTime = true
|
||||
|
||||
[notifs.translit]
|
||||
use = ["eASCII", "Russian", "Emoji"]
|
||||
|
||||
[notifs.ignore]
|
||||
sender = []
|
||||
summary = ["InfiniTime"]
|
||||
body = []
|
||||
|
||||
[music]
|
||||
volInterval = 5
|
||||
vol.interval = 5
|
||||
|
||||
|
||||
45
main.go
45
main.go
@@ -19,11 +19,8 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"os"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/rs/zerolog"
|
||||
"github.com/rs/zerolog/log"
|
||||
"github.com/spf13/viper"
|
||||
"go.arsenm.dev/infinitime"
|
||||
@@ -31,25 +28,11 @@ import (
|
||||
|
||||
var firmwareUpdating = false
|
||||
|
||||
func init() {
|
||||
// Set up logger
|
||||
log.Logger = log.Output(zerolog.ConsoleWriter{Out: os.Stderr})
|
||||
|
||||
// Set config settings
|
||||
viper.AddConfigPath("$HOME/.config")
|
||||
viper.AddConfigPath("/etc")
|
||||
viper.SetConfigName("itd")
|
||||
viper.SetConfigType("toml")
|
||||
viper.WatchConfig()
|
||||
viper.SetEnvKeyReplacer(strings.NewReplacer(".", "_"))
|
||||
viper.SetEnvPrefix("itd")
|
||||
if err := viper.ReadInConfig(); err != nil {
|
||||
log.Warn().Err(err).Msg("Could not read in config")
|
||||
}
|
||||
viper.AutomaticEnv()
|
||||
}
|
||||
|
||||
func main() {
|
||||
if viper.GetInt("cfg.version") != 2 {
|
||||
log.Fatal().Msg("Please update your config to the newest format, only v2 configs supported.")
|
||||
}
|
||||
|
||||
// Cleanly exit after function
|
||||
defer infinitime.Exit()
|
||||
|
||||
@@ -63,14 +46,16 @@ func main() {
|
||||
|
||||
// When InfiniTime reconnects
|
||||
dev.OnReconnect(func() {
|
||||
// Set time to current time
|
||||
err = dev.SetTime(time.Now())
|
||||
if err != nil {
|
||||
log.Error().Err(err).Msg("Error setting current time on connected InfiniTime")
|
||||
if viper.GetBool("on.reconnect.setTime") {
|
||||
// Set time to current time
|
||||
err = dev.SetTime(time.Now())
|
||||
if err != nil {
|
||||
log.Error().Err(err).Msg("Error setting current time on connected InfiniTime")
|
||||
}
|
||||
}
|
||||
|
||||
// If config specifies to notify on reconnect
|
||||
if viper.GetBool("notify.onReconnect") {
|
||||
if viper.GetBool("on.reconnect.notify") {
|
||||
// Send notification to InfiniTime
|
||||
err = dev.Notify("itd", "Successfully reconnected")
|
||||
if err != nil {
|
||||
@@ -89,7 +74,7 @@ func main() {
|
||||
log.Info().Str("version", ver).Msg("Connected to InfiniTime")
|
||||
|
||||
// If config specifies to notify on connect
|
||||
if viper.GetBool("notify.onConnect") {
|
||||
if viper.GetBool("on.connect.notify") {
|
||||
// Send notification to InfiniTime
|
||||
err = dev.Notify("itd", "Successfully connected")
|
||||
if err != nil {
|
||||
@@ -109,6 +94,12 @@ func main() {
|
||||
log.Error().Err(err).Msg("Error initializing music control")
|
||||
}
|
||||
|
||||
// Start control socket
|
||||
err = initCallNotifs(dev)
|
||||
if err != nil {
|
||||
log.Error().Err(err).Msg("Error starting socket")
|
||||
}
|
||||
|
||||
// Initialize notification relay
|
||||
err = initNotifRelay(dev)
|
||||
if err != nil {
|
||||
|
||||
8
music.go
8
music.go
@@ -19,10 +19,10 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"go.arsenm.dev/infinitime"
|
||||
"go.arsenm.dev/infinitime/pkg/player"
|
||||
"github.com/rs/zerolog/log"
|
||||
"github.com/spf13/viper"
|
||||
"go.arsenm.dev/infinitime"
|
||||
"go.arsenm.dev/infinitime/pkg/player"
|
||||
)
|
||||
|
||||
func initMusicCtrl(dev *infinitime.Device) error {
|
||||
@@ -85,9 +85,9 @@ func initMusicCtrl(dev *infinitime.Device) error {
|
||||
case infinitime.MusicEventPrev:
|
||||
player.Prev()
|
||||
case infinitime.MusicEventVolUp:
|
||||
player.VolUp(viper.GetUint("music.volInterval"))
|
||||
player.VolUp(viper.GetUint("music.vol.interval"))
|
||||
case infinitime.MusicEventVolDown:
|
||||
player.VolDown(viper.GetUint("music.volInterval"))
|
||||
player.VolDown(viper.GetUint("music.vol.interval"))
|
||||
}
|
||||
}
|
||||
}()
|
||||
|
||||
13
notifs.go
13
notifs.go
@@ -25,6 +25,7 @@ import (
|
||||
"github.com/rs/zerolog/log"
|
||||
"github.com/spf13/viper"
|
||||
"go.arsenm.dev/infinitime"
|
||||
"go.arsenm.dev/itd/translit"
|
||||
)
|
||||
|
||||
func initNotifRelay(dev *infinitime.Device) error {
|
||||
@@ -71,6 +72,12 @@ func initNotifRelay(dev *infinitime.Device) error {
|
||||
continue
|
||||
}
|
||||
|
||||
maps := viper.GetStringSlice("notifs.translit.use")
|
||||
translit.Transliterators["custom"] = translit.Map(viper.GetStringSlice("notifs.translit.custom"))
|
||||
sender = translit.Transliterate(sender, maps...)
|
||||
summary = translit.Transliterate(summary, maps...)
|
||||
body = translit.Transliterate(body, maps...)
|
||||
|
||||
var msg string
|
||||
// If summary does not exist, set message to body.
|
||||
// If it does, set message to summary, two newlines, and then body
|
||||
@@ -90,9 +97,9 @@ func initNotifRelay(dev *infinitime.Device) error {
|
||||
|
||||
// ignored checks whether any fields were ignored in the config
|
||||
func ignored(sender, summary, body string) bool {
|
||||
ignoreSender := viper.GetStringSlice("notifications.ignore.sender")
|
||||
ignoreSummary := viper.GetStringSlice("notifications.ignore.summary")
|
||||
ignoreBody := viper.GetStringSlice("notifications.ignore.body")
|
||||
ignoreSender := viper.GetStringSlice("notifs.ignore.sender")
|
||||
ignoreSummary := viper.GetStringSlice("notifs.ignore.summary")
|
||||
ignoreBody := viper.GetStringSlice("notifs.ignore.body")
|
||||
return strSlcContains(ignoreSender, sender) ||
|
||||
strSlcContains(ignoreSummary, summary) ||
|
||||
strSlcContains(ignoreBody, body)
|
||||
|
||||
287
socket.go
287
socket.go
@@ -27,44 +27,53 @@ import (
|
||||
"path/filepath"
|
||||
"time"
|
||||
|
||||
"github.com/google/uuid"
|
||||
"github.com/mitchellh/mapstructure"
|
||||
"github.com/rs/zerolog/log"
|
||||
"github.com/spf13/viper"
|
||||
"go.arsenm.dev/infinitime"
|
||||
"go.arsenm.dev/itd/internal/types"
|
||||
"go.arsenm.dev/itd/translit"
|
||||
)
|
||||
|
||||
const SockPath = "/tmp/itd/socket"
|
||||
type DoneMap map[string]chan struct{}
|
||||
|
||||
const (
|
||||
ReqTypeHeartRate = "hrt"
|
||||
ReqTypeBattLevel = "battlvl"
|
||||
ReqTypeFwVersion = "fwver"
|
||||
ReqTypeFwUpgrade = "fwupg"
|
||||
ReqTypeBtAddress = "btaddr"
|
||||
ReqTypeNotify = "notify"
|
||||
ReqTypeSetTime = "settime"
|
||||
)
|
||||
func (dm DoneMap) Exists(key string) bool {
|
||||
_, ok := dm[key]
|
||||
return ok
|
||||
}
|
||||
|
||||
const (
|
||||
UpgradeTypeArchive = iota
|
||||
UpgradeTypeFiles
|
||||
)
|
||||
func (dm DoneMap) Done(key string) {
|
||||
ch := dm[key]
|
||||
ch <- struct{}{}
|
||||
}
|
||||
|
||||
func (dm DoneMap) Create(key string) {
|
||||
dm[key] = make(chan struct{}, 1)
|
||||
}
|
||||
|
||||
func (dm DoneMap) Remove(key string) {
|
||||
close(dm[key])
|
||||
delete(dm, key)
|
||||
}
|
||||
|
||||
var done = DoneMap{}
|
||||
|
||||
func startSocket(dev *infinitime.Device) error {
|
||||
// Make socket directory if non-existent
|
||||
err := os.MkdirAll(filepath.Dir(SockPath), 0755)
|
||||
// Make socket directory if non-existant
|
||||
err := os.MkdirAll(filepath.Dir(viper.GetString("socket.path")), 0755)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// Remove old socket if it exists
|
||||
err = os.RemoveAll(SockPath)
|
||||
err = os.RemoveAll(viper.GetString("socket.path"))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// Listen on socket path
|
||||
ln, err := net.Listen("unix", SockPath)
|
||||
ln, err := net.Listen("unix", viper.GetString("socket.path"))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -83,18 +92,13 @@ func startSocket(dev *infinitime.Device) error {
|
||||
}()
|
||||
|
||||
// Log socket start
|
||||
log.Info().Str("path", SockPath).Msg("Started control socket")
|
||||
log.Info().Str("path", viper.GetString("socket.path")).Msg("Started control socket")
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func handleConnection(conn net.Conn, dev *infinitime.Device) {
|
||||
defer conn.Close()
|
||||
// If firmware is updating, return error
|
||||
if firmwareUpdating {
|
||||
connErr(conn, nil, "Firmware update in progress")
|
||||
return
|
||||
}
|
||||
|
||||
// Create new scanner on connection
|
||||
scanner := bufio.NewScanner(conn)
|
||||
@@ -103,80 +107,227 @@ func handleConnection(conn net.Conn, dev *infinitime.Device) {
|
||||
// Decode scanned message into types.Request
|
||||
err := json.Unmarshal(scanner.Bytes(), &req)
|
||||
if err != nil {
|
||||
connErr(conn, err, "Error decoding JSON input")
|
||||
connErr(conn, req.Type, err, "Error decoding JSON input")
|
||||
continue
|
||||
}
|
||||
|
||||
// If firmware is updating, return error
|
||||
if firmwareUpdating {
|
||||
connErr(conn, req.Type, nil, "Firmware update in progress")
|
||||
return
|
||||
}
|
||||
|
||||
switch req.Type {
|
||||
case ReqTypeHeartRate:
|
||||
case types.ReqTypeHeartRate:
|
||||
// Get heart rate from watch
|
||||
heartRate, err := dev.HeartRate()
|
||||
if err != nil {
|
||||
connErr(conn, err, "Error getting heart rate")
|
||||
connErr(conn, req.Type, err, "Error getting heart rate")
|
||||
break
|
||||
}
|
||||
// Encode heart rate to connection
|
||||
json.NewEncoder(conn).Encode(types.Response{
|
||||
Type: req.Type,
|
||||
Value: heartRate,
|
||||
})
|
||||
case ReqTypeBattLevel:
|
||||
case types.ReqTypeWatchHeartRate:
|
||||
heartRateCh, cancel, err := dev.WatchHeartRate()
|
||||
if err != nil {
|
||||
connErr(conn, req.Type, err, "Error getting heart rate channel")
|
||||
break
|
||||
}
|
||||
reqID := uuid.New().String()
|
||||
go func() {
|
||||
done.Create(reqID)
|
||||
// For every heart rate value
|
||||
for heartRate := range heartRateCh {
|
||||
select {
|
||||
case <-done[reqID]:
|
||||
// Stop notifications if done signal received
|
||||
cancel()
|
||||
done.Remove(reqID)
|
||||
return
|
||||
default:
|
||||
// Encode response to connection if no done signal received
|
||||
json.NewEncoder(conn).Encode(types.Response{
|
||||
Type: req.Type,
|
||||
ID: reqID,
|
||||
Value: heartRate,
|
||||
})
|
||||
}
|
||||
}
|
||||
}()
|
||||
case types.ReqTypeBattLevel:
|
||||
// Get battery level from watch
|
||||
battLevel, err := dev.BatteryLevel()
|
||||
if err != nil {
|
||||
connErr(conn, err, "Error getting battery level")
|
||||
connErr(conn, req.Type, err, "Error getting battery level")
|
||||
break
|
||||
}
|
||||
// Encode battery level to connection
|
||||
json.NewEncoder(conn).Encode(types.Response{
|
||||
Type: req.Type,
|
||||
Value: battLevel,
|
||||
})
|
||||
case ReqTypeFwVersion:
|
||||
case types.ReqTypeWatchBattLevel:
|
||||
battLevelCh, cancel, err := dev.WatchBatteryLevel()
|
||||
if err != nil {
|
||||
connErr(conn, req.Type, err, "Error getting battery level channel")
|
||||
break
|
||||
}
|
||||
reqID := uuid.New().String()
|
||||
go func() {
|
||||
done.Create(reqID)
|
||||
// For every battery level value
|
||||
for battLevel := range battLevelCh {
|
||||
select {
|
||||
case <-done[reqID]:
|
||||
// Stop notifications if done signal received
|
||||
cancel()
|
||||
done.Remove(reqID)
|
||||
return
|
||||
default:
|
||||
// Encode response to connection if no done signal received
|
||||
json.NewEncoder(conn).Encode(types.Response{
|
||||
Type: req.Type,
|
||||
ID: reqID,
|
||||
Value: battLevel,
|
||||
})
|
||||
}
|
||||
}
|
||||
}()
|
||||
case types.ReqTypeMotion:
|
||||
// Get battery level from watch
|
||||
motionVals, err := dev.Motion()
|
||||
if err != nil {
|
||||
connErr(conn, req.Type, err, "Error getting motion values")
|
||||
break
|
||||
}
|
||||
// Encode battery level to connection
|
||||
json.NewEncoder(conn).Encode(types.Response{
|
||||
Type: req.Type,
|
||||
Value: motionVals,
|
||||
})
|
||||
case types.ReqTypeWatchMotion:
|
||||
motionValCh, cancel, err := dev.WatchMotion()
|
||||
if err != nil {
|
||||
connErr(conn, req.Type, err, "Error getting heart rate channel")
|
||||
break
|
||||
}
|
||||
reqID := uuid.New().String()
|
||||
go func() {
|
||||
done.Create(reqID)
|
||||
// For every motion event
|
||||
for motionVals := range motionValCh {
|
||||
select {
|
||||
case <-done[reqID]:
|
||||
// Stop notifications if done signal received
|
||||
cancel()
|
||||
done.Remove(reqID)
|
||||
|
||||
return
|
||||
default:
|
||||
// Encode response to connection if no done signal received
|
||||
json.NewEncoder(conn).Encode(types.Response{
|
||||
Type: req.Type,
|
||||
ID: reqID,
|
||||
Value: motionVals,
|
||||
})
|
||||
}
|
||||
}
|
||||
}()
|
||||
case types.ReqTypeStepCount:
|
||||
// Get battery level from watch
|
||||
stepCount, err := dev.StepCount()
|
||||
if err != nil {
|
||||
connErr(conn, req.Type, err, "Error getting step count")
|
||||
break
|
||||
}
|
||||
// Encode battery level to connection
|
||||
json.NewEncoder(conn).Encode(types.Response{
|
||||
Type: req.Type,
|
||||
Value: stepCount,
|
||||
})
|
||||
case types.ReqTypeWatchStepCount:
|
||||
stepCountCh, cancel, err := dev.WatchStepCount()
|
||||
if err != nil {
|
||||
connErr(conn, req.Type, err, "Error getting heart rate channel")
|
||||
break
|
||||
}
|
||||
reqID := uuid.New().String()
|
||||
go func() {
|
||||
done.Create(reqID)
|
||||
// For every step count value
|
||||
for stepCount := range stepCountCh {
|
||||
select {
|
||||
case <-done[reqID]:
|
||||
// Stop notifications if done signal received
|
||||
cancel()
|
||||
done.Remove(reqID)
|
||||
return
|
||||
default:
|
||||
// Encode response to connection if no done signal received
|
||||
json.NewEncoder(conn).Encode(types.Response{
|
||||
Type: req.Type,
|
||||
ID: reqID,
|
||||
Value: stepCount,
|
||||
})
|
||||
}
|
||||
}
|
||||
}()
|
||||
case types.ReqTypeFwVersion:
|
||||
// Get firmware version from watch
|
||||
version, err := dev.Version()
|
||||
if err != nil {
|
||||
connErr(conn, err, "Error getting battery level")
|
||||
connErr(conn, req.Type, err, "Error getting firmware version")
|
||||
break
|
||||
}
|
||||
// Encode version to connection
|
||||
json.NewEncoder(conn).Encode(types.Response{
|
||||
Type: req.Type,
|
||||
Value: version,
|
||||
})
|
||||
case ReqTypeBtAddress:
|
||||
case types.ReqTypeBtAddress:
|
||||
// Encode bluetooth address to connection
|
||||
json.NewEncoder(conn).Encode(types.Response{
|
||||
Type: req.Type,
|
||||
Value: dev.Address(),
|
||||
})
|
||||
case ReqTypeNotify:
|
||||
case types.ReqTypeNotify:
|
||||
// If no data, return error
|
||||
if req.Data == nil {
|
||||
connErr(conn, nil, "Data required for notify request")
|
||||
connErr(conn, req.Type, nil, "Data required for notify request")
|
||||
break
|
||||
}
|
||||
var reqData types.ReqDataNotify
|
||||
// Decode data map to notify request data
|
||||
err = mapstructure.Decode(req.Data, &reqData)
|
||||
if err != nil {
|
||||
connErr(conn, err, "Error decoding request data")
|
||||
connErr(conn, req.Type, err, "Error decoding request data")
|
||||
break
|
||||
}
|
||||
maps := viper.GetStringSlice("notifs.translit.use")
|
||||
translit.Transliterators["custom"] = translit.Map(viper.GetStringSlice("notifs.translit.custom"))
|
||||
title := translit.Transliterate(reqData.Title, maps...)
|
||||
body := translit.Transliterate(reqData.Body, maps...)
|
||||
// Send notification to watch
|
||||
err = dev.Notify(reqData.Title, reqData.Body)
|
||||
err = dev.Notify(title, body)
|
||||
if err != nil {
|
||||
connErr(conn, err, "Error sending notification")
|
||||
connErr(conn, req.Type, err, "Error sending notification")
|
||||
break
|
||||
}
|
||||
// Encode empty types.Response to connection
|
||||
json.NewEncoder(conn).Encode(types.Response{})
|
||||
case ReqTypeSetTime:
|
||||
json.NewEncoder(conn).Encode(types.Response{Type: req.Type})
|
||||
case types.ReqTypeSetTime:
|
||||
// If no data, return error
|
||||
if req.Data == nil {
|
||||
connErr(conn, nil, "Data required for settime request")
|
||||
connErr(conn, req.Type, nil, "Data required for settime request")
|
||||
break
|
||||
}
|
||||
// Get string from data or return error
|
||||
reqTimeStr, ok := req.Data.(string)
|
||||
if !ok {
|
||||
connErr(conn, nil, "Data for settime request must be RFC3339 formatted time string")
|
||||
connErr(conn, req.Type, nil, "Data for settime request must be RFC3339 formatted time string")
|
||||
break
|
||||
}
|
||||
|
||||
@@ -187,69 +338,71 @@ func handleConnection(conn net.Conn, dev *infinitime.Device) {
|
||||
// Parse time as RFC3339/ISO8601
|
||||
reqTime, err = time.Parse(time.RFC3339, reqTimeStr)
|
||||
if err != nil {
|
||||
connErr(conn, err, "Invalid time format. Time string must be formatted as ISO8601 or the word `now`")
|
||||
connErr(conn, req.Type, err, "Invalid time format. Time string must be formatted as ISO8601 or the word `now`")
|
||||
break
|
||||
}
|
||||
}
|
||||
// Set time on watch
|
||||
err = dev.SetTime(reqTime)
|
||||
if err != nil {
|
||||
connErr(conn, err, "Error setting device time")
|
||||
connErr(conn, req.Type, err, "Error setting device time")
|
||||
break
|
||||
}
|
||||
// Encode empty types.Response to connection
|
||||
json.NewEncoder(conn).Encode(types.Response{})
|
||||
case ReqTypeFwUpgrade:
|
||||
json.NewEncoder(conn).Encode(types.Response{Type: req.Type})
|
||||
case types.ReqTypeFwUpgrade:
|
||||
// If no data, return error
|
||||
if req.Data == nil {
|
||||
connErr(conn, nil, "Data required for firmware upgrade request")
|
||||
connErr(conn, req.Type, nil, "Data required for firmware upgrade request")
|
||||
break
|
||||
}
|
||||
var reqData types.ReqDataFwUpgrade
|
||||
// Decode data map to firmware upgrade request data
|
||||
err = mapstructure.Decode(req.Data, &reqData)
|
||||
if err != nil {
|
||||
connErr(conn, err, "Error decoding request data")
|
||||
connErr(conn, req.Type, err, "Error decoding request data")
|
||||
break
|
||||
}
|
||||
// Reset DFU to prepare for next update
|
||||
dev.DFU.Reset()
|
||||
switch reqData.Type {
|
||||
case UpgradeTypeArchive:
|
||||
case types.UpgradeTypeArchive:
|
||||
// If less than one file, return error
|
||||
if len(reqData.Files) < 1 {
|
||||
connErr(conn, nil, "Archive upgrade requires one file with .zip extension")
|
||||
connErr(conn, req.Type, nil, "Archive upgrade requires one file with .zip extension")
|
||||
break
|
||||
}
|
||||
// If file is not zip archive, return error
|
||||
if filepath.Ext(reqData.Files[0]) != ".zip" {
|
||||
connErr(conn, nil, "Archive upgrade file must be a zip archive")
|
||||
connErr(conn, req.Type, nil, "Archive upgrade file must be a zip archive")
|
||||
break
|
||||
}
|
||||
// Load DFU archive
|
||||
err := dev.DFU.LoadArchive(reqData.Files[0])
|
||||
if err != nil {
|
||||
connErr(conn, err, "Error loading archive file")
|
||||
connErr(conn, req.Type, err, "Error loading archive file")
|
||||
break
|
||||
}
|
||||
case UpgradeTypeFiles:
|
||||
case types.UpgradeTypeFiles:
|
||||
// If less than two files, return error
|
||||
if len(reqData.Files) < 2 {
|
||||
connErr(conn, nil, "Files upgrade requires two files. First with .dat and second with .bin extension.")
|
||||
connErr(conn, req.Type, nil, "Files upgrade requires two files. First with .dat and second with .bin extension.")
|
||||
break
|
||||
}
|
||||
// If first file is not init packet, return error
|
||||
if filepath.Ext(reqData.Files[0]) != ".dat" {
|
||||
connErr(conn, nil, "First file must be a .dat file")
|
||||
connErr(conn, req.Type, nil, "First file must be a .dat file")
|
||||
break
|
||||
}
|
||||
// If second file is not firmware image, return error
|
||||
if filepath.Ext(reqData.Files[1]) != ".bin" {
|
||||
connErr(conn, nil, "Second file must be a .bin file")
|
||||
connErr(conn, req.Type, nil, "Second file must be a .bin file")
|
||||
break
|
||||
}
|
||||
// Load individual DFU files
|
||||
err := dev.DFU.LoadFiles(reqData.Files[0], reqData.Files[1])
|
||||
if err != nil {
|
||||
connErr(conn, err, "Error loading firmware files")
|
||||
connErr(conn, req.Type, err, "Error loading firmware files")
|
||||
break
|
||||
}
|
||||
}
|
||||
@@ -261,9 +414,11 @@ func handleConnection(conn net.Conn, dev *infinitime.Device) {
|
||||
for event := range progress {
|
||||
// Encode event on connection
|
||||
json.NewEncoder(conn).Encode(types.Response{
|
||||
Type: req.Type,
|
||||
Value: event,
|
||||
})
|
||||
}
|
||||
firmwareUpdating = false
|
||||
}()
|
||||
|
||||
// Set firmwareUpdating
|
||||
@@ -271,16 +426,30 @@ func handleConnection(conn net.Conn, dev *infinitime.Device) {
|
||||
// Start DFU
|
||||
err = dev.DFU.Start()
|
||||
if err != nil {
|
||||
connErr(conn, err, "Error performing upgrade")
|
||||
connErr(conn, req.Type, err, "Error performing upgrade")
|
||||
firmwareUpdating = false
|
||||
break
|
||||
}
|
||||
firmwareUpdating = false
|
||||
case types.ReqTypeCancel:
|
||||
if req.Data == nil {
|
||||
connErr(conn, req.Type, nil, "No data provided. Cancel request requires request ID string as data.")
|
||||
continue
|
||||
}
|
||||
reqID, ok := req.Data.(string)
|
||||
if !ok {
|
||||
connErr(conn, req.Type, nil, "Invalid data. Cancel request required request ID string as data.")
|
||||
}
|
||||
// Stop notifications
|
||||
done.Done(reqID)
|
||||
json.NewEncoder(conn).Encode(types.Response{Type: req.Type})
|
||||
default:
|
||||
connErr(conn, req.Type, nil, fmt.Sprintf("Unknown request type %d", req.Type))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func connErr(conn net.Conn, err error, msg string) {
|
||||
func connErr(conn net.Conn, resType int, err error, msg string) {
|
||||
var res types.Response
|
||||
// If error exists, add to types.Response, otherwise don't
|
||||
if err != nil {
|
||||
@@ -288,7 +457,7 @@ func connErr(conn net.Conn, err error, msg string) {
|
||||
res = types.Response{Message: fmt.Sprintf("%s: %s", msg, err)}
|
||||
} else {
|
||||
log.Error().Msg(msg)
|
||||
res = types.Response{Message: msg}
|
||||
res = types.Response{Message: msg, Type: resType}
|
||||
}
|
||||
res.Error = true
|
||||
|
||||
|
||||
150
translit/armenian.go
Normal file
150
translit/armenian.go
Normal file
@@ -0,0 +1,150 @@
|
||||
package translit
|
||||
|
||||
import (
|
||||
"strings"
|
||||
)
|
||||
|
||||
type ArmenianTranslit struct {
|
||||
initComplete bool
|
||||
}
|
||||
|
||||
var armenianMap = []string{
|
||||
"աու", "au",
|
||||
"բու", "bu",
|
||||
"գու", "gu",
|
||||
"դու", "du",
|
||||
"եու", "eu",
|
||||
"զու", "zu",
|
||||
"էու", "eu",
|
||||
"ըու", "yu",
|
||||
"թու", "tu",
|
||||
"ժու", "ju",
|
||||
"իու", "iu",
|
||||
"լու", "lu",
|
||||
"խու", "xu",
|
||||
"ծու", "cu",
|
||||
"կու", "ku",
|
||||
"հու", "hu",
|
||||
"ձու", "dzu",
|
||||
"ղու", "xu",
|
||||
"ճու", "cu",
|
||||
"մու", "mu",
|
||||
"յու", "yu",
|
||||
"նու", "nu",
|
||||
"շու", "shu",
|
||||
"չու", "chu",
|
||||
"պու", "pu",
|
||||
"ջու", "ju",
|
||||
"ռու", "ru",
|
||||
"սու", "su",
|
||||
"վու", "vu",
|
||||
"տու", "tu",
|
||||
"րու", "ru",
|
||||
"ցու", "cu",
|
||||
"փու", "pu",
|
||||
"քու", "qu",
|
||||
"օու", "ou",
|
||||
"ևու", "eu",
|
||||
"ֆու", "fu",
|
||||
"ոու", "vou",
|
||||
"ու", "u",
|
||||
"բո", "bo",
|
||||
"գո", "go",
|
||||
"դո", "do",
|
||||
"զո", "zo",
|
||||
"թո", "to",
|
||||
"ժո", "jo",
|
||||
"լո", "lo",
|
||||
"խո", "xo",
|
||||
"ծո", "co",
|
||||
"կո", "ko",
|
||||
"հո", "ho",
|
||||
"ձո", "dzo",
|
||||
"ղո", "xo",
|
||||
"ճո", "co",
|
||||
"մո", "mo",
|
||||
"յո", "yo",
|
||||
"նո", "no",
|
||||
"շո", "so",
|
||||
"չո", "co",
|
||||
"պո", "po",
|
||||
"ջո", "jo",
|
||||
"ռո", "ro",
|
||||
"սո", "so",
|
||||
"վո", "vo",
|
||||
"տո", "to",
|
||||
"րո", "ro",
|
||||
"ցո", "co",
|
||||
"փո", "po",
|
||||
"քո", "qo",
|
||||
"ևո", "eo",
|
||||
"ֆո", "fo",
|
||||
"ո", "vo",
|
||||
"եւ", "ev",
|
||||
"եվ", "ev",
|
||||
"ա", "a",
|
||||
"բ", "b",
|
||||
"գ", "g",
|
||||
"դ", "d",
|
||||
"ե", "e",
|
||||
"զ", "z",
|
||||
"է", "e",
|
||||
"ը", "y",
|
||||
"թ", "t",
|
||||
"ժ", "j",
|
||||
"ի", "i",
|
||||
"լ", "l",
|
||||
"խ", "x",
|
||||
"ծ", "c",
|
||||
"կ", "k",
|
||||
"հ", "h",
|
||||
"ձ", "dz",
|
||||
"ղ", "x",
|
||||
"ճ", "c",
|
||||
"մ", "m",
|
||||
"յ", "y",
|
||||
"ն", "n",
|
||||
"շ", "sh",
|
||||
"չ", "ch",
|
||||
"պ", "p",
|
||||
"ջ", "j",
|
||||
"ռ", "r",
|
||||
"ս", "s",
|
||||
"վ", "v",
|
||||
"տ", "t",
|
||||
"ր", "r",
|
||||
"ց", "c",
|
||||
"փ", "p",
|
||||
"ք", "q",
|
||||
"օ", "o",
|
||||
"և", "ev",
|
||||
"ֆ", "f",
|
||||
"ւ", "",
|
||||
}
|
||||
|
||||
func (at *ArmenianTranslit) Init() {
|
||||
if !at.initComplete {
|
||||
// Copy map as original will be changed
|
||||
lower := armenianMap
|
||||
// For every value in copied map
|
||||
for i, val := range lower {
|
||||
// If index is odd, skip
|
||||
if i%2 == 1 {
|
||||
continue
|
||||
}
|
||||
// Capitalize first letter
|
||||
capital := strings.Title(val)
|
||||
// If capital is not the same as lowercase
|
||||
if capital != val {
|
||||
// Add capital to map
|
||||
armenianMap = append(armenianMap, capital, strings.Title(armenianMap[i+1]))
|
||||
}
|
||||
}
|
||||
// Set init complete to true so it is not run again
|
||||
at.initComplete = true
|
||||
}
|
||||
}
|
||||
|
||||
func (at *ArmenianTranslit) Transliterate(s string) string {
|
||||
return strings.NewReplacer(armenianMap...).Replace(s)
|
||||
}
|
||||
53
translit/chinese.go
Normal file
53
translit/chinese.go
Normal file
@@ -0,0 +1,53 @@
|
||||
package translit
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"strings"
|
||||
"unicode"
|
||||
|
||||
"github.com/mozillazg/go-pinyin"
|
||||
)
|
||||
|
||||
// ChineseTranslit implements Transliterator using a pinyin
|
||||
// conversion library.
|
||||
type ChineseTranslit struct{}
|
||||
|
||||
func (ChineseTranslit) Init() {}
|
||||
|
||||
func (ct *ChineseTranslit) Transliterate(s string) string {
|
||||
// Create buffer for final output
|
||||
outBuf := &bytes.Buffer{}
|
||||
// Create buffer to temporarily store chinese characters
|
||||
tmpBuf := &bytes.Buffer{}
|
||||
// For every character in string
|
||||
for _, char := range s {
|
||||
// If character in Han range
|
||||
if unicode.Is(unicode.Han, char) {
|
||||
// Write character to temporary buffer
|
||||
tmpBuf.WriteRune(char)
|
||||
} else {
|
||||
// If buffer contains characters
|
||||
if tmpBuf.Len() > 0 {
|
||||
// Convert to pinyin (without tones)
|
||||
out := pinyin.LazyConvert(tmpBuf.String(), nil)
|
||||
// Write space-separated string to output
|
||||
outBuf.WriteString(strings.Join(out, " "))
|
||||
// Reset temporary buffer
|
||||
tmpBuf.Reset()
|
||||
}
|
||||
// Write character to output
|
||||
outBuf.WriteRune(char)
|
||||
}
|
||||
}
|
||||
// If buffer contains characters
|
||||
if tmpBuf.Len() > 0 {
|
||||
// Convert to pinyin (without tones)
|
||||
out := pinyin.LazyConvert(tmpBuf.String(), nil)
|
||||
// Write space-separated string to output
|
||||
outBuf.WriteString(strings.Join(out, " "))
|
||||
// Reset temporary buffer
|
||||
tmpBuf.Reset()
|
||||
}
|
||||
// Return output string
|
||||
return outBuf.String()
|
||||
}
|
||||
472
translit/korean.go
Normal file
472
translit/korean.go
Normal file
@@ -0,0 +1,472 @@
|
||||
package translit
|
||||
|
||||
import (
|
||||
"strings"
|
||||
"unicode"
|
||||
|
||||
"golang.org/x/text/unicode/norm"
|
||||
)
|
||||
|
||||
// https://en.wikipedia.org/wiki/Hangul_Jamo_%28Unicode_block%29
|
||||
var jamoBlock = &unicode.RangeTable{
|
||||
R16: []unicode.Range16{{
|
||||
Lo: 0x1100,
|
||||
Hi: 0x11FF,
|
||||
Stride: 1,
|
||||
}},
|
||||
}
|
||||
|
||||
// https://en.wikipedia.org/wiki/Hangul_Syllables
|
||||
var syllablesBlock = &unicode.RangeTable{
|
||||
R16: []unicode.Range16{{
|
||||
Lo: 0xAC00,
|
||||
Hi: 0xD7A3,
|
||||
Stride: 1,
|
||||
}},
|
||||
}
|
||||
|
||||
// https://en.wikipedia.org/wiki/Hangul_Compatibility_Jamo
|
||||
var compatJamoBlock = &unicode.RangeTable{
|
||||
R16: []unicode.Range16{{
|
||||
Lo: 0x3131,
|
||||
Hi: 0x318E,
|
||||
Stride: 1,
|
||||
}},
|
||||
}
|
||||
|
||||
// KoreanTranslit implements transliteration for Korean.
|
||||
//
|
||||
// This was translated to Go from the code in https://codeberg.org/Freeyourgadget/Gadgetbridge
|
||||
type KoreanTranslit struct{}
|
||||
|
||||
func (KoreanTranslit) Init() {}
|
||||
|
||||
// User input consisting of isolated jamo is usually mapped to the KS X 1001 compatibility
|
||||
// block, but jamo resulting from decomposed syllables are mapped to the modern one. This
|
||||
// function maps compat jamo to modern ones where possible and returns all other characters
|
||||
// unmodified.
|
||||
//
|
||||
// https://en.wikipedia.org/wiki/Hangul_Compatibility_Jamo
|
||||
// https://en.wikipedia.org/wiki/Hangul_Jamo_%28Unicode_block%29
|
||||
func decompatJamo(jamo rune) rune {
|
||||
// KS X 1001 Hangul filler, not used in modern Unicode. A useful landmark in the
|
||||
// compatibility jamo block.
|
||||
// https://en.wikipedia.org/wiki/KS_X_1001#Hangul_Filler
|
||||
var hangulFiller rune = 0x3164
|
||||
|
||||
// Ignore characters outside compatibility jamo block
|
||||
if !unicode.In(jamo, compatJamoBlock) {
|
||||
return jamo
|
||||
}
|
||||
|
||||
// Vowels are contiguous, in the same order, and unambiguous so it's a simple offset.
|
||||
if jamo >= 0x314F && jamo < hangulFiller {
|
||||
return jamo - 0x1FEE
|
||||
}
|
||||
|
||||
// Consonants are organized differently. No clean way to do this.
|
||||
// The compatibility jamo block doesn't distinguish between Choseong (leading) and Jongseong
|
||||
// (final) positions, but the modern block does. We map to Choseong here.
|
||||
switch jamo {
|
||||
case 0x3131:
|
||||
return 0x1100 // ㄱ
|
||||
case 0x3132:
|
||||
return 0x1101 // ㄲ
|
||||
case 0x3134:
|
||||
return 0x1102 // ㄴ
|
||||
case 0x3137:
|
||||
return 0x1103 // ㄷ
|
||||
case 0x3138:
|
||||
return 0x1104 // ㄸ
|
||||
case 0x3139:
|
||||
return 0x1105 // ㄹ
|
||||
case 0x3141:
|
||||
return 0x1106 // ㅁ
|
||||
case 0x3142:
|
||||
return 0x1107 // ㅂ
|
||||
case 0x3143:
|
||||
return 0x1108 // ㅃ
|
||||
case 0x3145:
|
||||
return 0x1109 // ㅅ
|
||||
case 0x3146:
|
||||
return 0x110A // ㅆ
|
||||
case 0x3147:
|
||||
return 0x110B // ㅇ
|
||||
case 0x3148:
|
||||
return 0x110C // ㅈ
|
||||
case 0x3149:
|
||||
return 0x110D // ㅉ
|
||||
case 0x314A:
|
||||
return 0x110E // ㅊ
|
||||
case 0x314B:
|
||||
return 0x110F // ㅋ
|
||||
case 0x314C:
|
||||
return 0x1110 // ㅌ
|
||||
case 0x314D:
|
||||
return 0x1111 // ㅍ
|
||||
case 0x314E:
|
||||
return 0x1112 // ㅎ
|
||||
}
|
||||
|
||||
// The rest of the compatibility block consists of archaic compounds that are
|
||||
// unlikely to be encountered in modern systems. Just leave them alone.
|
||||
return jamo
|
||||
}
|
||||
|
||||
// Transliterates one jamo at a time.
|
||||
// Does nothing if it isn't in the modern jamo block.
|
||||
func translitSingleJamo(jamo rune) string {
|
||||
jamo = decompatJamo(jamo)
|
||||
|
||||
switch jamo {
|
||||
// Choseong (leading position consonants)
|
||||
case 0x1100:
|
||||
return "g" // ㄱ
|
||||
case 0x1101:
|
||||
return "kk" // ㄲ
|
||||
case 0x1102:
|
||||
return "n" // ㄴ
|
||||
case 0x1103:
|
||||
return "d" // ㄷ
|
||||
case 0x1104:
|
||||
return "tt" // ㄸ
|
||||
case 0x1105:
|
||||
return "r" // ㄹ
|
||||
case 0x1106:
|
||||
return "m" // ㅁ
|
||||
case 0x1107:
|
||||
return "b" // ㅂ
|
||||
case 0x1108:
|
||||
return "pp" // ㅃ
|
||||
case 0x1109:
|
||||
return "s" // ㅅ
|
||||
case 0x110A:
|
||||
return "ss" // ㅆ
|
||||
case 0x110B:
|
||||
return "" // ㅇ
|
||||
case 0x110C:
|
||||
return "j" // ㅈ
|
||||
case 0x110D:
|
||||
return "jj" // ㅉ
|
||||
case 0x110E:
|
||||
return "ch" // ㅊ
|
||||
case 0x110F:
|
||||
return "k" // ㅋ
|
||||
case 0x1110:
|
||||
return "t" // ㅌ
|
||||
case 0x1111:
|
||||
return "p" // ㅍ
|
||||
case 0x1112:
|
||||
return "h" // ㅎ
|
||||
// Jungseong (vowels)
|
||||
case 0x1161:
|
||||
return "a" // ㅏ
|
||||
case 0x1162:
|
||||
return "ae" // ㅐ
|
||||
case 0x1163:
|
||||
return "ya" // ㅑ
|
||||
case 0x1164:
|
||||
return "yae" // ㅒ
|
||||
case 0x1165:
|
||||
return "eo" // ㅓ
|
||||
case 0x1166:
|
||||
return "e" // ㅔ
|
||||
case 0x1167:
|
||||
return "yeo" // ㅕ
|
||||
case 0x1168:
|
||||
return "ye" // ㅖ
|
||||
case 0x1169:
|
||||
return "o" // ㅗ
|
||||
case 0x116A:
|
||||
return "wa" // ㅘ
|
||||
case 0x116B:
|
||||
return "wae" // ㅙ
|
||||
case 0x116C:
|
||||
return "oe" // ㅚ
|
||||
case 0x116D:
|
||||
return "yo" // ㅛ
|
||||
case 0x116E:
|
||||
return "u" // ㅜ
|
||||
case 0x116F:
|
||||
return "wo" // ㅝ
|
||||
case 0x1170:
|
||||
return "we" // ㅞ
|
||||
case 0x1171:
|
||||
return "wi" // ㅟ
|
||||
case 0x1172:
|
||||
return "yu" // ㅠ
|
||||
case 0x1173:
|
||||
return "eu" // ㅡ
|
||||
case 0x1174:
|
||||
return "ui" // ㅢ
|
||||
case 0x1175:
|
||||
return "i" // ㅣ
|
||||
// Jongseong (final position consonants)
|
||||
case 0x11A8:
|
||||
return "k" // ㄱ
|
||||
case 0x11A9:
|
||||
return "k" // ㄲ
|
||||
case 0x11AB:
|
||||
return "n" // ㄴ
|
||||
case 0x11AE:
|
||||
return "t" // ㄷ
|
||||
case 0x11AF:
|
||||
return "l" // ㄹ
|
||||
case 0x11B7:
|
||||
return "m" // ㅁ
|
||||
case 0x11B8:
|
||||
return "p" // ㅂ
|
||||
case 0x11BA:
|
||||
return "t" // ㅅ
|
||||
case 0x11BB:
|
||||
return "t" // ㅆ
|
||||
case 0x11BC:
|
||||
return "ng" // ㅇ
|
||||
case 0x11BD:
|
||||
return "t" // ㅈ
|
||||
case 0x11BE:
|
||||
return "t" // ㅊ
|
||||
case 0x11BF:
|
||||
return "k" // ㅋ
|
||||
case 0x11C0:
|
||||
return "t" // ㅌ
|
||||
case 0x11C1:
|
||||
return "p" // ㅍ
|
||||
case 0x11C2:
|
||||
return "t" // ㅎ
|
||||
}
|
||||
|
||||
return string(jamo)
|
||||
}
|
||||
|
||||
// Some combinations of ending jamo in one syllable and initial jamo in the next are romanized
|
||||
// irregularly. These exceptions are called "special provisions". In cases where multiple
|
||||
// romanizations are permitted, we use the one that's least commonly used elsewhere.
|
||||
//
|
||||
// Returns empty strring and false if either character is not in the modern jamo block,
|
||||
// or if there is no special provision for that pair of jamo.
|
||||
func translitSpecialProvisions(previousEnding rune, nextInitial rune) (string, bool) {
|
||||
// Return false if previousEnding not in modern jamo block
|
||||
if !unicode.In(previousEnding, jamoBlock) {
|
||||
return "", false
|
||||
}
|
||||
// Return false if nextInitial not in modern jamo block
|
||||
if !unicode.In(nextInitial, jamoBlock) {
|
||||
return "", false
|
||||
}
|
||||
|
||||
// Jongseong (final position) ㅎ has a number of special provisions.
|
||||
if previousEnding == 0x11C2 {
|
||||
switch nextInitial {
|
||||
case 0x110B:
|
||||
return "h", true // ㅇ
|
||||
case 0x1100:
|
||||
return "k", true // ㄱ
|
||||
case 0x1102:
|
||||
return "nn", true // ㄴ
|
||||
case 0x1103:
|
||||
return "t", true // ㄷ
|
||||
case 0x1105:
|
||||
return "nn", true // ㄹ
|
||||
case 0x1106:
|
||||
return "nm", true // ㅁ
|
||||
case 0x1107:
|
||||
return "p", true // ㅂ
|
||||
case 0x1109:
|
||||
return "hs", true // ㅅ
|
||||
case 0x110C:
|
||||
return "ch", true // ㅈ
|
||||
case 0x1112:
|
||||
return "t", true // ㅎ
|
||||
default:
|
||||
return "", false
|
||||
}
|
||||
}
|
||||
|
||||
// Otherwise, special provisions are denser when grouped by the second jamo.
|
||||
switch nextInitial {
|
||||
case 0x1100: // ㄱ
|
||||
switch previousEnding {
|
||||
case 0x11AB:
|
||||
return "n-g", true // ㄴ
|
||||
default:
|
||||
return "", false
|
||||
}
|
||||
case 0x1102: // ㄴ
|
||||
switch previousEnding {
|
||||
case 0x11A8:
|
||||
return "ngn", true // ㄱ
|
||||
case 0x11AE:
|
||||
fallthrough // ㄷ
|
||||
case 0x11BA:
|
||||
fallthrough // ㅅ
|
||||
case 0x11BD:
|
||||
fallthrough // ㅈ
|
||||
case 0x11BE:
|
||||
fallthrough // ㅊ
|
||||
case 0x11C0: // ㅌ
|
||||
return "nn", true
|
||||
case 0x11AF:
|
||||
return "ll", true // ㄹ
|
||||
case 0x11B8:
|
||||
return "mn", true // ㅂ
|
||||
default:
|
||||
return "", false
|
||||
}
|
||||
case 0x1105: // ㄹ
|
||||
switch previousEnding {
|
||||
case 0x11A8:
|
||||
fallthrough // ㄱ
|
||||
case 0x11AB:
|
||||
fallthrough // ㄴ
|
||||
case 0x11AF: // ㄹ
|
||||
return "ll", true
|
||||
case 0x11AE:
|
||||
fallthrough // ㄷ
|
||||
case 0x11BA:
|
||||
fallthrough // ㅅ
|
||||
case 0x11BD:
|
||||
fallthrough // ㅈ
|
||||
case 0x11BE:
|
||||
fallthrough // ㅊ
|
||||
case 0x11C0: // ㅌ
|
||||
return "nn", true
|
||||
case 0x11B7:
|
||||
fallthrough // ㅁ
|
||||
case 0x11B8: // ㅂ
|
||||
return "mn", true
|
||||
case 0x11BC:
|
||||
return "ngn", true // ㅇ
|
||||
default:
|
||||
return "", false
|
||||
}
|
||||
case 0x1106: // ㅁ
|
||||
switch previousEnding {
|
||||
case 0x11A8:
|
||||
return "ngm", true // ㄱ
|
||||
case 0x11AE:
|
||||
fallthrough // ㄷ
|
||||
case 0x11BA:
|
||||
fallthrough // ㅅ
|
||||
case 0x11BD:
|
||||
fallthrough // ㅈ
|
||||
case 0x11BE:
|
||||
fallthrough // ㅊ
|
||||
case 0x11C0: // ㅌ
|
||||
return "nm", true
|
||||
case 0x11B8:
|
||||
return "mm", true // ㅂ
|
||||
default:
|
||||
return "", false
|
||||
}
|
||||
case 0x110B: // ㅇ
|
||||
switch previousEnding {
|
||||
case 0x11A8:
|
||||
return "g", true // ㄱ
|
||||
case 0x11AE:
|
||||
return "d", true // ㄷ
|
||||
case 0x11AF:
|
||||
return "r", true // ㄹ
|
||||
case 0x11B8:
|
||||
return "b", true // ㅂ
|
||||
case 0x11BA:
|
||||
return "s", true // ㅅ
|
||||
case 0x11BC:
|
||||
return "ng-", true // ㅇ
|
||||
case 0x11BD:
|
||||
return "j", true // ㅈ
|
||||
case 0x11BE:
|
||||
return "ch", true // ㅊ
|
||||
default:
|
||||
return "", false
|
||||
}
|
||||
case 0x110F: // ㅋ
|
||||
switch previousEnding {
|
||||
case 0x11A8:
|
||||
return "k-k", true // ㄱ
|
||||
default:
|
||||
return "", false
|
||||
}
|
||||
case 0x1110: // ㅌ
|
||||
switch previousEnding {
|
||||
case 0x11AE:
|
||||
fallthrough // ㄷ
|
||||
case 0x11BA:
|
||||
fallthrough // ㅅ
|
||||
case 0x11BD:
|
||||
fallthrough // ㅈ
|
||||
case 0x11BE:
|
||||
fallthrough // ㅊ
|
||||
case 0x11C0: // ㅌ
|
||||
return "t-t", true
|
||||
default:
|
||||
return "", false
|
||||
}
|
||||
case 0x1111: // ㅍ
|
||||
switch previousEnding {
|
||||
case 0x11B8:
|
||||
return "p-p", true // ㅂ
|
||||
default:
|
||||
return "", false
|
||||
}
|
||||
default:
|
||||
return "", false
|
||||
}
|
||||
}
|
||||
|
||||
// Decompose a syllable into several jamo. Does nothing if that isn't possible.
|
||||
func decompose(syllable rune) string {
|
||||
return norm.NFD.String(string(syllable))
|
||||
}
|
||||
|
||||
// Transliterate any Hangul in the given string.
|
||||
// Leaves any non-Hangul characters unmodified.
|
||||
func (kt *KoreanTranslit) Transliterate(s string) string {
|
||||
if len(s) == 0 {
|
||||
return s
|
||||
}
|
||||
|
||||
builder := &strings.Builder{}
|
||||
|
||||
nextInitialJamoConsumed := false
|
||||
|
||||
for i, syllable := range s {
|
||||
// If character not in blocks, leave it unmodified
|
||||
if !unicode.In(syllable, jamoBlock, syllablesBlock, compatJamoBlock) {
|
||||
builder.WriteRune(syllable)
|
||||
continue
|
||||
}
|
||||
|
||||
jamo := decompose(syllable)
|
||||
for j, char := range jamo {
|
||||
// If we already transliterated the first jamo of this syllable as part of a special
|
||||
// provision, skip it. Otherwise, handle it in the unconditional else branch.
|
||||
if j == 0 && nextInitialJamoConsumed {
|
||||
nextInitialJamoConsumed = false
|
||||
continue
|
||||
}
|
||||
|
||||
// If this is the last jamo of this syllable and not the last syllable of the
|
||||
// string, check for special provisions. If the next char is whitespace or not
|
||||
// Hangul, run translitSpecialProvisions() should return no value.
|
||||
if j == len(jamo)-1 && i < len(s)-1 {
|
||||
nextSyllable := s[i+1]
|
||||
nextJamo := decompose(rune(nextSyllable))[0]
|
||||
|
||||
// Attempt to handle special provision
|
||||
specialProvision, ok := translitSpecialProvisions(char, rune(nextJamo))
|
||||
if ok {
|
||||
builder.WriteString(specialProvision)
|
||||
nextInitialJamoConsumed = true
|
||||
} else {
|
||||
// Not a special provision, transliterate normally
|
||||
builder.WriteString(translitSingleJamo(char))
|
||||
}
|
||||
continue
|
||||
}
|
||||
// Transliterate normally
|
||||
builder.WriteString(translitSingleJamo(char))
|
||||
}
|
||||
}
|
||||
return builder.String()
|
||||
}
|
||||
361
translit/translit.go
Normal file
361
translit/translit.go
Normal file
@@ -0,0 +1,361 @@
|
||||
package translit
|
||||
|
||||
import (
|
||||
"strings"
|
||||
)
|
||||
|
||||
// Transliterate runs the given maps on s and returns the result
|
||||
func Transliterate(s string, useMaps ...string) string {
|
||||
// Create variable to store modified string
|
||||
out := s
|
||||
// If custom map exists
|
||||
if custom, ok := Transliterators["custom"]; ok {
|
||||
// Perform transliteration with it
|
||||
out = custom.Transliterate(out)
|
||||
}
|
||||
// For every map to use
|
||||
for _, useMap := range useMaps {
|
||||
// If custom, skip
|
||||
if useMap == "custom" {
|
||||
continue
|
||||
}
|
||||
// Get requested map
|
||||
transliterator, ok := Transliterators[useMap]
|
||||
if !ok {
|
||||
continue
|
||||
}
|
||||
transliterator.Init()
|
||||
// Perform transliteration
|
||||
out = transliterator.Transliterate(out)
|
||||
}
|
||||
// Return result
|
||||
return out
|
||||
}
|
||||
|
||||
// Transliterator is implemented by anything with a
|
||||
// Transliterate method, which performs transliteration
|
||||
// and returns the resulting string.
|
||||
type Transliterator interface {
|
||||
Transliterate(string) string
|
||||
Init()
|
||||
}
|
||||
|
||||
// Map implements Transliterator using a slice where
|
||||
// every even element is a key and every odd one is a value
|
||||
// which replaces the key.
|
||||
type Map []string
|
||||
|
||||
func (mt Map) Transliterate(s string) string {
|
||||
return strings.NewReplacer(mt...).Replace(s)
|
||||
}
|
||||
|
||||
func (Map) Init() {}
|
||||
|
||||
// Transliterators stores transliterator implementations for each supported language.
|
||||
// Some of these were sourced from https://codeberg.org/Freeyourgadget/Gadgetbridge
|
||||
var Transliterators = map[string]Transliterator{
|
||||
"eASCII": Map{
|
||||
"œ", "oe",
|
||||
"ª", "a",
|
||||
"°", "o",
|
||||
"«", `"`,
|
||||
"»", `"`,
|
||||
},
|
||||
"Scandinavian": Map{
|
||||
"Æ", "Ae",
|
||||
"æ", "ae",
|
||||
"Ø", "Oe",
|
||||
"ø", "oe",
|
||||
"Å", "Aa",
|
||||
"å", "aa",
|
||||
},
|
||||
"German": Map{
|
||||
"ä", "ae",
|
||||
"ö", "oe",
|
||||
"ü", "ue",
|
||||
"Ä", "Ae",
|
||||
"Ö", "Oe",
|
||||
"Ü", "Ue",
|
||||
"ß", "ss",
|
||||
"ẞ", "SS",
|
||||
},
|
||||
"Hebrew": Map{
|
||||
"א", "a",
|
||||
"ב", "b",
|
||||
"ג", "g",
|
||||
"ד", "d",
|
||||
"ה", "h",
|
||||
"ו", "u",
|
||||
"ז", "z",
|
||||
"ח", "kh",
|
||||
"ט", "t",
|
||||
"י", "y",
|
||||
"כ", "c",
|
||||
"ל", "l",
|
||||
"מ", "m",
|
||||
"נ", "n",
|
||||
"ס", "s",
|
||||
"ע", "'",
|
||||
"פ", "p",
|
||||
"צ", "ts",
|
||||
"ק", "k",
|
||||
"ר", "r",
|
||||
"ש", "sh",
|
||||
"ת", "th",
|
||||
"ף", "f",
|
||||
"ץ", "ts",
|
||||
"ך", "ch",
|
||||
"ם", "m",
|
||||
"ן", "n",
|
||||
},
|
||||
"Greek": Map{
|
||||
"α", "a",
|
||||
"ά", "a",
|
||||
"β", "v",
|
||||
"γ", "g",
|
||||
"δ", "d",
|
||||
"ε", "e",
|
||||
"έ", "e",
|
||||
"ζ", "z",
|
||||
"η", "i",
|
||||
"ή", "i",
|
||||
"θ", "th",
|
||||
"ι", "i",
|
||||
"ί", "i",
|
||||
"ϊ", "i",
|
||||
"ΐ", "i",
|
||||
"κ", "k",
|
||||
"λ", "l",
|
||||
"μ", "m",
|
||||
"ν", "n",
|
||||
"ξ", "ks",
|
||||
"ο", "o",
|
||||
"ό", "o",
|
||||
"π", "p",
|
||||
"ρ", "r",
|
||||
"σ", "s",
|
||||
"ς", "s",
|
||||
"τ", "t",
|
||||
"υ", "y",
|
||||
"ύ", "y",
|
||||
"ϋ", "y",
|
||||
"ΰ", "y",
|
||||
"φ", "f",
|
||||
"χ", "ch",
|
||||
"ψ", "ps",
|
||||
"ω", "o",
|
||||
"ώ", "o",
|
||||
"Α", "A",
|
||||
"Ά", "A",
|
||||
"Β", "B",
|
||||
"Γ", "G",
|
||||
"Δ", "D",
|
||||
"Ε", "E",
|
||||
"Έ", "E",
|
||||
"Ζ", "Z",
|
||||
"Η", "I",
|
||||
"Ή", "I",
|
||||
"Θ", "Th",
|
||||
"Ι", "I",
|
||||
"Ί", "I",
|
||||
"Ϊ", "I",
|
||||
"Κ", "K",
|
||||
"Λ", "L",
|
||||
"Μ", "M",
|
||||
"Ν", "N",
|
||||
"Ξ", "Ks",
|
||||
"Ο", "O",
|
||||
"Ό", "O",
|
||||
"Π", "P",
|
||||
"Ρ", "R",
|
||||
"Σ", "S",
|
||||
"Τ", "T",
|
||||
"Υ", "Y",
|
||||
"Ύ", "Y",
|
||||
"Ϋ", "Y",
|
||||
"Φ", "F",
|
||||
"Χ", "Ch",
|
||||
"Ψ", "Ps",
|
||||
"Ω", "O",
|
||||
"Ώ", "O",
|
||||
},
|
||||
"Russian": Map{
|
||||
"Ё", "Йo",
|
||||
"ё", "йo",
|
||||
},
|
||||
"Ukranian": Map{
|
||||
"ґ", "gh",
|
||||
"є", "je",
|
||||
"і", "i",
|
||||
"ї", "ji",
|
||||
"Ґ", "Gh",
|
||||
"Є", "Je",
|
||||
"І", "I",
|
||||
"Ї", "JI",
|
||||
},
|
||||
"Arabic": Map{
|
||||
"ا", "a",
|
||||
"ب", "b",
|
||||
"ت", "t",
|
||||
"ث", "th",
|
||||
"ج", "j",
|
||||
"ح", "7",
|
||||
"خ", "5",
|
||||
"د", "d",
|
||||
"ذ", "th",
|
||||
"ر", "r",
|
||||
"ز", "z",
|
||||
"س", "s",
|
||||
"ش", "sh",
|
||||
"ص", "9",
|
||||
"ض", "9'",
|
||||
"ط", "6",
|
||||
"ظ", "6'",
|
||||
"ع", "3",
|
||||
"غ", "3'",
|
||||
"ف", "f",
|
||||
"ق", "q",
|
||||
"ك", "k",
|
||||
"ل", "l",
|
||||
"م", "m",
|
||||
"ن", "n",
|
||||
"ه", "h",
|
||||
"و", "w",
|
||||
"ي", "y",
|
||||
"ى", "a",
|
||||
"ﺓ", "",
|
||||
"آ", "2",
|
||||
"ئ", "2",
|
||||
"إ", "2",
|
||||
"ؤ", "2",
|
||||
"أ", "2",
|
||||
"ء", "2",
|
||||
"٠", "0",
|
||||
"١", "1",
|
||||
"٢", "2",
|
||||
"٣", "3",
|
||||
"٤", "4",
|
||||
"٥", "5",
|
||||
"٦", "6",
|
||||
"٧", "7",
|
||||
"٨", "8",
|
||||
"٩", "9",
|
||||
},
|
||||
"Farsi": Map{
|
||||
"پ", "p",
|
||||
"چ", "ch",
|
||||
"ژ", "zh",
|
||||
"ک", "k",
|
||||
"گ", "g",
|
||||
"ی", "y",
|
||||
"\u200c", " ",
|
||||
"؟", "?",
|
||||
"٪", "%",
|
||||
"؛", ";",
|
||||
"،", ":",
|
||||
"۱", "1",
|
||||
"۲", "2",
|
||||
"۳", "3",
|
||||
"۴", "4",
|
||||
"۵", "5",
|
||||
"۶", "6",
|
||||
"۷", "7",
|
||||
"۸", "8",
|
||||
"۹", "9",
|
||||
"۰", "0",
|
||||
"»", "<",
|
||||
"«", ">",
|
||||
"ِ", "e",
|
||||
"َ", "a",
|
||||
"ُ", "o",
|
||||
"ّ", "",
|
||||
},
|
||||
"Polish": Map{
|
||||
"Ł", "L",
|
||||
"ł", "l",
|
||||
},
|
||||
"Lithuanian": Map{
|
||||
"ą", "a",
|
||||
"č", "c",
|
||||
"ę", "e",
|
||||
"ė", "e",
|
||||
"į", "i",
|
||||
"š", "s",
|
||||
"ų", "u",
|
||||
"ū", "u",
|
||||
"ž", "z",
|
||||
},
|
||||
"Estonian": Map{
|
||||
"ä", "a",
|
||||
"Ä", "A",
|
||||
"ö", "o",
|
||||
"õ", "o",
|
||||
"Ö", "O",
|
||||
"Õ", "O",
|
||||
"ü", "u",
|
||||
"Ü", "U",
|
||||
},
|
||||
"Icelandic": Map{
|
||||
"Þ", "Th",
|
||||
"þ", "th",
|
||||
"Ð", "D",
|
||||
"ð", "d",
|
||||
},
|
||||
"Czeck": Map{
|
||||
"ř", "r",
|
||||
"ě", "e",
|
||||
"ý", "y",
|
||||
"á", "a",
|
||||
"í", "i",
|
||||
"é", "e",
|
||||
"ó", "o",
|
||||
"ú", "u",
|
||||
"ů", "u",
|
||||
"ď", "d",
|
||||
"ť", "t",
|
||||
"ň", "n",
|
||||
},
|
||||
"French": Map{
|
||||
"à", "a",
|
||||
"â", "a",
|
||||
"é", "e",
|
||||
"è", "e",
|
||||
"ê", "e",
|
||||
"ë", "e",
|
||||
"ù", "u",
|
||||
"ü", "u",
|
||||
"ÿ", "y",
|
||||
"ç", "c",
|
||||
},
|
||||
"Emoji": Map{
|
||||
"😂", ":')",
|
||||
"😊", ":)",
|
||||
"😃", ":)",
|
||||
"😩", "-_-",
|
||||
"😏", ":‑J",
|
||||
"💜", "<3",
|
||||
"💖", "<3",
|
||||
"💗", "<3",
|
||||
"❤️", "<3",
|
||||
"💕", "<3",
|
||||
"💞", "<3",
|
||||
"💘", "<3",
|
||||
"💓", "<3",
|
||||
"💚", "<3",
|
||||
"💙", "<3",
|
||||
"💔", "</3",
|
||||
"😱", "D:",
|
||||
"😮", ":O",
|
||||
"😝", ":P",
|
||||
"😍", ":x",
|
||||
"😢", ":(",
|
||||
"💯", ":100:",
|
||||
"🔥", ":fire:",
|
||||
"😉", ";)",
|
||||
"😴", ":zzz:",
|
||||
"💤", ":zzz:",
|
||||
},
|
||||
"Korean": &KoreanTranslit{},
|
||||
"Chinese": &ChineseTranslit{},
|
||||
"Armenian": &ArmenianTranslit{},
|
||||
}
|
||||
Reference in New Issue
Block a user