goxel

package module
v0.0.0-...-9c083bd Latest Latest
Warning

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

Go to latest
Published: May 19, 2024 License: Apache-2.0 Imports: 24 Imported by: 0

README

GoXel is a download accelerator written in Golang, which inspired by axel.

Features

  • Unlimited multithreading downloads
  • Download multiple files concurrently
  • Resume unfinished downloads
  • Monitor download progress
  • Guess filename from URL path

Installation

go install github.com/chengxuncc/goxel/cmd/goxel@latest

Usage

$ bin/goxel -h
GoXel is a download accelerator written in Go
Usage: goxel [options] [url1] [url2] [url...]
      --alldebrid-password string         Alldebrid password, can also be passed in the GOXEL_ALLDEBRID_PASSWD environment variable                                                                                 
      --alldebrid-username string         Alldebrid username, can also be passed in the GOXEL_ALLDEBRID_USERNAME environment variable                                                                               
      --buffer-size int                   Buffer size in KB (default 256)
  -f, --file string                       File containing links to download (1 per line)
      --header header-name=header-value   Extra header(s) (default [])
  -h, --help                              This information
      --insecure                          Bypass SSL validation
      --max-conn int                      Max number of connections (default 8)
  -m, --max-conn-file int                 Max number of connections per file (default 4)
      --no-resume                         Don't resume downloads
  -o, --output string                     Output directory
      --overwrite                         Overwrite existing file(s)
  -p, --proxy string                      Proxy string: (http|https|socks5)://0.0.0.0:0000
  -q, --quiet                             No stdout output
  -s, --scroll                            Scroll output instead of in place display
      --version                           Version

Visit https://github.com/m1ck43l/goxel/issues to report bugs.

Benchmark

This benchmark compares Axel and GoXel for multiple downloads using files from https://www.thinkbroadband.com/download. All links were done using a broadhand connection: 455.0 Mbit/s download, 276.4 Mbit/s upload, lantency 3ms over WiFi.

Benchmark

Contributing

Pull requests for new features, bug fixes, and suggestions are welcome!

License

Apache 2

Credits

m1ck43l/goxel

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BuildURLSlice

func BuildURLSlice(urls []string, inputFile string) []string

BuildURLSlice builds the initial URLs list containing URLs from command line and input file

func DownloadWorker

func DownloadWorker(i int, wg *sync.WaitGroup, chunks chan download, bs int, finished chan header)

DownloadWorker is the worker functions that processes the download of one Chunk. It takes a WaitGroup to ensure all workers have finished before exiting the program. It also takes a Channel of Chunks to receive the chunks to download.

func Monitoring

func Monitoring(files []*File, done chan bool, d chan download, quiet bool)

Monitoring handles the files' termination and monitoring

func NewClient

func NewClient() (*http.Client, error)

NewClient returns a HTTP client with the requested configuration It supports HTTP and SOCKS proxies

func RebalanceChunks

func RebalanceChunks(h chan header, d chan download, files []*File)

RebalanceChunks ensures new connections have a chunk attributed to help delayed ones

Types

type Chunk

type Chunk struct {
	ID, Worker              uint32
	Start, End, Done, Total uint64
}

Chunk stores a part of a file being downloaded

func (*Chunk) BuildProgress

func (c *Chunk) BuildProgress(buf []string, unit float64)

BuildProgress builds the progress display for a specific Chunk "-" means downloaded during this process " " means not yet downloaded

func (*Chunk) Write

func (c *Chunk) Write(b []byte) (int, error)

type ConsoleMonitoring

type ConsoleMonitoring struct {
	// contains filtered or unexported fields
}

ConsoleMonitoring monitors the current downloads and display the speed and progress for each files

type File

type File struct {
	URL, Output, OutputWork      string
	Chunks                       []Chunk
	Finished, Valid, Initialized bool
	Error                        string
	Size, Initial                uint64
	Progress                     []string
	Mux                          sync.Mutex
	ID                           uint32
}

