Documentation ¶
Index ¶
- Constants
- Variables
- func Create(path string) (*os.File, error)
- func DOWNLOAD_FIREFOX_PATH() string
- func DOWNLOAD_PATH() string
- func DefaultDir() string
- func FetchContentLength(dl, name string) (int64, error)
- func FileExists(path string) bool
- func FindSnarkDirectory() (string, error)
- func GetTorBrowserVersionFromUpdateURL() (string, error)
- func Languages() []string
- func MirrorIsI2P(mirror string) bool
- func Seconds(now int) int
- func SetupProxy(mirror, tp string) error
- func StartConf(tp string) *tor.StartConf
- func TestHTTPBackupProxy() bool
- func TestHTTPDefaultProxy() bool
- func TestHTTPProxy(host, port string) bool
- func Torrent(ietf, rtpair string) bool
- func TorrentDownloaded(ietf, rtpair string) bool
- func TorrentPath() (string, string)
- func TorrentReady() bool
- func UNPACK_PATH() string
- func Verify(keyrings, detached, target string) error
- type TBDownloader
- func (t *TBDownloader) BoolCheckFirefoxSignature(binpath, sigpath string) bool
- func (t *TBDownloader) BoolCheckSignature(binpath, sigpath string) bool
- func (t *TBDownloader) BotherToDownload(dl, name string) bool
- func (t *TBDownloader) BrowserDir() string
- func (t *TBDownloader) CheckFirefoxSignature(binpath, sigpath string) (string, error)
- func (t *TBDownloader) CheckSignature(binpath, sigpath string) (string, error)
- func (t *TBDownloader) DownloadFirefoxUpdater() (string, string, error)
- func (t *TBDownloader) DownloadFirefoxUpdaterForLang(ietf string) (string, string, error)
- func (t *TBDownloader) DownloadUpdater() (string, string, string, error)
- func (t *TBDownloader) DownloadUpdaterForLang(ietf string) (string, string, string, error)
- func (t *TBDownloader) DownloadedFilesList() ([]string, error)
- func (t *TBDownloader) ExtractFirefoxVersion() (string, error)
- func (t *TBDownloader) FetchContentLength(dl, name string) (int64, error)
- func (t *TBDownloader) FirefoxBrowserDir() string
- func (t *TBDownloader) GenerateMissingTorrents() error
- func (t *TBDownloader) GenerateTorrent(file string, announces []string) (*metainfo.MetaInfo, error)
- func (t *TBDownloader) GetFirefoxUpdater() (string, string, error)
- func (t *TBDownloader) GetFirefoxUpdaterForLang(ietf string) (string, string, error)
- func (t *TBDownloader) GetLatestFirefoxVersionLinuxSigURL(os, lang string) string
- func (t *TBDownloader) GetLatestFirefoxVersionURL(os, lang string) string
- func (t *TBDownloader) GetName() string
- func (t *TBDownloader) GetRuntimePair() string
- func (t *TBDownloader) GetUpdater() (string, string, error)
- func (t *TBDownloader) GetUpdaterForLang(ietf string) (string, string, error)
- func (t *TBDownloader) GetUpdaterForLangFromJSON(body io.ReadCloser, ietf string) (string, string, error)
- func (t *TBDownloader) GetUpdaterForLangFromJSONBytes(jsonBytes []byte, ietf string) (string, string, error)
- func (t *TBDownloader) GetVersion() string
- func (t *TBDownloader) Log(function, message string)
- func (t *TBDownloader) MakeTBDirectory()
- func (t *TBDownloader) MirrorIsI2P() bool
- func (t *TBDownloader) MirrorIze(replaceStr string) string
- func (t *TBDownloader) NamePerPlatform(ietf, version string) string
- func (t *TBDownloader) NamePerPlatformFirefox(ietf string) string
- func (t *TBDownloader) SendFirefoxVersionHEADRequest() (string, error)
- func (t *TBDownloader) Serve()
- func (t *TBDownloader) ServeHTTP(w http.ResponseWriter, r *http.Request)
- func (t *TBDownloader) SetupProxy() error
- func (t *TBDownloader) SingleFileDownload(dl, name string, rangebottom int64) (string, error)
- func (t *TBDownloader) StartConf() *tor.StartConf
- func (s *TBDownloader) TorPath() string
- func (t *TBDownloader) UnpackFirefox(binpath string) (string, error)
- func (t *TBDownloader) UnpackUpdater(binpath string) (string, error)
- type WriteCounter
Constants ¶
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
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 ¶
var ARCH = "64"
ARCH is the architecture of the TBDownloader.
var (
// DefaultIETFLang is the default language for the TBDownloader.
DefaultIETFLang, _ = jibber_jabber.DetectIETF()
)
var OS = "linux"
OS is the operating system of the TBDownloader.
var WORKING_DIR = ""
WORKING_DIR is the working directory for the application.
Functions ¶
func DOWNLOAD_FIREFOX_PATH ¶
func DOWNLOAD_FIREFOX_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 FileExists ¶
FileExists returns true if the given file exists. It will return true if used on an existing directory.
func FindSnarkDirectory ¶
func MirrorIsI2P ¶
func SetupProxy ¶
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 ¶
TestHTTPProxy returns true if the proxy at host:port is up or blocks until it is.
func TorrentDownloaded ¶
func TorrentPath ¶
func TorrentReady ¶
func TorrentReady() bool
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 ¶
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 (*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) 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()