Skip to content

Commit 4520768

Browse files
committed
status api, linter
1 parent 3427877 commit 4520768

File tree

7 files changed

+68
-8
lines changed

7 files changed

+68
-8
lines changed

.golangci.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ linters:
2727
- wsl
2828
- exhaustruct
2929
- depguard
30+
- err113
3031

3132
#
3233
# Disabled because of generics:

README.md

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,12 @@ WIP Toolbox
66
- [Create TLS certificate + key (PEM format)](cmd/tls-gen/main.go)
77
- [Server using custom TLS certificate](cmd/https-server/main.go)
88
- [Client allowing only server using the custom TLS certificate](cmd/https-client/main.go)
9+
- [Status API server for recording and querying events](cmd/status-api/)
910

1011
## Usage
1112

1213
```bash
13-
# create the TLS cert
14+
# create the TLS cert (cert.pem) and key (key.pem)
1415
$ go run cmd/tls-gen/main.go --host 127.0.0.1,localhost
1516

1617
# run the server (serving the created TLS cert)
@@ -23,6 +24,31 @@ $ curl --cacert cert.pem https://127.0.0.1:8080
2324
$ go run cmd/https-client/main.go
2425
```
2526

27+
Status api server that can be used to record and query events.
28+
29+
```bash
30+
# Start the server
31+
$ go run cmd/status-api/*
32+
33+
# Add events
34+
$ curl localhost:8082/api/v1/new_event?message=111
35+
$ curl localhost:8082/api/v1/new_event?message=222
36+
37+
# Query events
38+
$ curl -s localhost:8082/api/v1/events | jq
39+
[
40+
{
41+
"ReceivedAt": "2024-09-21T07:51:47.709512Z",
42+
"Message": "111"
43+
},
44+
{
45+
"ReceivedAt": "2024-09-21T07:51:49.294175Z",
46+
"Message": "222"
47+
}
48+
]
49+
```
50+
51+
2652
## Next Steps
2753

2854
These partly overlap with https://github.com/flashbots/cvm-reverse-proxy:

cmd/ecdsa-gen/main.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import (
99
"github.com/ethereum/go-ethereum/common/hexutil"
1010
"github.com/ethereum/go-ethereum/crypto"
1111
"github.com/flashbots/go-template/common"
12-
"github.com/urfave/cli/v2" // imports as package "cli"
12+
cli "github.com/urfave/cli/v2" // imports as package "cli"
1313
)
1414

1515
// var flags []cli.Flag = []cli.Flag{

cmd/https-client/main.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import (
1010
"os"
1111

1212
"github.com/flashbots/go-template/common"
13-
"github.com/urfave/cli/v2" // imports as package "cli"
13+
cli "github.com/urfave/cli/v2"
1414
)
1515

