Compare commits
4 Commits
Author | SHA1 | Date | |
---|---|---|---|
8cd92a4b57 | |||
26b7711543 | |||
31afe70a4a | |||
bf535b18bc |
@ -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"
|
||||
}
|
||||
|
69
getmeanetdb/getmeanetdb.go
Normal file
69
getmeanetdb/getmeanetdb.go
Normal 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()
|
||||
}
|
1
getmeanetdb/getmeanetdb_test.go
Normal file
1
getmeanetdb/getmeanetdb_test.go
Normal 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
@ -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
|
||||
}
|
||||
|
Reference in New Issue
Block a user