File stores a file to be downloaded

func (*File) BuildChunks

func (f *File) BuildChunks(wg *sync.WaitGroup, chunks chan download, nbrPerFile int)

BuildChunks builds the Chunks slice for each part of the file to be downloaded It retrieves existing metadata file in order to resume downloads. Each created chunk is sent to the channel past in parameters. The nbrPerFile parameter determines the max number of splits for each file. In case the download is being resumed, the nbrPerFile is ignored in favor of the number stored in the metadata file.

func (*File) BuildProgress

func (f *File) BuildProgress(unit float64) string

BuildProgress builds the progress display for a specific File "-" means downloaded during this process " " means not yet downloaded "+" means already downloaded during a previous process (resumed)

func (*File) ResumeChunks

func (f *File) ResumeChunks(maxConnPerFile int) bool

ResumeChunks tries to resume the current download by checking if the file exists and is valid

func (*File) UpdateStatus

func (f *File) UpdateStatus(commit bool) (float64, uint64, uint64, uint64)

UpdateStatus returns the current status of the download The first returned value is the progress percentage The second returned value is the number of active connections for this file The third returned value is the number of bytes downloaded The last returned value is the number of bytes downloaded during this session

type GoXel

type GoXel struct {
	IgnoreSSLVerification, OverwriteOutputFile, Quiet, Scroll, Resume bool
	OutputDirectory, InputFile, Proxy                                 string
	MaxConnections, MaxConnectionsPerFile, BufferSize                 int
	Headers                                                           map[string]string
	URLs                                                              []string
}

GoXel structure contains all the parameters to be used for the GoXel accelerator Credentials can either be passed in command line arguments or using the following environment variables: - GOXEL_ALLDEBRID_USERNAME - GOXEL_ALLDEBRID_PASSWD

func NewGoXel

func NewGoXel() *GoXel

NewGoXel builds a GoXel instance based on the command line arguments

func (*GoXel) Run

func (g *GoXel) Run()

Run starts the downloading process

type Message

type Message struct {
	FileID           uint32
	Content, Context string
	Type             MessageType
}

Message contains global messages to be displayed by monitoring

func NewErrorMessage

func NewErrorMessage(context string, content string) Message

NewErrorMessage builds an Error message with no related file

func NewErrorMessageForFile

func NewErrorMessageForFile(fileID uint32, context string, content string) Message

NewErrorMessageForFile builds an Error message with a related file

func NewInfoMessage

func NewInfoMessage(context string, content string) Message

NewInfoMessage builds an Info message with no related file

func NewInfoMessageForFile

func NewInfoMessageForFile(fileID uint32, context string, content string) Message

NewInfoMessageForFile builds an Info message with a related file

func NewMessageForFile

func NewMessageForFile(fileID uint32, context string, content string, t MessageType) Message

NewMessageForFile builds a standard Message

func NewWarningMessage

func NewWarningMessage(context string, content string) Message

NewWarningMessage builds a Warning message with no related file

func NewWarningMessageForFile

func NewWarningMessageForFile(fileID uint32, context string, content string) Message

NewWarningMessageForFile builds a Warning message with a related file

type MessageType

type MessageType int

MessageType identifies the severity of the message

const (
	Info MessageType = iota + 1
	Warning
	Error
)

Message Severities

func (MessageType) String

func (t MessageType) String() string

type QuietMonitoring

type QuietMonitoring struct {
	// contains filtered or unexported fields
}

QuietMonitoring only ensures the Files are synced every Xs

type StandardURLPreprocessor

type StandardURLPreprocessor struct{}

StandardURLPreprocessor ensures the URL is correct and trims it

type URLPreprocessor

type URLPreprocessor interface {
	// contains filtered or unexported methods
}

URLPreprocessor defines the interface for the URL processors New processors can easily be added to transform input URLs for example

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

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