tbget

package
v0.0.0-...-943de35 Latest Latest
Warning

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

Go to latest
Published: Apr 11, 2022 License: MIT Imports: 35 Imported by: 1

Documentation

Index

Constants

View Source
const FFOX_UPDATES_URL string = "https://download.mozilla.org/?product=firefox-latest&os=%s&lang=%s"

FFOX_UPDATES_URL is the URL to the Firefox updates page

View Source
const TOR_UPDATES_URL string = "https://aus1.torproject.org/torbrowser/update_3/release/downloads.json"

TOR_UPDATES_URL is the URL of the Tor Browser update list.

Variables

View Source
var ARCH = "64"

ARCH is the architecture of the TBDownloader.

View Source
var (
	// DefaultIETFLang is the default language for the TBDownloader.
	DefaultIETFLang, _ = jibber_jabber.DetectIETF()
)
View Source
var OS = "linux"

OS is the operating system of the TBDownloader.

View Source
var WORKING_DIR = ""

WORKING_DIR is the working directory for the application.

Functions

func Create

func Create(path string) (*os.File, error)

func DOWNLOAD_FIREFOX_PATH

func DOWNLOAD_FIREFOX_PATH() string

DOWNLOAD_PATH returns the path to the downloads.

func DOWNLOAD_PATH

func DOWNLOAD_PATH() string

DOWNLOAD_PATH returns the path to the downloads.

func DefaultDir

func DefaultDir() string

DefaultDir returns the default directory for the application.

func FetchContentLength

func FetchContentLength(dl, name string) (int64, error)

func FileExists

func FileExists(path string) bool

FileExists returns true if the given file exists. It will return true if used on an existing directory.

func FindSnarkDirectory

func FindSnarkDirectory() (string, error)

func GetTorBrowserVersionFromUpdateURL

func GetTorBrowserVersionFromUpdateURL() (string, error)

func Languages

func Languages() []string

func MirrorIsI2P

func MirrorIsI2P(mirror string) bool

func Seconds

func Seconds(now int) int

Seconds increments the seconds and displays the number of seconds every 10 seconds

func SetupProxy

func SetupProxy(mirror, tp string) error

func StartConf

func StartConf(tp string) *tor.StartConf

func TestHTTPBackupProxy

func TestHTTPBackupProxy() bool

TestHTTPBackupProxy returns true if the I2P backup proxy is up or blocks until it is.

func TestHTTPDefaultProxy

func TestHTTPDefaultProxy() bool

TestHTTPDefaultProxy returns true if the I2P proxy is up or blocks until it is.

func TestHTTPProxy

func TestHTTPProxy(host, port string) bool

TestHTTPProxy returns true if the proxy at host:port is up or blocks until it is.

func Torrent

func Torrent(ietf, rtpair string) bool

func TorrentDownloaded

func TorrentDownloaded(ietf, rtpair string) bool

func TorrentPath

func TorrentPath() (string, string)

func TorrentReady

func TorrentReady() bool

func UNPACK_PATH

func UNPACK_PATH() string

UNPACK_PATH returns the path to the unpacked files.

func Verify

func Verify(keyrings, detached, target string) error

Types

type TBDownloader

type TBDownloader struct {
	UnpackPath   string
	DownloadPath string
	Lang         string
	OS, ARCH     string
	Mirror       string
	Verbose      bool
	NoUnpack     bool
	Profile      *embed.FS
	// contains filtered or unexported fields
}

TBDownloader is a struct which manages browser updates

func NewFirefoxDownloader

func NewFirefoxDownloader(lang string, os, arch string, content *embed.FS) *TBDownloader

NewFirefoxDownloader returns a new TBDownloader with the given language, using the TBDownloader's OS/ARCH pair

func NewTBDownloader

func NewTBDownloader(lang string, os, arch string, content *embed.FS) *TBDownloader

NewTBDownloader returns a new TBDownloader with the given language, using the TBDownloader's OS/ARCH pair

func (*TBDownloader) BoolCheckFirefoxSignature

func (t *TBDownloader) BoolCheckFirefoxSignature(binpath, sigpath string) bool

BoolCheckFirefoxSignature turns CheckFirefoxSignature into a bool.

func (*TBDownloader) BoolCheckSignature

func (t *TBDownloader) BoolCheckSignature(binpath, sigpath string) bool

BoolCheckSignature turns CheckSignature into a bool.

func (*TBDownloader) BotherToDownload

