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

@ -70,7 +70,7 @@ const (
errReadConnReset = "read_conn_reset"
errWriteConnReset = "write_conn_reset"
errReadConnTimedOut = "read_conn_timed_out"
errNoNetworkActivity = "no_network_activity"
errNoNetworkActivity = "no_network_activity"
errWriteConnTimedOut = "write_conn_timed_out"
errWriteBrokenPipe = "write_broken_pipe"
errEPipe = "e_pipe"
@ -84,6 +84,7 @@ const (
errHashMismatch = "hash_mismatch"
errZeroByteBlob = "zero_byte_blob"
errInvalidCharacter = "invalid_character"
errNoErr = "no_error"
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
//log.Warnln("read conn timed out is not the same as ETIMEDOUT")
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")
errType = errNoNetworkActivity
} 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
} else if _, ok := e.(*json.SyntaxError); ok {
errType = errJSONSyntax
} else if strings.Contains(err.Error(), "NO_ERROR") {
errType = errNoErr
} else {
log.Warnf("error '%s' for direction '%s' is not being tracked", err.TypeName(), direction)
shouldLog = true

View file

@ -27,6 +27,15 @@ func NewStore(opts StoreOpts) *Store {
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
func (p *Store) Has(hash string) (bool, error) {
if p.connErr != nil {