fix some issues reported from Matrix
This commit is contained in:
2
Makefile
2
Makefile
@ -264,7 +264,7 @@ tor-browser/TPO-signing-key.pub:
|
||||
#gpg --output ./tor-browser/TPO-signing-key.pub --export -r torbrowser@torproject.org
|
||||
#gpg --armor --output ./tor-browser/TPO-signing-key.pub --export -r torbrowser@torproject.org
|
||||
#gpg -r 0xEF6E286DDA85EA2A4BA7DE684E2C6E8793298290 --output ./tor-browser/TPO-signing-key.pub --export
|
||||
#gpg -r 0xEF6E286DDA85EA2A4BA7DE684E2C6E8793298290 --armor --output ./tor-browser/TPO-signing-key.pub --export
|
||||
gpg -r 0xEF6E286DDA85EA2A4BA7DE684E2C6E8793298290 --armor --output ./tor-browser/TPO-signing-key.pub --export
|
||||
|
||||
deb: clean
|
||||
mv "hankhill19580_at_gmail.com.crl" ../; true
|
||||
|
165
get/get.go
165
get/get.go
@ -17,6 +17,7 @@ import (
|
||||
"path"
|
||||
"path/filepath"
|
||||
"runtime"
|
||||
"strconv"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
@ -334,6 +335,7 @@ func (t *TBDownloader) StartConf() *tor.StartConf {
|
||||
if FileExists(path) {
|
||||
return &tor.StartConf{
|
||||
ExePath: path,
|
||||
RetainTempDataDir: false,
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -341,6 +343,54 @@ func (t *TBDownloader) StartConf() *tor.StartConf {
|
||||
if FileExists(tp) {
|
||||
return &tor.StartConf{
|
||||
ExePath: tp,
|
||||
RetainTempDataDir: false,
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// SetupProxy sets up the proxy for the given URL
|
||||
func (t *TBDownloader) SetupProxy() error {
|
||||
var d proxy.Dialer
|
||||
if t.MirrorIsI2P() {
|
||||
log.Println("Using I2P mirror, setting up proxy")
|
||||
var err error
|
||||
proxyURL, err := url.Parse("http://127.0.0.1:4444")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
d, err = connectproxy.New(proxyURL, proxy.Direct)
|
||||
if nil != err {
|
||||
return err
|
||||
}
|
||||
tr := &http.Transport{
|
||||
Dial: d.Dial,
|
||||
}
|
||||
http.DefaultClient.Transport = tr
|
||||
} else {
|
||||
if !strings.Contains(t.Mirror, "127.0.0.1") {
|
||||
if tmp, torerr := net.Listen("tcp", "127.0.0.1:9050"); torerr != nil {
|
||||
log.Println("System Tor is running, downloading over that because obviously.")
|
||||
t, err := tor.Start(context.Background(), t.StartConf())
|
||||
if err != nil {
|
||||
if t == nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
//defer t.Close()
|
||||
// Wait at most a minute to start network and get
|
||||
dialCtx, _ := context.WithTimeout(context.Background(), time.Minute)
|
||||
//defer dialCancel()
|
||||
// Make connection
|
||||
dialer, err := t.Dialer(dialCtx, nil)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
tr := &http.Transport{DialContext: dialer.DialContext}
|
||||
http.DefaultClient.Transport = tr
|
||||
} else {
|
||||
tmp.Close()
|
||||
}
|
||||
}
|
||||
}
|
||||
return nil
|
||||
@ -356,48 +406,10 @@ func (t *TBDownloader) SingleFileDownload(dl, name string, rangebottom int64) (s
|
||||
t.Log("SingleFileDownload()", "File already exists, skipping download")
|
||||
return path, nil
|
||||
}
|
||||
var d proxy.Dialer
|
||||
if t.MirrorIsI2P() {
|
||||
log.Println("Using I2P mirror, setting up proxy")
|
||||
var err error
|
||||
proxyURL, err := url.Parse("http://127.0.0.1:4444")
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
d, err = connectproxy.New(proxyURL, proxy.Direct)
|
||||
if nil != err {
|
||||
panic(err)
|
||||
}
|
||||
tr := &http.Transport{
|
||||
Dial: d.Dial,
|
||||
}
|
||||
http.DefaultClient.Transport = tr
|
||||
} else {
|
||||
if !strings.Contains(t.Mirror, "127.0.0.1") {
|
||||
if tmp, torerr := net.Listen("tcp", "127.0.0.1:9050"); torerr != nil {
|
||||
log.Println("System Tor is running, downloading over that because obviously.")
|
||||
t, err := tor.Start(context.Background(), t.StartConf())
|
||||
if err != nil {
|
||||
if t == nil {
|
||||
return "", err
|
||||
}
|
||||
}
|
||||
defer t.Close()
|
||||
// Wait at most a minute to start network and get
|
||||
dialCtx, dialCancel := context.WithTimeout(context.Background(), time.Minute)
|
||||
defer dialCancel()
|
||||
// Make connection
|
||||
dialer, err := t.Dialer(dialCtx, nil)
|
||||
err := t.SetupProxy()
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
tr := &http.Transport{DialContext: dialer.DialContext}
|
||||
http.DefaultClient.Transport = tr
|
||||
} else {
|
||||
tmp.Close()
|
||||
}
|
||||
}
|
||||
}
|
||||
dlurl, err := url.Parse(dl)
|
||||
if err != nil {
|
||||
return "", err
|
||||
@ -474,46 +486,10 @@ func (t *TBDownloader) FetchContentLength(dl, name string) (int64, error) {
|
||||
// t.Log("FetchContentLength()", "File already exists, skipping download")
|
||||
// return 0, nil
|
||||
//}
|
||||
var d proxy.Dialer
|
||||
if t.MirrorIsI2P() {
|
||||
log.Println("Using I2P mirror, setting up proxy")
|
||||
var err error
|
||||
proxyURL, err := url.Parse("http://127.0.0.1:4444")
|
||||
err := t.SetupProxy()
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
d, err = connectproxy.New(proxyURL, proxy.Direct)
|
||||
if nil != err {
|
||||
return 0, err
|
||||
}
|
||||
tr := &http.Transport{
|
||||
Dial: d.Dial,
|
||||
}
|
||||
http.DefaultClient.Transport = tr
|
||||
} else {
|
||||
if !strings.Contains(t.Mirror, "127.0.0.1") {
|
||||
if tmp, torerr := net.Listen("tcp", "127.0.0.1:9050"); torerr != nil {
|
||||
log.Println("System Tor is running, downloading over that because obviously.")
|
||||
t, err := tor.Start(context.Background(), nil)
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
defer t.Close()
|
||||
// Wait at most a minute to start network and get
|
||||
dialCtx, dialCancel := context.WithTimeout(context.Background(), time.Minute)
|
||||
defer dialCancel()
|
||||
// Make connection
|
||||
dialer, err := t.Dialer(dialCtx, nil)
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
tr := &http.Transport{DialContext: dialer.DialContext}
|
||||
http.DefaultClient.Transport = tr
|
||||
} else {
|
||||
tmp.Close()
|
||||
}
|
||||
}
|
||||
}
|
||||
dlurl, err := url.Parse(dl)
|
||||
if err != nil {
|
||||
return 0, err
|
||||
@ -551,8 +527,16 @@ func (t *TBDownloader) BotherToDownload(dl, name string) bool {
|
||||
if err != nil {
|
||||
return true
|
||||
}
|
||||
if stat.Size() < contentLength { //TODO: Make this the real size of the file by requesting content-length
|
||||
|
||||
lenString := strconv.Itoa(int(contentLength))[:4]
|
||||
lenSize := strconv.Itoa(int(stat.Size()))[:4]
|
||||
log.Println("comparing sizes:", lenString, lenSize)
|
||||
|
||||
//if stat.Size() != contentLength {
|
||||
if lenString != lenSize {
|
||||
return true
|
||||
} else {
|
||||
return false
|
||||
}
|
||||
}
|
||||
defer ioutil.WriteFile(filepath.Join(t.DownloadPath, name+".last-url"), []byte(dl), 0644)
|
||||
@ -567,7 +551,7 @@ func (t *TBDownloader) BotherToDownload(dl, name string) bool {
|
||||
}
|
||||
|
||||
// NamePerPlatform returns the name of the updater for the given platform with appropriate extensions.
|
||||
func (t *TBDownloader) NamePerPlatform(ietf string) string {
|
||||
func (t *TBDownloader) NamePerPlatform(ietf, version string) string {
|
||||
extension := "tar.xz"
|
||||
windowsonly := ""
|
||||
switch t.OS {
|
||||
@ -577,7 +561,21 @@ func (t *TBDownloader) NamePerPlatform(ietf string) string {
|
||||
windowsonly = "-installer"
|
||||
extension = "exe"
|
||||
}
|
||||
return fmt.Sprintf("torbrowser%s-%s-%s.%s", windowsonly, t.GetRuntimePair(), ietf, extension)
|
||||
//version, err := t.Get
|
||||
return fmt.Sprintf("torbrowser%s-%s-%s_%s.%s", windowsonly, t.GetRuntimePair(), version, ietf, extension)
|
||||
}
|
||||
|
||||
func (t *TBDownloader) GetVersion() string {
|
||||
binary, _, err := t.GetUpdaterForLang(t.Lang)
|
||||
if err != nil {
|
||||
return ""
|
||||
}
|
||||
version := strings.Split(binary, "/")[len(strings.Split(binary, "/"))-2]
|
||||
return version
|
||||
}
|
||||
|
||||
func (t *TBDownloader) GetName() string {
|
||||
return t.NamePerPlatform(t.Lang, t.GetVersion())
|
||||
}
|
||||
|
||||
// DownloadUpdater downloads the updater for the t.Lang. It returns
|
||||
@ -595,18 +593,19 @@ func (t *TBDownloader) DownloadUpdaterForLang(ietf string) (string, string, stri
|
||||
if err != nil {
|
||||
return "", "", "", fmt.Errorf("DownloadUpdaterForLang: %s", err)
|
||||
}
|
||||
version := t.GetVersion()
|
||||
|
||||
sigpath, err := t.SingleFileDownload(sig, t.NamePerPlatform(ietf)+".asc", 0)
|
||||
sigpath, err := t.SingleFileDownload(sig, t.NamePerPlatform(ietf, version)+".asc", 0)
|
||||
if err != nil {
|
||||
return "", "", "", fmt.Errorf("DownloadUpdaterForLang: %s", err)
|
||||
}
|
||||
binpath, err := t.SingleFileDownload(binary, t.NamePerPlatform(ietf), 0)
|
||||
binpath, err := t.SingleFileDownload(binary, t.NamePerPlatform(ietf, version), 0)
|
||||
if err != nil {
|
||||
return "", sigpath, "", fmt.Errorf("DownloadUpdaterForLang: %s", err)
|
||||
}
|
||||
var sumpath string
|
||||
if t.OS == "linux" && runtime.GOARCH == "arm64" {
|
||||
sumpath, err = t.SingleFileDownload("https://sourceforge.net/projects/tor-browser-ports/files/11.0.6/sha256sums-unsigned-build.txt/download", t.NamePerPlatform(ietf)+".sha256sums", 0)
|
||||
sumpath, err = t.SingleFileDownload("https://sourceforge.net/projects/tor-browser-ports/files/11.0.6/sha256sums-unsigned-build.txt/download", t.NamePerPlatform(ietf, version)+".sha256sums", 0)
|
||||
if err != nil {
|
||||
return "", sigpath, sumpath, fmt.Errorf("DownloadUpdaterForLang: %s", err)
|
||||
}
|
||||
@ -728,7 +727,7 @@ func (t *TBDownloader) CheckSignature(binpath, sigpath string) (string, error) {
|
||||
}
|
||||
var err error
|
||||
if err = Verify(pk, sigpath, binpath); err == nil {
|
||||
t.Log("CheckSignature: signature", "verified successfully")
|
||||
log.Println("CheckSignature: signature", "verified successfully")
|
||||
return t.UnpackUpdater(binpath)
|
||||
}
|
||||
return "", fmt.Errorf("CheckSignature: %s", err)
|
||||
|
@ -29,6 +29,8 @@ func Verify(keyrings, detached, target string) error {
|
||||
return fmt.Errorf("Verify: failed to read keyrings: %s\n\t%s", err, keyrings)
|
||||
}
|
||||
log.Printf("Verify: %s", fmt.Sprintf("Read %d keyrings", len(entities)))
|
||||
log.Printf("Verifying: %s against %s\n", target, detached)
|
||||
log.Printf("Verify: using keyring %s\n", keyrings)
|
||||
_, err = openpgp.CheckArmoredDetachedSignature(entities, verification_target, signature, nil)
|
||||
if err != nil {
|
||||
return fmt.Errorf("Verify: failed to verify signature: %s\n\t%s\n\t%s\n\t%s", err, keyrings, detached, target)
|
||||
|
41
main.go
41
main.go
@ -83,7 +83,7 @@ var (
|
||||
shortcuts = flag.Bool("shortcuts", false, "Create desktop shortcuts")
|
||||
apparmor = flag.Bool("apparmor", false, "Generate apparmor rules")
|
||||
offline = flag.Bool("offline", false, "Work offline. Differs from Firefox's offline mode in that cannot be disabled until the browser is closed.")
|
||||
clearnet = flag.Bool("clearnet", false, "Use clearnet (no Tor or I2P)")
|
||||
clearnet = flag.Bool("clearnet", Clearnet(), "Use clearnet (no Tor or I2P)")
|
||||
profile = flag.String("profile", "", "use a custom profile path, normally blank")
|
||||
help = flag.Bool("help", false, "Print help")
|
||||
mirror = flag.String("mirror", Mirror(), "Mirror to use. I2P will be used if an I2P proxy is present, if system Tor is available, it will be downloaded over the Tor proxy.")
|
||||
@ -95,12 +95,23 @@ var (
|
||||
/*ptop = flag.Bool("p2p", tbget.TorrentReady(), "Use bittorrent over I2P to download the initial copy of Tor Browser")*/
|
||||
)
|
||||
|
||||
func Clearnet() bool {
|
||||
if tmc := os.Getenv("TOR_MANAGER_CLEARNET"); tmc != "" {
|
||||
switch tmc {
|
||||
case "1", "true", "yes", "on":
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
func Password() string {
|
||||
require_password := os.Getenv("TOR_MANAGER_REQUIRE_PASSWORD")
|
||||
if require_password == "" && !PluginStat() {
|
||||
require_password = "true"
|
||||
}
|
||||
if require_password == "true" || require_password == "1" {
|
||||
switch require_password {
|
||||
case "true", "1", "yes", "on":
|
||||
passwd, err := zenity.Entry(
|
||||
"Enter a password if you want to encrypt the working directory",
|
||||
zenity.Title("Work Directory Encryption"),
|
||||
@ -122,16 +133,24 @@ func Password() string {
|
||||
}
|
||||
|
||||
func Mirror() string {
|
||||
if tbget.TestHTTPDefaultProxy() {
|
||||
return "http://dist.torproject.i2p/torbrowser/"
|
||||
}
|
||||
if tbget.TorrentReady() {
|
||||
//return "http://127.0.0.1:7657/i2psnark/"
|
||||
return "https://dist.torproject.org/torbrowser/"
|
||||
if mir := os.Getenv("TOR_MANAGER_MIRROR"); mir != "" {
|
||||
return mir
|
||||
}
|
||||
if runtime.GOOS == "linux" && runtime.GOARCH == "arm64" {
|
||||
return "https://sourceforge.net/projects/tor-browser-ports/files"
|
||||
}
|
||||
clear := os.Getenv("TOR_MANAGER_CLEARNET")
|
||||
if clear == "true" || clear == "1" {
|
||||
return "https://dist.torproject.org/torbrowser/"
|
||||
}
|
||||
if tbget.TorrentReady() {
|
||||
// return "http://127.0.0.1:7657/i2psnark/"
|
||||
return "https://dist.torproject.org/torbrowser/"
|
||||
}
|
||||
if tbget.TestHTTPDefaultProxy() {
|
||||
return "http://dist.torproject.i2p/torbrowser/"
|
||||
}
|
||||
|
||||
return "https://dist.torproject.org/torbrowser/"
|
||||
}
|
||||
|
||||
@ -147,7 +166,8 @@ func main() {
|
||||
fmt.Printf("Usage: %s %s\n", filename, "[options]")
|
||||
fmt.Printf("\n")
|
||||
fmt.Printf("Downloads, verifies and unpacks Tor Browser. Manages the Tor Browser\n")
|
||||
fmt.Printf("system in environments where Tor is not in use.\n")
|
||||
fmt.Printf("system in environments where Tor is not in use. Monitors a long-running\n")
|
||||
fmt.Printf("Tor process and downloads updates when Tor is not available.\n")
|
||||
fmt.Printf("\n")
|
||||
fmt.Printf("Options:\n")
|
||||
fmt.Printf("\n")
|
||||
@ -310,7 +330,10 @@ func main() {
|
||||
log.Fatal(err)
|
||||
}
|
||||
}
|
||||
if !*clearnet {
|
||||
client.TBS.RunTorWithLang()
|
||||
}
|
||||
|
||||
if *chat {
|
||||
log.Println("Starting I2P chat")
|
||||
go BRBClient(*directory, "brb")
|
||||
|
@ -13,6 +13,7 @@ import (
|
||||
"os"
|
||||
"path"
|
||||
"path/filepath"
|
||||
"runtime"
|
||||
"strconv"
|
||||
"strings"
|
||||
|
||||
@ -53,7 +54,7 @@ func NewClient(verbose bool, lang, OS, arch, mirror string, content *embed.FS) (
|
||||
panic(err)
|
||||
}
|
||||
sum := ""
|
||||
if sums != "" {
|
||||
if sums != "" && runtime.GOOS == "linux" && runtime.GOARCH == "arm64" {
|
||||
b, err := ioutil.ReadFile(sums)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
|
Reference in New Issue
Block a user