diff --git a/.README.assets/image-20211115105354958.png b/.README.assets/image-20211115105354958.png new file mode 100644 index 0000000..fd8841e Binary files /dev/null and b/.README.assets/image-20211115105354958.png differ diff --git a/README.md b/README.md new file mode 100644 index 0000000..9eb2b8b --- /dev/null +++ b/README.md @@ -0,0 +1,109 @@ +# 디바이스 공통 정보 + +- 디바이스 이름 / 관리 서비스 이름 / prompt + + + +# 컨트롤러 및 등록 + + + +# 디바이스 탐색 및 등록 + +- Procedure + +> ![image-20211115105354958](.README.assets/image-20211115105354958.png) + +- Device -> Controller + + ```json + { + "dname": "thermometer", + "type": "sensor", + "sname": "devicemanagerA", + "cid": + } + ``` + +- controller -> server + + ```json + { + "name": "temp", + "type": "sensor", + "did": "temp-1", + "cid": "controller-1", + "sid": "devicemanagerA" + } + ``` + +- client -> server + + ```json + { + "did": "thermometer-1" + } + ``` + + + +# API + +- get-services + + - `http://{{server}}/services` + +- post-services + + - `http://{{server}}/services` + + ```json + { + "name": "devicemanagera" + } + ``` + +- post-controller + + - `http://{{server}}/controllers` + + ```json + { + "cname": "controller-A" + } + ``` + +- get-controller + + - `http://{{server}}/controllers` + +- post-devices + + - `http://{{server}}/devices` + + ```json + { + "dname": "device-A", + "type": "sensor", + "cid": "e09c50b3-40d1-4267-888e-272d6a7d4845", + "sname": "devicemanagerb" + } + ``` + +- get-devices + + - `http://{{server}}/devices` + +- put-devices + + - `http://{{server}}/services` + + ```json + { + "name": "devicemanagerA", + "addr": "127.0.1.1:3001" + } + ``` + + + diff --git a/bootstrap/cli.go b/bootstrap/cli.go new file mode 100644 index 0000000..2a600d4 --- /dev/null +++ b/bootstrap/cli.go @@ -0,0 +1,66 @@ +package bootstrap + +import ( + "bytes" + "log" + gonet "net" + + "github.com/plgd-dev/go-coap/v2/message" + "github.com/plgd-dev/go-coap/v2/message/codes" + "github.com/plgd-dev/go-coap/v2/mux" + "github.com/plgd-dev/go-coap/v2/net" + "github.com/plgd-dev/go-coap/v2/udp" +) + +func handleMcast(w mux.ResponseWriter, r *mux.Message) { + path, err := r.Options.Path() + if err != nil { + log.Printf("cannot get path: %v", err) + return + } + + log.Printf("Got mcast message: path=%q: from %v", path, w.Client().RemoteAddr()) + w.SetResponse(codes.Content, message.TextPlain, bytes.NewReader([]byte("mcast response"))) +} + +func RunBootstrapServer() { + m := mux.NewRouter() + m.Handle("/bs", mux.HandlerFunc(handleMcast)) + multicastAddr := "224.0.1.187:5683" + + l, err := net.NewListenUDP("udp4", multicastAddr) + if err != nil { + log.Println(err) + return + } + + ifaces, err := gonet.Interfaces() + if err != nil { + log.Println(err) + return + } + + a, err := gonet.ResolveUDPAddr("udp", multicastAddr) + if err != nil { + log.Println(err) + return + } + + for _, iface := range ifaces { + err := l.JoinGroup(&iface, a) + if err != nil { + log.Printf("cannot JoinGroup(%v, %v): %v", iface, a, err) + } + } + + err = l.SetMulticastLoopback(true) + if err != nil { + log.Println(err) + return + } + + defer l.Close() + s := udp.NewServer(udp.WithMux(m)) + defer s.Stop() + log.Fatal(s.Serve(l)) +} diff --git a/config.properties b/config.properties new file mode 100644 index 0000000..878c735 --- /dev/null +++ b/config.properties @@ -0,0 +1 @@ +BootstrapAddr = 224.0.1.185:5684 \ No newline at end of file diff --git a/containermgmt/manager.go b/containermgmt/manager.go index b71172c..d9394d9 100644 --- a/containermgmt/manager.go +++ b/containermgmt/manager.go @@ -1,42 +1,19 @@ -package containermgnt +package containermgmt import ( - "context" - "encoding/json" "fmt" "log" "os/exec" "strings" ) -type Container struct { - Image string `json:"image"` - Name string `json:"name"` -} - -type ContainerReturnKey struct{} - -var ReturnKey = ContainerReturnKey{} - -func CreateContainer(ctx context.Context, cont *Container) context.Context { - - fmt.Println("container : ", *cont) - args := strings.Split(fmt.Sprintf("container\\run\\-d\\--name\\%s\\%s", cont.Name, cont.Image), "\\") - fmt.Println(args) - bout, err := exec.Command("docker", args...).Output() - if err != nil { - log.Fatalln(err) - } - - ctx = context.WithValue(ctx, ReturnKey, bout) - - return ctx -} - -func GetContainers(ctx context.Context) context.Context { - // cmd := exec.Command("firefox") - // err := cmd.Run() +// type Container struct { +// ID string `json:"image"` +// Name string `json:"name"` +// Addr string `json:addr` +// } +func IsExist(name string) bool { cmd := strings.Split("container\\ls\\--format\\'{{.Image}} {{.Names}}'\\-a", "\\") bout, err := exec.Command("docker", cmd...).Output() if err != nil { @@ -45,7 +22,6 @@ func GetContainers(ctx context.Context) context.Context { sout := strings.Split(string(bout), "\n") - var list []Container for _, e := range sout { l := strings.Split(e, " ") @@ -53,22 +29,25 @@ func GetContainers(ctx context.Context) context.Context { continue } - container := Container{ - Image: l[0], - Name: l[1], + if name == l[0] { + return true } - - list = append(list, container) } - b, err := json.Marshal(list) - if err != nil { - log.Fatalln("JSON Marshal error!!") - } - - fmt.Println(string(b)) - - ctx = context.WithValue(ctx, ReturnKey, b) - - return ctx + return false +} + +func CreateContainer(name string) error { + + if IsExist(name) { + return nil + } + args := strings.Split(fmt.Sprintf("container\\run\\-d\\%s", name), "\\") + fmt.Println(args) + _, err := exec.Command("docker", args...).Output() + if err != nil { + return err + } + + return nil } diff --git a/containers/devicemanagera/Dockerfile b/containers/devicemanagera/Dockerfile new file mode 100644 index 0000000..5ae849f --- /dev/null +++ b/containers/devicemanagera/Dockerfile @@ -0,0 +1,25 @@ +# build app +FROM golang:alpine AS gobuild +RUN apk update && \ + apk add ca-certificates gcc git make musl-dev +RUN mkdir /home/build +COPY . /home/build +WORKDIR /home/build +RUN go mod tidy && go build -o devicemanager + +FROM alpine:latest +ARG PUID=2000 +ARG PGID=2000 + +# Run App +RUN addgroup -g ${PGID} devicemanager && \ + adduser -H -D -u ${PUID} -G devicemanager devicemanager + +WORKDIR /opt/devicemanager + +COPY --from=gobuild /home/build/devicemanager devicemanager +RUN chown -R ${PUID}:${PGID} /opt/devicemanager + +USER devicemanager + +CMD ["/opt/devicemanager/devicemanager"] \ No newline at end of file diff --git a/containers/devicemanagera/go.mod b/containers/devicemanagera/go.mod new file mode 100644 index 0000000..f4d8c95 --- /dev/null +++ b/containers/devicemanagera/go.mod @@ -0,0 +1,3 @@ +module devicemanagera + +go 1.17 diff --git a/containers/devicemanagera/main.go b/containers/devicemanagera/main.go new file mode 100644 index 0000000..1b48d18 --- /dev/null +++ b/containers/devicemanagera/main.go @@ -0,0 +1,68 @@ +package main + +import ( + "bytes" + "devicemanagera/router" + "encoding/json" + "fmt" + "io/ioutil" + "net" + "net/http" + "os" + "strings" +) + +var server_addr string + +func getIP() string { + host, _ := os.Hostname() + addrs, _ := net.LookupIP(host) + + return addrs[0].String() +} +func registerToServer() { + var exist bool + server_addr, exist = os.LookupEnv("SERVER_ADDR") + if !exist { + fmt.Println("Please set SERVER_ADDR as environment variable") + } + + ip := getIP() + idx := strings.LastIndex(ip, ".") + serverAddr := ip[:idx+1] + "1" + fmt.Println(serverAddr) + + var obj map[string]string = make(map[string]string) + obj["name"] = "devicemanagera" + obj["addr"] = getIP() + ":3000" + + b, err := json.Marshal(obj) + if err != nil { + panic(err) + } + + req, err := http.NewRequest("PUT", "http://"+serverAddr+":3000/services", bytes.NewBuffer(b)) + if err != nil { + panic(err) + } + + resp, err := http.DefaultClient.Do(req) + if err != nil { + panic(err) + } + + b, err = ioutil.ReadAll(resp.Body) + if err != nil { + panic(err) + } + fmt.Println(string(b)) + // http.Post("") +} + +func main() { + registerToServer() + err := http.ListenAndServe(":3000", router.NewRouter()) + if err != nil { + panic(err) + } +} diff --git a/containers/devicemanagera/router/route.go b/containers/devicemanagera/router/route.go new file mode 100644 index 0000000..6750683 --- /dev/null +++ b/containers/devicemanagera/router/route.go @@ -0,0 +1,15 @@ +package router + +import ( + "net/http" +) + +func NewRouter() http.Handler { + mux := http.NewServeMux() + mux.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) { + w.WriteHeader(http.StatusOK) + w.Write([]byte("I am devicemanagerA")) + }) + + return mux +} diff --git a/containers/devicemanagerb/Dockerfile b/containers/devicemanagerb/Dockerfile new file mode 100644 index 0000000..5ae849f --- /dev/null +++ b/containers/devicemanagerb/Dockerfile @@ -0,0 +1,25 @@ +# build app +FROM golang:alpine AS gobuild +RUN apk update && \ + apk add ca-certificates gcc git make musl-dev +RUN mkdir /home/build +COPY . /home/build +WORKDIR /home/build +RUN go mod tidy && go build -o devicemanager + +FROM alpine:latest +ARG PUID=2000 +ARG PGID=2000 + +# Run App +RUN addgroup -g ${PGID} devicemanager && \ + adduser -H -D -u ${PUID} -G devicemanager devicemanager + +WORKDIR /opt/devicemanager + +COPY --from=gobuild /home/build/devicemanager devicemanager +RUN chown -R ${PUID}:${PGID} /opt/devicemanager + +USER devicemanager + +CMD ["/opt/devicemanager/devicemanager"] \ No newline at end of file diff --git a/containers/devicemanagerb/go.mod b/containers/devicemanagerb/go.mod new file mode 100644 index 0000000..ae71788 --- /dev/null +++ b/containers/devicemanagerb/go.mod @@ -0,0 +1,3 @@ +module devicemanagerb + +go 1.17 diff --git a/containers/devicemanagerb/go.sum b/containers/devicemanagerb/go.sum new file mode 100644 index 0000000..e69de29 diff --git a/containers/devicemanagerb/main.go b/containers/devicemanagerb/main.go new file mode 100644 index 0000000..9df4de8 --- /dev/null +++ b/containers/devicemanagerb/main.go @@ -0,0 +1,68 @@ +package main + +import ( + "bytes" + "devicemanagerb/router" + "encoding/json" + "fmt" + "io/ioutil" + "net" + "net/http" + "os" + "strings" +) + +var server_addr string + +func getIP() string { + host, _ := os.Hostname() + addrs, _ := net.LookupIP(host) + + return addrs[0].String() +} +func registerToServer() { + var exist bool + server_addr, exist = os.LookupEnv("SERVER_ADDR") + if !exist { + fmt.Println("Please set SERVER_ADDR as environment variable") + } + + ip := getIP() + idx := strings.LastIndex(ip, ".") + serverAddr := ip[:idx+1] + "1" + fmt.Println(serverAddr) + + var obj map[string]string = make(map[string]string) + obj["name"] = "devicemanagerb" + obj["addr"] = getIP() + ":3000" + + b, err := json.Marshal(obj) + if err != nil { + panic(err) + } + + req, err := http.NewRequest("PUT", "http://"+serverAddr+":3000/services", bytes.NewBuffer(b)) + if err != nil { + panic(err) + } + + resp, err := http.DefaultClient.Do(req) + if err != nil { + panic(err) + } + + b, err = ioutil.ReadAll(resp.Body) + if err != nil { + panic(err) + } + fmt.Println(string(b)) + // http.Post("") +} + +func main() { + registerToServer() + err := http.ListenAndServe(":3000", router.NewRouter()) + if err != nil { + panic(err) + } +} diff --git a/containers/devicemanagerb/router/route.go b/containers/devicemanagerb/router/route.go new file mode 100644 index 0000000..f1728f5 --- /dev/null +++ b/containers/devicemanagerb/router/route.go @@ -0,0 +1,15 @@ +package router + +import ( + "net/http" +) + +func NewRouter() http.Handler { + mux := http.NewServeMux() + mux.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) { + w.WriteHeader(http.StatusOK) + w.Write([]byte("I am devicemanagerB")) + }) + + return mux +} diff --git a/containers/docker-compose.yaml b/containers/docker-compose.yaml new file mode 100644 index 0000000..74ae9ab --- /dev/null +++ b/containers/docker-compose.yaml @@ -0,0 +1,21 @@ +version: '3.8' + +services: + devicemanagera: + build: ./devicemanagera + networks: + - container-net + image: devicemanagera + hostname: devicemanagera + + devicemanagerb: + build: ./devicemanagerb + networks: + - container-net + image: devicemanagerb + hostname: devicemanagerb + volumes: + - ./volumes:/home/build + +networks: + container-net: null diff --git a/docker-compose.yaml b/docker-compose.yaml new file mode 100644 index 0000000..2b00df8 --- /dev/null +++ b/docker-compose.yaml @@ -0,0 +1,18 @@ +version: "3.8" + +services: + db: + image: postgres:14-alpine + restart: unless-stopped + # security_opt: + # - no-new-privileges:true + pids_limit: 100 + ports: + - 5432:5432 + volumes: + # - ./db/data-14:/var/lib/postgresql/data + - /etc/localtime:/etc/localtime:ro + environment: + - POSTGRES_USER=user + - POSTGRES_PASSWORD=user_password + - POSTGRES_DB=godopudb diff --git a/dump.db b/dump.db new file mode 100644 index 0000000..6cee3d5 Binary files /dev/null and b/dump.db differ diff --git a/go.mod b/go.mod index eab91f8..df01275 100644 --- a/go.mod +++ b/go.mod @@ -3,12 +3,41 @@ module etrismartfarmpoc go 1.17 require ( + github.com/google/uuid v1.3.0 github.com/gorilla/mux v1.8.0 - github.com/unrolled/render v1.4.0 + github.com/gorilla/websocket v1.4.2 + github.com/plgd-dev/go-coap/v2 v2.4.0 github.com/urfave/negroni v1.0.0 + gorm.io/driver/postgres v1.2.2 + gorm.io/driver/sqlite v1.2.4 + gorm.io/gorm v1.22.2 ) require ( - github.com/fsnotify/fsnotify v1.4.9 // indirect - golang.org/x/sys v0.0.0-20210525143221-35b2ab0089ea // indirect + github.com/jackc/chunkreader/v2 v2.0.1 // indirect + github.com/jackc/pgconn v1.10.0 // indirect + github.com/jackc/pgio v1.0.0 // indirect + github.com/jackc/pgpassfile v1.0.0 // indirect + github.com/jackc/pgproto3/v2 v2.1.1 // indirect + github.com/jackc/pgservicefile v0.0.0-20200714003250-2b9c44734f2b // indirect + github.com/jackc/pgtype v1.8.1 // indirect + github.com/jackc/pgx/v4 v4.13.0 // indirect + github.com/jinzhu/inflection v1.0.0 // indirect + github.com/jinzhu/now v1.1.2 // indirect + github.com/mattn/go-sqlite3 v1.14.9 // indirect + golang.org/x/text v0.3.7 // indirect +) + +require ( + github.com/dsnet/golib/memfile v0.0.0-20200723050859-c110804dfa93 // indirect + github.com/patrickmn/go-cache v2.1.0+incompatible // indirect + github.com/pion/dtls/v2 v2.0.1-0.20200503085337-8e86b3a7d585 // indirect + github.com/pion/logging v0.2.2 // indirect + github.com/pion/transport v0.10.0 // indirect + github.com/plgd-dev/kit v0.0.0-20200819113605-d5fcf3e94f63 // indirect + go.uber.org/atomic v1.6.0 // indirect + golang.org/x/crypto v0.0.0-20210921155107-089bfa567519 // indirect + golang.org/x/net v0.0.0-20210226172049-e18ecbb05110 // indirect + golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1 // indirect + golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 // indirect ) diff --git a/go.sum b/go.sum index 2bde986..06b013e 100644 --- a/go.sum +++ b/go.sum @@ -1,11 +1,332 @@ -github.com/fsnotify/fsnotify v1.4.9 h1:hsms1Qyu0jgnwNXIxa+/V/PDsU6CfLf6CNO8H7IWoS4= +cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= +cloud.google.com/go v0.34.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= +github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= +github.com/Masterminds/semver/v3 v3.1.1 h1:hLg3sBzpNErnxhQtUy/mmLR2I9foDujNK030IGemrRc= +github.com/Masterminds/semver/v3 v3.1.1/go.mod h1:VPu/7SZ7ePZ3QOrcuXROw5FAcLl4a0cBrbBpGY/8hQs= +github.com/cenkalti/backoff v2.2.1+incompatible/go.mod h1:90ReRw6GdpyfrHakVjL/QHaoyV4aDUVVkXQJJJ3NXXM= +github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU= +github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw= +github.com/cncf/udpa/go v0.0.0-20191209042840-269d4d468f6f/go.mod h1:M8M6+tZqaGXZJjfX53e64911xZQV5JYwmTeXPW+k8Sc= +github.com/cockroachdb/apd v1.1.0 h1:3LFP3629v+1aKXU5Q37mxmRxX/pIu1nijXydLShEq5I= +github.com/cockroachdb/apd v1.1.0/go.mod h1:8Sl8LxpKi29FqWXR16WEFZRNSz3SoPzUzeMeY4+DwBQ= +github.com/coreos/go-systemd v0.0.0-20190321100706-95778dfbb74e/go.mod h1:F5haX7vjVVG0kc13fIWeqUViNPyEJxv/OmvnBo0Yme4= +github.com/coreos/go-systemd v0.0.0-20190719114852-fd7a80b32e1f/go.mod h1:F5haX7vjVVG0kc13fIWeqUViNPyEJxv/OmvnBo0Yme4= +github.com/creack/pty v1.1.7/go.mod h1:lj5s0c3V2DBrqTV7llrYr5NG6My20zk30Fl46Y7DoTY= +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= +github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/dgrijalva/jwt-go v3.2.0+incompatible/go.mod h1:E3ru+11k8xSBh+hMPgOLZmtrrCbhqsmaPHjLKYnJCaQ= +github.com/dsnet/golib/memfile v0.0.0-20190531212259-571cdbcff553/go.mod h1:tXGNW9q3RwvWt1VV2qrRKlSSz0npnh12yftCSCy2T64= +github.com/dsnet/golib/memfile v0.0.0-20200723050859-c110804dfa93 h1:I48YLRgQEeWsjF7LmNcl62vTHSUfUfEVe3I1oHXiS5o= +github.com/dsnet/golib/memfile v0.0.0-20200723050859-c110804dfa93/go.mod h1:tXGNW9q3RwvWt1VV2qrRKlSSz0npnh12yftCSCy2T64= +github.com/envoyproxy/go-control-plane v0.9.0/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= +github.com/envoyproxy/go-control-plane v0.9.1-0.20191026205805-5f8ba28d4473/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= +github.com/envoyproxy/go-control-plane v0.9.4/go.mod h1:6rpuAdCZL397s3pYoYcLgu1mIlRU8Am5FuJP05cCM98= +github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c= github.com/fsnotify/fsnotify v1.4.9/go.mod h1:znqG4EE+3YCdAaPaxE2ZRY/06pZUdp0tY4IgpuI1SZQ= +github.com/fxamacker/cbor/v2 v2.2.0/go.mod h1:TA1xS00nchWmaBnEIxPSE5oHLuJBAVvqrtAnWBwBCVo= +github.com/go-acme/lego v2.7.2+incompatible/go.mod h1:yzMNe9CasVUhkquNvti5nAtPmG94USbYxYrZfTkIn0M= +github.com/go-kit/kit v0.9.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as= +github.com/go-kit/log v0.1.0/go.mod h1:zbhenjAZHb184qTLMA9ZjW7ThYL0H2mk7Q6pNt4vbaY= +github.com/go-logfmt/logfmt v0.4.0/go.mod h1:3RMwSq7FuexP4Kalkev3ejPJsZTpXXBr9+V4qmtdjCk= +github.com/go-logfmt/logfmt v0.5.0/go.mod h1:wCYkCAKZfumFQihp8CzCvQ3paCTfi41vtzG1KdI/P7A= +github.com/go-ocf/go-coap/v2 v2.0.4-0.20200728125043-f38b86f047a7/go.mod h1:X9wVKcaOSx7wBxKcvrWgMQq1R2DNeA7NBLW2osIb8TM= +github.com/go-ocf/kit v0.0.0-20200728130040-4aebdb6982bc/go.mod h1:TIsoMT/iB7t9P6ahkcOnsmvS83SIJsv9qXRfz/yLf6M= +github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY= +github.com/gofrs/uuid v3.3.0+incompatible/go.mod h1:b2aQJv3Z4Fp6yNu3cdSllBxTCLRxnplIgP/c0N/04lM= +github.com/gofrs/uuid v4.0.0+incompatible h1:1SD/1F5pU8p29ybwgQSwpQk+mwdRrXCYuPhW6m+TnJw= +github.com/gofrs/uuid v4.0.0+incompatible/go.mod h1:b2aQJv3Z4Fp6yNu3cdSllBxTCLRxnplIgP/c0N/04lM= +github.com/gogo/protobuf v1.2.1/go.mod h1:hp+jE20tsWTFYpLwKvXlhS1hjn+gTNwPg2I6zVXpSg4= +github.com/gogo/protobuf v1.3.1/go.mod h1:SlYgWuQ5SjCEi6WLHjHCa1yvBfUnHcTbrrZtXPKa29o= +github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q= +github.com/golang/mock v1.1.1/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A= +github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= +github.com/golang/protobuf v1.3.2/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= +github.com/golang/protobuf v1.3.3/go.mod h1:vzj43D7+SQXF/4pzW/hwtAqwc6iTitCiVSaWz5lYuqw= +github.com/golang/protobuf v1.4.0-rc.1/go.mod h1:ceaxUfeHdC40wWswd/P6IGgMaK3YpKi5j83Wpe3EHw8= +github.com/golang/protobuf v1.4.0-rc.1.0.20200221234624-67d41d38c208/go.mod h1:xKAWHe0F5eneWXFV3EuXVDTCmh+JuBKY0li0aMyXATA= +github.com/golang/protobuf v1.4.0-rc.2/go.mod h1:LlEzMj4AhA7rCAGe4KMBDvJI+AwstrUpVNzEA03Pprs= +github.com/golang/protobuf v1.4.0-rc.4.0.20200313231945-b860323f09d0/go.mod h1:WU3c8KckQ9AFe+yFwt9sWVRKCVIyN9cPHBJSNnbL67w= +github.com/golang/protobuf v1.4.0/go.mod h1:jodUvKwWbYaEsadDk5Fwe5c77LiNKVO9IDvqG2KuDX0= +github.com/golang/protobuf v1.4.1/go.mod h1:U8fpvMrcmy5pZrNK1lt4xCsGvpyWQ/VVv6QDs8UjoX8= +github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M= +github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= +github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= +github.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= +github.com/google/renameio v0.1.0/go.mod h1:KWCgfxg9yswjAJkECMjeO8J8rahYeXnNhOm40UhjYkI= +github.com/google/uuid v1.3.0 h1:t6JiXgmwXMjEs8VusXIJk2BXHsn+wx8BZdTaoZ5fu7I= +github.com/google/uuid v1.3.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= +github.com/gorilla/mux v1.7.4/go.mod h1:DVbg23sWSpFRCP0SfiEN6jmj59UnW/n46BH5rLB71So= github.com/gorilla/mux v1.8.0 h1:i40aqfkR1h2SlN9hojwV5ZA91wcXFOvkdNIeFDP5koI= github.com/gorilla/mux v1.8.0/go.mod h1:DVbg23sWSpFRCP0SfiEN6jmj59UnW/n46BH5rLB71So= -github.com/unrolled/render v1.4.0 h1:p73obhpsXuE3paXOtcuXTBKgBJpLCfmABnsUiO35x+Q= -github.com/unrolled/render v1.4.0/go.mod h1:cK4RSTTVdND5j9EYEc0LAMOvdG11JeiKjyjfyZRvV2w= +github.com/gorilla/websocket v1.4.2 h1:+/TMaTYc4QFitKJxsQ7Yye35DkWvkdLcvGKqM+x0Ufc= +github.com/gorilla/websocket v1.4.2/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE= +github.com/grpc-ecosystem/go-grpc-middleware v1.2.0/go.mod h1:mJzapYve32yjrKlk9GbyCZHuPgZsrbyIbyKhSzOpg6s= +github.com/jackc/chunkreader v1.0.0 h1:4s39bBR8ByfqH+DKm8rQA3E1LHZWB9XWcrz8fqaZbe0= +github.com/jackc/chunkreader v1.0.0/go.mod h1:RT6O25fNZIuasFJRyZ4R/Y2BbhasbmZXF9QQ7T3kePo= +github.com/jackc/chunkreader/v2 v2.0.0/go.mod h1:odVSm741yZoC3dpHEUXIqA9tQRhFrgOHwnPIn9lDKlk= +github.com/jackc/chunkreader/v2 v2.0.1 h1:i+RDz65UE+mmpjTfyz0MoVTnzeYxroil2G82ki7MGG8= +github.com/jackc/chunkreader/v2 v2.0.1/go.mod h1:odVSm741yZoC3dpHEUXIqA9tQRhFrgOHwnPIn9lDKlk= +github.com/jackc/pgconn v0.0.0-20190420214824-7e0022ef6ba3/go.mod h1:jkELnwuX+w9qN5YIfX0fl88Ehu4XC3keFuOJJk9pcnA= +github.com/jackc/pgconn v0.0.0-20190824142844-760dd75542eb/go.mod h1:lLjNuW/+OfW9/pnVKPazfWOgNfH2aPem8YQ7ilXGvJE= +github.com/jackc/pgconn v0.0.0-20190831204454-2fabfa3c18b7/go.mod h1:ZJKsE/KZfsUgOEh9hBm+xYTstcNHg7UPMVJqRfQxq4s= +github.com/jackc/pgconn v1.8.0/go.mod h1:1C2Pb36bGIP9QHGBYCjnyhqu7Rv3sGshaQUvmfGIB/o= +github.com/jackc/pgconn v1.9.0/go.mod h1:YctiPyvzfU11JFxoXokUOOKQXQmDMoJL9vJzHH8/2JY= +github.com/jackc/pgconn v1.9.1-0.20210724152538-d89c8390a530/go.mod h1:4z2w8XhRbP1hYxkpTuBjTS3ne3J48K83+u0zoyvg2pI= +github.com/jackc/pgconn v1.10.0 h1:4EYhlDVEMsJ30nNj0mmgwIUXoq7e9sMJrVC2ED6QlCU= +github.com/jackc/pgconn v1.10.0/go.mod h1:4z2w8XhRbP1hYxkpTuBjTS3ne3J48K83+u0zoyvg2pI= +github.com/jackc/pgio v1.0.0 h1:g12B9UwVnzGhueNavwioyEEpAmqMe1E/BN9ES+8ovkE= +github.com/jackc/pgio v1.0.0/go.mod h1:oP+2QK2wFfUWgr+gxjoBH9KGBb31Eio69xUb0w5bYf8= +github.com/jackc/pgmock v0.0.0-20190831213851-13a1b77aafa2/go.mod h1:fGZlG77KXmcq05nJLRkk0+p82V8B8Dw8KN2/V9c/OAE= +github.com/jackc/pgmock v0.0.0-20201204152224-4fe30f7445fd/go.mod h1:hrBW0Enj2AZTNpt/7Y5rr2xe/9Mn757Wtb2xeBzPv2c= +github.com/jackc/pgmock v0.0.0-20210724152146-4ad1a8207f65 h1:DadwsjnMwFjfWc9y5Wi/+Zz7xoE5ALHsRQlOctkOiHc= +github.com/jackc/pgmock v0.0.0-20210724152146-4ad1a8207f65/go.mod h1:5R2h2EEX+qri8jOWMbJCtaPWkrrNc7OHwsp2TCqp7ak= +github.com/jackc/pgpassfile v1.0.0 h1:/6Hmqy13Ss2zCq62VdNG8tM1wchn8zjSGOBJ6icpsIM= +github.com/jackc/pgpassfile v1.0.0/go.mod h1:CEx0iS5ambNFdcRtxPj5JhEz+xB6uRky5eyVu/W2HEg= +github.com/jackc/pgproto3 v1.1.0 h1:FYYE4yRw+AgI8wXIinMlNjBbp/UitDJwfj5LqqewP1A= +github.com/jackc/pgproto3 v1.1.0/go.mod h1:eR5FA3leWg7p9aeAqi37XOTgTIbkABlvcPB3E5rlc78= +github.com/jackc/pgproto3/v2 v2.0.0-alpha1.0.20190420180111-c116219b62db/go.mod h1:bhq50y+xrl9n5mRYyCBFKkpRVTLYJVWeCc+mEAI3yXA= +github.com/jackc/pgproto3/v2 v2.0.0-alpha1.0.20190609003834-432c2951c711/go.mod h1:uH0AWtUmuShn0bcesswc4aBTWGvw0cAxIJp+6OB//Wg= +github.com/jackc/pgproto3/v2 v2.0.0-rc3/go.mod h1:ryONWYqW6dqSg1Lw6vXNMXoBJhpzvWKnT95C46ckYeM= +github.com/jackc/pgproto3/v2 v2.0.0-rc3.0.20190831210041-4c03ce451f29/go.mod h1:ryONWYqW6dqSg1Lw6vXNMXoBJhpzvWKnT95C46ckYeM= +github.com/jackc/pgproto3/v2 v2.0.6/go.mod h1:WfJCnwN3HIg9Ish/j3sgWXnAfK8A9Y0bwXYU5xKaEdA= +github.com/jackc/pgproto3/v2 v2.1.1 h1:7PQ/4gLoqnl87ZxL7xjO0DR5gYuviDCZxQJsUlFW1eI= +github.com/jackc/pgproto3/v2 v2.1.1/go.mod h1:WfJCnwN3HIg9Ish/j3sgWXnAfK8A9Y0bwXYU5xKaEdA= +github.com/jackc/pgservicefile v0.0.0-20200714003250-2b9c44734f2b h1:C8S2+VttkHFdOOCXJe+YGfa4vHYwlt4Zx+IVXQ97jYg= +github.com/jackc/pgservicefile v0.0.0-20200714003250-2b9c44734f2b/go.mod h1:vsD4gTJCa9TptPL8sPkXrLZ+hDuNrZCnj29CQpr4X1E= +github.com/jackc/pgtype v0.0.0-20190421001408-4ed0de4755e0/go.mod h1:hdSHsc1V01CGwFsrv11mJRHWJ6aifDLfdV3aVjFF0zg= +github.com/jackc/pgtype v0.0.0-20190824184912-ab885b375b90/go.mod h1:KcahbBH1nCMSo2DXpzsoWOAfFkdEtEJpPbVLq8eE+mc= +github.com/jackc/pgtype v0.0.0-20190828014616-a8802b16cc59/go.mod h1:MWlu30kVJrUS8lot6TQqcg7mtthZ9T0EoIBFiJcmcyw= +github.com/jackc/pgtype v1.8.1-0.20210724151600-32e20a603178/go.mod h1:C516IlIV9NKqfsMCXTdChteoXmwgUceqaLfjg2e3NlM= +github.com/jackc/pgtype v1.8.1 h1:9k0IXtdJXHJbyAWQgbWr1lU+MEhPXZz6RIXxfR5oxXs= +github.com/jackc/pgtype v1.8.1/go.mod h1:LUMuVrfsFfdKGLw+AFFVv6KtHOFMwRgDDzBt76IqCA4= +github.com/jackc/pgx/v4 v4.0.0-20190420224344-cc3461e65d96/go.mod h1:mdxmSJJuR08CZQyj1PVQBHy9XOp5p8/SHH6a0psbY9Y= +github.com/jackc/pgx/v4 v4.0.0-20190421002000-1b8f0016e912/go.mod h1:no/Y67Jkk/9WuGR0JG/JseM9irFbnEPbuWV2EELPNuM= +github.com/jackc/pgx/v4 v4.0.0-pre1.0.20190824185557-6972a5742186/go.mod h1:X+GQnOEnf1dqHGpw7JmHqHc1NxDoalibchSk9/RWuDc= +github.com/jackc/pgx/v4 v4.12.1-0.20210724153913-640aa07df17c/go.mod h1:1QD0+tgSXP7iUjYm9C1NxKhny7lq6ee99u/z+IHFcgs= +github.com/jackc/pgx/v4 v4.13.0 h1:JCjhT5vmhMAf/YwBHLvrBn4OGdIQBiFG6ym8Zmdx570= +github.com/jackc/pgx/v4 v4.13.0/go.mod h1:9P4X524sErlaxj0XSGZk7s+LD0eOyu1ZDUrrpznYDF0= +github.com/jackc/puddle v0.0.0-20190413234325-e4ced69a3a2b/go.mod h1:m4B5Dj62Y0fbyuIc15OsIqK0+JU8nkqQjsgx7dvjSWk= +github.com/jackc/puddle v0.0.0-20190608224051-11cab39313c9/go.mod h1:m4B5Dj62Y0fbyuIc15OsIqK0+JU8nkqQjsgx7dvjSWk= +github.com/jackc/puddle v1.1.3/go.mod h1:m4B5Dj62Y0fbyuIc15OsIqK0+JU8nkqQjsgx7dvjSWk= +github.com/jessevdk/go-flags v1.4.0/go.mod h1:4FA24M0QyGHXBuZZK/XkWh8h0e1EYbRYJSGM75WSRxI= +github.com/jinzhu/inflection v1.0.0 h1:K317FqzuhWc8YvSVlFMCCUb36O/S9MCKRDI7QkRKD/E= +github.com/jinzhu/inflection v1.0.0/go.mod h1:h+uFLlag+Qp1Va5pdKtLDYj+kHp5pxUVkryuEj+Srlc= +github.com/jinzhu/now v1.1.2 h1:eVKgfIdy9b6zbWBMgFpfDPoAMifwSZagU9HmEU6zgiI= +github.com/jinzhu/now v1.1.2/go.mod h1:d3SSVoowX0Lcu0IBviAWJpolVfI5UJVZZ7cO71lE/z8= +github.com/kisielk/errcheck v1.1.0/go.mod h1:EZBBE59ingxPouuu3KfxchcWSUPOHkagtvWXihfKN4Q= +github.com/kisielk/errcheck v1.2.0/go.mod h1:/BMXB+zMLi60iA8Vv6Ksmxu/1UDYcXs4uQLJ+jE2L00= +github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= +github.com/klauspost/compress v1.10.4/go.mod h1:aoV0uJVorq1K+umq18yTdKaF57EivdYsUV+/s2qKfXs= +github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= +github.com/konsorten/go-windows-terminal-sequences v1.0.2/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= +github.com/kr/logfmt v0.0.0-20140226030751-b84e30acd515/go.mod h1:+0opPa2QZZtGFBFZlji/RkVcI2GknAs/DXo4wKdlNEc= +github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= +github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= +github.com/kr/pty v1.1.8/go.mod h1:O1sed60cT9XZ5uDucP5qwvh+TE3NnUj51EiZO/lmSfw= +github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= +github.com/lestrrat-go/iter v0.0.0-20200422075355-fc1769541911/go.mod h1:zIdgO1mRKhn8l9vrZJZz9TUMMFbQbLeTsbqPDrJ/OJc= +github.com/lestrrat-go/jwx v1.0.2/go.mod h1:TPF17WiSFegZo+c20fdpw49QD+/7n4/IsGvEmCSWwT0= +github.com/lestrrat-go/pdebug v0.0.0-20200204225717-4d6bd78da58d/go.mod h1:B06CSso/AWxiPejj+fheUINGeBKeeEZNt8w+EoU7+L8= +github.com/lib/pq v1.0.0/go.mod h1:5WUZQaWbwv1U+lTReE5YruASi9Al49XbQIvNi/34Woo= +github.com/lib/pq v1.1.0/go.mod h1:5WUZQaWbwv1U+lTReE5YruASi9Al49XbQIvNi/34Woo= +github.com/lib/pq v1.2.0/go.mod h1:5WUZQaWbwv1U+lTReE5YruASi9Al49XbQIvNi/34Woo= +github.com/lib/pq v1.10.2 h1:AqzbZs4ZoCBp+GtejcpCpcxM3zlSMx29dXbUSeVtJb8= +github.com/lib/pq v1.10.2/go.mod h1:AlVN5x4E4T544tWzH6hKfbfQvm3HdbOxrmggDNAPY9o= +github.com/mattn/go-colorable v0.1.1/go.mod h1:FuOcm+DKB9mbwrcAfNl7/TZVBZ6rcnceauSikq3lYCQ= +github.com/mattn/go-colorable v0.1.6/go.mod h1:u6P/XSegPjTcexA+o6vUJrdnUu04hMope9wVRipJSqc= +github.com/mattn/go-isatty v0.0.5/go.mod h1:Iq45c/XA43vh69/j3iqttzPXn0bhXyGjM0Hdxcsrc5s= +github.com/mattn/go-isatty v0.0.7/go.mod h1:Iq45c/XA43vh69/j3iqttzPXn0bhXyGjM0Hdxcsrc5s= +github.com/mattn/go-isatty v0.0.12/go.mod h1:cbi8OIDigv2wuxKPP5vlRcQ1OAZbq2CE4Kysco4FUpU= +github.com/mattn/go-sqlite3 v1.14.9 h1:10HX2Td0ocZpYEjhilsuo6WWtUqttj2Kb0KtD86/KYA= +github.com/mattn/go-sqlite3 v1.14.9/go.mod h1:NyWgC/yNuGj7Q9rpYnZvas74GogHl5/Z4A/KQRfk6bU= +github.com/miekg/dns v1.1.29/go.mod h1:KNUDUusw/aVsxyTYZM1oqvCicbwhgbNgztCETuNZ7xM= +github.com/opentracing/opentracing-go v1.1.0/go.mod h1:UkNAQd3GIcIGf0SeVgPpRdFStlNbqXla1AfSYxPUl2o= +github.com/patrickmn/go-cache v2.1.0+incompatible h1:HRMgzkcYKYpi3C8ajMPV8OFXaaRUnok+kx1WdO15EQc= +github.com/patrickmn/go-cache v2.1.0+incompatible/go.mod h1:3Qf8kWWT7OJRJbdiICTKqZju1ZixQ/KpMGzzAfe6+WQ= +github.com/pion/dtls/v2 v2.0.1-0.20200503085337-8e86b3a7d585 h1:0v1k/bHrth28TctdEWnrCgLehYn3nOvFAwOwtwmyC34= +github.com/pion/dtls/v2 v2.0.1-0.20200503085337-8e86b3a7d585/go.mod h1:/GahSOC8ZY/+17zkaGJIG4OUkSGAcZu/N/g3roBOCkM= +github.com/pion/logging v0.2.2 h1:M9+AIj/+pxNsDfAT64+MAVgJO0rsyLnoJKCqf//DoeY= +github.com/pion/logging v0.2.2/go.mod h1:k0/tDVsRCX2Mb2ZEmTqNa7CWsQPc+YYCB7Q+5pahoms= +github.com/pion/transport v0.10.0 h1:9M12BSneJm6ggGhJyWpDveFOstJsTiQjkLf4M44rm80= +github.com/pion/transport v0.10.0/go.mod h1:BnHnUipd0rZQyTVB2SBGojFHT9CBt5C5TcsJSQGkvSE= +github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= +github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4= +github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= +github.com/plgd-dev/go-coap/v2 v2.0.4-0.20200819112225-8eb712b901bc/go.mod h1:+tCi9Q78H/orWRtpVWyBgrr4vKFo2zYtbbxUllerBp4= +github.com/plgd-dev/go-coap/v2 v2.4.0 h1:pEexScWQ0I+t35gyHSKRciIyJxdmcfosnCX78BZbFzk= +github.com/plgd-dev/go-coap/v2 v2.4.0/go.mod h1:0lg7sgOTxlHtfyGhPiak214vQ7CuBRD99LbdBCpDRW8= +github.com/plgd-dev/kit v0.0.0-20200819113605-d5fcf3e94f63 h1:cI6kESUBU1KUHtufZepEkaTsSkLN2kE6xz+Ec5V17q0= +github.com/plgd-dev/kit v0.0.0-20200819113605-d5fcf3e94f63/go.mod h1:Yl9zisyXfPdtP9hTWlJqjJYXmgU/jtSDKttz9/CeD90= +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/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= +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.13.0/go.mod h1:YbFCdg8HfsridGWAh22vktObvhZbQsZXe4/zB0OKkWU= +github.com/rs/zerolog v1.15.0/go.mod h1:xYTKnLHcpfU2225ny5qZjxnj9NvkumZYjJHlAThCjNc= +github.com/satori/go.uuid v1.2.0/go.mod h1:dA0hQrYB0VpLJoorglMZABFdXlWrHn1NEOzdhQKdks0= +github.com/shopspring/decimal v0.0.0-20180709203117-cd690d0c9e24/go.mod h1:M+9NzErvs504Cn4c5DxATwIqPbtswREoFCre64PpcG4= +github.com/shopspring/decimal v1.2.0 h1:abSATXmQEYyShuxI4/vyW3tV1MrKAJzCZ/0zLUXYbsQ= +github.com/shopspring/decimal v1.2.0/go.mod h1:DKyhrW/HYNuLGql+MJL6WCR6knT2jwCFRcu2hWCYk4o= +github.com/sirupsen/logrus v1.4.1/go.mod h1:ni0Sbl8bgC9z8RoU9G6nDWqqs/fq4eDPysMBDgk/93Q= +github.com/sirupsen/logrus v1.4.2/go.mod h1:tLMulIdttU9McNUspp0xgXVQah82FyeX6MwdIuYE2rE= +github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= +github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= +github.com/stretchr/objx v0.2.0/go.mod h1:qt09Ya8vawLte6SNmTgCsAVtYtaKzEcn8ATUoHMkEqE= +github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= +github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= +github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= +github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA= +github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY= +github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= +github.com/ugorji/go v1.1.7/go.mod h1:kZn38zHttfInRq0xu/PH0az30d+z6vm202qpg1oXVMw= +github.com/ugorji/go/codec v1.1.7/go.mod h1:Ax+UKWsSmolVDwsd+7N3ZtXu+yMGCf907BLYF3GoBXY= github.com/urfave/negroni v1.0.0 h1:kIimOitoypq34K7TG7DUaJ9kq/N4Ofuwi1sjz0KipXc= github.com/urfave/negroni v1.0.0/go.mod h1:Meg73S6kFm/4PpbYdq35yYWoCZ9mS/YSx+lKnmiohz4= +github.com/valyala/bytebufferpool v1.0.0/go.mod h1:6bBcMArwyJ5K/AmCkWv1jt77kVWyCJ6HpOuEn7z0Csc= +github.com/valyala/fasthttp v1.12.0/go.mod h1:229t1eWu9UXTPmoUkbpN/fctKPBY4IJoFXQnxHGXy6E= +github.com/valyala/tcplisten v0.0.0-20161114210144-ceec8f93295a/go.mod h1:v3UYOV9WzVtRmSR+PDvWpU/qWl4Wa5LApYYX4ZtKbio= +github.com/x448/float16 v0.8.4/go.mod h1:14CWIYCyZA/cWjXOioeEpHeN/83MdbZDRQHoFcYsOfg= +github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= +github.com/zenazn/goji v0.9.0/go.mod h1:7S9M489iMyHBNxwZnk9/EHS098H4/F6TATF2mIxtB1Q= +go.uber.org/atomic v1.3.2/go.mod h1:gD2HeocX3+yG+ygLZcrzQJaqmWj9AIm7n08wl/qW/PE= +go.uber.org/atomic v1.4.0/go.mod h1:gD2HeocX3+yG+ygLZcrzQJaqmWj9AIm7n08wl/qW/PE= +go.uber.org/atomic v1.5.0/go.mod h1:sABNBOSYdrvTF6hTgEIbc7YasKWGhgEQZyfxyTvoXHQ= +go.uber.org/atomic v1.6.0 h1:Ezj3JGmsOnG1MoRWQkPBsKLe9DwWD9QeXzTRzzldNVk= +go.uber.org/atomic v1.6.0/go.mod h1:sABNBOSYdrvTF6hTgEIbc7YasKWGhgEQZyfxyTvoXHQ= +go.uber.org/multierr v1.1.0/go.mod h1:wR5kodmAFQ0UK8QlbwjlSNy0Z68gJhDJUG5sjR94q/0= +go.uber.org/multierr v1.3.0/go.mod h1:VgVr7evmIr6uPjLBxg28wmKNXyqE9akIJ5XnfpiKl+4= +go.uber.org/multierr v1.5.0/go.mod h1:FeouvMocqHpRaaGuG9EjoKcStLC43Zu/fmqdUMPcKYU= +go.uber.org/tools v0.0.0-20190618225709-2cfd321de3ee/go.mod h1:vJERXedbb3MVM5f9Ejo0C68/HhF8uaILCdgjnY+goOA= +go.uber.org/zap v1.9.1/go.mod h1:vwi/ZaCAaUcBkycHslxD9B2zi4UTXhF60s6SWpuDF0Q= +go.uber.org/zap v1.10.0/go.mod h1:vwi/ZaCAaUcBkycHslxD9B2zi4UTXhF60s6SWpuDF0Q= +go.uber.org/zap v1.13.0/go.mod h1:zwrFLgMcdUuIBviXEYEH1YKNaOBnKXsx2IPda5bBwHM= +go.uber.org/zap v1.15.0/go.mod h1:Mb2vm2krFEG5DV0W9qcHBYFtp/Wku1cvYaqPsS/WYfc= +golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= +golang.org/x/crypto v0.0.0-20190411191339-88737f569e3a/go.mod h1:WFFai1msRO1wXaEeE5yQxYXgSfI8pQAWXbQop6sCtWE= +golang.org/x/crypto v0.0.0-20190510104115-cbcb75029529/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= +golang.org/x/crypto v0.0.0-20190820162420-60c769a6c586/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= +golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= +golang.org/x/crypto v0.0.0-20200323165209-0ec3e9974c59/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= +golang.org/x/crypto v0.0.0-20200510223506-06a226fb4e37/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= +golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= +golang.org/x/crypto v0.0.0-20201203163018-be400aefbc4c/go.mod h1:jdWPYTVW3xRLrWPugEBEK3UY2ZEsg3UU495nc5E+M+I= +golang.org/x/crypto v0.0.0-20210616213533-5ff15b29337e/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= +golang.org/x/crypto v0.0.0-20210711020723-a769d52b0f97/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= +golang.org/x/crypto v0.0.0-20210921155107-089bfa567519 h1:7I4JAnoQBe7ZtJcBaYHi5UtiO8tQHbUSXxL+pnGRANg= +golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= +golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= +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-20190313153728-d0100b6bd8b3/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= +golang.org/x/lint v0.0.0-20190930215403-16217165b5de h1:5hukYrvBGR8/eNkX5mdUezrA6JiaEZDtJb9Ei+1LlBs= +golang.org/x/lint v0.0.0-20190930215403-16217165b5de/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= +golang.org/x/mod v0.0.0-20190513183733-4bf6d317e70e/go.mod h1:mXi4GBBbnImb6dmsKGUJ2LatrhH/nqhxcFungHvyanc= +golang.org/x/mod v0.1.1-0.20191105210325-c90efee705ee/go.mod h1:QqPTAvyqsEbceGzBzNggFXnrqF1CaUcvgkdR5Ot7KZg= +golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= +golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= +golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= +golang.org/x/net v0.0.0-20190108225652-1e06a53dbb7e/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= +golang.org/x/net v0.0.0-20190213061140-3a22650c66bd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= +golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= +golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= +golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +golang.org/x/net v0.0.0-20190813141303-74dc4d7220e7/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-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +golang.org/x/net v0.0.0-20200324143707-d3edc9973b7e/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A= +golang.org/x/net v0.0.0-20200501053045-e0ff5e5a1de5/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A= +golang.org/x/net v0.0.0-20200506145744-7e3656a0809f/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A= +golang.org/x/net v0.0.0-20210226172049-e18ecbb05110 h1:qWPm9rbaAMKs8Bq/9LRpbMqxWRVUAQwMI9fVrssnTfw= +golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= +golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= +golang.org/x/oauth2 v0.0.0-20200107190931-bf48bf16ab8d/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= +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= +golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/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-20190403152447-81d4e9dc473e/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= +golang.org/x/sys v0.0.0-20190813064441-fde4db37ae7a/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20190924154521-2837fb4f24fe/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20191005200804-aed5e4c7ecf9/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20210525143221-35b2ab0089ea h1:+WiDlPBBaO+h9vPNZi8uJ3k4BkKQB7Iow3aqwHVA5hI= -golang.org/x/sys v0.0.0-20210525143221-35b2ab0089ea/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20191026070338-33540a1f6037/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200116001909-b77594299b42/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200223170610-d5e6a3e2c0ae/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1 h1:SrN+KX8Art/Sf4HNj6Zcz06G7VEz+7w9tdXTPOZ7+l4= +golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/term v0.0.0-20201117132131-f5c789dd3221/go.mod h1:Nr5EML6q2oocZ2LXRh80K7BxOlk5/8JxuGnuhpl+muw= +golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= +golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= +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.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/tools v0.0.0-20180221164845-07fd8470d635/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= +golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= +golang.org/x/tools v0.0.0-20181030221726-6c7e314b6563/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= +golang.org/x/tools v0.0.0-20190114222345-bf090417da8b/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= +golang.org/x/tools v0.0.0-20190226205152-f727befe758c/go.mod h1:9Yl7xja0Znq3iFh3HoIrodX9oNMXvdceNzlUR8zjMvY= +golang.org/x/tools v0.0.0-20190311212946-11955173bddd/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= +golang.org/x/tools v0.0.0-20190425163242-31fd60d6bfdc/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q= +golang.org/x/tools v0.0.0-20190524140312-2c0ae7006135/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q= +golang.org/x/tools v0.0.0-20190621195816-6e04913cbbac/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc= +golang.org/x/tools v0.0.0-20190823170909-c4a336ef6a2f/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= +golang.org/x/tools v0.0.0-20191029041327-9cc4af7d6b2c/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= +golang.org/x/tools v0.0.0-20191029190741-b9c20aec41a5/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= +golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= +golang.org/x/tools v0.0.0-20191216052735-49a3e744a425/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= +golang.org/x/tools v0.0.0-20200103221440-774c71fcf114/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= +golang.org/x/tools v0.0.0-20200417140056-c07e33ef3290 h1:NXNmtp0ToD36cui5IqWy95LC4Y6vT/4y3RnPxlQPinU= +golang.org/x/tools v0.0.0-20200417140056-c07e33ef3290/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= +golang.org/x/xerrors v0.0.0-20190410155217-1f06c39b4373/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +golang.org/x/xerrors v0.0.0-20190513163551-3ee3066db522/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +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= +golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 h1:go1bK/D/BFZV2I8cIQd1NKEZ+0owSTG1fDTci4IqFcE= +golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +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/genproto v0.0.0-20180817151627-c66870c02cf8/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc= +google.golang.org/genproto v0.0.0-20190819201941-24fa4b261c55/go.mod h1:DMBHOl98Agz4BDEuKkezgsaosCRResVns1a3J2ZsMNc= +google.golang.org/genproto v0.0.0-20200511104702-f5ebc3bea380/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= +google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c= +google.golang.org/grpc v1.23.0/go.mod h1:Y5yQAOtifL1yxbo5wqy6BxZv8vAUGQwXBOALyacEbxg= +google.golang.org/grpc v1.25.1/go.mod h1:c3i+UQWmh7LiEpx4sFZnkU36qjEYZ0imhYfXVyQciAY= +google.golang.org/grpc v1.27.0/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8abTk= +google.golang.org/grpc v1.29.1/go.mod h1:itym6AZVZYACWQqET3MqgPpjcuV5QH3BxFS3IjizoKk= +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= +google.golang.org/protobuf v1.20.1-0.20200309200217-e05f789c0967/go.mod h1:A+miEFZTKqfCUM6K7xSMQL9OKL/b6hQv+e19PK+JZNE= +google.golang.org/protobuf v1.21.0/go.mod h1:47Nbq4nVaFHyn7ilMalzfO3qCViNmqZ2kzikPIcrTAo= +google.golang.org/protobuf v1.22.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU= +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/errgo.v2 v2.1.0/go.mod h1:hNsd1EY+bozCKY1Ytp96fpM3vjJbqLJn88ws8XvfDNI= +gopkg.in/inconshreveable/log15.v2 v2.0.0-20180818164646-67afb5ed74ec/go.mod h1:aPpfJ7XW+gOuirDoZ8gHhLh3kZ1B08FtV2bbmy7Jv3s= +gopkg.in/square/go-jose.v2 v2.5.1/go.mod h1:M9dMgbHiYLoDGQrXy7OpJDJWiKiU//h+vD76mk0e1AI= +gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= +gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c h1:dUUwHk2QECo/6vqA44rthZ8ie2QXMNeKRTHCNY2nXvo= +gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= +gorm.io/driver/postgres v1.2.2 h1:Ka9W6feOU+rPM9m007eYLMD4QoZuYGBnQ3Jp0faGSwg= +gorm.io/driver/postgres v1.2.2/go.mod h1:Ik3tK+a3FMp8ORZl29v4b3M0RsgXsaeMXh9s9eVMXco= +gorm.io/driver/sqlite v1.2.4 h1:jx16ESo1WzNjgBJNSbhEDoMKJnlhkU8BuBR2C0GC7D8= +gorm.io/driver/sqlite v1.2.4/go.mod h1:n8/CTEIEmo7lKrehQI4pd+rz6O514tMkBeCAR5UTXLs= +gorm.io/gorm v1.22.2 h1:1iKcvyJnR5bHydBhDqTwasOkoo6+o4Ms5cknSt6qP7I= +gorm.io/gorm v1.22.2/go.mod h1:F+OptMscr0P2F2qU97WT1WimdH9GaQPoDW7AYd5i2Y0= +honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= +honnef.co/go/tools v0.0.0-20190523083050-ea95bdfd59fc/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= +honnef.co/go/tools v0.0.1-2019.2.3/go.mod h1:a3bituU0lyd329TUQxRnasdCoJDkEUEAqEt0JzvZhAg= diff --git a/main.go b/main.go index 5a902d1..833259a 100644 --- a/main.go +++ b/main.go @@ -6,6 +6,14 @@ import ( ) func main() { - http.ListenAndServe(":3000", router.NewRouter()) - // fmt.Println(string(out)) + err := http.ListenAndServe(":3000", router.NewRouter()) + if err != nil { + panic(err) + } + + // fmt.Scanln() + + // fmt.Println(uuid.New()) + // bootstrap.RunBootstrapServer() + } diff --git a/model/controller.go b/model/controller.go new file mode 100644 index 0000000..6830092 --- /dev/null +++ b/model/controller.go @@ -0,0 +1,64 @@ +package model + +import ( + "encoding/json" + "fmt" + "io" + + "github.com/google/uuid" + "gorm.io/gorm" +) + +type Controller struct { + gorm.Model + CID string `gorm:"uniqueIndex;column:cid" json:"cid"` // Controller ID + CName string `gorm:"column:cname" json:"cname"` // Device ID + Key string `gorm:"column:key" json:"key"` // Service ID +} + +func (s *dbHandler) AddController(r io.Reader) (*Controller, error) { + decoder := json.NewDecoder(r) + var controller = &Controller{} + + err := decoder.Decode(controller) + if err != nil { + return nil, err + } + + controller.CID = uuid.NewString() + controller.Key = controller.CID + + tx := s.db.Create(controller) + if tx.Error != nil { + return nil, tx.Error + } + + tx.First(&controller, "cid=?", controller.CID) + fmt.Println(controller) + return controller, nil +} + +func (s *dbHandler) GetControllers() ([]*Controller, error) { + var list []*Controller + + result := s.db.Find(&list) + + if result.Error != nil { + return nil, result.Error + } + + return list, nil +} + +func (s *dbHandler) IsExistController(cid string) bool { + var controller = Controller{} + + result := s.db.First(&controller, "cid=?", cid) + + if result.Error != nil { + fmt.Println(result.Error) + return false + } + + return true +} diff --git a/model/device.go b/model/device.go new file mode 100644 index 0000000..552551b --- /dev/null +++ b/model/device.go @@ -0,0 +1,43 @@ +package model + +import ( + "gorm.io/gorm" +) + +type Device struct { + gorm.Model + DID string `gorm:"uniqueIndex;column:did" json:"did"` // Device ID + DName string `gorm:"column:dname" json:"dname"` // Device Name + Type string `gorm:"column:type" json:"type"` // Device Type + CID string `gorm:"column:cid" json:"cid"` // Controller ID + SID string `gorm:"column:sid" json:"sid"` // Service ID + SName string `gorm:"column:sname" json:"sname"` // Service Name + // Opts []string +} + +func (s *dbHandler) GetDevices() ([]*Device, int, error) { + var devices []*Device + + result := s.db.Find(&devices) + + if result.Error != nil { + return nil, -1, result.Error + } + return devices, int(result.RowsAffected), nil +} + +// func (s *dbHandler) GetDevice() *Device { +// device := &Device{} +// } + +func (s *dbHandler) AddDevice(device *Device) error { + + tx := s.db.Create(device) + if tx.Error != nil { + return tx.Error + } + + tx.First(device, "did=?", device.DID) + return nil + +} diff --git a/model/handler.go b/model/handler.go new file mode 100644 index 0000000..191d606 --- /dev/null +++ b/model/handler.go @@ -0,0 +1,38 @@ +package model + +import ( + "gorm.io/driver/postgres" + "gorm.io/driver/sqlite" + "gorm.io/gorm" +) + +type dbHandler struct { + db *gorm.DB +} + +func newSqliteHandler(path string) (DBHandler, error) { + db, err := gorm.Open(sqlite.Open(path), &gorm.Config{}) + if err != nil { + return nil, err + } + + db.AutoMigrate(&Device{}) + db.AutoMigrate(&Controller{}) + db.AutoMigrate(&Service{}) + + return &dbHandler{db}, nil +} + +func newPostgresqlHandler(path string) (DBHandler, error) { + dsn := "host=localhost user=user password=user_password dbname=godopudb port=5432 sslmode=disable TimeZone=Asia/Seoul" + db, err := gorm.Open(postgres.Open(dsn), &gorm.Config{}) + if err != nil { + return nil, err + } + + db.AutoMigrate(&Device{}) + db.AutoMigrate(&Controller{}) + db.AutoMigrate(&Service{}) + + return &dbHandler{db}, nil +} diff --git a/model/interface.go b/model/interface.go new file mode 100644 index 0000000..65f4f62 --- /dev/null +++ b/model/interface.go @@ -0,0 +1,31 @@ +package model + +import ( + "io" +) + +// func newDBHandler(dbtype, path string) (*gorm.DB, error) { +// if dbtype == "sqlite" { +// return gorm.Open(sqlite.Open("./test.db"), &gorm.Config{}) +// } else { +// dsn := "host=localhost user=user password=user_password dbname=godopudb port=5432 sslmode=disable TimeZone=Asia/Seoul" +// return gorm.Open(postgres.Open(dsn), &gorm.Config{}) +// } +// } + +type DBHandler interface { + GetDevices() ([]*Device, int, error) + AddDevice(d *Device) error + AddController(r io.Reader) (*Controller, error) + GetControllers() ([]*Controller, error) + IsExistController(cid string) bool + GetServices() ([]*Service, error) + AddService(name string) error + UpdateService(name, addr string) (*Service, error) + GetAddr(sid string) (string, error) +} + +func NewDBHandler(dbtype, path string) (DBHandler, error) { + // return newSqliteHandler(path) + return newPostgresqlHandler(path) +} diff --git a/model/service.go b/model/service.go new file mode 100644 index 0000000..402b8df --- /dev/null +++ b/model/service.go @@ -0,0 +1,76 @@ +package model + +import ( + "github.com/google/uuid" + "gorm.io/gorm" +) + +type Service struct { + gorm.Model + SName string `gorm:"column:sname" json:"sname"` + SID string `gorm:"column:sid" json:"sid"` + NumOfDevs int `gorm:"column:ndevs" json:"ndevs"` + Addr string `gorm:"column:addr"` +} + +func (s *dbHandler) GetServices() ([]*Service, error) { + var services []*Service + + result := s.db.Find(&services) + + if result.Error != nil { + return nil, result.Error + } + + // var devices []*Device + for _, service := range services { + tx := s.db.Where("sname=?", service.SName).Find(&[]*Device{}) + if tx.Error == gorm.ErrRecordNotFound { + service.NumOfDevs = 0 + } else if tx.Error != nil { + return nil, tx.Error + } else { + service.NumOfDevs = int(tx.RowsAffected) + } + } + return services, nil +} + +func (s *dbHandler) AddService(name string) error { + result := s.db.First(&Service{}, "sname=?", name) + if result.Error != nil { + if result.Error == gorm.ErrRecordNotFound { + tx := s.db.Create(&Service{SName: name}) + if tx.Error != nil { + return tx.Error + } + } + + return result.Error + } + + return nil +} + +func (s *dbHandler) UpdateService(name, addr string) (*Service, error) { + tx := s.db.Model(&Service{}).Where("sname = ?", name).Updates(Service{SName: name, SID: uuid.NewString(), Addr: addr}) + if tx.Error != nil { + return nil, tx.Error + } + + var service Service + tx.First(&service, "sname=?", name) + return &service, nil +} + +func (s *dbHandler) GetAddr(sid string) (string, error) { + var service Service + + result := s.db.First(&service, "sid=?", sid) + + if result.Error != nil { + return "", result.Error + } + + return service.Addr, nil +} diff --git a/router/route.go b/router/route.go index 5e7ffe4..1fc7e8b 100644 --- a/router/route.go +++ b/router/route.go @@ -1,56 +1,417 @@ package router import ( - "bytes" - "context" "encoding/json" - containermgnt "etrismartfarmpoc/containermgmt" + "etrismartfarmpoc/containermgmt" + "etrismartfarmpoc/model" "fmt" + "io" + "log" "net/http" + "strings" + "sync" + "time" + "github.com/google/uuid" "github.com/gorilla/mux" + "github.com/gorilla/websocket" "github.com/urfave/negroni" ) -// var rd *render.Render = render.New() +type Notification struct { + Msg string `json:msg` +} +var db model.DBHandler + +func init() { + var err error + db, err = model.NewDBHandler("postgres", "dump.db") + if err != nil { + panic(err) + } +} + +// var rd *render.Render = render.New() func NewRouter() http.Handler { mux := mux.NewRouter() + mux.HandleFunc("/noti", GetNotification).Methods("GET") + mux.HandleFunc("/controllers", GetControllerList).Methods("GET") + mux.HandleFunc("/controllers", PostController).Methods("POST") + mux.HandleFunc("/services", GetServices).Methods("GET") + mux.HandleFunc("/services", PostService).Methods("POST") + mux.HandleFunc("/services", PutServices).Methods("PUT") + mux.HandleFunc("/devices", PostDevice).Methods("POST") + mux.HandleFunc("/devices", GetDevices).Methods("GET") + mux.HandleFunc("/devices", PutDevice).Methods("PUT", "OPTIONS") + mux.HandleFunc("/discover", GetDiscoveredDevices).Methods("GET") + mux.PathPrefix("/services/").HandlerFunc(RouteRequestToService) - mux.HandleFunc("/service", GetServiceList).Methods("GET") - mux.HandleFunc("/extension", PostService).Methods("POST") - - // mux.Handle("/", http.FileServer(http.Dir("public"))) n := negroni.Classic() // 파일 서버 및 로그기능을 제공함 n.UseHandler(mux) return n } -func GetServiceList(w http.ResponseWriter, r *http.Request) { - result := containermgnt.GetContainers(context.Background()) - b := result.Value(containermgnt.ReturnKey).([]byte) - w.Write(b) +func EchoRoute(w http.ResponseWriter, r *http.Request) { + // w.Write([]byte(r.RequestURI)) + // token := strings.Split(r.RequestURI, "/") + + l := len([]rune("/services/")) + idx := strings.Index(r.RequestURI[l:], "/") + id := r.RequestURI[l : l+idx] + url := r.RequestURI[l+idx:] + + m := make(map[string]string) + m["id"] = id + m["url"] = url + + encoder := json.NewEncoder(w) + encoder.Encode(m) } -func PostService(w http.ResponseWriter, r *http.Request) { - request := containermgnt.Container{ - Image: "hello-world", - Name: "TempContainer", +func GetControllerList(w http.ResponseWriter, r *http.Request) { + w.Header().Set("Access-Control-Allow-Origin", "*") + w.Header().Set("Access-Control-Allow-Methods", "POST, GET, OPTIONS, PUT, DELETE") + list, err := db.GetControllers() + if err != nil { + w.WriteHeader(http.StatusBadRequest) + w.Write([]byte(err.Error())) } + fmt.Println(list) + encoder := json.NewEncoder(w) - s, err := json.Marshal(request) + err = encoder.Encode(list) + if err != nil { + w.WriteHeader(http.StatusBadRequest) + w.Write([]byte(err.Error())) + } +} + +func PostController(w http.ResponseWriter, r *http.Request) { + w.Header().Set("Access-Control-Allow-Origin", "*") + w.Header().Set("Access-Control-Allow-Methods", "POST, GET, OPTIONS, PUT, DELETE") + + controller, err := db.AddController(r.Body) if err != nil { w.WriteHeader(http.StatusBadRequest) w.Write([]byte(err.Error())) } - fmt.Println(s) - cont := new(containermgnt.Container) - decoder := json.NewDecoder(bytes.NewReader(s)) - decoder.Decode(cont) + encoder := json.NewEncoder(w) + err = encoder.Encode(controller) - result := containermgnt.CreateContainer(context.Background(), cont) - b := result.Value(containermgnt.ReturnKey).([]byte) - w.Write(b) + if err != nil { + w.WriteHeader(http.StatusBadRequest) + w.Write([]byte(err.Error())) + } + + sendNotification(&Notification{Msg: "Added Controller"}) } + +var upgrader = websocket.Upgrader{ + ReadBufferSize: 1024, + WriteBufferSize: 1024, + CheckOrigin: func(r *http.Request) bool { return true }, +} + +var notifications []chan *Notification + +func sendNotification(noti *Notification) { + for _, ch := range notifications { + ch <- noti + } +} + +func removeNotification(noti chan *Notification) { + for i, e := range notifications { + if e == noti { + discoveredDevices[i] = discoveredDevices[len(discoveredDevices)-1] + discoveredDevices = discoveredDevices[:len(discoveredDevices)-1] + } + } +} +func GetNotification(w http.ResponseWriter, r *http.Request) { + notiChan := make(chan *Notification, 1) + notifications = append(notifications, notiChan) + conn, err := upgrader.Upgrade(w, r, nil) + if err != nil { + w.WriteHeader(http.StatusBadRequest) + w.Write([]byte(err.Error())) + } + + for { + notification := <-notiChan + // fmt.Println("Write!!", discoveredDevices) + if conn.WriteJSON(notification) != nil { + log.Println(err) + w.WriteHeader(http.StatusBadRequest) + w.Write([]byte(err.Error())) + removeNotification(notiChan) + notiChan = nil + return + } + } +} + +func GetDiscoveredDevices(w http.ResponseWriter, r *http.Request) { + noti := make(chan string, 1) + discoveredNotifications = append(discoveredNotifications, noti) + conn, err := upgrader.Upgrade(w, r, nil) + if err != nil { + w.WriteHeader(http.StatusBadRequest) + w.Write([]byte(err.Error())) + } + + for { + <-noti + // fmt.Println("Write!!", discoveredDevices) + if conn.WriteJSON(discoveredDevices) != nil { + log.Println(err) + return + } + } +} + +var waitPermission = map[string]chan bool{} +var mutex sync.Mutex +var discoveredDevices []*model.Device +var discoveredNotifications []chan string + +func removeDevice(device *model.Device) { + for i, e := range discoveredDevices { + if e == device { + discoveredDevices[i] = discoveredDevices[len(discoveredDevices)-1] + discoveredDevices = discoveredDevices[:len(discoveredDevices)-1] + } + } +} + +func GetDevices(w http.ResponseWriter, r *http.Request) { + w.Header().Set("Access-Control-Allow-Origin", "*") + w.Header().Set("Access-Control-Allow-Methods", "POST, GET, OPTIONS, PUT, DELETE") + devices, _, err := db.GetDevices() + + if err != nil { + w.WriteHeader(http.StatusBadRequest) + return + } + + encoder := json.NewEncoder(w) + encoder.Encode(devices) +} + +// PostDevice : Handle for Receiving discovery message +func PostDevice(w http.ResponseWriter, r *http.Request) { + var device = &model.Device{} + decoder := json.NewDecoder(r.Body) + err := decoder.Decode(device) + if err != nil { + w.WriteHeader(http.StatusBadRequest) + return + } + + if !db.IsExistController(device.CID) { + w.WriteHeader(http.StatusBadRequest) + w.Write([]byte("Wrong Controller ID")) + return + } + + device.DID = uuid.NewString() + mutex.Lock() + waitPermission[device.DID] = make(chan bool) + discoveredDevices = append(discoveredDevices, device) + mutex.Unlock() + for _, noti := range discoveredNotifications { + noti <- device.DID + } + + timer := time.NewTimer(3 * time.Second) + select { + case <-timer.C: + mutex.Lock() + delete(waitPermission, device.DID) + removeDevice(device) + mutex.Unlock() + for _, noti := range discoveredNotifications { + noti <- device.DID + } + + w.WriteHeader(http.StatusOK) + w.Write([]byte("This operation is not permitted")) + case b := <-waitPermission[device.DID]: + if b { + // 디바이스 등록 절차 수행 + db.AddDevice(device) + db.AddService(device.SName) + + // 디바이스 등록 알림 + w.WriteHeader(http.StatusCreated) + sendNotification(&Notification{Msg: "Added Device"}) + mutex.Lock() + delete(waitPermission, device.DID) + removeDevice(device) + mutex.Unlock() + for _, noti := range discoveredNotifications { + noti <- device.DID + } + } else { + mutex.Lock() + delete(waitPermission, device.DID) + removeDevice(device) + mutex.Unlock() + for _, noti := range discoveredNotifications { + noti <- device.DID + } + + w.WriteHeader(http.StatusOK) + w.Write([]byte("This operation is not permitted")) + } + } +} + +func PutDevice(w http.ResponseWriter, r *http.Request) { + w.Header().Set("Access-Control-Allow-Origin", "*") + w.Header().Set("Access-Control-Allow-Methods", "POST, GET, OPTIONS, PUT, DELETE") + msg := map[string]string{} + decoder := json.NewDecoder(r.Body) + err := decoder.Decode(&msg) + + fmt.Println("msg[did]: ", msg["did"]) + + if err != nil { + w.WriteHeader(http.StatusBadRequest) + w.Write([]byte(err.Error())) + } + + ch, ok := waitPermission[msg["did"]] + if !ok { + w.WriteHeader(http.StatusBadRequest) + w.Write([]byte("Wrong Device ID is Sended")) + return + } + + ch <- true + w.WriteHeader(http.StatusOK) +} + +func GetServices(w http.ResponseWriter, r *http.Request) { + w.Header().Set("Access-Control-Allow-Origin", "*") + w.Header().Set("Access-Control-Allow-Methods", "POST, GET, OPTIONS, PUT, DELETE") + l, err := db.GetServices() + if err != nil { + w.WriteHeader(http.StatusBadRequest) + return + } + + err = json.NewEncoder(w).Encode(l) + if err != nil { + w.WriteHeader(http.StatusBadRequest) + return + } +} + +func PutServices(w http.ResponseWriter, r *http.Request) { + var obj = map[string]string{} + + decoder := json.NewDecoder(r.Body) + err := decoder.Decode(&obj) + + if err != nil { + w.WriteHeader(http.StatusBadRequest) + return + } + + s, err := db.UpdateService(obj["name"], obj["addr"]) + if err != nil { + w.WriteHeader(http.StatusBadRequest) + return + } + + sendNotification(&Notification{Msg: "Update Service"}) + err = json.NewEncoder(w).Encode(s) + if err != nil { + w.WriteHeader(http.StatusBadRequest) + return + } +} + +// func GetServiceList(w http.ResponseWriter, r *http.Request) { +// result := containermgmt.GetContainers(context.Background()) +// b := result.Value(containermgmt.ReturnKey).([]byte) +// w.Write(b) +// } + +func PostService(w http.ResponseWriter, r *http.Request) { + + var obj = map[string]string{} + decoder := json.NewDecoder(r.Body) + err := decoder.Decode(&obj) + + if err != nil { + w.WriteHeader(http.StatusBadRequest) + w.Write([]byte(err.Error())) + return + } + + err = containermgmt.CreateContainer(obj["name"]) + if err != nil { + w.WriteHeader(http.StatusBadRequest) + w.Write([]byte(err.Error())) + return + } + + w.WriteHeader(http.StatusCreated) + + // result := containermgmt.CreateContainer(context.Background(), cont) + // b := result.Value(containermgmt.ReturnKey).([]byte) +} + +func RouteRequestToService(w http.ResponseWriter, r *http.Request) { + l := len([]rune("/services/")) + var id string + var url string + idx := strings.Index(r.RequestURI[l:], "/") + if idx == -1 { + id = r.RequestURI[l:] + url = "/" + } else { + id = r.RequestURI[l : l+idx] + if len([]rune(r.RequestURI)) <= l+idx { + url = "/" + } else { + url = r.RequestURI[l+idx:] + } + } + + // w.Write([]byte(vars["url"])) + host, err := db.GetAddr(id) + if err != nil { + w.WriteHeader(http.StatusNotFound) + return + } + + log.Println("Route to", host+"/"+url) + req, err := http.NewRequest(r.Method, "http://"+host+"/"+url, r.Body) + if err != nil { + // 잘못된 메시지 포맷이 전달된 경우 + w.WriteHeader(http.StatusBadRequest) + fmt.Fprint(w, err) + return + } + + resp, err := http.DefaultClient.Do(req) + + if err != nil { + // 잘못된 메시지 포맷이 전달된 경우 + w.WriteHeader(http.StatusBadRequest) + fmt.Fprint(w, err) + return + } + + io.Copy(w, resp.Body) +} + +// func mapService(urls []string) { + +// } diff --git a/server b/server deleted file mode 100755 index 4ba242b..0000000 Binary files a/server and /dev/null differ