func (t *TBDownloader) BotherToDownload(dl, name string) bool

BotherToDownload returns true if we need to download a file because we don't have an up-to-date version yet.

func (*TBDownloader) BrowserDir

func (t *TBDownloader) BrowserDir() string

BrowserDir returns the path to the directory where the browser is installed.

func (*TBDownloader) CheckFirefoxSignature

func (t *TBDownloader) CheckFirefoxSignature(binpath, sigpath string) (string, error)

CheckFirefoxSignature checks the signature of the updater. it returns an error if one is encountered. If not, it runs the updater and returns an error if one is encountered.

func (*TBDownloader) CheckSignature

func (t *TBDownloader) CheckSignature(binpath, sigpath string) (string, error)

CheckSignature checks the signature of the updater. it returns an error if one is encountered. If not, it runs the updater and returns an error if one is encountered.

func (*TBDownloader) DownloadFirefoxUpdater

func (t *TBDownloader) DownloadFirefoxUpdater() (string, string, error)

DownloadFirefoxUpdater downloads the updater for the t.Lang. It returns the path to the downloaded updater and the downloaded detatched signature, or an error if one is encountered.

func (*TBDownloader) DownloadFirefoxUpdaterForLang

func (t *TBDownloader) DownloadFirefoxUpdaterForLang(ietf string) (string, string, error)

DownloadFirefoxUpdaterForLang downloads the updater for the given language, overriding t.Lang. It returns the path to the downloaded updater and the downloaded detatched signature, or an error if one is encountered.

func (*TBDownloader) DownloadUpdater

func (t *TBDownloader) DownloadUpdater() (string, string, string, error)

DownloadUpdater downloads the updater for the t.Lang. It returns the path to the downloaded updater and the downloaded detatched signature, or an error if one is encountered.

func (*TBDownloader) DownloadUpdaterForLang

func (t *TBDownloader) DownloadUpdaterForLang(ietf string) (string, string, string, error)

DownloadUpdaterForLang downloads the updater for the given language, overriding t.Lang. It returns the path to the downloaded updater and the downloaded detatched signature, or an error if one is encountered.

func (*TBDownloader) DownloadedFilesList

func (t *TBDownloader) DownloadedFilesList() ([]string, error)

func (*TBDownloader) ExtractFirefoxVersion

func (t *TBDownloader) ExtractFirefoxVersion() (string, error)

ExtractFirefoxVersion extracts the Firefox version from the updater URL

func (*TBDownloader) FetchContentLength

func (t *TBDownloader) FetchContentLength(dl, name string) (int64, error)

func (*TBDownloader) FirefoxBrowserDir

func (t *TBDownloader) FirefoxBrowserDir() string

FirefoxBrowserDir returns the path to the directory where the Firefox browser is installed.

func (*TBDownloader) GenerateMissingTorrents

func (t *TBDownloader) GenerateMissingTorrents() error

func (*TBDownloader) GenerateTorrent

func (t *TBDownloader) GenerateTorrent(file string, announces []string) (*metainfo.MetaInfo, error)

func (*TBDownloader) GetFirefoxUpdater

func (t *TBDownloader) GetFirefoxUpdater() (string, string, error)

GetFirefoxUpdater gets the updater URL for the t.Lang. It returns the URL, a detatched sig if available for the platform, or an error

func (*TBDownloader) GetFirefoxUpdaterForLang

func (t *TBDownloader) GetFirefoxUpdaterForLang(ietf string) (string, string, error)

GetFirefoxUpdaterForLang gets the updater URL for the given language, overriding the t.Lang. It returns the URL, a detatched sig if available for the platform, or an error

func (*TBDownloader) GetLatestFirefoxVersionLinuxSigURL

func (t *TBDownloader) GetLatestFirefoxVersionLinuxSigURL(os, lang string) string

GetLatestFirefoxVersionLinuxSigURL returns the URL to the latest Firefox version detatched signature for the given os and lang

func (*TBDownloader) GetLatestFirefoxVersionURL

func (t *TBDownloader) GetLatestFirefoxVersionURL(os, lang string) string

GetLatestFirefoxVersionURL returns the URL to the latest Firefox version for the given os and lang

func (*TBDownloader) GetName

func (t *TBDownloader) GetName() string

func (*TBDownloader) GetRuntimePair

func (t *TBDownloader) GetRuntimePair() string

GetRuntimePair returns the runtime.GOOS and runtime.GOARCH pair.

func (*TBDownloader) GetUpdater

