4 Commits

Author SHA1 Message Date
idk
8cd92a4b57 improve i2pd compat a bit 2020-05-16 21:10:31 -04:00
idk
26b7711543 improve i2pd compat a bit 2020-05-16 21:06:53 -04:00
idk
31afe70a4a improve OSX compatibility 2020-05-16 21:04:34 -04:00
idk
bf535b18bc Add godoc to readme 2020-05-15 20:42:07 -04:00
8 changed files with 163 additions and 85 deletions

View File

@ -33,6 +33,8 @@ func checkfileexists(path string) bool {
func home() string {
if runtime.GOOS == "windows" {
return "\\i2p"
} else if runtime.GOOS == "darwin" {
return "/Library/Application Support/i2p"
}
return "/.i2p"
}

View File

@ -0,0 +1,69 @@
package getmeanetdb
import (
"fmt"
"os"
"path/filepath"
"github.com/eyedeekay/checki2cp"
"github.com/eyedeekay/checki2cp/i2pdbundle"
)
var UnpackI2PdDir = i2pd.UnpackI2PdDir
// WhereIsTheNetDB returns the path to whatever the first local NetDB
// it can find is. If it can't find one, it will output the path to an embedded NetDB
func WhereIstheNetDB() (string, error) {
path, err := WhereIsTheConfigDir()
if err != nil {
return "", err
}
return filepath.Join(path, "netDb"), nil
}
// WhereIstheConfigDir returns the path to the I2P configuration
// directory or the path to the one that will be created if an
// embedded router is run.
func WhereIsTheConfigDir() (string, error) {
path, err := checki2p.FindI2PIsInstalledDefaultLocation()
if err != nil {
}
switch path {
case checki2p.WINDOWS_DEFAULT_LOCATION:
env := os.Getenv("APPDATA")
if env == "" {
return "", fmt.Errorf("Could not find local appdata path")
} else {
env = os.Getenv("LOCALAPPDATA")
if env == "" {
return "", fmt.Errorf("Could not find local appdata path")
}
}
return filepath.Join(env, "I2P"), nil
case checki2p.I2PD_WINDOWS_DEFAULT_LOCATION:
env := os.Getenv("APPDATA")
if env == "" {
return "", fmt.Errorf("Could not find local appdata path")
} else {
env = os.Getenv("LOCALAPPDATA")
if env == "" {
return "", fmt.Errorf("Could not find local appdata path")
}
}
return filepath.Join(env, "i2pd"), nil
case checki2p.LINUX_SYSTEM_LOCATION[0]:
return "/var/lib/i2p/i2p-config/", nil
case checki2p.LINUX_SYSTEM_LOCATION[1]:
return "/var/lib/i2p/i2p-config/", nil
case checki2p.I2PD_LINUX_SYSTEM_LOCATION:
return "/var/lib/i2pd/", nil
case checki2p.I2P_ASUSER_HOME_LOCATION:
return checki2p.I2P_ASUSER_HOME_LOCATION, nil
case checki2p.HOME_DIRECTORY_LOCATION:
return checki2p.I2P_ASUSER_HOME_LOCATION, nil
case checki2p.OSX_DEFAULT_LOCATION:
return checki2p.I2P_ASUSER_HOME_LOCATION, nil
}
return UnpackI2PdDir()
}

View File

@ -0,0 +1 @@
package getmeanetdb

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -137,7 +137,9 @@ var walkFn = func(path string, fi os.FileInfo, r io.ReadSeeker, err error) error
}
// WriteConfOptions generates a default config file for the bundle
func WriteConfOptions(targetdir string) error {
var WriteConfOptions = writeConfOptions
func writeConfOptions(targetdir string) error {
if FileOK(filepath.Join(filepath.Dir(targetdir), "i2pd.conf")) != nil {
err := ioutil.WriteFile(filepath.Join(filepath.Dir(targetdir), "i2pd.conf"), []byte(configFile), 0644)
if err != nil {
@ -148,7 +150,9 @@ func WriteConfOptions(targetdir string) error {
}
// WritetunnelOptions generates a default tunnel config file for the bundle
func WriteTunnelOptions(targetdir string) error {
var WriteTunnelOptions = writeTunnelOptions
func writeTunnelOptions(targetdir string) error {
if FileOK(filepath.Join(filepath.Dir(targetdir), "tunnels.conf")) != nil {
err := ioutil.WriteFile(filepath.Join(filepath.Dir(targetdir), "tunnels.conf"), []byte(tunnelFile), 0644)
if err != nil {
@ -159,7 +163,9 @@ func WriteTunnelOptions(targetdir string) error {
}
// WriteAllFiles generates an I2Pd installation and configuration for the bundle
func WriteAllFiles(targetdir string) error {
var WriteAllFiles = writeAllFiles
func writeAllFiles(targetdir string) error {
if err := vfsutil.WalkFiles(FS, "/", walkFn); err != nil {
return err
}