Replace QUIC with HTTP3/QUIC #43
2 changed files with 9 additions and 1 deletions
|
@ -12,6 +12,7 @@ import (
|
||||||
|
|
||||||
ee "github.com/lbryio/lbry.go/v2/extras/errors"
|
ee "github.com/lbryio/lbry.go/v2/extras/errors"
|
||||||
"github.com/lbryio/lbry.go/v2/extras/stop"
|
"github.com/lbryio/lbry.go/v2/extras/stop"
|
||||||
|
"github.com/lbryio/reflector.go/store"
|
||||||
|
|
||||||
"github.com/prometheus/client_golang/prometheus"
|
"github.com/prometheus/client_golang/prometheus"
|
||||||
"github.com/prometheus/client_golang/prometheus/promauto"
|
"github.com/prometheus/client_golang/prometheus/promauto"
|
||||||
|
@ -84,6 +85,7 @@ const (
|
||||||
errHashMismatch = "hash_mismatch"
|
errHashMismatch = "hash_mismatch"
|
||||||
errZeroByteBlob = "zero_byte_blob"
|
errZeroByteBlob = "zero_byte_blob"
|
||||||
errInvalidCharacter = "invalid_character"
|
errInvalidCharacter = "invalid_character"
|
||||||
|
errBlobNotFound = "blob_not_found"
|
||||||
errNoErr = "no_error"
|
errNoErr = "no_error"
|
||||||
errOther = "other"
|
errOther = "other"
|
||||||
)
|
)
|
||||||
|
@ -146,6 +148,8 @@ func TrackError(direction string, e error) (shouldLog bool) { // shouldLog is a
|
||||||
errType = errUnexpectedEOFStr
|
errType = errUnexpectedEOFStr
|
||||||
} else if errors.Is(e, syscall.EPIPE) {
|
} else if errors.Is(e, syscall.EPIPE) {
|
||||||
errType = errEPipe
|
errType = errEPipe
|
||||||
|
} else if errors.Is(e, store.ErrBlobNotFound) {
|
||||||
|
errType = errBlobNotFound
|
||||||
} else if strings.Contains(err.Error(), "write: broken pipe") { // tried to write to a pipe or socket that was closed by the peer
|
} else if strings.Contains(err.Error(), "write: broken pipe") { // tried to write to a pipe or socket that was closed by the peer
|
||||||
// I believe this is the same as EPipe when direction == "download", but not for upload
|
// I believe this is the same as EPipe when direction == "download", but not for upload
|
||||||
errType = errWriteBrokenPipe
|
errType = errWriteBrokenPipe
|
||||||
|
@ -156,6 +160,8 @@ func TrackError(direction string, e error) (shouldLog bool) { // shouldLog is a
|
||||||
errType = errBlobTooBig
|
errType = errBlobTooBig
|
||||||
} else if strings.Contains(err.Error(), "hash of received blob data does not match hash from send request") {
|
} else if strings.Contains(err.Error(), "hash of received blob data does not match hash from send request") {
|
||||||
errType = errHashMismatch
|
errType = errHashMismatch
|
||||||
|
} else if strings.Contains(err.Error(), "blob not found") {
|
||||||
|
errType = errBlobNotFound
|
||||||
} else if strings.Contains(err.Error(), "0-byte blob received") {
|
} else if strings.Contains(err.Error(), "0-byte blob received") {
|
||||||
errType = errZeroByteBlob
|
errType = errZeroByteBlob
|
||||||
} else if strings.Contains(err.Error(), "invalid character") {
|
} else if strings.Contains(err.Error(), "invalid character") {
|
||||||
|
|
|
@ -7,6 +7,7 @@ import (
|
||||||
"crypto/x509"
|
"crypto/x509"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"encoding/pem"
|
"encoding/pem"
|
||||||
|
"fmt"
|
||||||
"math/big"
|
"math/big"
|
||||||
"net/http"
|
"net/http"
|
||||||
"time"
|
"time"
|
||||||
|
@ -69,7 +70,8 @@ func (s *Server) Start(address string) error {
|
||||||
requestedBlob := vars["hash"]
|
requestedBlob := vars["hash"]
|
||||||
blob, err := s.store.Get(requestedBlob)
|
blob, err := s.store.Get(requestedBlob)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Errorln(errors.FullTrace(err))
|
fmt.Printf("%s: %s", requestedBlob, errors.FullTrace(err))
|
||||||
|
s.logError(err)
|
||||||
http.Error(w, err.Error(), http.StatusBadRequest)
|
http.Error(w, err.Error(), http.StatusBadRequest)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue