Compare commits
5 Commits
Author | SHA1 | Date | |
---|---|---|---|
4d5f344b88 | |||
759a5aec9c | |||
a3982e2904 | |||
5dea25453c | |||
775052865c |
5
Makefile
5
Makefile
@ -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
|
||||
|
48
checki2cp.go
48
checki2cp.go
@ -40,7 +40,7 @@ var (
|
||||
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"
|
||||
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")
|
||||
@ -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
5
go.mod
Normal 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.
@ -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)
|
||||
}
|
||||
|
Reference in New Issue
Block a user