Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix linting errors #2

Merged
merged 1 commit into from
Oct 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions metrics/metrics.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// Package metrics provides a way to collect and expose metrics for the application.
package metrics

import "github.com/VictoriaMetrics/metrics"
Expand Down
8 changes: 6 additions & 2 deletions proxy/cert_gen.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,14 @@ import (
"time"
)

// hosts is a list of ip / dns names for the certificate
// GenerateCert generated a TLS certificate and key.
// - `hosts`: a list of ip / dns names to include in the certificate
func GenerateCert(validFor time.Duration, hosts []string) (cert, key []byte, err error) {
// copied from https://go.dev/src/crypto/tls/generate_cert.go
priv, err := ecdsa.GenerateKey(elliptic.P256(), rand.Reader)
if err != nil {
return nil, nil, err
}
keyUsage := x509.KeyUsageDigitalSignature

notBefore := time.Now()
Expand Down Expand Up @@ -75,5 +79,5 @@ func GenerateCert(validFor time.Duration, hosts []string) (cert, key []byte, err
return nil, nil, err
}
key = keyOut.Bytes()
return
return cert, key, nil
}
1 change: 1 addition & 0 deletions proxy/confighub.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// Package proxy provides the main proxy server.
package proxy

import "github.com/ethereum/go-ethereum/common"
Expand Down
15 changes: 10 additions & 5 deletions proxy/proxy.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,8 @@ func New(config Config) (*Proxy, error) {

func (prx *Proxy) ServeHTTP(w http.ResponseWriter, r *http.Request) {
if r.URL.Path == "/cert" {
w.Header().Add("content-type", "application/octet-stream")
w.Write(prx.publicCertPEM)
w.Header().Add("Content-Type", "application/octet-stream")
w.Write(prx.publicCertPEM) //nolint: errcheck
return
}

Expand All @@ -63,7 +63,7 @@ func (prx *Proxy) ServeHTTP(w http.ResponseWriter, r *http.Request) {
Timeout: 1 * time.Second,
}

req, err := http.NewRequest("POST", prx.Config.BuilderEndpoint, bytes.NewBuffer(body))
req, err := http.NewRequest(http.MethodPost, prx.Config.BuilderEndpoint, bytes.NewBuffer(body))
if err != nil {
prx.log.Error("Failed to create a req to the local builder", "err", err)
return
Expand Down Expand Up @@ -122,7 +122,9 @@ func (prx *Proxy) StartServersInBackground() error {
Handler: prx,
TLSConfig: &tls.Config{
Certificates: []tls.Certificate{*prx.certificate},
MinVersion: tls.VersionTLS13,
},
ReadHeaderTimeout: 2 * time.Second,
}
go func() {
prx.log.Info("Starting orderflow users input", "addr", srvUsers.Addr)
Expand All @@ -137,7 +139,9 @@ func (prx *Proxy) StartServersInBackground() error {
Handler: prx,
TLSConfig: &tls.Config{
Certificates: []tls.Certificate{*prx.certificate},
MinVersion: tls.VersionTLS13,
},
ReadHeaderTimeout: 2 * time.Second,
}
go func() {
prx.log.Info("Starting orderflow network input", "addr", srvNetwork.Addr)
Expand All @@ -148,8 +152,9 @@ func (prx *Proxy) StartServersInBackground() error {

// cert server
srvCert := &http.Server{
Addr: prx.Config.CertListenAddr,
Handler: prx,
Addr: prx.Config.CertListenAddr,
Handler: prx,
ReadHeaderTimeout: 2 * time.Second,
}
go func() {
prx.log.Info("Starting cert server", "addr", srvCert.Addr)
Expand Down
Loading