5 Commits

Author SHA1 Message Date
idk
491b3d37f3 update gs 2020-09-09 21:17:43 -04:00
idk
cc8e85c89c Allow Firefox to break completely free of the Go app should the dev choose to do so 2020-09-06 17:41:59 -04:00
idk
d7055ec1f4 make it possible to just import it and use it in another app 2020-09-06 16:55:22 -04:00
idk
3d5c7fe9c1 bump 2020-08-24 00:54:46 -04:00
idk
a740c15292 bump 2020-08-24 00:46:57 -04:00
10 changed files with 223 additions and 131 deletions

View File

@@ -2,6 +2,8 @@
export GO111MODULE=on
GO111MODULE=on
BIN_NAME=i2pbrowser
EXT_VERSION=0.73
SNOW_VERSION=0.2.2
UMAT_VERSION=1.25.2
@@ -26,7 +28,7 @@ gen:
go run $(GO_COMPILER_OPTS) -tags generate gen.go extensions.go
clean: fmt
rm -f i2pfirefox*
rm -f $(BIN_NAME)*
fmt:
gofmt -w -s *.go
@@ -49,31 +51,31 @@ all: pure variant
pure: fmt lib/assets.go windows osx linux
windows: fmt
GOOS=windows go build $(GO_COMPILER_OPTS) -o i2pfirefox.exe
GOOS=windows go build $(GO_COMPILER_OPTS) -o $(BIN_NAME).exe
osx: fmt
GOOS=darwin go build $(GO_COMPILER_OPTS) -o i2pfirefox-darwin
GOOS=darwin go build $(GO_COMPILER_OPTS) -o $(BIN_NAME)-darwin
linux: fmt
GOOS=linux go build $(GO_COMPILER_OPTS) -o i2pfirefox
GOOS=linux go build $(GO_COMPILER_OPTS) -o $(BIN_NAME)
variant: fmt lib/assets.go vwindows vosx vlinux
vwindows: fmt
GOOS=windows go build $(GO_COMPILER_OPTS) -tags variant -o i2pfirefox-variant.exe
GOOS=windows go build $(GO_COMPILER_OPTS) -tags variant -o $(BIN_NAME)-variant.exe
vosx: fmt
GOOS=darwin go build $(GO_COMPILER_OPTS) -tags variant -o i2pfirefox-variant-darwin
GOOS=darwin go build $(GO_COMPILER_OPTS) -tags variant -o $(BIN_NAME)-variant-darwin
vlinux: fmt
GOOS=linux go build $(GO_COMPILER_OPTS) -tags variant -o i2pfirefox-variant
GOOS=linux go build $(GO_COMPILER_OPTS) -tags variant -o $(BIN_NAME)-variant
sumwindows=`sha256sum i2pfirefox.exe`
sumlinux=`sha256sum i2pfirefox`
sumdarwin=`sha256sum i2pfirefox-darwin`
sumvwindows=`sha256sum i2pfirefox-variant.exe`
sumvlinux=`sha256sum i2pfirefox-variant`
sumvdarwin=`sha256sum i2pfirefox-variant-darwin`
sumwindows=`sha256sum $(BIN_NAME).exe`
sumlinux=`sha256sum $(BIN_NAME)`
sumdarwin=`sha256sum $(BIN_NAME)-darwin`
sumvwindows=`sha256sum $(BIN_NAME)-variant.exe`
sumvlinux=`sha256sum $(BIN_NAME)-variant`
sumvdarwin=`sha256sum $(BIN_NAME)-variant-darwin`
check:
echo "$(sumwindows)"
@@ -84,7 +86,7 @@ check:
echo "$(sumvdarwin)"
release:
gothub release -p -u eyedeekay -r "i2pfirefox" -t $(LAUNCH_VERSION) -n "Launchers" -d "A self-configuring launcher for mixed I2P and clearnet Browsing with Firefox"
gothub release -p -u eyedeekay -r "$(BIN_NAME)" -t $(LAUNCH_VERSION) -n "Launchers" -d "A self-configuring launcher for mixed I2P and clearnet Browsing with Firefox"
sed -i "s|$(LAST_VERSION)|$(LAUNCH_VERSION)|g" README.md
sed -i "s|$(LAST_VERSION)|$(LAUNCH_VERSION)|g" Makefile
git commit -am "Make release version $(LAUNCH_VERSION)" && git push
@@ -92,24 +94,24 @@ release:
upload: upload-windows upload-darwin upload-linux
upload-windows:
gothub upload -R -u eyedeekay -r "i2pfirefox" -t $(LAUNCH_VERSION) -l "$(sumwindows)" -n "i2pfirefox.exe" -f "i2pfirefox.exe"
gothub upload -R -u eyedeekay -r "$(BIN_NAME)" -t $(LAUNCH_VERSION) -l "$(sumwindows)" -n "$(BIN_NAME).exe" -f "$(BIN_NAME).exe"
upload-darwin:
gothub upload -R -u eyedeekay -r "i2pfirefox" -t $(LAUNCH_VERSION) -l "$(sumdarwin)" -n "i2pfirefox-darwin" -f "i2pfirefox-darwin"
gothub upload -R -u eyedeekay -r "$(BIN_NAME)" -t $(LAUNCH_VERSION) -l "$(sumdarwin)" -n "$(BIN_NAME)-darwin" -f "$(BIN_NAME)-darwin"
upload-linux:
gothub upload -R -u eyedeekay -r "i2pfirefox" -t $(LAUNCH_VERSION) -l "$(sumlinux)" -n "i2pfirefox" -f "i2pfirefox"
gothub upload -R -u eyedeekay -r "$(BIN_NAME)" -t $(LAUNCH_VERSION) -l "$(sumlinux)" -n "$(BIN_NAME)" -f "$(BIN_NAME)"
upload-variant: upload-variant-windows upload-variant-darwin upload-variant-linux
upload-variant-windows:
gothub upload -R -u eyedeekay -r "i2pfirefox" -t $(LAUNCH_VERSION) -l "$(sumvwindows)" -n "i2pfirefox-variant.exe" -f "i2pfirefox-variant.exe"
gothub upload -R -u eyedeekay -r "$(BIN_NAME)" -t $(LAUNCH_VERSION) -l "$(sumvwindows)" -n "$(BIN_NAME)-variant.exe" -f "$(BIN_NAME)-variant.exe"
upload-variant-darwin:
gothub upload -R -u eyedeekay -r "i2pfirefox" -t $(LAUNCH_VERSION) -l "$(sumvdarwin)" -n "i2pfirefox-variant-darwin" -f "i2pfirefox-variant-darwin"
gothub upload -R -u eyedeekay -r "$(BIN_NAME)" -t $(LAUNCH_VERSION) -l "$(sumvdarwin)" -n "$(BIN_NAME)-variant-darwin" -f "$(BIN_NAME)-variant-darwin"
upload-variant-linux:
gothub upload -R -u eyedeekay -r "i2pfirefox" -t $(LAUNCH_VERSION) -l "$(sumvlinux)" -n "i2pfirefox-variant" -f "i2pfirefox-variant"
gothub upload -R -u eyedeekay -r "$(BIN_NAME)" -t $(LAUNCH_VERSION) -l "$(sumvlinux)" -n "$(BIN_NAME)-variant" -f "$(BIN_NAME)-variant"
upload-all: upload upload-variant