func (t *TBDownloader) GetUpdater() (string, string, error)

GetUpdater returns the updater for the given language, using the TBDownloader's OS/ARCH pair and only the defaults. It returns the URL of the updater and the detatched signature, or an error if one is not found.

func (*TBDownloader) GetUpdaterForLang

func (t *TBDownloader) GetUpdaterForLang(ietf string) (string, string, error)

GetUpdaterForLang returns the updater for the given language, using the TBDownloader's OS/ARCH pair it expects ietf to be a language. It returns the URL of the updater and the detatched signature, or an error if one is not found.

func (*TBDownloader) GetUpdaterForLangFromJSON

func (t *TBDownloader) GetUpdaterForLangFromJSON(body io.ReadCloser, ietf string) (string, string, error)

GetUpdaterForLangFromJSON returns the updater for the given language, using the TBDownloader's OS/ARCH pair it expects body to be a valid json reader and ietf to be a language. It returns the URL of the updater and the detatched signature, or an error if one is not found.

func (*TBDownloader) GetUpdaterForLangFromJSONBytes

func (t *TBDownloader) GetUpdaterForLangFromJSONBytes(jsonBytes []byte, ietf string) (string, string, error)

GetUpdaterForLangFromJSONBytes returns the updater for the given language, using the TBDownloader's OS/ARCH pair it expects jsonBytes to be a valid json string and ietf to be a language. It returns the URL of the updater and the detatched signature, or an error if one is not found.

func (*TBDownloader) GetVersion

func (t *TBDownloader) GetVersion() string

func (*TBDownloader) Log

func (t *TBDownloader) Log(function, message string)

Log logs things if Verbose is true.

func (*TBDownloader) MakeTBDirectory

func (t *TBDownloader) MakeTBDirectory()

MakeTBDirectory creates the tor-browser directory if it doesn't exist. It also unpacks a local copy of the TPO signing key.

func (*TBDownloader) MirrorIsI2P

func (t *TBDownloader) MirrorIsI2P() bool

func (*TBDownloader) MirrorIze

func (t *TBDownloader) MirrorIze(replaceStr string) string

func (*TBDownloader) NamePerPlatform

func (t *TBDownloader) NamePerPlatform(ietf, version string) string

NamePerPlatform returns the name of the updater for the given platform with appropriate extensions.

func (*TBDownloader) NamePerPlatformFirefox

func (t *TBDownloader) NamePerPlatformFirefox(ietf string) string

NamePerPlatformFirefox returns the name of the Firefox package per platform.

func (*TBDownloader) SendFirefoxVersionHEADRequest

func (t *TBDownloader) SendFirefoxVersionHEADRequest() (string, error)

SendFirefoxVersionHEADRequest sends a HEAD request to the Firefox version URL

func (*TBDownloader) Serve

func (t *TBDownloader) Serve()

Serve runs ServeHTTP on an I2P listener

func (*TBDownloader) ServeHTTP

func (t *TBDownloader) ServeHTTP(w http.ResponseWriter, r *http.Request)

ServeHTTP serves the DOWNLOAD_PATH as a mirror

func (*TBDownloader) SetupProxy

func (t *TBDownloader) SetupProxy() error

SetupProxy sets up the proxy for the given URL

func (*TBDownloader) SingleFileDownload

func (t *TBDownloader) SingleFileDownload(dl, name string, rangebottom int64) (string, error)

SingleFileDownload downloads a single file from the given URL to the given path. it returns the path to the downloaded file, or an error if one is encountered.

func (*TBDownloader) StartConf

func (t *TBDownloader) StartConf() *tor.StartConf

func (*TBDownloader) TorPath

func (s *TBDownloader) TorPath() string

TorPath returns the path to the Tor executable

func (*TBDownloader) UnpackFirefox

func (t *TBDownloader) UnpackFirefox(binpath string) (string, error)

UnpackFirefox unpacks the Firefox package to the t.FirefoxBrowserDir()

func (*TBDownloader) UnpackUpdater

func (t *TBDownloader) UnpackUpdater(binpath string) (string, error)

UnpackUpdater unpacks the updater to the given path. it returns the path or an erorr if one is encountered.

type WriteCounter

type WriteCounter struct {
	Total uint64
}

func (WriteCounter) PrintProgress

func (wc WriteCounter) PrintProgress()

func (*WriteCounter) Write

func (wc *WriteCounter) Write(p []byte) (int, error)

Jump to

Keyboard shortcuts

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