5 Commits

Author SHA1 Message Date
idk
4d5f344b88 Add find i2p function 2020-04-03 17:07:24 -04:00
idk
759a5aec9c Add find i2p function 2020-04-03 17:07:05 -04:00
idk
a3982e2904 Add find i2p function 2020-04-03 17:05:54 -04:00
idk
5dea25453c fix release 2020-01-21 21:40:49 -05:00
idk
775052865c fix releas 2020-01-21 21:39:16 -05:00
5 changed files with 63 additions and 14 deletions

View File

@ -2,12 +2,15 @@
GO111MODULE=on
VERSION=0.0.05
VERSION=0.0.06
USER_GH=eyedeekay
version:
gothub release -s $(GITHUB_TOKEN) -u $(USER_GH) -r checki2cp -t v$(VERSION) -d "I2P Router Checking CLI utility"
delete:
gothub delete -s $(GITHUB_TOKEN) -u $(USER_GH) -r checki2cp -t v$(VERSION)
GO_COMPILER_OPTS = -a -tags netgo -ldflags '-w -extldflags "-static"'
build: fmt test clean

View File

@ -36,15 +36,15 @@ func home() string {
}
var (
I2CP_HOST string = ""
I2CP_PORT string = ""
WINDOWS_DEFAULT_LOCATION string = `C:\\Program Files\i2p\i2psvc.exe`
I2PD_WINDOWS_DEFAULT_LOCATION string = `C:\\Program Files\I2Pd\i2pd.exe`
LINUX_SYSTEM_LOCATION string = "/usr/bin/i2prouter"
I2PD_LINUX_SYSTEM_LOCATION string = "/usr/sbin/i2pd"
I2P_ASUSER_HOME_LOCATION string = inithome(home())
HOME_DIRECTORY_LOCATION string = inithome("/i2p/i2prouter")
OSX_DEFAULT_LOCATION string = inithome("/Library/Application Support/i2p/clients.config")
I2CP_HOST string = ""
I2CP_PORT string = ""
WINDOWS_DEFAULT_LOCATION string = `C:\\Program Files\i2p\i2psvc.exe`
I2PD_WINDOWS_DEFAULT_LOCATION string = `C:\\Program Files\I2Pd\i2pd.exe`
LINUX_SYSTEM_LOCATION []string = []string{"/usr/bin/i2prouter", "/usr/sbin/i2prouter"}
I2PD_LINUX_SYSTEM_LOCATION string = "/usr/sbin/i2pd"
I2P_ASUSER_HOME_LOCATION string = inithome(home())
HOME_DIRECTORY_LOCATION string = inithome("/i2p/i2prouter")
OSX_DEFAULT_LOCATION string = inithome("/Library/Application Support/i2p/clients.config")
)
// CheckIC2PIsRunning is frequently the only thing I need a reliable, non-SAM
@ -81,7 +81,11 @@ func CheckI2PIsInstalledDefaultLocation() (bool, error) {
log.Println("Windows i2p router detected")
return true, nil
}
if checkfileexists(LINUX_SYSTEM_LOCATION) {
if checkfileexists(LINUX_SYSTEM_LOCATION[0]) {
log.Println("Linux i2p router detected")
return true, nil
}
if checkfileexists(LINUX_SYSTEM_LOCATION[1]) {
log.Println("Linux i2p router detected")
return true, nil
}
@ -123,7 +127,11 @@ func CheckI2PUserName() (string, error) {
log.Println("Windows i2p router detected")
return "i2psvc", nil
}
if checkfileexists(LINUX_SYSTEM_LOCATION) {
if checkfileexists(LINUX_SYSTEM_LOCATION[0]) {
log.Println("Linux i2p router detected")
return "i2psvc", nil
}
if checkfileexists(LINUX_SYSTEM_LOCATION[1]) {
log.Println("Linux i2p router detected")
return "i2psvc", nil
}
@ -156,3 +164,37 @@ func GetFirewallPort() (string, error) {
}
return "", fmt.Errorf("Improperly formed router.config file")
}
// FindI2PIsInstalledDefaultLocation looks in various locations for the
// presence of an I2P router, reporting back the location
func FindI2PIsInstalledDefaultLocation() (string, error) {
if checkfileexists(I2PD_WINDOWS_DEFAULT_LOCATION) {
log.Println("Windows i2pd router detected")
return I2PD_WINDOWS_DEFAULT_LOCATION, nil
}
if checkfileexists(I2PD_LINUX_SYSTEM_LOCATION) {
log.Println("Linux i2pd router detected")
return I2PD_LINUX_SYSTEM_LOCATION, nil
}
if checkfileexists(WINDOWS_DEFAULT_LOCATION) {
log.Println("Windows i2p router detected")
return WINDOWS_DEFAULT_LOCATION, nil
}
if checkfileexists(LINUX_SYSTEM_LOCATION[0]) {
log.Println("Linux i2p router detected")
return LINUX_SYSTEM_LOCATION[0], nil
}
if checkfileexists(LINUX_SYSTEM_LOCATION[1]) {
log.Println("Linux i2p router detected")
return LINUX_SYSTEM_LOCATION[1], nil
}
if checkfileexists(HOME_DIRECTORY_LOCATION) {
log.Println("Linux i2p router detected")
return HOME_DIRECTORY_LOCATION, nil
}
if checkfileexists(OSX_DEFAULT_LOCATION) {
log.Println("OSX i2p router detected")
return OSX_DEFAULT_LOCATION, nil
}
return "", fmt.Errorf("i2p router not found.")
}

5
go.mod Normal file
View File

@ -0,0 +1,5 @@
module github.com/eyedeekay/checki2cp
go 1.13
require github.com/eyedeekay/go-i2cp v0.0.0-20190716135428-6d41bed718b0

Binary file not shown.

View File

@ -13,11 +13,10 @@ func main() {
}
if ok {
log.Println("I2P is running, successfully confirmed I2CP")
os.Exit(0)
} else {
log.Println("I2P is not running, further testing is needed")
}
firewallport, err := checki2p.CheckFirewallPort()
firewallport, err := checki2p.GetFirewallPort()
if err != nil {
log.Fatal(err)
}