mirror of
https://github.com/MetaCubeX/mihomo.git
synced 2026-03-02 10:50:24 +00:00
chore: support ETag for providers
This commit is contained in:
29
constant/provider/hash.go
Normal file
29
constant/provider/hash.go
Normal file
@@ -0,0 +1,29 @@
|
||||
package provider
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"crypto/md5"
|
||||
)
|
||||
|
||||
type HashType [md5.Size]byte // MD5
|
||||
|
||||
func MakeHash(data []byte) HashType {
|
||||
return md5.Sum(data)
|
||||
}
|
||||
|
||||
func (h HashType) Equal(hash HashType) bool {
|
||||
return h == hash
|
||||
}
|
||||
|
||||
func (h HashType) EqualBytes(hashBytes []byte) bool {
|
||||
return bytes.Equal(hashBytes, h[:])
|
||||
}
|
||||
|
||||
func (h HashType) Bytes() []byte {
|
||||
return h[:]
|
||||
}
|
||||
|
||||
func (h HashType) IsValid() bool {
|
||||
var zero HashType
|
||||
return h != zero
|
||||
}
|
||||
@@ -32,7 +32,7 @@ func (v VehicleType) String() string {
|
||||
}
|
||||
|
||||
type Vehicle interface {
|
||||
Read(ctx context.Context) ([]byte, error)
|
||||
Read(ctx context.Context, oldHash HashType) (buf []byte, hash HashType, err error)
|
||||
Path() string
|
||||
Url() string
|
||||
Proxy() string
|
||||
|
||||
Reference in New Issue
Block a user