2
go.mod
View File

@@ -4,7 +4,7 @@ go 1.14
require (
github.com/bmizerany/assert v0.0.0-20160611221934-b7ed37b82869 // indirect
github.com/eyedeekay/GingerShrew v0.0.0-20200823015403-11c67f550c33
github.com/eyedeekay/GingerShrew v0.0.0-20200828154258-d799f84952aa
github.com/eyedeekay/I2P-Configuration-for-Chromium v0.0.0-20200802063209-8973270c836e
github.com/eyedeekay/go-fpw v0.0.0-20200805184710-5435dc443213
github.com/eyedeekay/httptunnel v0.0.0-20200116022455-631ab90f707d

4
go.sum
View File

@@ -107,6 +107,10 @@ github.com/eyedeekay/GingerShrew v0.0.0-20200702210346-bb2ed34c11fb h1:tUfxSHBVa
github.com/eyedeekay/GingerShrew v0.0.0-20200702210346-bb2ed34c11fb/go.mod h1:PY7znvZ1ZF1QG5/4j9u769EX49l49z2rCdE0o4z8fMw=
github.com/eyedeekay/GingerShrew v0.0.0-20200823015403-11c67f550c33 h1:VD2HttHlFt6wfTjkbJMt/M/pmQT8Iq0I7CmEG81dwVM=
github.com/eyedeekay/GingerShrew v0.0.0-20200823015403-11c67f550c33/go.mod h1:kDfSkqEyzswi8r4m6U0Q9jD4PJqOzKXVCX4XbYhBJCs=
github.com/eyedeekay/GingerShrew v0.0.0-20200824044622-7e8d465550e5 h1:vUDYV/R8RNo7cxVN4ftdrXa9zsGQ74Bot5E/LMndhv0=
github.com/eyedeekay/GingerShrew v0.0.0-20200824044622-7e8d465550e5/go.mod h1:kDfSkqEyzswi8r4m6U0Q9jD4PJqOzKXVCX4XbYhBJCs=
github.com/eyedeekay/GingerShrew v0.0.0-20200828154258-d799f84952aa h1:wqjB9kcYjAMrw92QxZnbAbdMsfF0FSPq9vsKx98XWrU=
github.com/eyedeekay/GingerShrew v0.0.0-20200828154258-d799f84952aa/go.mod h1:kDfSkqEyzswi8r4m6U0Q9jD4PJqOzKXVCX4XbYhBJCs=
github.com/eyedeekay/I2P-Configuration-for-Chromium v0.0.0-20200802063209-8973270c836e h1:oEoiXkil4L/ahtVlljDwz5LXbE1qBsJqvC3/utNrKe4=
github.com/eyedeekay/I2P-Configuration-for-Chromium v0.0.0-20200802063209-8973270c836e/go.mod h1:XchhjbeZKhEszN64SHavfaLGP2lFhWeO0ipH4cyBq5o=
github.com/eyedeekay/checki2cp v0.0.15 h1:Vlwp9opuQJSgp139VVrLkKXRwLYYrXiBkqed35ZbqzY=

View File

@@ -1,4 +1,4 @@
package main
package i2pbrowser
/*
Released under the The MIT License (MIT)

View File

@@ -1,6 +1,6 @@
//+build generate
package main
package i2pbrowser
/*
Released under the The MIT License (MIT)

View File

@@ -1,4 +1,4 @@
package main
package i2pbrowser
/*
Released under the The MIT License (MIT)
@@ -10,3 +10,7 @@ import "github.com/eyedeekay/i2pbrowser/lib"
func firefoxMain() {
i2pfirefox.FirefoxMain()
}
func firefoxLaunch() {
i2pfirefox.FirefoxLaunch()
}

View File

@@ -1,4 +1,4 @@
package main
package i2pbrowser
/*
Released under the The MIT License (MIT)

142
import/import.go Normal file
View File

@@ -0,0 +1,142 @@
//go:generate go run -tags generate gen.go extensions.go
/*
Released under the The MIT License (MIT)
see ./LICENSE
*/
package i2pbrowser
import (
"context"
"flag"
"fmt"
"log"
"net"
"net/http"
"os"
"path/filepath"
"runtime"
"time"
"github.com/eyedeekay/GingerShrew/import"
. "github.com/eyedeekay/go-fpw"
. "github.com/eyedeekay/i2pbrowser/lib"
"github.com/eyedeekay/zerobundle"
)
type handler struct {
}
func (h *handler) ServeHTTP(w http.ResponseWriter, req *http.Request) {
fmt.Fprintf(w, "hello\n")
/*In the future, we may use this as a sort of loopback for privately testing the browser
fingerprint. At first this will be 100% user-initiated, but it may be useful to query such
a service periodically, in order to inform the user when a fingerprint change has occurred
and prompt them to potentially re-set their browser to it's original state.
for name, headers := range req.Header {
for _, h := range headers {
fmt.Fprintf(w, "%v: %v\n", name, h)
}
}*/
}
func hello() error {
server := &http.Server{Addr: "localhost:", Handler: &handler{}}
go func() {
if err := server.ListenAndServe(); err != nil {
log.Println(err)
}
}()
// Setting up signal capturing
// stop := make(chan os.Signal, 1)
// signal.Notify(stop, os.Interrupt)
// Waiting for SIGINT (pkill -2)
// <-stop
ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second)
defer cancel()
if err := server.Shutdown(ctx); err != nil {
log.Println(err)
}
return nil
}
func proxyCheck() bool {
conn, err := net.Dial("tcp4", "localhost:4444")
log.Println("Doing dial check")
if err != nil {
return false
}
log.Println("Dial check true, proxy is up")
defer conn.Close()
return true
}
func Main() {
if err := hello(); err != nil {
log.Fatal(err)
}
chromium := flag.Bool("chromium", false, "use a chromium-based browser instead of a firefox-based browser.")
flag.Parse()
ARGS = append(ARGS, flag.Args()...)
ctx, cancel := context.WithCancel(context.Background())
defer cancel()
if runtime.GOOS == "linux" {
if !*chromium {
if os.Getenv("FIREFOX_BIN") == "" {
if err := gingershrew.UnpackTBZ(GingerDir); err != nil {
log.Fatal("Error unpacking embedded browser")
} else {
os.Setenv("LD_LIBRARY_PATH", filepath.Join(GingerDir, "lib/x86_64-linux-gnu")+","+filepath.Join(GingerDir, "usr/lib/x86_64-linux-gnu"))
log.Println("LD_LIBRARY_PATH", filepath.Join(GingerDir, "lib/x86_64-linux-gnu")+","+filepath.Join(GingerDir, "usr/lib/x86_64-linux-gnu"))
os.Setenv("FIREFOX_BIN", filepath.Join(GingerDir, "gingershrew", "gingershrew"))
}
}
}
} else {
if LocateFirefox() == "" {
*chromium = true
}
}
if err := WriteI2CPConf(); err != nil {
log.Println(err)
}
if err := zerobundle.ZeroMain(); err != nil {
log.Println(err)
}
time.Sleep(time.Second * 2)
if !proxyCheck() {
go proxyMain(ctx)
}
if !*chromium {
firefoxMain()
} else {
chromiumMain()
}
}
func MainNoEmbeddedStuff() {
if err := hello(); err != nil {
log.Fatal(err)
}
chromium := false
ARGS = append(ARGS, flag.Args()...)
ctx, cancel := context.WithCancel(context.Background())
defer cancel()
if LocateFirefox() == "" {
chromium = true
}
if !proxyCheck() {
go proxyMain(ctx)
}
if !chromium {
firefoxLaunch()
} else {
chromiumMain()
}
}

