Documentation
¶
Overview ¶
Package resources contains code to download resources.
Index ¶
Constants ¶
View Source
const ( // Version contains the assets version. Version = 20201112191431 // ASNDatabaseName is the ASN-DB file name ASNDatabaseName = "asn.mmdb" // CountryDatabaseName is country-DB file name CountryDatabaseName = "country.mmdb" // BaseURL is the asset's repository base URL BaseURL = "https://github.com/" )
Variables ¶
View Source
var All = map[string]ResourceInfo{
"asn.mmdb": {
URLPath: "/ooni/probe-assets/releases/download/20201112191431/asn.mmdb.gz",
GzSHA256: "44945b2c056c05b7a48b13659bcdb92ea0b6d511e94cc615dd1467400ea57637",
SHA256: "b4b2d3c33ff4167a95850295421c13e7e3d0bd429c269cda86341c465c4e76e1",
},
"country.mmdb": {
URLPath: "/ooni/probe-assets/releases/download/20201112191431/country.mmdb.gz",
GzSHA256: "2cc5f66f6eada914a01b1f9da032beb7fef2a14e546de51028a9662d58cbf6b0",
SHA256: "c28169745af88c0f512072dcc6091e26a7969e4755ef1bb061e9eaee15900106",
},
}
All contains info on all known assets.
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client struct {
// HTTPClient is the HTTP client to use.
HTTPClient *http.Client
// Logger is the logger to use.
Logger model.Logger
// OSMkdirAll allows testing os.MkdirAll failures.
OSMkdirAll func(path string, perm os.FileMode) error
// UserAgent is the user agent to use.
UserAgent string
// WorkDir is the directory where to save resources.
WorkDir string
}
Client is a client for fetching resources.
func (*Client) EnsureForSingleResource ¶
func (c *Client) EnsureForSingleResource( ctx context.Context, name string, resource ResourceInfo, equal func(real, expected string) bool, gzipNewReader func(r io.Reader) (*gzip.Reader, error), ioutilReadAll func(r io.Reader) ([]byte, error), ) error
EnsureForSingleResource ensures that a single resource is downloaded and is current.
type ResourceInfo ¶
type ResourceInfo struct {
// URLPath is the resource's URL path.
URLPath string
// GzSHA256 is used to validate the downloaded file.
GzSHA256 string
// SHA256 is used to check whether the assets file
// stored locally is still up-to-date.
SHA256 string
}
ResourceInfo contains information on a resource.
Click to show internal directories.
Click to hide internal directories.