1616
var flags []cli.Flag = []cli.Flag{
@@ -57,7 +57,8 @@ func runCli(cCtx *cli.Context) error {
5757
client := &http.Client{
5858
Transport: &http.Transport{
5959
TLSClientConfig: &tls.Config{
60-
RootCAs: roots,
60+
RootCAs: roots,
61+
MinVersion: tls.VersionTLS13,
6162
},
6263
},
6364
}

cmd/https-server/main.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import (
99
"time"
1010

1111
"github.com/flashbots/go-template/common"
12-
"github.com/urfave/cli/v2" // imports as package "cli"
12+
cli "github.com/urfave/cli/v2" // imports as package "cli"
1313
)
1414

1515
var flags []cli.Flag = []cli.Flag{

go.mod

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,22 @@ toolchain go1.23.1
66

77
require (
88
github.com/ethereum/go-ethereum v1.14.9
9+
github.com/flashbots/go-utils v0.6.1-0.20240611151222-14d18c5e94d0
10+
github.com/go-chi/chi/v5 v5.1.0
911
github.com/urfave/cli/v2 v2.27.2
1012
)
1113

1214
require (
1315
github.com/btcsuite/btcd/btcec/v2 v2.3.4 // indirect
1416
github.com/cpuguy83/go-md2man/v2 v2.0.4 // indirect
1517
github.com/decred/dcrd/dcrec/secp256k1/v4 v4.2.0 // indirect
18+
github.com/google/uuid v1.6.0 // indirect
1619
github.com/holiman/uint256 v1.3.1 // indirect
1720
github.com/russross/blackfriday/v2 v2.1.0 // indirect
21+
github.com/sirupsen/logrus v1.9.3 // indirect
1822
github.com/xrash/smetrics v0.0.0-20240312152122-5f08fbb34913 // indirect
23+
go.uber.org/multierr v1.11.0 // indirect
24+
go.uber.org/zap v1.27.0 // indirect
1925
golang.org/x/crypto v0.22.0 // indirect
20-
golang.org/x/sys v0.22.0 // indirect
26+
golang.org/x/sys v0.25.0 // indirect
2127
)

go.sum

Lines changed: 28 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ github.com/btcsuite/btcd/chaincfg/chainhash v1.0.1 h1:q0rUy8C/TYNBQS1+CGKw68tLOF
44
github.com/btcsuite/btcd/chaincfg/chainhash v1.0.1/go.mod h1:7SFka0XMvUgj3hfZtydOrQY2mwhPclbT2snogU7SQQc=
55
github.com/cpuguy83/go-md2man/v2 v2.0.4 h1:wfIWP927BUkWJb2NmU/kNDYIBTh/ziUX91+lVfRxZq4=
66
github.com/cpuguy83/go-md2man/v2 v2.0.4/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o=
7+
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
78
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
89
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
910
github.com/decred/dcrd/crypto/blake256 v1.0.1 h1:7PltbUIQB7u/FfZ39+DGa/ShuMyJ5ilcvdfma9wOH6Y=
@@ -12,15 +13,40 @@ github.com/decred/dcrd/dcrec/secp256k1/v4 v4.2.0 h1:8UrgZ3GkP4i/CLijOJx79Yu+etly
1213
github.com/decred/dcrd/dcrec/secp256k1/v4 v4.2.0/go.mod h1:v57UDF4pDQJcEfFUCRop3lJL149eHGSe9Jvczhzjo/0=
1314
github.com/ethereum/go-ethereum v1.14.9 h1:J7iwXDrtUyE9FUjUYbd4c9tyzwMh6dTJsKzo9i6SrwA=
1415
github.com/ethereum/go-ethereum v1.14.9/go.mod h1:QeW+MtTpRdBEm2pUFoonByee8zfHv7kGp0wK0odvU1I=
16+
github.com/flashbots/go-utils v0.6.1-0.20240611151222-14d18c5e94d0 h1:aJ+jlJVI8p8Wnj/+o6Ds/URwMg0d/+msQB7RgrxacOA=
17+
github.com/flashbots/go-utils v0.6.1-0.20240611151222-14d18c5e94d0/go.mod h1:l5jkDHCCt225ohwNtqafEJSKV7PfrFfXb2JT145I1ms=
18+
github.com/go-chi/chi/v5 v5.1.0 h1:acVI1TYaD+hhedDJ3r54HyA6sExp3HfXq7QWEEY/xMw=
19+
github.com/go-chi/chi/v5 v5.1.0/go.mod h1:DslCQbL2OYiznFReuXYUmQ2hGd1aDpCnlMNITLSKoi8=
20+
github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0=
21+
github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
1522
github.com/holiman/uint256 v1.3.1 h1:JfTzmih28bittyHM8z360dCjIA9dbPIBlcTI6lmctQs=
1623
github.com/holiman/uint256 v1.3.1/go.mod h1:EOMSn4q6Nyt9P6efbI3bueV4e1b3dGlUCXeiRV4ng7E=
24+
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
25+
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
1726
github.com/russross/blackfriday/v2 v2.1.0 h1:JIOH55/0cWyOuilr9/qlrm0BSXldqnqwMsf35Ld67mk=
1827
github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
28+
github.com/sirupsen/logrus v1.9.3 h1:dueUQJ1C2q9oE3F7wvmSGAaVtTmUizReu6fjN8uqzbQ=
29+
github.com/sirupsen/logrus v1.9.3/go.mod h1:naHLuLoDiP4jHNo9R0sCBMtWGeIprob74mVsIT4qYEQ=
30+
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
31+
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
32+
github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg=
33+
github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
1934
github.com/urfave/cli/v2 v2.27.2 h1:6e0H+AkS+zDckwPCUrZkKX38mRaau4nL2uipkJpbkcI=
2035
github.com/urfave/cli/v2 v2.27.2/go.mod h1:g0+79LmHHATl7DAcHO99smiR/T7uGLw84w8Y42x+4eM=
2136
github.com/xrash/smetrics v0.0.0-20240312152122-5f08fbb34913 h1:+qGGcbkzsfDQNPPe9UDgpxAWQrhbbBXOYJFQDq/dtJw=
2237
github.com/xrash/smetrics v0.0.0-20240312152122-5f08fbb34913/go.mod h1:4aEEwZQutDLsQv2Deui4iYQ6DWTxR14g6m8Wv88+Xqk=
38+
go.uber.org/goleak v1.3.0 h1:2K3zAYmnTNqV73imy9J1T3WC+gmCePx2hEGkimedGto=
39+
go.uber.org/goleak v1.3.0/go.mod h1:CoHD4mav9JJNrW/WLlf7HGZPjdw8EucARQHekz1X6bE=
40+
go.uber.org/multierr v1.11.0 h1:blXXJkSxSSfBVBlC76pxqeO+LN3aDfLQo+309xJstO0=
41+
go.uber.org/multierr v1.11.0/go.mod h1:20+QtiLqy0Nd6FdQB9TLXag12DsQkrbs3htMFfDN80Y=
42+
go.uber.org/zap v1.27.0 h1:aJMhYGrd5QSmlpLMr2MftRKl7t8J8PTZPA732ud/XR8=
43+
go.uber.org/zap v1.27.0/go.mod h1:GB2qFLM7cTU87MWRP2mPIjqfIDnGu+VIO4V/SdhGo2E=
2344
golang.org/x/crypto v0.22.0 h1:g1v0xeRhjcugydODzvb3mEM9SQ0HGp9s/nh3COQ/C30=
2445
golang.org/x/crypto v0.22.0/go.mod h1:vr6Su+7cTlO45qkww3VDJlzDn0ctJvRgYbC2NvXHt+M=
25-
golang.org/x/sys v0.22.0 h1:RI27ohtqKCnwULzJLqkv897zojh5/DwS/ENaMzUOaWI=
26-
golang.org/x/sys v0.22.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
46+
golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
47+
golang.org/x/sys v0.25.0 h1:r+8e+loiHxRqhXVl6ML1nO3l1+oFoWbnlu2Ehimmi34=
48+
golang.org/x/sys v0.25.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
49+
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
50+
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
51+
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
52+
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=

0 commit comments

Comments
 (0)