Replace QUIC with HTTP3/QUIC #43

Merged
nikooo777 merged 18 commits from http3 into master 2020-07-09 15:17:35 +02:00
2 changed files with 9 additions and 1 deletions
Showing only changes of commit 264390a2b2 - Show all commits

View file

@ -12,6 +12,7 @@ import (
ee "github.com/lbryio/lbry.go/v2/extras/errors"
"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/promauto"
@ -84,6 +85,7 @@ const (
errHashMismatch = "hash_mismatch"
errZeroByteBlob = "zero_byte_blob"
errInvalidCharacter = "invalid_character"
errBlobNotFound = "blob_not_found"
errNoErr = "no_error"
errOther = "other"
)
@ -146,6 +148,8 @@ func TrackError(direction string, e error) (shouldLog bool) { // shouldLog is a
errType = errUnexpectedEOFStr
} else if errors.Is(e, syscall.EPIPE) {
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
// I believe this is the same as EPipe when direction == "download", but not for upload
errType = errWriteBrokenPipe
@ -156,6 +160,8 @@ func TrackError(direction string, e error) (shouldLog bool) { // shouldLog is a
errType = errBlobTooBig
} else if strings.Contains(err.Error(), "hash of received blob data does not match hash from send request") {
errType = errHashMismatch
} else if strings.Contains(err.Error(), "blob not found") {
errType = errBlobNotFound
} else if strings.Contains(err.Error(), "0-byte blob received") {
errType = errZeroByteBlob
} else if strings.Contains(err.Error(), "invalid character") {

View file

@ -7,6 +7,7 @@ import (
"crypto/x509"
"encoding/json"
"encoding/pem"
"fmt"
"math/big"
"net/http"
"time"
@ -69,7 +70,8 @@ func (s *Server) Start(address string) error {
requestedBlob := vars["hash"]
blob, err := s.store.Get(requestedBlob)
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)
return
}