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 14 additions and 2 deletions
Showing only changes of commit e98794e125 - Show all commits

View file

@ -84,6 +84,7 @@ const (
errHashMismatch = "hash_mismatch" errHashMismatch = "hash_mismatch"
errZeroByteBlob = "zero_byte_blob" errZeroByteBlob = "zero_byte_blob"
errInvalidCharacter = "invalid_character" errInvalidCharacter = "invalid_character"
errNoErr = "no_error"
errOther = "other" errOther = "other"
) )
@ -134,7 +135,7 @@ func TrackError(direction string, e error) (shouldLog bool) { // shouldLog is a
} else if strings.Contains(err.Error(), "read: connection timed out") { // the other side closed the connection using TCP reset } else if strings.Contains(err.Error(), "read: connection timed out") { // the other side closed the connection using TCP reset
//log.Warnln("read conn timed out is not the same as ETIMEDOUT") //log.Warnln("read conn timed out is not the same as ETIMEDOUT")
errType = errReadConnTimedOut errType = errReadConnTimedOut
}else if strings.Contains(err.Error(), "NO_ERROR: No recent network activity") { // the other side closed the QUIC connection } else if strings.Contains(err.Error(), "NO_ERROR: No recent network activity") { // the other side closed the QUIC connection
//log.Warnln("read conn timed out is not the same as ETIMEDOUT") //log.Warnln("read conn timed out is not the same as ETIMEDOUT")
errType = errNoNetworkActivity errType = errNoNetworkActivity
} else if strings.Contains(err.Error(), "write: connection timed out") { } else if strings.Contains(err.Error(), "write: connection timed out") {
@ -161,6 +162,8 @@ func TrackError(direction string, e error) (shouldLog bool) { // shouldLog is a
errType = errInvalidCharacter errType = errInvalidCharacter
} else if _, ok := e.(*json.SyntaxError); ok { } else if _, ok := e.(*json.SyntaxError); ok {
errType = errJSONSyntax errType = errJSONSyntax
} else if strings.Contains(err.Error(), "NO_ERROR") {
errType = errNoErr
} else { } else {
log.Warnf("error '%s' for direction '%s' is not being tracked", err.TypeName(), direction) log.Warnf("error '%s' for direction '%s' is not being tracked", err.TypeName(), direction)
shouldLog = true shouldLog = true

View file

@ -27,6 +27,15 @@ func NewStore(opts StoreOpts) *Store {
return &Store{client: c, connErr: err} return &Store{client: c, connErr: err}
} }
// CloseStore closes the client that gets initialized when the store is initialized
func (p *Store) CloseStore() error {
err := p.client.stream.Close()
if err != nil {
return errors.Err(err)
}
return p.client.Close()
}
// Has asks the peer if they have a hash // Has asks the peer if they have a hash
func (p *Store) Has(hash string) (bool, error) { func (p *Store) Has(hash string) (bool, error) {
if p.connErr != nil { if p.connErr != nil {