Make OSX work!

This commit is contained in:
idk
2022-02-08 18:31:32 -05:00
parent c85e5b1cb8
commit cfdfc5a092
4 changed files with 61 additions and 22 deletions

View File

@ -39,14 +39,14 @@ The plugin will not start a Tor instance if a SOCKS proxy is open on port 9050.
### Secondary Goals: ### Secondary Goals:
1. Launch Tor Browser 1. Launch Tor Browser
- Works on Linux, Windows, not OSX yet but soon - Works on Linux, Windows, OSX with minor bugs
2. Configure and launch Tor browser for use with I2P 2. Configure and launch Tor browser for use with I2P
- Works on Linux, Windows, not OSX yet but soon - Works on Linux, Windows, OSX with minor bugs
#### Optional Features I might add if there is interest #### Optional Features I might add if there is interest
1. Mirror the files which it downloads to an I2P Site 1. Mirror the files which it downloads to an I2P Site
- Probably works on everything - Works on Windows, Linux, OSX
2. Mirror the files which it downloads to I2P torrents 2. Mirror the files which it downloads to I2P torrents
- Not done - Not done
3. Set up an onion site which announces an I2P mirror exists 3. Set up an onion site which announces an I2P mirror exists

View File

@ -140,8 +140,8 @@ profile torbrowser_firefox @{torbrowser_firefox_executable} {
deny /etc/group r, deny /etc/group r,
deny /etc/mailcap r, deny /etc/mailcap r,
/etc/machine-id r, /etc/osxhine-id r,
/var/lib/dbus/machine-id r, /var/lib/dbus/osxhine-id r,
/dev/ r, /dev/ r,
/dev/shm/ r, /dev/shm/ r,

33
main.go
View File

@ -11,6 +11,9 @@ import (
"github.com/cloudfoundry/jibber_jabber" "github.com/cloudfoundry/jibber_jabber"
i2cpcheck "github.com/eyedeekay/checki2cp" i2cpcheck "github.com/eyedeekay/checki2cp"
"github.com/itchio/damage"
"github.com/itchio/damage/hdiutil"
"github.com/itchio/headway/state"
tbget "i2pgit.org/idk/i2p.plugins.tor-manager/get" tbget "i2pgit.org/idk/i2p.plugins.tor-manager/get"
tbserve "i2pgit.org/idk/i2p.plugins.tor-manager/serve" tbserve "i2pgit.org/idk/i2p.plugins.tor-manager/serve"
) )
@ -44,6 +47,9 @@ func OS() string {
} }
func ARCH() string { func ARCH() string {
// if OS() == "osx" {
// return ""
// }
switch runtime.GOARCH { switch runtime.GOARCH {
case "386": case "386":
return "32" return "32"
@ -177,6 +183,13 @@ func main() {
client.Port = *port client.Port = *port
client.TBS.Profile = &content client.TBS.Profile = &content
client.TBS.PassThroughArgs = flag.Args() client.TBS.PassThroughArgs = flag.Args()
consumer := &state.Consumer{
OnMessage: func(lvl string, msg string) {
log.Printf("[%s] %s", lvl, msg)
},
}
host := hdiutil.NewHost(consumer)
defer damage.Unmount(host, client.TBD.BrowserDir())
// log.Fatalf("%s", client.TBS.PassThroughArgs) // log.Fatalf("%s", client.TBS.PassThroughArgs)
if *help { if *help {
flag.Usage() flag.Usage()
@ -185,20 +198,30 @@ func main() {
} }
if *profile != "" && !*offline { if *profile != "" && !*offline {
log.Println("Using a custom profile") log.Println("Using a custom profile")
client.TBS.RunTBBWithProfile(*profile) if client.TBS.RunTBBWithProfile(*profile); err != nil {
log.Fatal(err)
}
} else if *offline { } else if *offline {
if *profile == "" { if *profile == "" {
*profile = "firefox.offline" *profile = "firefox.offline"
} }
log.Println("Working offline") log.Println("Working offline")
client.TBS.RunTBBWithOfflineProfile(*profile, *offline) if client.TBS.RunTBBWithOfflineProfile(*profile, *offline); err != nil {
log.Fatal(err)
}
} else if *i2pbrowser { } else if *i2pbrowser {
client.TBS.RunI2PBWithLang() if client.TBS.RunI2PBWithLang(); err != nil {
log.Fatal(err)
}
} else if *i2pconfig { } else if *i2pconfig {
client.TBS.RunI2PBAppWithLang() if client.TBS.RunI2PBAppWithLang(); err != nil {
log.Fatal(err)
}
} else if *torbrowser { } else if *torbrowser {
client.TBS.RunTBWithLang() if err := client.TBS.RunTBWithLang(); err != nil {
log.Fatal(err)
}
} else { } else {
if *bemirror { if *bemirror {
go client.TBD.Serve() go client.TBD.Serve()

View File

@ -245,9 +245,13 @@ func (s *Supervisor) RunTBWithLang() error {
} }
log.Println("tor browser not found at", s.TBPath()) log.Println("tor browser not found at", s.TBPath())
return fmt.Errorf("tor browser not found at %s", s.TBPath()) return fmt.Errorf("tor browser not found at %s", s.TBPath())
case "darwin": case "osx":
s.tbcmd = exec.Command("/usr/bin/env", "open", "-a", "\"Tor Browser.app\"") firefoxPath := filepath.Join(s.UnpackPath, "Tor Browser.app", "Contents", "MacOS", "firefox")
s.tbcmd.Dir = s.TBDirectory() s.tbcmd = exec.Command(firefoxPath)
s.tbcmd.Dir = s.UnpackPath
s.tbcmd.Stdout = os.Stdout
s.tbcmd.Stderr = os.Stderr
defer s.tbcmd.Process.Kill()
return s.tbcmd.Run() return s.tbcmd.Run()
case "win": case "win":
log.Println("Running Windows EXE", s.TBDirectory(), "firefox.exe") log.Println("Running Windows EXE", s.TBDirectory(), "firefox.exe")
@ -288,9 +292,13 @@ func (s *Supervisor) RunTBHelpWithLang() error {
} }
log.Println("tor browser not found at", s.TBPath()) log.Println("tor browser not found at", s.TBPath())
return fmt.Errorf("tor browser not found at %s", s.TBPath()) return fmt.Errorf("tor browser not found at %s", s.TBPath())
case "darwin": case "osx":
s.tbcmd = exec.Command("/usr/bin/env", "open", "-a", "\"Tor Browser.app\"") firefoxPath := filepath.Join(s.UnpackPath, "Tor Browser.app", "Contents", "MacOS", "firefox")
s.tbcmd = exec.Command(firefoxPath, "--help")
s.tbcmd.Stdout = os.Stdout
s.tbcmd.Stderr = os.Stderr
s.tbcmd.Dir = s.TBDirectory() s.tbcmd.Dir = s.TBDirectory()
defer s.tbcmd.Process.Kill()
return s.tbcmd.Run() return s.tbcmd.Run()
case "win": case "win":
log.Println("Running Windows EXE", s.TBDirectory(), "firefox.exe") log.Println("Running Windows EXE", s.TBDirectory(), "firefox.exe")
@ -373,9 +381,13 @@ func (s *Supervisor) RunTBBWithOfflineProfile(profiledata string, offline bool)
} }
log.Println("tor browser not found at", s.FirefoxPath()) log.Println("tor browser not found at", s.FirefoxPath())
return fmt.Errorf("tor browser not found at %s", s.FirefoxPath()) return fmt.Errorf("tor browser not found at %s", s.FirefoxPath())
case "darwin": case "osx":
s.ibcmd = exec.Command("/usr/bin/env", "open", "-a", "\"Tor Browser.app\"") firefoxPath := filepath.Join(s.UnpackPath, "Tor Browser.app", "Contents", "MacOS", "firefox")
s.ibcmd.Dir = s.TBDirectory() s.ibcmd = exec.Command(firefoxPath, "--profile", profiledata)
s.ibcmd.Dir = profiledata
s.ibcmd.Stdout = os.Stdout
s.ibcmd.Stderr = os.Stderr
defer s.ibcmd.Process.Kill()
return s.ibcmd.Run() return s.ibcmd.Run()
case "win": case "win":
log.Println("Running Windows EXE", filepath.Join(s.TBDirectory(), "firefox.exe"), "--profile", profiledata) log.Println("Running Windows EXE", filepath.Join(s.TBDirectory(), "firefox.exe"), "--profile", profiledata)
@ -455,10 +467,14 @@ func (s *Supervisor) RunTorWithLang() error {
} }
log.Println("tor not found at", s.TorPath()) log.Println("tor not found at", s.TorPath())
return fmt.Errorf("tor not found at %s", s.TorPath()) return fmt.Errorf("tor not found at %s", s.TorPath())
case "darwin": case "osx":
s.torcmd = exec.Command("/usr/bin/env", "open", "-a", "\"Tor Browser.app\"") torPath := filepath.Join(s.UnpackPath, "Tor Browser.app", "Contents", "Resources", "TorBrowser", "Tor", "tor")
s.torcmd.Dir = s.TBDirectory() s.ibcmd = exec.Command(torPath)
return s.torcmd.Run() s.ibcmd.Dir = filepath.Dir(torPath)
s.ibcmd.Stdout = os.Stdout
s.ibcmd.Stderr = os.Stderr
defer s.ibcmd.Process.Kill()
return s.tbcmd.Run()
case "win": case "win":
log.Println("Running Windows EXE", filepath.Join(s.TBDirectory(), "TorBrowser", "Tor", "tor.exe")) log.Println("Running Windows EXE", filepath.Join(s.TBDirectory(), "TorBrowser", "Tor", "tor.exe"))
s.torcmd = exec.Command(filepath.Join(s.TBDirectory(), "TorBrowser", "Tor", "tor.exe")) s.torcmd = exec.Command(filepath.Join(s.TBDirectory(), "TorBrowser", "Tor", "tor.exe"))