netutils

package
v0.0.0-...-1941b44 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 6, 2024 License: MIT Imports: 23 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DefaultOptions = &Options{}

DefaultOptions default

View Source
var DefaultUserAgent = "Bulk/2.0"

DefaultUserAgent user-agent

View Source
var (
	ErrProxyNotConfigured = errors.New("Proxy is not configured correctly")
)

error

Functions

func FileHashEqual

func FileHashEqual(fullname string, eu *DownloadEntity) bool

FileHashEqual file exists

func IsHashNotMatch

func IsHashNotMatch(err error) bool

IsHashNotMatch is hash not match

func StripExtension

func StripExtension(name string) (string, string)

StripExtension stripExtension

Types

type DownloadEntity

type DownloadEntity struct {
	URL               string
	Destination       string
	HashValue         string
	Algorithm         string
	OverwriteExisting bool
}

DownloadEntity metadata

type Executor

type Executor struct {
	DestinationPath string
	UserAgent       string
	// contains filtered or unexported fields
}

Executor download executor

func NewExecutor

func NewExecutor(opt *Options) *Executor

NewExecutor new executor

func (*Executor) ResolveFileName

func (e *Executor) ResolveFileName(resp *http.Response, rawurl string) string

ResolveFileName resolve filename from response and rawurl

func (*Executor) ResolvePath

func (e *Executor) ResolvePath(resp *http.Response, eu *DownloadEntity) (string, error)

ResolvePath todo

func (*Executor) WebGet

func (e *Executor) WebGet(eu *DownloadEntity) (string, error)

WebGet get file from network

type Options

type Options struct {
	InsecureSkipVerify bool
	DisableAutoProxy   bool
	DestinationPath    string
	ProxyURL           string
	UserAgent          string
}

Options todo

func (*Options) GetProxyURL

func (opt *Options) GetProxyURL() string

GetProxyURL get proxy url

type ProxySettings

type ProxySettings struct {
	ProxyServer   string
	ProxyOverride string // aka no proxy
	// contains filtered or unexported fields
}

ProxySettings todo

func ResolveProxy

func ResolveProxy() (*ProxySettings, error)

ResolveProxy todo

type Verifier

type Verifier struct {
	H hash.Hash
	S string
}

Verifier hash Verifier

func NewSumizer

func NewSumizer(algorithm string) *Verifier

NewSumizer new

func NewVerifier

func NewVerifier(eu *DownloadEntity) *Verifier

NewVerifier todo

func (*Verifier) IsMatch

func (hc *Verifier) IsMatch(filename string) error

IsMatch hash is matched

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL