Compare commits
13 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 47b96cd598 | |||
| 19c02063e9 | |||
| 84523661e2 | |||
| 6553b4711b | |||
| 9280668d28 | |||
| ccc2fd401f | |||
| f2e4530023 | |||
| 8f333354d2 | |||
| 41e7585637 | |||
| 36f695c146 | |||
| 404c64b910 | |||
| 2cd4d8a35a | |||
| bae726dba6 |
26
go.mod
26
go.mod
@@ -5,15 +5,15 @@ go 1.21.3
|
|||||||
// replace github.com/samber/slog-echo => github.com/abh/slog-echo v0.0.0-20231024051244-af740639893e
|
// replace github.com/samber/slog-echo => github.com/abh/slog-echo v0.0.0-20231024051244-af740639893e
|
||||||
|
|
||||||
require (
|
require (
|
||||||
github.com/ClickHouse/clickhouse-go/v2 v2.16.0
|
github.com/ClickHouse/clickhouse-go/v2 v2.17.0
|
||||||
github.com/go-sql-driver/mysql v1.7.1
|
github.com/go-sql-driver/mysql v1.7.1
|
||||||
github.com/hashicorp/go-retryablehttp v0.7.5
|
github.com/hashicorp/go-retryablehttp v0.7.5
|
||||||
github.com/labstack/echo/v4 v4.11.3
|
github.com/labstack/echo/v4 v4.11.4
|
||||||
github.com/samber/slog-echo v1.9.0
|
github.com/samber/slog-echo v1.9.1
|
||||||
github.com/spf13/cobra v1.8.0
|
github.com/spf13/cobra v1.8.0
|
||||||
github.com/stretchr/testify v1.8.4
|
github.com/stretchr/testify v1.8.4
|
||||||
go.ntppool.org/api v0.1.8-0.20231210025001-f2c143296511
|
go.ntppool.org/api v0.1.8-0.20231210025001-f2c143296511
|
||||||
go.ntppool.org/common v0.2.6-0.20231211031613-608f05d39551
|
go.ntppool.org/common v0.2.6-0.20231211044338-5c7ae6ab8ac9
|
||||||
go.opentelemetry.io/contrib/instrumentation/github.com/labstack/echo/otelecho v0.46.1
|
go.opentelemetry.io/contrib/instrumentation/github.com/labstack/echo/otelecho v0.46.1
|
||||||
go.opentelemetry.io/contrib/instrumentation/net/http/httptrace/otelhttptrace v0.46.1
|
go.opentelemetry.io/contrib/instrumentation/net/http/httptrace/otelhttptrace v0.46.1
|
||||||
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.46.1
|
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.46.1
|
||||||
@@ -32,17 +32,17 @@ require (
|
|||||||
github.com/davecgh/go-spew v1.1.1 // indirect
|
github.com/davecgh/go-spew v1.1.1 // indirect
|
||||||
github.com/felixge/httpsnoop v1.0.4 // indirect
|
github.com/felixge/httpsnoop v1.0.4 // indirect
|
||||||
github.com/go-faster/city v1.0.1 // indirect
|
github.com/go-faster/city v1.0.1 // indirect
|
||||||
github.com/go-faster/errors v0.7.0 // indirect
|
github.com/go-faster/errors v0.7.1 // indirect
|
||||||
github.com/go-logr/logr v1.3.0 // indirect
|
github.com/go-logr/logr v1.4.0 // indirect
|
||||||
github.com/go-logr/stdr v1.2.2 // indirect
|
github.com/go-logr/stdr v1.2.2 // indirect
|
||||||
github.com/golang-jwt/jwt v3.2.2+incompatible // indirect
|
github.com/golang-jwt/jwt v3.2.2+incompatible // indirect
|
||||||
github.com/golang/protobuf v1.5.3 // indirect
|
github.com/golang/protobuf v1.5.3 // indirect
|
||||||
github.com/google/uuid v1.4.0 // indirect
|
github.com/google/uuid v1.5.0 // indirect
|
||||||
github.com/grpc-ecosystem/grpc-gateway/v2 v2.18.1 // indirect
|
github.com/grpc-ecosystem/grpc-gateway/v2 v2.18.1 // indirect
|
||||||
github.com/hashicorp/go-cleanhttp v0.5.2 // indirect
|
github.com/hashicorp/go-cleanhttp v0.5.2 // indirect
|
||||||
github.com/inconshreveable/mousetrap v1.1.0 // indirect
|
github.com/inconshreveable/mousetrap v1.1.0 // indirect
|
||||||
github.com/klauspost/compress v1.17.4 // indirect
|
github.com/klauspost/compress v1.17.4 // indirect
|
||||||
github.com/labstack/gommon v0.4.1 // indirect
|
github.com/labstack/gommon v0.4.2 // indirect
|
||||||
github.com/mattn/go-colorable v0.1.13 // indirect
|
github.com/mattn/go-colorable v0.1.13 // indirect
|
||||||
github.com/mattn/go-isatty v0.0.20 // indirect
|
github.com/mattn/go-isatty v0.0.20 // indirect
|
||||||
github.com/matttproud/golang_protobuf_extensions/v2 v2.0.0 // indirect
|
github.com/matttproud/golang_protobuf_extensions/v2 v2.0.0 // indirect
|
||||||
@@ -67,15 +67,15 @@ require (
|
|||||||
go.opentelemetry.io/otel/metric v1.21.0 // indirect
|
go.opentelemetry.io/otel/metric v1.21.0 // indirect
|
||||||
go.opentelemetry.io/otel/sdk v1.21.0 // indirect
|
go.opentelemetry.io/otel/sdk v1.21.0 // indirect
|
||||||
go.opentelemetry.io/proto/otlp v1.0.0 // indirect
|
go.opentelemetry.io/proto/otlp v1.0.0 // indirect
|
||||||
golang.org/x/crypto v0.16.0 // indirect
|
golang.org/x/crypto v0.17.0 // indirect
|
||||||
golang.org/x/exp v0.0.0-20231206192017-f3f8817b8deb // indirect
|
golang.org/x/exp v0.0.0-20231219180239-dc181d75b848 // indirect
|
||||||
golang.org/x/mod v0.14.0 // indirect
|
golang.org/x/mod v0.14.0 // indirect
|
||||||
golang.org/x/net v0.19.0 // indirect
|
golang.org/x/net v0.19.0 // indirect
|
||||||
golang.org/x/sys v0.15.0 // indirect
|
golang.org/x/sys v0.15.0 // indirect
|
||||||
golang.org/x/text v0.14.0 // indirect
|
golang.org/x/text v0.14.0 // indirect
|
||||||
golang.org/x/time v0.5.0 // indirect
|
golang.org/x/time v0.5.0 // indirect
|
||||||
google.golang.org/genproto/googleapis/api v0.0.0-20231127180814-3a041ad873d4 // indirect
|
google.golang.org/genproto/googleapis/api v0.0.0-20231212172506-995d672761c0 // indirect
|
||||||
google.golang.org/genproto/googleapis/rpc v0.0.0-20231127180814-3a041ad873d4 // indirect
|
google.golang.org/genproto/googleapis/rpc v0.0.0-20231212172506-995d672761c0 // indirect
|
||||||
google.golang.org/grpc v1.59.0 // indirect
|
google.golang.org/grpc v1.60.1 // indirect
|
||||||
google.golang.org/protobuf v1.31.0 // indirect
|
google.golang.org/protobuf v1.31.0 // indirect
|
||||||
)
|
)
|
||||||
|
|||||||
30
go.sum
30
go.sum
@@ -3,6 +3,8 @@ github.com/ClickHouse/ch-go v0.61.0/go.mod h1:POJBl0MxEMS91Zd0uTgDDt05KfXEjf5KIw
|
|||||||
github.com/ClickHouse/clickhouse-go v1.5.4 h1:cKjXeYLNWVJIx2J1K6H2CqyRmfwVJVY1OV1coaaFcI0=
|
github.com/ClickHouse/clickhouse-go v1.5.4 h1:cKjXeYLNWVJIx2J1K6H2CqyRmfwVJVY1OV1coaaFcI0=
|
||||||
github.com/ClickHouse/clickhouse-go/v2 v2.16.0 h1:rhMfnPewXPnY4Q4lQRGdYuTLRBRKJEIEYHtbUMrzmvI=
|
github.com/ClickHouse/clickhouse-go/v2 v2.16.0 h1:rhMfnPewXPnY4Q4lQRGdYuTLRBRKJEIEYHtbUMrzmvI=
|
||||||
github.com/ClickHouse/clickhouse-go/v2 v2.16.0/go.mod h1:J7SPfIxwR+x4mQ+o8MLSe0oY50NNntEqCIjFe/T1VPM=
|
github.com/ClickHouse/clickhouse-go/v2 v2.16.0/go.mod h1:J7SPfIxwR+x4mQ+o8MLSe0oY50NNntEqCIjFe/T1VPM=
|
||||||
|
github.com/ClickHouse/clickhouse-go/v2 v2.17.0 h1:xvsVYxOWb2obaIwL9NJZSZ3T/umJSh9P1gf1dfMFlI8=
|
||||||
|
github.com/ClickHouse/clickhouse-go/v2 v2.17.0/go.mod h1:rkGTvFDTLqLIm0ma+13xmcCfr/08Gvs7KmFt1tgiWHQ=
|
||||||
github.com/andybalholm/brotli v1.0.6 h1:Yf9fFpf49Zrxb9NlQaluyE92/+X7UVHlhMNJN2sxfOI=
|
github.com/andybalholm/brotli v1.0.6 h1:Yf9fFpf49Zrxb9NlQaluyE92/+X7UVHlhMNJN2sxfOI=
|
||||||
github.com/andybalholm/brotli v1.0.6/go.mod h1:fO7iG3H7G2nSZ7m0zPUDn85XEX2GTukHGRSepvi9Eig=
|
github.com/andybalholm/brotli v1.0.6/go.mod h1:fO7iG3H7G2nSZ7m0zPUDn85XEX2GTukHGRSepvi9Eig=
|
||||||
github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM=
|
github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM=
|
||||||
@@ -21,9 +23,13 @@ github.com/go-faster/city v1.0.1 h1:4WAxSZ3V2Ws4QRDrscLEDcibJY8uf41H6AhXDrNDcGw=
|
|||||||
github.com/go-faster/city v1.0.1/go.mod h1:jKcUJId49qdW3L1qKHH/3wPeUstCVpVSXTM6vO3VcTw=
|
github.com/go-faster/city v1.0.1/go.mod h1:jKcUJId49qdW3L1qKHH/3wPeUstCVpVSXTM6vO3VcTw=
|
||||||
github.com/go-faster/errors v0.7.0 h1:UnD/xusnfUgtEYkgRZohqL2AfmPTwv13NAJwwFFaNYc=
|
github.com/go-faster/errors v0.7.0 h1:UnD/xusnfUgtEYkgRZohqL2AfmPTwv13NAJwwFFaNYc=
|
||||||
github.com/go-faster/errors v0.7.0/go.mod h1:5ySTjWFiphBs07IKuiL69nxdfd5+fzh1u7FPGZP2quo=
|
github.com/go-faster/errors v0.7.0/go.mod h1:5ySTjWFiphBs07IKuiL69nxdfd5+fzh1u7FPGZP2quo=
|
||||||
|
github.com/go-faster/errors v0.7.1 h1:MkJTnDoEdi9pDabt1dpWf7AA8/BaSYZqibYyhZ20AYg=
|
||||||
|
github.com/go-faster/errors v0.7.1/go.mod h1:5ySTjWFiphBs07IKuiL69nxdfd5+fzh1u7FPGZP2quo=
|
||||||
github.com/go-logr/logr v1.2.2/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A=
|
github.com/go-logr/logr v1.2.2/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A=
|
||||||
github.com/go-logr/logr v1.3.0 h1:2y3SDp0ZXuc6/cjLSZ+Q3ir+QB9T/iG5yYRXqsagWSY=
|
github.com/go-logr/logr v1.3.0 h1:2y3SDp0ZXuc6/cjLSZ+Q3ir+QB9T/iG5yYRXqsagWSY=
|
||||||
github.com/go-logr/logr v1.3.0/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY=
|
github.com/go-logr/logr v1.3.0/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY=
|
||||||
|
github.com/go-logr/logr v1.4.0 h1:wx+BduGRXjIL6VPeeb7DRX+ii7sR/ch8DlRifHR589o=
|
||||||
|
github.com/go-logr/logr v1.4.0/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY=
|
||||||
github.com/go-logr/stdr v1.2.2 h1:hSWxHoqTgW2S2qGc0LTAI563KZ5YKYRhT3MFKZMbjag=
|
github.com/go-logr/stdr v1.2.2 h1:hSWxHoqTgW2S2qGc0LTAI563KZ5YKYRhT3MFKZMbjag=
|
||||||
github.com/go-logr/stdr v1.2.2/go.mod h1:mMo/vtBO5dYbehREoey6XUKy/eSumjCCveDpRre4VKE=
|
github.com/go-logr/stdr v1.2.2/go.mod h1:mMo/vtBO5dYbehREoey6XUKy/eSumjCCveDpRre4VKE=
|
||||||
github.com/go-sql-driver/mysql v1.7.1 h1:lUIinVbN1DY0xBg0eMOzmmtGoHwWBbvnWubQUrtU8EI=
|
github.com/go-sql-driver/mysql v1.7.1 h1:lUIinVbN1DY0xBg0eMOzmmtGoHwWBbvnWubQUrtU8EI=
|
||||||
@@ -41,6 +47,8 @@ github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI=
|
|||||||
github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
|
github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
|
||||||
github.com/google/uuid v1.4.0 h1:MtMxsa51/r9yyhkyLsVeVt0B+BGQZzpQiTQ4eHZ8bc4=
|
github.com/google/uuid v1.4.0 h1:MtMxsa51/r9yyhkyLsVeVt0B+BGQZzpQiTQ4eHZ8bc4=
|
||||||
github.com/google/uuid v1.4.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
|
github.com/google/uuid v1.4.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
|
||||||
|
github.com/google/uuid v1.5.0 h1:1p67kYwdtXjb0gL0BPiP1Av9wiZPo5A8z2cWkTZ+eyU=
|
||||||
|
github.com/google/uuid v1.5.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
|
||||||
github.com/grpc-ecosystem/grpc-gateway/v2 v2.18.1 h1:6UKoz5ujsI55KNpsJH3UwCq3T8kKbZwNZBNPuTTje8U=
|
github.com/grpc-ecosystem/grpc-gateway/v2 v2.18.1 h1:6UKoz5ujsI55KNpsJH3UwCq3T8kKbZwNZBNPuTTje8U=
|
||||||
github.com/grpc-ecosystem/grpc-gateway/v2 v2.18.1/go.mod h1:YvJ2f6MplWDhfxiUC3KpyTy76kYUZA4W3pTv/wdKQ9Y=
|
github.com/grpc-ecosystem/grpc-gateway/v2 v2.18.1/go.mod h1:YvJ2f6MplWDhfxiUC3KpyTy76kYUZA4W3pTv/wdKQ9Y=
|
||||||
github.com/hashicorp/go-cleanhttp v0.5.2 h1:035FKYIWjmULyFRBKPs8TBQoi0x6d9G4xc9neXJWAZQ=
|
github.com/hashicorp/go-cleanhttp v0.5.2 h1:035FKYIWjmULyFRBKPs8TBQoi0x6d9G4xc9neXJWAZQ=
|
||||||
@@ -64,8 +72,12 @@ github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
|
|||||||
github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE=
|
github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE=
|
||||||
github.com/labstack/echo/v4 v4.11.3 h1:Upyu3olaqSHkCjs1EJJwQ3WId8b8b1hxbogyommKktM=
|
github.com/labstack/echo/v4 v4.11.3 h1:Upyu3olaqSHkCjs1EJJwQ3WId8b8b1hxbogyommKktM=
|
||||||
github.com/labstack/echo/v4 v4.11.3/go.mod h1:UcGuQ8V6ZNRmSweBIJkPvGfwCMIlFmiqrPqiEBfPYws=
|
github.com/labstack/echo/v4 v4.11.3/go.mod h1:UcGuQ8V6ZNRmSweBIJkPvGfwCMIlFmiqrPqiEBfPYws=
|
||||||
|
github.com/labstack/echo/v4 v4.11.4 h1:vDZmA+qNeh1pd/cCkEicDMrjtrnMGQ1QFI9gWN1zGq8=
|
||||||
|
github.com/labstack/echo/v4 v4.11.4/go.mod h1:noh7EvLwqDsmh/X/HWKPUl1AjzJrhyptRyEbQJfxen8=
|
||||||
github.com/labstack/gommon v0.4.1 h1:gqEff0p/hTENGMABzezPoPSRtIh1Cvw0ueMOe0/dfOk=
|
github.com/labstack/gommon v0.4.1 h1:gqEff0p/hTENGMABzezPoPSRtIh1Cvw0ueMOe0/dfOk=
|
||||||
github.com/labstack/gommon v0.4.1/go.mod h1:TyTrpPqxR5KMk8LKVtLmfMjeQ5FEkBYdxLYPw/WfrOM=
|
github.com/labstack/gommon v0.4.1/go.mod h1:TyTrpPqxR5KMk8LKVtLmfMjeQ5FEkBYdxLYPw/WfrOM=
|
||||||
|
github.com/labstack/gommon v0.4.2 h1:F8qTUNXgG1+6WQmqoUWnz8WiEU60mXVVw0P4ht1WRA0=
|
||||||
|
github.com/labstack/gommon v0.4.2/go.mod h1:QlUFxVM+SNXhDL/Z7YhocGIBYOiwB0mXm1+1bAPHPyU=
|
||||||
github.com/mattn/go-colorable v0.1.13 h1:fFA4WZxdEF4tXPZVKMLwD8oUnCTTo08duU7wxecdEvA=
|
github.com/mattn/go-colorable v0.1.13 h1:fFA4WZxdEF4tXPZVKMLwD8oUnCTTo08duU7wxecdEvA=
|
||||||
github.com/mattn/go-colorable v0.1.13/go.mod h1:7S9/ev0klgBDR4GtXTXX8a3vIGJpMovkB8vQcUbaXHg=
|
github.com/mattn/go-colorable v0.1.13/go.mod h1:7S9/ev0klgBDR4GtXTXX8a3vIGJpMovkB8vQcUbaXHg=
|
||||||
github.com/mattn/go-isatty v0.0.16/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM=
|
github.com/mattn/go-isatty v0.0.16/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM=
|
||||||
@@ -103,6 +115,8 @@ github.com/samber/lo v1.39.0 h1:4gTz1wUhNYLhFSKl6O+8peW0v2F4BCY034GRpU9WnuA=
|
|||||||
github.com/samber/lo v1.39.0/go.mod h1:+m/ZKRl6ClXCE2Lgf3MsQlWfh4bn1bz6CXEOxnEXnEA=
|
github.com/samber/lo v1.39.0/go.mod h1:+m/ZKRl6ClXCE2Lgf3MsQlWfh4bn1bz6CXEOxnEXnEA=
|
||||||
github.com/samber/slog-echo v1.9.0 h1:1Cvn2/JXAM2ki26uBMbbk0jB9UxZgaE9xM1DVZvLAlo=
|
github.com/samber/slog-echo v1.9.0 h1:1Cvn2/JXAM2ki26uBMbbk0jB9UxZgaE9xM1DVZvLAlo=
|
||||||
github.com/samber/slog-echo v1.9.0/go.mod h1:0ab2AwcciQXNAXEcjkHwD9okOh9vEHEYn8xP97ocuhM=
|
github.com/samber/slog-echo v1.9.0/go.mod h1:0ab2AwcciQXNAXEcjkHwD9okOh9vEHEYn8xP97ocuhM=
|
||||||
|
github.com/samber/slog-echo v1.9.1 h1:QEzOuZtZiXe0/60bmfcVZdwYzq1T6SCBC4RiMfg9Riw=
|
||||||
|
github.com/samber/slog-echo v1.9.1/go.mod h1:/f78pHjVxGrIlHlS5fzWiW+BxkWltQ+SWKk8LKMjAMQ=
|
||||||
github.com/segmentio/asm v1.2.0 h1:9BQrFxC+YOHJlTlHGkTrFWf59nbL3XnCoFLTwDCI7ys=
|
github.com/segmentio/asm v1.2.0 h1:9BQrFxC+YOHJlTlHGkTrFWf59nbL3XnCoFLTwDCI7ys=
|
||||||
github.com/segmentio/asm v1.2.0/go.mod h1:BqMnlJP91P8d+4ibuonYZw9mfnzI9HfxselHZr5aAcs=
|
github.com/segmentio/asm v1.2.0/go.mod h1:BqMnlJP91P8d+4ibuonYZw9mfnzI9HfxselHZr5aAcs=
|
||||||
github.com/shopspring/decimal v1.3.1 h1:2Usl1nmF/WZucqkFZhnfFYxxxu8LG21F6nPQBE5gKV8=
|
github.com/shopspring/decimal v1.3.1 h1:2Usl1nmF/WZucqkFZhnfFYxxxu8LG21F6nPQBE5gKV8=
|
||||||
@@ -144,6 +158,8 @@ go.ntppool.org/common v0.2.5 h1:fvuFrCCbmaRzZOSwv71+yhqVLOTDB/fD7YlscdGa6qs=
|
|||||||
go.ntppool.org/common v0.2.5/go.mod h1:Cw8mq8jd2sLCxbTNzYXKXn3qKo2ZLERZ6V/eLcSgDHw=
|
go.ntppool.org/common v0.2.5/go.mod h1:Cw8mq8jd2sLCxbTNzYXKXn3qKo2ZLERZ6V/eLcSgDHw=
|
||||||
go.ntppool.org/common v0.2.6-0.20231211031613-608f05d39551 h1:kJdF3U4KBuJJtbF04d5OA/QttxDY/fOgHe1oUDEgLGA=
|
go.ntppool.org/common v0.2.6-0.20231211031613-608f05d39551 h1:kJdF3U4KBuJJtbF04d5OA/QttxDY/fOgHe1oUDEgLGA=
|
||||||
go.ntppool.org/common v0.2.6-0.20231211031613-608f05d39551/go.mod h1:Cw8mq8jd2sLCxbTNzYXKXn3qKo2ZLERZ6V/eLcSgDHw=
|
go.ntppool.org/common v0.2.6-0.20231211031613-608f05d39551/go.mod h1:Cw8mq8jd2sLCxbTNzYXKXn3qKo2ZLERZ6V/eLcSgDHw=
|
||||||
|
go.ntppool.org/common v0.2.6-0.20231211044338-5c7ae6ab8ac9 h1:5NHaULU9+qu6hA/teqYSfPag4Mkozt0baIb3DP9Hcng=
|
||||||
|
go.ntppool.org/common v0.2.6-0.20231211044338-5c7ae6ab8ac9/go.mod h1:Cw8mq8jd2sLCxbTNzYXKXn3qKo2ZLERZ6V/eLcSgDHw=
|
||||||
go.opentelemetry.io/contrib/instrumentation/github.com/labstack/echo/otelecho v0.46.1 h1:yJWyqeE+8jdOJpt+ZFn7sX05EJAK/9C4jjNZyb61xZg=
|
go.opentelemetry.io/contrib/instrumentation/github.com/labstack/echo/otelecho v0.46.1 h1:yJWyqeE+8jdOJpt+ZFn7sX05EJAK/9C4jjNZyb61xZg=
|
||||||
go.opentelemetry.io/contrib/instrumentation/github.com/labstack/echo/otelecho v0.46.1/go.mod h1:tlgpIvi6LCv4QIZQyBc8Gkr6HDxbJLTh9eQPNZAaljE=
|
go.opentelemetry.io/contrib/instrumentation/github.com/labstack/echo/otelecho v0.46.1/go.mod h1:tlgpIvi6LCv4QIZQyBc8Gkr6HDxbJLTh9eQPNZAaljE=
|
||||||
go.opentelemetry.io/contrib/instrumentation/net/http/httptrace/otelhttptrace v0.46.1 h1:gbhw/u49SS3gkPWiYweQNJGm/uJN5GkI/FrosxSHT7A=
|
go.opentelemetry.io/contrib/instrumentation/net/http/httptrace/otelhttptrace v0.46.1 h1:gbhw/u49SS3gkPWiYweQNJGm/uJN5GkI/FrosxSHT7A=
|
||||||
@@ -172,8 +188,14 @@ golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPh
|
|||||||
golang.org/x/crypto v0.0.0-20220622213112-05595931fe9d/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4=
|
golang.org/x/crypto v0.0.0-20220622213112-05595931fe9d/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4=
|
||||||
golang.org/x/crypto v0.16.0 h1:mMMrFzRSCF0GvB7Ne27XVtVAaXLrPmgPC7/v0tkwHaY=
|
golang.org/x/crypto v0.16.0 h1:mMMrFzRSCF0GvB7Ne27XVtVAaXLrPmgPC7/v0tkwHaY=
|
||||||
golang.org/x/crypto v0.16.0/go.mod h1:gCAAfMLgwOJRpTjQ2zCCt2OcSfYMTeZVSRtQlPC7Nq4=
|
golang.org/x/crypto v0.16.0/go.mod h1:gCAAfMLgwOJRpTjQ2zCCt2OcSfYMTeZVSRtQlPC7Nq4=
|
||||||
|
golang.org/x/crypto v0.17.0 h1:r8bRNjWL3GshPW3gkd+RpvzWrZAwPS49OmTGZ/uhM4k=
|
||||||
|
golang.org/x/crypto v0.17.0/go.mod h1:gCAAfMLgwOJRpTjQ2zCCt2OcSfYMTeZVSRtQlPC7Nq4=
|
||||||
golang.org/x/exp v0.0.0-20231206192017-f3f8817b8deb h1:c0vyKkb6yr3KR7jEfJaOSv4lG7xPkbN6r52aJz1d8a8=
|
golang.org/x/exp v0.0.0-20231206192017-f3f8817b8deb h1:c0vyKkb6yr3KR7jEfJaOSv4lG7xPkbN6r52aJz1d8a8=
|
||||||
golang.org/x/exp v0.0.0-20231206192017-f3f8817b8deb/go.mod h1:iRJReGqOEeBhDZGkGbynYwcHlctCvnjTYIamk7uXpHI=
|
golang.org/x/exp v0.0.0-20231206192017-f3f8817b8deb/go.mod h1:iRJReGqOEeBhDZGkGbynYwcHlctCvnjTYIamk7uXpHI=
|
||||||
|
golang.org/x/exp v0.0.0-20231214170342-aacd6d4b4611 h1:qCEDpW1G+vcj3Y7Fy52pEM1AWm3abj8WimGYejI3SC4=
|
||||||
|
golang.org/x/exp v0.0.0-20231214170342-aacd6d4b4611/go.mod h1:iRJReGqOEeBhDZGkGbynYwcHlctCvnjTYIamk7uXpHI=
|
||||||
|
golang.org/x/exp v0.0.0-20231219180239-dc181d75b848 h1:+iq7lrkxmFNBM7xx+Rae2W6uyPfhPeDWD+n+JgppptE=
|
||||||
|
golang.org/x/exp v0.0.0-20231219180239-dc181d75b848/go.mod h1:iRJReGqOEeBhDZGkGbynYwcHlctCvnjTYIamk7uXpHI=
|
||||||
golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
|
golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
|
||||||
golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
|
golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
|
||||||
golang.org/x/mod v0.14.0 h1:dGoOF9QVLYng8IHTm7BAyWqCqSheQ5pYWGhzW00YJr0=
|
golang.org/x/mod v0.14.0 h1:dGoOF9QVLYng8IHTm7BAyWqCqSheQ5pYWGhzW00YJr0=
|
||||||
@@ -222,10 +244,18 @@ google.golang.org/genproto v0.0.0-20231120223509-83a465c0220f h1:Vn+VyHU5guc9KjB
|
|||||||
google.golang.org/genproto v0.0.0-20231120223509-83a465c0220f/go.mod h1:nWSwAFPb+qfNJXsoeO3Io7zf4tMSfN8EA8RlDA04GhY=
|
google.golang.org/genproto v0.0.0-20231120223509-83a465c0220f/go.mod h1:nWSwAFPb+qfNJXsoeO3Io7zf4tMSfN8EA8RlDA04GhY=
|
||||||
google.golang.org/genproto/googleapis/api v0.0.0-20231127180814-3a041ad873d4 h1:ZcOkrmX74HbKFYnpPY8Qsw93fC29TbJXspYKaBkSXDQ=
|
google.golang.org/genproto/googleapis/api v0.0.0-20231127180814-3a041ad873d4 h1:ZcOkrmX74HbKFYnpPY8Qsw93fC29TbJXspYKaBkSXDQ=
|
||||||
google.golang.org/genproto/googleapis/api v0.0.0-20231127180814-3a041ad873d4/go.mod h1:k2dtGpRrbsSyKcNPKKI5sstZkrNCZwpU/ns96JoHbGg=
|
google.golang.org/genproto/googleapis/api v0.0.0-20231127180814-3a041ad873d4/go.mod h1:k2dtGpRrbsSyKcNPKKI5sstZkrNCZwpU/ns96JoHbGg=
|
||||||
|
google.golang.org/genproto/googleapis/api v0.0.0-20231212172506-995d672761c0 h1:s1w3X6gQxwrLEpxnLd/qXTVLgQE2yXwaOaoa6IlY/+o=
|
||||||
|
google.golang.org/genproto/googleapis/api v0.0.0-20231212172506-995d672761c0/go.mod h1:CAny0tYF+0/9rmDB9fahA9YLzX3+AEVl1qXbv5hhj6c=
|
||||||
google.golang.org/genproto/googleapis/rpc v0.0.0-20231127180814-3a041ad873d4 h1:DC7wcm+i+P1rN3Ff07vL+OndGg5OhNddHyTA+ocPqYE=
|
google.golang.org/genproto/googleapis/rpc v0.0.0-20231127180814-3a041ad873d4 h1:DC7wcm+i+P1rN3Ff07vL+OndGg5OhNddHyTA+ocPqYE=
|
||||||
google.golang.org/genproto/googleapis/rpc v0.0.0-20231127180814-3a041ad873d4/go.mod h1:eJVxU6o+4G1PSczBr85xmyvSNYAKvAYgkub40YGomFM=
|
google.golang.org/genproto/googleapis/rpc v0.0.0-20231127180814-3a041ad873d4/go.mod h1:eJVxU6o+4G1PSczBr85xmyvSNYAKvAYgkub40YGomFM=
|
||||||
|
google.golang.org/genproto/googleapis/rpc v0.0.0-20231212172506-995d672761c0 h1:/jFB8jK5R3Sq3i/lmeZO0cATSzFfZaJq1J2Euan3XKU=
|
||||||
|
google.golang.org/genproto/googleapis/rpc v0.0.0-20231212172506-995d672761c0/go.mod h1:FUoWkonphQm3RhTS+kOEhF8h0iDpm4tdXolVCeZ9KKA=
|
||||||
google.golang.org/grpc v1.59.0 h1:Z5Iec2pjwb+LEOqzpB2MR12/eKFhDPhuqW91O+4bwUk=
|
google.golang.org/grpc v1.59.0 h1:Z5Iec2pjwb+LEOqzpB2MR12/eKFhDPhuqW91O+4bwUk=
|
||||||
google.golang.org/grpc v1.59.0/go.mod h1:aUPDwccQo6OTjy7Hct4AfBPD1GptF4fyUjIkQ9YtF98=
|
google.golang.org/grpc v1.59.0/go.mod h1:aUPDwccQo6OTjy7Hct4AfBPD1GptF4fyUjIkQ9YtF98=
|
||||||
|
google.golang.org/grpc v1.60.0 h1:6FQAR0kM31P6MRdeluor2w2gPaS4SVNrD/DNTxrQ15k=
|
||||||
|
google.golang.org/grpc v1.60.0/go.mod h1:OlCHIeLYqSSsLi6i49B5QGdzaMZK9+M7LXN2FKz4eGM=
|
||||||
|
google.golang.org/grpc v1.60.1 h1:26+wFr+cNqSGFcOXcabYC0lUVJVRa2Sb2ortSK7VrEU=
|
||||||
|
google.golang.org/grpc v1.60.1/go.mod h1:OlCHIeLYqSSsLi6i49B5QGdzaMZK9+M7LXN2FKz4eGM=
|
||||||
google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw=
|
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.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc=
|
||||||
google.golang.org/protobuf v1.27.1/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc=
|
google.golang.org/protobuf v1.27.1/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc=
|
||||||
|
|||||||
@@ -317,3 +317,21 @@ type Server struct {
|
|||||||
ScoreRaw float64 `db:"score_raw" json:"score_raw"`
|
ScoreRaw float64 `db:"score_raw" json:"score_raw"`
|
||||||
DeletionOn sql.NullTime `db:"deletion_on" json:"deletion_on"`
|
DeletionOn sql.NullTime `db:"deletion_on" json:"deletion_on"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type Zone struct {
|
||||||
|
ID uint32 `db:"id" json:"id"`
|
||||||
|
Name string `db:"name" json:"name"`
|
||||||
|
Description sql.NullString `db:"description" json:"description"`
|
||||||
|
ParentID sql.NullInt32 `db:"parent_id" json:"parent_id"`
|
||||||
|
Dns bool `db:"dns" json:"dns"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type ZoneServerCount struct {
|
||||||
|
ID uint32 `db:"id" json:"id"`
|
||||||
|
ZoneID uint32 `db:"zone_id" json:"zone_id"`
|
||||||
|
IpVersion ZoneServerCountsIpVersion `db:"ip_version" json:"ip_version"`
|
||||||
|
Date time.Time `db:"date" json:"date"`
|
||||||
|
CountActive uint32 `db:"count_active" json:"count_active"`
|
||||||
|
CountRegistered uint32 `db:"count_registered" json:"count_registered"`
|
||||||
|
NetspeedActive uint32 `db:"netspeed_active" json:"netspeed_active"`
|
||||||
|
}
|
||||||
|
|||||||
@@ -263,6 +263,52 @@ func (_d QuerierTxWithTracing) GetServerScores(ctx context.Context, arg GetServe
|
|||||||
return _d.QuerierTx.GetServerScores(ctx, arg)
|
return _d.QuerierTx.GetServerScores(ctx, arg)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// GetZoneByName implements QuerierTx
|
||||||
|
func (_d QuerierTxWithTracing) GetZoneByName(ctx context.Context, name string) (z1 Zone, err error) {
|
||||||
|
ctx, _span := otel.Tracer(_d._instance).Start(ctx, "QuerierTx.GetZoneByName")
|
||||||
|
defer func() {
|
||||||
|
if _d._spanDecorator != nil {
|
||||||
|
_d._spanDecorator(_span, map[string]interface{}{
|
||||||
|
"ctx": ctx,
|
||||||
|
"name": name}, map[string]interface{}{
|
||||||
|
"z1": z1,
|
||||||
|
"err": err})
|
||||||
|
} else if err != nil {
|
||||||
|
_span.RecordError(err)
|
||||||
|
_span.SetAttributes(
|
||||||
|
attribute.String("event", "error"),
|
||||||
|
attribute.String("message", err.Error()),
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
_span.End()
|
||||||
|
}()
|
||||||
|
return _d.QuerierTx.GetZoneByName(ctx, name)
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetZoneCounts implements QuerierTx
|
||||||
|
func (_d QuerierTxWithTracing) GetZoneCounts(ctx context.Context, zoneID uint32) (za1 []ZoneServerCount, err error) {
|
||||||
|
ctx, _span := otel.Tracer(_d._instance).Start(ctx, "QuerierTx.GetZoneCounts")
|
||||||
|
defer func() {
|
||||||
|
if _d._spanDecorator != nil {
|
||||||
|
_d._spanDecorator(_span, map[string]interface{}{
|
||||||
|
"ctx": ctx,
|
||||||
|
"zoneID": zoneID}, map[string]interface{}{
|
||||||
|
"za1": za1,
|
||||||
|
"err": err})
|
||||||
|
} else if err != nil {
|
||||||
|
_span.RecordError(err)
|
||||||
|
_span.SetAttributes(
|
||||||
|
attribute.String("event", "error"),
|
||||||
|
attribute.String("message", err.Error()),
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
_span.End()
|
||||||
|
}()
|
||||||
|
return _d.QuerierTx.GetZoneCounts(ctx, zoneID)
|
||||||
|
}
|
||||||
|
|
||||||
// GetZoneStatsData implements QuerierTx
|
// GetZoneStatsData implements QuerierTx
|
||||||
func (_d QuerierTxWithTracing) GetZoneStatsData(ctx context.Context) (ga1 []GetZoneStatsDataRow, err error) {
|
func (_d QuerierTxWithTracing) GetZoneStatsData(ctx context.Context) (ga1 []GetZoneStatsDataRow, err error) {
|
||||||
ctx, _span := otel.Tracer(_d._instance).Start(ctx, "QuerierTx.GetZoneStatsData")
|
ctx, _span := otel.Tracer(_d._instance).Start(ctx, "QuerierTx.GetZoneStatsData")
|
||||||
|
|||||||
@@ -18,6 +18,8 @@ type Querier interface {
|
|||||||
GetServerLogScoresByMonitorID(ctx context.Context, arg GetServerLogScoresByMonitorIDParams) ([]LogScore, error)
|
GetServerLogScoresByMonitorID(ctx context.Context, arg GetServerLogScoresByMonitorIDParams) ([]LogScore, error)
|
||||||
GetServerNetspeed(ctx context.Context, ip string) (uint32, error)
|
GetServerNetspeed(ctx context.Context, ip string) (uint32, error)
|
||||||
GetServerScores(ctx context.Context, arg GetServerScoresParams) ([]GetServerScoresRow, error)
|
GetServerScores(ctx context.Context, arg GetServerScoresParams) ([]GetServerScoresRow, error)
|
||||||
|
GetZoneByName(ctx context.Context, name string) (Zone, error)
|
||||||
|
GetZoneCounts(ctx context.Context, zoneID uint32) ([]ZoneServerCount, error)
|
||||||
GetZoneStatsData(ctx context.Context) ([]GetZoneStatsDataRow, error)
|
GetZoneStatsData(ctx context.Context) ([]GetZoneStatsDataRow, error)
|
||||||
GetZoneStatsV2(ctx context.Context, ip string) ([]GetZoneStatsV2Row, error)
|
GetZoneStatsV2(ctx context.Context, ip string) ([]GetZoneStatsV2Row, error)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,7 +13,11 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
const getMonitorByName = `-- name: GetMonitorByName :one
|
const getMonitorByName = `-- name: GetMonitorByName :one
|
||||||
select id, type, user_id, account_id, name, location, ip, ip_version, tls_name, api_key, status, config, client_version, last_seen, last_submit, created_on from monitors where tls_name = ?
|
select id, type, user_id, account_id, name, location, ip, ip_version, tls_name, api_key, status, config, client_version, last_seen, last_submit, created_on from monitors
|
||||||
|
where
|
||||||
|
tls_name like ?
|
||||||
|
order by id
|
||||||
|
limit 1
|
||||||
`
|
`
|
||||||
|
|
||||||
func (q *Queries) GetMonitorByName(ctx context.Context, tlsName sql.NullString) (Monitor, error) {
|
func (q *Queries) GetMonitorByName(ctx context.Context, tlsName sql.NullString) (Monitor, error) {
|
||||||
@@ -329,6 +333,62 @@ func (q *Queries) GetServerScores(ctx context.Context, arg GetServerScoresParams
|
|||||||
return items, nil
|
return items, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const getZoneByName = `-- name: GetZoneByName :one
|
||||||
|
select id, name, description, parent_id, dns from zones
|
||||||
|
where
|
||||||
|
name = ?
|
||||||
|
`
|
||||||
|
|
||||||
|
func (q *Queries) GetZoneByName(ctx context.Context, name string) (Zone, error) {
|
||||||
|
row := q.db.QueryRowContext(ctx, getZoneByName, name)
|
||||||
|
var i Zone
|
||||||
|
err := row.Scan(
|
||||||
|
&i.ID,
|
||||||
|
&i.Name,
|
||||||
|
&i.Description,
|
||||||
|
&i.ParentID,
|
||||||
|
&i.Dns,
|
||||||
|
)
|
||||||
|
return i, err
|
||||||
|
}
|
||||||
|
|
||||||
|
const getZoneCounts = `-- name: GetZoneCounts :many
|
||||||
|
select id, zone_id, ip_version, date, count_active, count_registered, netspeed_active from zone_server_counts
|
||||||
|
where zone_id = ?
|
||||||
|
order by date
|
||||||
|
`
|
||||||
|
|
||||||
|
func (q *Queries) GetZoneCounts(ctx context.Context, zoneID uint32) ([]ZoneServerCount, error) {
|
||||||
|
rows, err := q.db.QueryContext(ctx, getZoneCounts, zoneID)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
defer rows.Close()
|
||||||
|
var items []ZoneServerCount
|
||||||
|
for rows.Next() {
|
||||||
|
var i ZoneServerCount
|
||||||
|
if err := rows.Scan(
|
||||||
|
&i.ID,
|
||||||
|
&i.ZoneID,
|
||||||
|
&i.IpVersion,
|
||||||
|
&i.Date,
|
||||||
|
&i.CountActive,
|
||||||
|
&i.CountRegistered,
|
||||||
|
&i.NetspeedActive,
|
||||||
|
); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
items = append(items, i)
|
||||||
|
}
|
||||||
|
if err := rows.Close(); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
if err := rows.Err(); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return items, nil
|
||||||
|
}
|
||||||
|
|
||||||
const getZoneStatsData = `-- name: GetZoneStatsData :many
|
const getZoneStatsData = `-- name: GetZoneStatsData :many
|
||||||
SELECT zc.date, z.name, zc.ip_version, count_active, count_registered, netspeed_active
|
SELECT zc.date, z.name, zc.ip_version, count_active, count_registered, netspeed_active
|
||||||
FROM zone_server_counts zc USE INDEX (date_idx)
|
FROM zone_server_counts zc USE INDEX (date_idx)
|
||||||
|
|||||||
16
ntpdb/server.go
Normal file
16
ntpdb/server.go
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
package ntpdb
|
||||||
|
|
||||||
|
import "time"
|
||||||
|
|
||||||
|
func (s *Server) DeletionAge(dur time.Duration) bool {
|
||||||
|
if !s.DeletionOn.Valid {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
if dur > 0 {
|
||||||
|
dur = dur * -1
|
||||||
|
}
|
||||||
|
if s.DeletionOn.Time.Before(time.Now().Add(dur)) {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
return false
|
||||||
|
}
|
||||||
16
query.sql
16
query.sql
@@ -48,7 +48,11 @@ where
|
|||||||
ip = sqlc.arg(ip);
|
ip = sqlc.arg(ip);
|
||||||
|
|
||||||
-- name: GetMonitorByName :one
|
-- name: GetMonitorByName :one
|
||||||
select * from monitors where tls_name = ?;
|
select * from monitors
|
||||||
|
where
|
||||||
|
tls_name like sqlc.arg('tls_name')
|
||||||
|
order by id
|
||||||
|
limit 1;
|
||||||
|
|
||||||
-- name: GetMonitorsByID :many
|
-- name: GetMonitorsByID :many
|
||||||
select * from monitors
|
select * from monitors
|
||||||
@@ -79,3 +83,13 @@ where
|
|||||||
monitor_id = ?
|
monitor_id = ?
|
||||||
order by ts desc
|
order by ts desc
|
||||||
limit ?;
|
limit ?;
|
||||||
|
|
||||||
|
-- name: GetZoneByName :one
|
||||||
|
select * from zones
|
||||||
|
where
|
||||||
|
name = sqlc.arg(name);
|
||||||
|
|
||||||
|
-- name: GetZoneCounts :many
|
||||||
|
select * from zone_server_counts
|
||||||
|
where zone_id = ?
|
||||||
|
order by date;
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ import (
|
|||||||
"net/http/httptrace"
|
"net/http/httptrace"
|
||||||
"net/url"
|
"net/url"
|
||||||
"os"
|
"os"
|
||||||
|
"time"
|
||||||
|
|
||||||
"github.com/hashicorp/go-retryablehttp"
|
"github.com/hashicorp/go-retryablehttp"
|
||||||
"github.com/labstack/echo/v4"
|
"github.com/labstack/echo/v4"
|
||||||
@@ -33,6 +34,8 @@ func (srv *Server) graphImage(c echo.Context) error {
|
|||||||
log = log.With("serverID", serverID).With("type", imageType)
|
log = log.With("serverID", serverID).With("type", imageType)
|
||||||
log.Info("graph parameters")
|
log.Info("graph parameters")
|
||||||
|
|
||||||
|
span.SetAttributes(attribute.String("url.server_parameter", serverID))
|
||||||
|
|
||||||
if imageType != "offset.png" {
|
if imageType != "offset.png" {
|
||||||
return c.String(http.StatusNotFound, "invalid image name")
|
return c.String(http.StatusNotFound, "invalid image name")
|
||||||
}
|
}
|
||||||
@@ -46,9 +49,16 @@ func (srv *Server) graphImage(c echo.Context) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
serverData, err := srv.FindServer(ctx, serverID)
|
serverData, err := srv.FindServer(ctx, serverID)
|
||||||
|
if err != nil {
|
||||||
|
span.RecordError(err)
|
||||||
|
return c.String(http.StatusInternalServerError, "server error")
|
||||||
|
}
|
||||||
if serverData.ID == 0 {
|
if serverData.ID == 0 {
|
||||||
return c.String(http.StatusNotFound, "not found")
|
return c.String(http.StatusNotFound, "not found")
|
||||||
}
|
}
|
||||||
|
if serverData.DeletionAge(7 * 24 * time.Hour) {
|
||||||
|
return c.String(http.StatusNotFound, "not found")
|
||||||
|
}
|
||||||
|
|
||||||
if serverData.Ip != serverID {
|
if serverData.Ip != serverID {
|
||||||
return c.Redirect(308, fmt.Sprintf("/graph/%s/offset.png", serverData.Ip))
|
return c.Redirect(308, fmt.Sprintf("/graph/%s/offset.png", serverData.Ip))
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ import (
|
|||||||
"context"
|
"context"
|
||||||
"database/sql"
|
"database/sql"
|
||||||
"encoding/csv"
|
"encoding/csv"
|
||||||
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"math"
|
"math"
|
||||||
"net/http"
|
"net/http"
|
||||||
@@ -48,10 +49,10 @@ func (srv *Server) getHistory(ctx context.Context, c echo.Context, server ntpdb.
|
|||||||
if limitParam, err := strconv.Atoi(c.QueryParam("limit")); err == nil {
|
if limitParam, err := strconv.Atoi(c.QueryParam("limit")); err == nil {
|
||||||
limit = limitParam
|
limit = limitParam
|
||||||
} else {
|
} else {
|
||||||
limit = 50
|
limit = 100
|
||||||
}
|
}
|
||||||
if limit > 4000 {
|
if limit > 10000 {
|
||||||
limit = 4000
|
limit = 10000
|
||||||
}
|
}
|
||||||
|
|
||||||
since, _ := strconv.ParseInt(c.QueryParam("since"), 10, 64) // defaults to 0 so don't care if it parses
|
since, _ := strconv.ParseInt(c.QueryParam("since"), 10, 64) // defaults to 0 so don't care if it parses
|
||||||
@@ -77,11 +78,25 @@ func (srv *Server) getHistory(ctx context.Context, c echo.Context, server ntpdb.
|
|||||||
monitorID = 0 // don't filter on monitor ID
|
monitorID = 0 // don't filter on monitor ID
|
||||||
default:
|
default:
|
||||||
mID, err := strconv.ParseUint(monitorParam, 10, 32)
|
mID, err := strconv.ParseUint(monitorParam, 10, 32)
|
||||||
if err != nil {
|
if err == nil {
|
||||||
log.InfoContext(ctx, "invalid monitor parameter", "monitor", monitorParam)
|
monitorID = uint32(mID)
|
||||||
return nil, nil
|
} else {
|
||||||
|
// only accept the name prefix; no wildcards; trust the database
|
||||||
|
// to filter out any other crazy
|
||||||
|
if strings.ContainsAny(monitorParam, "_%. \t\n") {
|
||||||
|
return nil, echo.NewHTTPError(http.StatusNotFound, "monitor not found")
|
||||||
|
}
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
monitorParam = monitorParam + ".%"
|
||||||
|
monitor, err := q.GetMonitorByName(ctx, sql.NullString{Valid: true, String: monitorParam})
|
||||||
|
if err != nil {
|
||||||
|
log.Warn("could not find monitor", "name", monitorParam, "err", err)
|
||||||
|
return nil, echo.NewHTTPError(http.StatusNotFound, "monitor not found")
|
||||||
|
}
|
||||||
|
monitorID = monitor.ID
|
||||||
|
}
|
||||||
}
|
}
|
||||||
monitorID = uint32(mID)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
log.Info("monitor param", "monitor", monitorID)
|
log.Info("monitor param", "monitor", monitorID)
|
||||||
@@ -106,25 +121,38 @@ func (srv *Server) history(c echo.Context) error {
|
|||||||
|
|
||||||
mode := paramHistoryMode(c.Param("mode"))
|
mode := paramHistoryMode(c.Param("mode"))
|
||||||
if mode == historyModeUnknown {
|
if mode == historyModeUnknown {
|
||||||
return c.String(http.StatusNotFound, "invalid mode")
|
return echo.NewHTTPError(http.StatusNotFound, "invalid mode")
|
||||||
}
|
}
|
||||||
|
|
||||||
server, err := srv.FindServer(ctx, c.Param("server"))
|
server, err := srv.FindServer(ctx, c.Param("server"))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Error("find server", "err", err)
|
log.Error("find server", "err", err)
|
||||||
span.RecordError(err)
|
span.RecordError(err)
|
||||||
return c.String(http.StatusInternalServerError, "internal error")
|
return echo.NewHTTPError(http.StatusInternalServerError, "internal error")
|
||||||
|
}
|
||||||
|
if server.DeletionAge(30 * 24 * time.Hour) {
|
||||||
|
span.AddEvent("server deleted")
|
||||||
|
return echo.NewHTTPError(http.StatusNotFound, "server not found")
|
||||||
}
|
}
|
||||||
if server.ID == 0 {
|
if server.ID == 0 {
|
||||||
span.AddEvent("server not found")
|
span.AddEvent("server not found")
|
||||||
return c.String(http.StatusNotFound, "server not found")
|
return echo.NewHTTPError(http.StatusNotFound, "server not found")
|
||||||
}
|
}
|
||||||
|
|
||||||
history, err := srv.getHistory(ctx, c, server)
|
history, err := srv.getHistory(ctx, c, server)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Error("get history", "err", err)
|
var httpError *echo.HTTPError
|
||||||
span.RecordError(err)
|
if errors.As(err, &httpError) {
|
||||||
return c.String(http.StatusInternalServerError, "internal error")
|
if httpError.Code >= 500 {
|
||||||
|
log.Error("get history", "err", err)
|
||||||
|
span.RecordError(err)
|
||||||
|
}
|
||||||
|
return httpError
|
||||||
|
} else {
|
||||||
|
log.Error("get history", "err", err)
|
||||||
|
span.RecordError(err)
|
||||||
|
return c.String(http.StatusInternalServerError, "internal error")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
c.Response().Header().Set("Access-Control-Allow-Origin", "*")
|
c.Response().Header().Set("Access-Control-Allow-Origin", "*")
|
||||||
@@ -226,7 +254,8 @@ func (srv *Server) historyJSON(ctx context.Context, c echo.Context, server ntpdb
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if history.LogScores[len(history.LogScores)-1].Ts.After(time.Now().Add(-8 * time.Hour)) {
|
if len(history.LogScores) == 0 ||
|
||||||
|
history.LogScores[len(history.LogScores)-1].Ts.After(time.Now().Add(-8*time.Hour)) {
|
||||||
// cache for longer if data hasn't updated for a while
|
// cache for longer if data hasn't updated for a while
|
||||||
c.Request().Header.Set("Cache-Control", "s-maxage=3600,max-age=1800")
|
c.Request().Header.Set("Cache-Control", "s-maxage=3600,max-age=1800")
|
||||||
} else {
|
} else {
|
||||||
@@ -295,8 +324,10 @@ func (srv *Server) historyCSV(ctx context.Context, c echo.Context, history *logs
|
|||||||
|
|
||||||
// log.Info("entries", "count", len(history.LogScores), "out_bytes", b.Len())
|
// log.Info("entries", "count", len(history.LogScores), "out_bytes", b.Len())
|
||||||
|
|
||||||
c.Request().Header.Set("Cache-Control", "s-maxage=120,max-age=120")
|
c.Response().Header().Set("Cache-Control", "s-maxage=150,max-age=120")
|
||||||
|
c.Response().Header().Set("Content-Disposition", "inline")
|
||||||
return c.Blob(http.StatusOK, "text/csv", b.Bytes())
|
// Chrome and Firefox force-download text/csv files, so use text/plain
|
||||||
|
// https://bugs.chromium.org/p/chromium/issues/detail?id=152911
|
||||||
|
return c.Blob(http.StatusOK, "text/plain", b.Bytes())
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -83,12 +83,15 @@ func NewServer(ctx context.Context, configFile string) (*Server, error) {
|
|||||||
func (srv *Server) Run() error {
|
func (srv *Server) Run() error {
|
||||||
log := logger.Setup()
|
log := logger.Setup()
|
||||||
|
|
||||||
|
ntpconf := config.New()
|
||||||
|
|
||||||
ctx, cancel := context.WithCancel(srv.ctx)
|
ctx, cancel := context.WithCancel(srv.ctx)
|
||||||
defer cancel()
|
defer cancel()
|
||||||
|
|
||||||
g, _ := errgroup.WithContext(ctx)
|
g, _ := errgroup.WithContext(ctx)
|
||||||
|
|
||||||
g.Go(func() error {
|
g.Go(func() error {
|
||||||
|
version.RegisterMetric("dataapi", srv.metrics.Registry())
|
||||||
return srv.metrics.ListenAndServe(ctx, 9020)
|
return srv.metrics.ListenAndServe(ctx, 9020)
|
||||||
})
|
})
|
||||||
|
|
||||||
@@ -138,7 +141,7 @@ func (srv *Server) Run() error {
|
|||||||
span.SetAttributes(attribute.String("http.real_ip", c.RealIP()))
|
span.SetAttributes(attribute.String("http.real_ip", c.RealIP()))
|
||||||
|
|
||||||
// since the Go library (temporarily?) isn't including this
|
// since the Go library (temporarily?) isn't including this
|
||||||
span.SetAttributes(attribute.String("url.path", c.Path()))
|
span.SetAttributes(attribute.String("url.path", c.Request().RequestURI))
|
||||||
if q := c.QueryString(); len(q) > 0 {
|
if q := c.QueryString(); len(q) > 0 {
|
||||||
span.SetAttributes(attribute.String("url.query", q))
|
span.SetAttributes(attribute.String("url.query", q))
|
||||||
}
|
}
|
||||||
@@ -189,9 +192,25 @@ func (srv *Server) Run() error {
|
|||||||
e.GET("/api/usercc", srv.userCountryData)
|
e.GET("/api/usercc", srv.userCountryData)
|
||||||
e.GET("/api/server/dns/answers/:server", srv.dnsAnswers)
|
e.GET("/api/server/dns/answers/:server", srv.dnsAnswers)
|
||||||
e.GET("/api/server/scores/:server/:mode", srv.history)
|
e.GET("/api/server/scores/:server/:mode", srv.history)
|
||||||
|
|
||||||
|
if len(ntpconf.WebHostname()) > 0 {
|
||||||
|
e.POST("/api/server/scores/:server/:mode", func(c echo.Context) error {
|
||||||
|
// POST requests used to work, so make them not error out
|
||||||
|
mode := c.Param("mode")
|
||||||
|
server := c.Param("server")
|
||||||
|
query := c.Request().URL.Query()
|
||||||
|
return c.Redirect(
|
||||||
|
http.StatusSeeOther,
|
||||||
|
ntpconf.WebURL(
|
||||||
|
fmt.Sprintf("/scores/%s/%s", server, mode),
|
||||||
|
&query,
|
||||||
|
),
|
||||||
|
)
|
||||||
|
})
|
||||||
|
}
|
||||||
e.GET("/graph/:server/:type", srv.graphImage)
|
e.GET("/graph/:server/:type", srv.graphImage)
|
||||||
|
|
||||||
// e.GET("/api/server/scores/:server/:type", srv.logScores)
|
e.GET("/api/zone/counts/:zone_name", srv.zoneCounts)
|
||||||
|
|
||||||
g.Go(func() error {
|
g.Go(func() error {
|
||||||
return e.Start(":8030")
|
return e.Start(":8030")
|
||||||
|
|||||||
148
server/zones.go
Normal file
148
server/zones.go
Normal file
@@ -0,0 +1,148 @@
|
|||||||
|
package server
|
||||||
|
|
||||||
|
import (
|
||||||
|
"database/sql"
|
||||||
|
"errors"
|
||||||
|
"net/http"
|
||||||
|
"strconv"
|
||||||
|
"time"
|
||||||
|
|
||||||
|
"github.com/labstack/echo/v4"
|
||||||
|
"go.ntppool.org/common/logger"
|
||||||
|
"go.ntppool.org/common/tracing"
|
||||||
|
"go.ntppool.org/data-api/ntpdb"
|
||||||
|
)
|
||||||
|
|
||||||
|
func (srv *Server) zoneCounts(c echo.Context) error {
|
||||||
|
log := logger.Setup()
|
||||||
|
ctx, span := tracing.Tracer().Start(c.Request().Context(), "zoneCounts")
|
||||||
|
defer span.End()
|
||||||
|
|
||||||
|
// just cache for a short time by default
|
||||||
|
c.Response().Header().Set("Cache-Control", "public,max-age=240")
|
||||||
|
c.Response().Header().Set("Access-Control-Allow-Origin", "*")
|
||||||
|
c.Response().Header().Del("Vary")
|
||||||
|
|
||||||
|
q := ntpdb.NewWrappedQuerier(ntpdb.New(srv.db))
|
||||||
|
|
||||||
|
zone, err := q.GetZoneByName(ctx, c.Param("zone_name"))
|
||||||
|
if err != nil || zone.ID == 0 {
|
||||||
|
if errors.Is(err, sql.ErrNoRows) {
|
||||||
|
return c.String(http.StatusNotFound, "Not found")
|
||||||
|
}
|
||||||
|
log.ErrorContext(ctx, "could not query for zone", "err", err)
|
||||||
|
span.RecordError(err)
|
||||||
|
return echo.NewHTTPError(http.StatusInternalServerError, "internal error")
|
||||||
|
}
|
||||||
|
|
||||||
|
counts, err := q.GetZoneCounts(ctx, zone.ID)
|
||||||
|
if err != nil {
|
||||||
|
if !errors.Is(err, sql.ErrNoRows) {
|
||||||
|
log.ErrorContext(ctx, "get counts", "err", err)
|
||||||
|
span.RecordError(err)
|
||||||
|
return c.String(http.StatusInternalServerError, "internal error")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
type historyEntry struct {
|
||||||
|
D string `json:"d"` // date
|
||||||
|
Ts int `json:"ts"` // epoch timestamp
|
||||||
|
Rc int `json:"rc"` // count registered
|
||||||
|
Ac int `json:"ac"` // count active
|
||||||
|
W int `json:"w"` // netspeed active
|
||||||
|
Iv string `json:"iv"` // ip version
|
||||||
|
}
|
||||||
|
|
||||||
|
rv := struct {
|
||||||
|
History []historyEntry `json:"history"`
|
||||||
|
}{}
|
||||||
|
|
||||||
|
skipCount := 0.0
|
||||||
|
limit := 0
|
||||||
|
|
||||||
|
if limitParam := c.QueryParam("limit"); len(limitParam) > 0 {
|
||||||
|
if limitInt, err := strconv.Atoi(limitParam); err == nil && limitInt > 0 {
|
||||||
|
limit = limitInt
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
var mostRecentDate int64 = -1
|
||||||
|
if limit > 0 {
|
||||||
|
count := 0
|
||||||
|
dates := map[int64]bool{}
|
||||||
|
for _, c := range counts {
|
||||||
|
ep := c.Date.Unix()
|
||||||
|
if _, ok := dates[ep]; !ok {
|
||||||
|
count++
|
||||||
|
dates[ep] = true
|
||||||
|
mostRecentDate = ep
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if limit < count {
|
||||||
|
if limit > 1 {
|
||||||
|
skipCount = float64(count) / float64(limit-1)
|
||||||
|
} else {
|
||||||
|
// skip everything and use the special logic that we always include the most recent date
|
||||||
|
skipCount = float64(count) + 1
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
log.DebugContext(ctx, "mod", "count", count, "limit", limit, "mod", count%limit, "skipCount", skipCount)
|
||||||
|
// log.Info("limit plan", "date count", count, "limit", limit, "skipCount", skipCount)
|
||||||
|
}
|
||||||
|
|
||||||
|
toSkip := 0.0
|
||||||
|
if limit == 1 {
|
||||||
|
toSkip = skipCount // we just want to look for the last entry
|
||||||
|
}
|
||||||
|
lastDate := int64(0)
|
||||||
|
lastSkip := int64(0)
|
||||||
|
skipThreshold := 0.5
|
||||||
|
for _, c := range counts {
|
||||||
|
cDate := c.Date.Unix()
|
||||||
|
if (toSkip <= skipThreshold && cDate != lastSkip) ||
|
||||||
|
lastDate == cDate ||
|
||||||
|
mostRecentDate == cDate {
|
||||||
|
// log.Info("adding date", "date", c.Date.Format(time.DateOnly))
|
||||||
|
rv.History = append(rv.History, historyEntry{
|
||||||
|
D: c.Date.Format(time.DateOnly),
|
||||||
|
Ts: int(cDate),
|
||||||
|
Ac: int(c.CountActive),
|
||||||
|
Rc: int(c.CountRegistered),
|
||||||
|
W: int(c.NetspeedActive),
|
||||||
|
Iv: string(c.IpVersion),
|
||||||
|
})
|
||||||
|
lastDate = cDate
|
||||||
|
} else {
|
||||||
|
// log.Info("skipping date", "date", c.Date.Format(time.DateOnly))
|
||||||
|
if lastSkip == cDate {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
toSkip--
|
||||||
|
lastSkip = cDate
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
if toSkip <= skipThreshold && skipCount > 0 {
|
||||||
|
toSkip += skipCount
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
if limit > 0 {
|
||||||
|
count := 0
|
||||||
|
dates := map[int]bool{}
|
||||||
|
for _, c := range rv.History {
|
||||||
|
ep := c.Ts
|
||||||
|
if _, ok := dates[ep]; !ok {
|
||||||
|
count++
|
||||||
|
dates[ep] = true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
log.DebugContext(ctx, "result counts", "skipCount", skipCount, "limit", limit, "got", count)
|
||||||
|
}
|
||||||
|
|
||||||
|
c.Response().Header().Set("Cache-Control", "s-maxage=28800, max-age=7200")
|
||||||
|
return c.JSON(http.StatusOK, rv)
|
||||||
|
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user