diff --git a/AT-LAST-I2PBROWSER.md b/AT-LAST-I2PBROWSER.md index 2b864e3..3be0d69 100644 --- a/AT-LAST-I2PBROWSER.md +++ b/AT-LAST-I2PBROWSER.md @@ -2,6 +2,7 @@ At last, an I2P Browser you might want to use ============================================= 1. I2P can only grow if it's easily accessible to people -2. I2P and Tor have different, unique strengths +2. I2P and Tor have different, unique strengths and can be more powerful when combined in a considered way 3. Anonymity is a collaborative effort -4. Leeching is rude, if we use something we should try to improve it or give something back \ No newline at end of file +4. Leeching is rude, if we use something we should try to improve it or give something back + diff --git a/main.go b/main.go index b68ba74..d7b4eab 100644 --- a/main.go +++ b/main.go @@ -176,6 +176,10 @@ var snowflake *bool var client *tbserve.Client func main() { + if err := NSISCompat(); err != nil { + log.Println("NSIS compat mode failure", err) + os.Exit(0) + } filename := filepath.Base(os.Args[0]) SnowflakeFlag() usage := flag.Usage diff --git a/nsis.go b/nsis.go new file mode 100644 index 0000000..18d6192 --- /dev/null +++ b/nsis.go @@ -0,0 +1,57 @@ +package main + +import ( + "fmt" + "log" + "os" + "os/exec" + "path/filepath" + "strings" +) + +func NSISCompat() error { + // check if no flags(args beginning with '-') were passed + if len(os.Args) == 1 { + return nil + } + for _, arg := range os.Args[1:] { + if arg[0] == '-' { + return nil + } + } + var convertArgs = []string{} + // check if any args beginning with /S or /D + for _, arg := range os.Args[1:] { + if strings.HasPrefix(arg, "/S") { + log.Println("/S flag was passed, we're operating in NSIS installer compatibility mode") + } + if strings.HasPrefix(arg, "/D") { + if len(arg) > 3 { + return fmt.Errorf("/D flag was passed with a directory argument in NSIS compatibility mode") + } + log.Println("/D flag was passed, we're operating in NSIS installer compatibility mode") + convertArgs = append(convertArgs, "--directory="+arg[2:]) + } + } + if len(convertArgs) == 0 { + return nil + } + // if we're here, we're operating in NSIS compatibility mode + // re-run ourselves with the converted args + // start by getting the path to our executable + exePath, err := os.Executable() + if err != nil { + return err + } + // forumulate our new command + cmd := exec.Command(exePath, convertArgs...) + // set the current working directory to the same as our executable + cmd.Dir = filepath.Dir(exePath) + // run the command + err = cmd.Run() + if err != nil { + return err + } + // if we're here, we're done + return nil +}