Library and terminal application which checks for the presence of a usable i2p router by attempting various I2P client-related probes and tests. Includes everything you need to completely embed I2Pd in a Go application on Linux, OSX, and Windows, or use them as modular tools for checking the status of your I2P router.
Currently the command-line tool only does presence detection by checking for I2CP and or an I2P router installed in a default location.
ok, err := CheckI2PIsInstalledDefaultLocation()
if err != nil {
t.Fatal(err)
}
if ok {
t.Log("I2P is installed, successfully confirmed")
} else {
t.Log("I2P is in a default location, user feedback is needed")
}
ok, err := CheckI2PIsRunning()
if err != nil {
t.Fatal(err)
}
if ok {
t.Log("I2P is running, successfully confirmed I2CP")
} else {
t.Log("I2P is not running, further testing is needed")
}
TODO: Make this function work better with i2pd, find a way to integrate it into into the tests, then write the example.
if ProxyDotI2P() {
t.Log("Proxy success")
} else {
t.Fatal("Proxy not found")
}
It honors the
http_proxy
environment variable, so just set it(I like to set both of these in case some system is
weird, I suppose it’s a meager measure.):
if err := os.Setenv("HTTP_PROXY", "http://127.0.0.1:4444"); err != nil {
return false
}
if err := os.Setenv("http_proxy", "http://127.0.0.1:4444"); err != nil {
return false
}
if ProxyDotI2P() {
t.Log("Proxy success")
} else {
t.Fatal("Proxy not found")
}
if CheckSAMAvailable("") {
t.Log("SAM success")
} else {
t.Fatal("SAM not found")
}
if CheckSAMAvailable("127.0.1.1:1234") {
t.Log("SAM success")
} else {
t.Fatal("SAM not found")
}
In the very far future, it would be cool to have a 100% pure-Go I2P router, but for right now, what I want to work on is a way of working with I2P and with Go applications, without requiring undue knowledge on the part of the user. The theory is that they want to install one application at a time, and don’t want to run more than one I2P router unless they need to. So the embedding tools assume that if they find an I2P router, that they should use that I2P router. At this time, almost any useful I2P configuration will be detected and the embedded router will not start. In the future, this behavior will be configurable.
if itworks, err := CheckI2PControlEcho("", "", "", ""); works {
t.Log("Proxy success")
} else if err != nil {
t.Fatal(err)
} else {
t.Fatal("Proxy not found")
}
TODO: Explain why you need this if your goal is to tolerate Java, I2Pd, and Embedded I2Pd all at once
if host, port, path, err := GetDefaultI2PControlPath(); err != nil {
t.Fatal("I2PControl Not found")
} else {
t.Log("I2Pcontrol found at", host, port, path)
}
This will completely install, configure, wrap, and run a minimal i2pd router from within a Go application. From here you attach applications via SAM and I2PControl.
package main
import (
"log"
"github.com/eyedeekay/checki2cp/i2pdbundle"
)
func main() {
if err := i2pd.UnpackI2Pd(); err != nil {
log.Println(err)
}
if path, err := i2pd.FindI2Pd(); err != nil {
log.Println(err)
} else {
log.Println(path)
}
// if cmd, err := i2pd.LaunchI2Pd(); err != nil {
if _, err := i2pd.LaunchI2Pd(); err != nil {
log.Println(err)
}
}
libboost-date-time1.67.0,libboost-filesystem1.67.0,libboost-program-options1.67.0,libboost-system1.67.0,libc6,libgcc1,libminiupnpc17,libssl1.1,libstdc++6,zlib1g,lsb-base
MIT License
Copyright (c) 2019 idk
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
Hide license