View File

@@ -92,6 +92,50 @@ func WriteProfile(FS *fs) bool {
return firstrun
}
func FirefoxLaunch() {
firstrun := WriteProfile(FS)
prefs := filepath.Join(UserDir, "/user.js")
if _, err := os.Stat(prefs); os.IsNotExist(err) {
if err := ioutil.WriteFile(prefs, []byte(PREFS), 0644); err == nil {
log.Println("wrote", prefs)
} else {
log.Fatal(err)
}
}
if firstrun {
_, ERROR := SecureExtendedFirefox(UserDir, false, EXTENSIONS, EXTENSIONHASHES, ARGS...)
if ERROR != nil {
log.Fatal(ERROR)
}
// defer FIREFOX.Close()
//<-FIREFOX.Done()
} else {
_, ERROR := BasicFirefox(UserDir, false, ARGS...)
if ERROR != nil {
log.Fatal(ERROR)
}
//<-FIREFOX.Done()
// defer FIREFOX.Close()
/* sigs := make(chan os.Signal, 1)
done := make(chan bool, 1)
signal.Notify(sigs, syscall.SIGINT, syscall.SIGTERM)
go func() {
sig := <-sigs
fmt.Println()
fmt.Println(sig)
done <- true
}()
fmt.Println("awaiting signal")
<-done
fmt.Println("exiting")
<-FIREFOX.Done()*/
}
}
func FirefoxMain() {
firstrun := WriteProfile(FS)
prefs := filepath.Join(UserDir, "/user.js")

108
main.go
View File

@@ -8,113 +8,9 @@ see ./LICENSE
package main
import (
"context"
"flag"
"fmt"
"log"
"net"
"net/http"
"os"
"path/filepath"
"runtime"
"time"
"github.com/eyedeekay/GingerShrew/import"
. "github.com/eyedeekay/go-fpw"
. "github.com/eyedeekay/i2pbrowser/lib"
"github.com/eyedeekay/zerobundle"
. "github.com/eyedeekay/i2pbrowser/import"
)
type handler struct {
}
func (h *handler) ServeHTTP(w http.ResponseWriter, req *http.Request) {
fmt.Fprintf(w, "hello\n")
/*In the future, we may use this as a sort of loopback for privately testing the browser
fingerprint. At first this will be 100% user-initiated, but it may be useful to query such
a service periodically, in order to inform the user when a fingerprint change has occurred
and prompt them to potentially re-set their browser to it's original state.
for name, headers := range req.Header {
for _, h := range headers {
fmt.Fprintf(w, "%v: %v\n", name, h)
}
}*/
}
func hello() error {
server := &http.Server{Addr: "localhost:", Handler: &handler{}}
go func() {
if err := server.ListenAndServe(); err != nil {
log.Println(err)
}
}()
// Setting up signal capturing
// stop := make(chan os.Signal, 1)
// signal.Notify(stop, os.Interrupt)
// Waiting for SIGINT (pkill -2)
// <-stop
ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second)
defer cancel()
if err := server.Shutdown(ctx); err != nil {
log.Println(err)
}
return nil
}
func proxyCheck() bool {
conn, err := net.Dial("tcp4", "localhost:4444")
log.Println("Doing dial check")
if err != nil {
return false
}
log.Println("Dial check true, proxy is up")
defer conn.Close()
return true
}
func main() {
if err := hello(); err != nil {
log.Fatal(err)
}
chromium := flag.Bool("chromium", false, "use a chromium-based browser instead of a firefox-based browser.")
flag.Parse()
ARGS = append(ARGS, flag.Args()...)
ctx, cancel := context.WithCancel(context.Background())
defer cancel()
if runtime.GOOS == "linux" {
if !*chromium {
if os.Getenv("FIREFOX_BIN") == "" {
if err := gingershrew.UnpackTBZ(GingerDir); err != nil {
log.Fatal("Error unpacking embedded browser")
} else {
os.Setenv("LD_LIBRARY_PATH", filepath.Join(GingerDir, "x86_64-linux-gnu"))
log.Println("LD_LIBRARY_PATH", filepath.Join(GingerDir, "x86_64-linux-gnu"))
os.Setenv("FIREFOX_BIN", filepath.Join(GingerDir, "gingershrew", "gingershrew"))
}
}
}
} else {
if LocateFirefox() == "" {
*chromium = true
}
}
if err := WriteI2CPConf(); err != nil {
log.Println(err)
}
if err := zerobundle.ZeroMain(); err != nil {
log.Println(err)
}
time.Sleep(time.Second * 2)
if !proxyCheck() {
go proxyMain(ctx)
}
if !*chromium {
firefoxMain()
} else {
chromiumMain()
}
Main()
}