Compare commits
122 Commits
Author | SHA1 | Date | |
---|---|---|---|
8cd92a4b57 | |||
26b7711543 | |||
31afe70a4a | |||
bf535b18bc | |||
e6a6f50cc7 | |||
d1a7b72071 | |||
de9c5b8a11 | |||
c1c1d8643e | |||
4330702ceb | |||
a48f4eb9d9 | |||
ee5c8f5189 | |||
76f9c6c729 | |||
7083c338bf | |||
84e98dcb07 | |||
de115ff851 | |||
a16c24e3f6 | |||
7c0c7ff219 | |||
5e90ce02df | |||
67faec9746 | |||
d6caa793cd | |||
ac28ba748b | |||
cadee441e7 | |||
e39ac2ec32 | |||
46522c0cac | |||
bdafad7005 | |||
5d489a8942 | |||
6a61d26e7a | |||
80637cde24 | |||
64519cbfd4 | |||
322857037b | |||
148858f5f6 | |||
0fac0870b5 | |||
1714e0bd59 | |||
d6b2ed372d | |||
69ba077931 | |||
23e38e8cc1 | |||
6c60c1f209 | |||
60536cec17 | |||
d3e1db40cb | |||
e3a29e9d09 | |||
b4bac15c97 | |||
982c1e8433 | |||
b77c62c0d9 | |||
e4f6eb6b01 | |||
1a94f9c002 | |||
1777ac1ffd | |||
847f302996 | |||
81c8315bdc | |||
94d2bb0a8c | |||
e51e271a4c | |||
f53e5538b3 | |||
dc5f7c6f86 | |||
c55794e9c5 | |||
384e18adfa | |||
351321451f | |||
e2fd37915a | |||
b3d52b9814 | |||
d879529160 | |||
8322751059 | |||
ef1e734272 | |||
d6f38ec2fe | |||
d01a0d006b | |||
39197765cc | |||
f3afec5baf | |||
7e90907275 | |||
32805a46a1 | |||
02f4952e03 | |||
14a0a2f936 | |||
0aac6adc7f | |||
380f815c9b | |||
138b33004c | |||
c39e1d3ca9 | |||
59c7be16eb | |||
bad6581c58 | |||
7dbcd9250d | |||
9a6aec3572 | |||
1fc9b4434b | |||
4b9ec28b51 | |||
ac84962019 | |||
6e7a3cc7e7 | |||
1cccd225cc | |||
2c54f78916 | |||
6e58fa6b89 | |||
26d737065f | |||
d64dba523f | |||
f0d99c571c | |||
d16aa9c5d0 | |||
5951aa1de8 | |||
6418611681 | |||
38669552bb | |||
444db8da69 | |||
1fdf0792e2 | |||
8182593513 | |||
a9121331c7 | |||
21e9812057 | |||
aa2370e598 | |||
b552af3fc9 | |||
0f09f719f9 | |||
bc19ad29af | |||
0395860c7c | |||
69b9f4a6e5 | |||
57caf7c8a5 | |||
8e3c3933cf | |||
d46e7e76a1 | |||
3f96e9240a | |||
d998e46dc7 | |||
51e976fc2b | |||
fc9ff2e443 | |||
9258a782f1 | |||
69a1415faa | |||
2fad4bb6a9 | |||
66313bb7f0 | |||
40e6aac44e | |||
3f4bea6c35 | |||
7eea40c5aa | |||
3bff02397e | |||
b46f04344d | |||
dbb85e950b | |||
e6e48920d8 | |||
acc8d4e0f5 | |||
750ce7e6d8 | |||
643d7991fd |
28
.gitignore
vendored
Normal file
28
.gitignore
vendored
Normal file
@ -0,0 +1,28 @@
|
||||
zerobundle/i2p-zero
|
||||
zerobundle/mac/assets.go
|
||||
zerobundle/windows/assets.go
|
||||
zerobundle/linux/assets.go
|
||||
i2pdbundle/i2pd
|
||||
i2pdbundle/zlib
|
||||
i2pdbundle/openssl
|
||||
i2pdbundle/boost
|
||||
i2pdbundle/miniupnpc
|
||||
i2pdbundle/mac
|
||||
i2pdbundle/win
|
||||
i2pdbundle/linux
|
||||
i2pdbundle/*amd64/
|
||||
i2pdbundle/*386/
|
||||
i2pdbungle/*.zip
|
||||
i2pdbundle/mac/
|
||||
i2pdbundle/test/
|
||||
i2pdbundle/test_files/
|
||||
i2pdbundle/mac.zip
|
||||
i2pdbundle/windows.zip
|
||||
go-i2pd/*/
|
||||
go-i2pd/*.keys
|
||||
go-i2pd/*.info
|
||||
go-i2pd/*.pem
|
||||
go-i2pd/go-i2pd
|
||||
go-i2pd/go-i2pd.exe
|
||||
i2cpcheck/i2cpcheck
|
||||
i2cpcheck/i2cpcheck.exe
|
114
Makefile
114
Makefile
@ -2,7 +2,7 @@
|
||||
|
||||
GO111MODULE=on
|
||||
|
||||
VERSION=0.0.07
|
||||
VERSION=0.0.12
|
||||
USER_GH=eyedeekay
|
||||
|
||||
version:
|
||||
@ -13,12 +13,25 @@ delete:
|
||||
|
||||
GO_COMPILER_OPTS = -a -tags netgo -ldflags '-w -extldflags "-static"'
|
||||
|
||||
launchers: fmt test clean
|
||||
cd ./go-i2pd && rm -rf i2pd lib i2pd.pid && go build $(GO_COMPILER_OPTS)
|
||||
cd ./go-i2pd && rm -rf i2pd lib i2pd.pid && GOOS=windows go build -o go-i2pd.exe $(GO_COMPILER_OPTS)
|
||||
cd ./go-i2pd && rm -rf i2pd lib i2pd.pid && GOOS=windows go build -o go-i2pd-32.exe $(GO_COMPILER_OPTS)
|
||||
#cd ./go-i2pd && rm -rf i2pd lib i2pd.pid && GOOS=darwin go build $(GO_COMPILER_OPTS)
|
||||
|
||||
|
||||
btest: fmt
|
||||
cd ./go-i2pd && rm -rf i2pd lib i2pd.pid && go build $(GO_COMPILER_OPTS) && ./go-i2pd
|
||||
|
||||
build: fmt test clean
|
||||
cd ./i2cpcheck && go build $(GO_COMPILER_OPTS)
|
||||
cd ./i2cpcheck && GOOS=windows GOARCH=amd64 go build $(GO_COMPILER_OPTS) -buildmode=exe -o i2cpcheck.exe
|
||||
|
||||
test:
|
||||
go test -v
|
||||
go test -v ./controlcheck
|
||||
go test -v ./samcheck
|
||||
go test -v ./proxycheck
|
||||
|
||||
cli:
|
||||
./i2cpcheck/i2cpcheck && echo "Error condition confirmed"
|
||||
@ -28,3 +41,102 @@ clean:
|
||||
|
||||
fmt:
|
||||
find . -name '*.go' -exec gofmt -w -s {} \;
|
||||
|
||||
ZERO_VERSION=v1.16
|
||||
|
||||
i2p-zero:
|
||||
cd zerobundle && git clone https://github.com/i2p-zero/i2p-zero.git; \
|
||||
cd i2p-zero && \
|
||||
git fetch --all --tags && \
|
||||
git checkout $(ZERO_VERSION)
|
||||
|
||||
zero-build: i2p-zero
|
||||
cd zerobundle/i2p-zero && \
|
||||
./bin/build-all-and-zip.sh
|
||||
|
||||
zero-zip:
|
||||
|
||||
zero-bundle: zero-zip
|
||||
cd zerobundle && \
|
||||
go run --tags generate ./gen/gen.go
|
||||
|
||||
ZEROB_VERSION=z9.45.12
|
||||
|
||||
zero-assets:
|
||||
gothub release -p -u eyedeekay -r "checki2cp" -t $(ZEROB_VERSION) -n "I2P Zero pre-encoded assets" -d "assets.go file containing a zipped bundle of I2P Zero"
|
||||
gothub upload -R -u eyedeekay -r "checki2cp" -t $(ZEROB_VERSION) -n "assets_windows.go" -f "zerobundle/windows/assets.go"
|
||||
gothub upload -R -u eyedeekay -r "checki2cp" -t $(ZEROB_VERSION) -n "assets_darwin.go" -f "zerobundle/mac/assets.go"
|
||||
gothub upload -R -u eyedeekay -r "checki2cp" -t $(ZEROB_VERSION) -n "assets_linux.go" -f "zerobundle/linux/assets.go"
|
||||
|
||||
I2PD_VERSION=2.31.0
|
||||
|
||||
i2pd-clean:
|
||||
rm -rf i2pdbundle/osx i2pdbundle/win_amd64 i2pdbundle/win_386 i2pdbundle/linux_amd64 i2pdbundle/test i2pdbundle/test_files
|
||||
|
||||
i2pd-zip: i2pd-clean i2pd-linux
|
||||
mkdir -p i2pdbundle/mac i2pdbundle/win_amd64 i2pdbundle/win_386 i2pdbundle/test i2pdbundle/test/subtest i2pdbundle/test/subtest/subsubtest i2pdbundle/test/subsubsubtest
|
||||
wget -c -qO i2pdbundle/mac.tar.gz https://github.com/PurpleI2P/i2pd/releases/download/$(I2PD_VERSION)/i2pd_$(I2PD_VERSION)_osx.tar.gz
|
||||
cd i2pdbundle/mac && cp ../mac.tar.gz .
|
||||
wget -c -qO i2pdbundle/win_amd64.zip https://github.com/PurpleI2P/i2pd/releases/download/$(I2PD_VERSION)/i2pd_$(I2PD_VERSION)_win64_mingw_avx_aesni.zip
|
||||
cd i2pdbundle/win_amd64 && cp ../win_amd64.zip .
|
||||
wget -c -qO i2pdbundle/win_386.zip https://github.com/PurpleI2P/i2pd/releases/download/$(I2PD_VERSION)/i2pd_$(I2PD_VERSION)_win32_mingw_avx_aesni.zip
|
||||
cd i2pdbundle/win_386 && cp ../win_386.zip .
|
||||
touch i2pdbundle/test/test.txt \
|
||||
i2pdbundle/test/subtest/test.txt \
|
||||
i2pdbundle/test/subtest/subsubtest/test.txt \
|
||||
i2pdbundle/test/subsubsubtest/test.txt \
|
||||
i2pdbundle/test/test_other.txt \
|
||||
i2pdbundle/test/subtest/test_other.txt \
|
||||
i2pdbundle/test/subtest/subsubtest/test_other.txt \
|
||||
i2pdbundle/test/subsubsubtest/test_other.txt
|
||||
|
||||
i2pd-linux:
|
||||
mkdir -p i2pdbundle/linux_amd64/lib
|
||||
cd $(WORK_DIR)/i2pd-static-64-build/ && tar czvf ../../../i2pdbundle/linux_amd64/i2pd.tar.gz ./i2pd
|
||||
cp /lib64/ld-linux-x86-64.so.2 i2pdbundle/linux_amd64/lib
|
||||
cp /lib/x86_64-linux-gnu/libc.so.6 i2pdbundle/linux_amd64/lib
|
||||
cp /lib/x86_64-linux-gnu/libdl.so.2 i2pdbundle/linux_amd64/lib
|
||||
cp /lib/x86_64-linux-gnu/libgcc_s.so.1 i2pdbundle/linux_amd64/lib
|
||||
cp /lib/x86_64-linux-gnu/libm.so.6 i2pdbundle/linux_amd64/lib
|
||||
cp /lib/x86_64-linux-gnu/libpthread.so.0 i2pdbundle/linux_amd64/lib
|
||||
cp /usr/lib/x86_64-linux-gnu/libstdc++.so.6 i2pdbundle/linux_amd64/lib
|
||||
cd i2pdbundle/linux_amd64/lib && tar czvf ../lib.tar.gz .
|
||||
rm -rf i2pdbundle/linux_amd64/lib
|
||||
|
||||
|
||||
i2p-i2pd:
|
||||
cd i2pdbundle && git clone https://github.com/purplei2p/i2pd.git; \
|
||||
cd i2pd && \
|
||||
git fetch --all --tags && \
|
||||
git checkout $(I2PD_VERSION)
|
||||
|
||||
|
||||
#i2pd-build-static: i2p-i2pd
|
||||
# cd i2pdbundle/i2pd/ && make clean && \
|
||||
# USE_STATIC=yes make USE_STATIC=yes
|
||||
|
||||
|
||||
WORK_DIR=$(PWD)/i2pdbundle/i2pd
|
||||
|
||||
i2pd-build: i2p-i2pd
|
||||
cd $(WORK_DIR) && \
|
||||
rm -rf $(WORK_DIR)/i2pd-static-64-build && \
|
||||
mkdir -p $(WORK_DIR)/i2pd-static-64-build && \
|
||||
cd $(WORK_DIR)/i2pd-static-64-build && \
|
||||
cmake -G 'Unix Makefiles' $(WORK_DIR)/build \
|
||||
-DBUILD_TYPE=Release \
|
||||
-DWITH_STATIC=ON -DWITH_HARDENING=ON -DWITH_UPNP=ON \
|
||||
-DCMAKE_INSTALL_PREFIX:PATH=$(WORK_DIR)/i2pd-static-64-build && \
|
||||
make CXXFLAGS=-static
|
||||
|
||||
i2pd-bundle: i2pd-zip
|
||||
cd i2pdbundle && \
|
||||
go run --tags generate ./gen.go
|
||||
|
||||
I2PDB_VERSION=d9.45.12
|
||||
|
||||
i2pd-assets:
|
||||
#gothub release -p -u eyedeekay -r "checki2cp" -t $(I2PD_VERSION) -n "i2pd C++ pre-encoded assets" -d "assets.go file containing a zipped bundle of I2P Zero"
|
||||
#gothub upload -R -u eyedeekay -r "checki2cp" -t $(I2PD_VERSION) -n "assets_windows.go" -f "i2pdbundle/windows/assets.go"
|
||||
#gothub upload -R -u eyedeekay -r "checki2cp" -t $(I2PD_VERSION) -n "assets_darwin.go" -f "i2pdbundle/mac/assets.go"
|
||||
#gothub upload -R -u eyedeekay -r "checki2cp" -t $(I2PD_VERSION) -n "assets_linux.go" -f "i2pdbundle/linux_amd64/assets.go"
|
||||
|
197
README.md
197
README.md
@ -1,17 +1,188 @@
|
||||
# checki2cp
|
||||
checki2cp
|
||||
=========
|
||||
|
||||
[](https://goreportcard.com/report/github.com/eyedeekay/checki2cp)
|
||||
[](http://godoc.org/github.com/eyedeekay/checki2cp)
|
||||
|
||||
Library and terminal application which checks for the presence of a usable i2p
|
||||
router by attempting to connect to i2cp. Yet another tiny but essential function
|
||||
I don't want to be bothered with writing a billion times.
|
||||
router by attempting various I2P client-related probes and tests. Includes
|
||||
everything you need to completely embed I2Pd in a Go application on Linux,
|
||||
with Windows and OSX support forthcoming.
|
||||
|
||||
It contains just two functions, for helping Go applications confirm the presence
|
||||
of an I2P router on the system. The first is *CheckI2PIsRunning*, which attempts
|
||||
to connect to the I2CP Port, generate a destination, and quit. If this is
|
||||
successful, an i2p router is obviously installed. The second is
|
||||
*CheckI2PIsInstalledDefaultLocation* which checks the default locations for
|
||||
the I2P router on various platforms to confirm whether an i2p router is present.
|
||||
Both of these functions return a bool and an error. If a router is present, they
|
||||
return true amd nil, if not, they return false and an error.
|
||||
Directories
|
||||
-----------
|
||||
|
||||
It does not launch the router or anything else to do with managing the router.
|
||||
It is solely for checking whether a router is present.
|
||||
* **./** **-** Files in the base directory contain functions that check for the presence of an I2P router in a default
|
||||
location, or for the presence of an I2CP port. Makefile is also here.
|
||||
* **./controlcheck** **-** Detects whether an I2PControl API endpoint is available, and provides a tool for finding
|
||||
one if it is available. It is not recommended to use I2PControl checking for presence detection, you will need to
|
||||
parse the errors to know what is going on.
|
||||
* **./go-i2pd** **-** An example of running an embedded I2Pd router from a Go application
|
||||
* **./i2cpcheck** **-** A terminal application which probes for an I2P router by looking in a default location, the
|
||||
$PATH, or by probing I2CP.
|
||||
* **./i2pdbundle** **-** A set of tools and libraries for embedding an I2Pd router in a Go application, then
|
||||
installing it to a location under the application's control.
|
||||
* **./proxycheck** **-** A tool for determining the presence of an I2P router by making a request(to "proxy.i2p" by
|
||||
default) over an I2P HTTP Proxy.
|
||||
* **./samcheck** **-** A tool for determining the presence of an I2P router by doing a brief interaction with the SAM
|
||||
API.
|
||||
* **./zerobundle** **-** *DO NOT USE THIS!* It will require some lateral thinking to make this one work right.
|
||||
|
||||
I2P Router Presence Detection tools
|
||||
-----------------------------------
|
||||
|
||||
Currently the command-line tool only does presence detection by checking for I2CP and or an I2P router installed in a
|
||||
default location.
|
||||
|
||||
### Examples:
|
||||
|
||||
#### ./ Base Directory
|
||||
|
||||
##### Checking for an I2P Router by default install 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")
|
||||
}
|
||||
|
||||
##### Checking for an I2P Router by I2CP Port
|
||||
|
||||
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")
|
||||
}
|
||||
|
||||
##### Launching an installed I2P router from the Library
|
||||
|
||||
TODO: Make this function work better with i2pd, find a way to integrate it into into the tests, then write the example.
|
||||
|
||||
#### ./proxycheck
|
||||
|
||||
##### Make a request through the default I2P HTTP Proxy to test presence
|
||||
|
||||
if ProxyDotI2P() {
|
||||
t.Log("Proxy success")
|
||||
} else {
|
||||
t.Fatal("Proxy not found")
|
||||
}
|
||||
|
||||
##### Use a non-default proxy instead
|
||||
|
||||
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")
|
||||
}
|
||||
|
||||
#### ./samcheck
|
||||
|
||||
##### Check if SAM is available on a default port
|
||||
|
||||
if CheckSAMAvailable("") {
|
||||
t.Log("SAM success")
|
||||
} else {
|
||||
t.Fatal("SAM not found")
|
||||
}
|
||||
|
||||
##### Check if SAM is available on a non-default host or port
|
||||
|
||||
if CheckSAMAvailable("127.0.1.1:1234") {
|
||||
t.Log("SAM success")
|
||||
} else {
|
||||
t.Fatal("SAM not found")
|
||||
}
|
||||
|
||||
I2PD Embedding Tools:
|
||||
---------------------
|
||||
|
||||
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.
|
||||
|
||||
#### ./controlcheck
|
||||
|
||||
##### See if an I2PControl API is present on any default port
|
||||
|
||||
if itworks, err := CheckI2PControlEcho("", "", "", ""); works {
|
||||
t.Log("Proxy success")
|
||||
} else if err != nil {
|
||||
t.Fatal(err)
|
||||
} else {
|
||||
t.Fatal("Proxy not found")
|
||||
}
|
||||
|
||||
##### Check what host:port/path corresponds to an available default I2PControl API
|
||||
|
||||
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)
|
||||
}
|
||||
|
||||
#### ./i2pdbundle
|
||||
|
||||
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)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
### Roadmap
|
||||
|
||||
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
|
||||
|
||||
1. Minimum requirement for Golang UI: Use i2pd and a custom LD\_LIBRARY\_PATH to create an i2pd bundle for use as a
|
||||
fallback in the non-presence of a usable router.
|
||||
2. Set up router with SWIG instead of with static embedded executable.
|
||||
3. Minimize number of components we build(nothing but I2PControl, SAM, and
|
||||
I2CP).
|
||||
4. Provide easy router/client setup functions to import i2p routers into
|
||||
applications with minimal boilerplate.
|
||||
3. Pure-Go I2PControl implementation.
|
||||
4. Pure-Go SAM implementation.
|
||||
5. Pure-Go I2CP implementation.
|
||||
|
80
checki2cp.go
80
checki2cp.go
@ -2,13 +2,15 @@ package checki2p
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/eyedeekay/go-i2cp"
|
||||
"io/ioutil"
|
||||
"log"
|
||||
"os"
|
||||
"os/exec"
|
||||
"os/user"
|
||||
"runtime"
|
||||
"strings"
|
||||
|
||||
"github.com/eyedeekay/go-i2cp"
|
||||
)
|
||||
|
||||
func inithome(str string) string {
|
||||
@ -31,23 +33,38 @@ 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"
|
||||
}
|
||||
|
||||
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 = []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")
|
||||
// I2CP_HOST is the i2cp host
|
||||
I2CP_HOST string
|
||||
// I2CP_PORT is the i2cp port
|
||||
I2CP_PORT string
|
||||
// WINDOWS_DEFAULT_LOCATION
|
||||
WINDOWS_DEFAULT_LOCATION string = `C:\\Program Files\i2p\i2psvc.exe`
|
||||
// I2PD_WINDOWS_DEFAULT_LOCATION
|
||||
I2PD_WINDOWS_DEFAULT_LOCATION string = `C:\\Program Files\I2Pd\i2pd.exe`
|
||||
// LINUX_SYSTEM_LOCATION
|
||||
LINUX_SYSTEM_LOCATION []string = []string{"/usr/bin/i2prouter", "/usr/sbin/i2prouter"}
|
||||
// I2PD_LINUX_SYSTEM_LOCATION
|
||||
I2PD_LINUX_SYSTEM_LOCATION string = "/usr/sbin/i2pd"
|
||||
// I2P_ASUSER_HOME_LOCATION This is the path to the default I2P config directory when running as a user
|
||||
I2P_ASUSER_HOME_LOCATION string = inithome(home())
|
||||
// HOME_DIRECTORY_LOCATION can use config/run from a user's $HOME directory, this is the path to that router
|
||||
HOME_DIRECTORY_LOCATION string = inithome("/i2p/i2prouter")
|
||||
// OSX_DEFAULT_LOCATION
|
||||
OSX_DEFAULT_LOCATION string = inithome("/Library/Application Support/i2p/clients.config")
|
||||
)
|
||||
|
||||
// CheckIC2PIsRunning is frequently the only thing I need a reliable, non-SAM
|
||||
func i2pdArgs() ([]string, error) {
|
||||
return []string{""}, nil
|
||||
}
|
||||
|
||||
// CheckI2PIsRunning is frequently the only thing I need a reliable, non-SAM
|
||||
// way to test at runtime.
|
||||
func CheckI2PIsRunning() (bool, error) {
|
||||
client := go_i2cp.NewClient(nil)
|
||||
@ -100,6 +117,8 @@ func CheckI2PIsInstalledDefaultLocation() (bool, error) {
|
||||
return false, nil
|
||||
}
|
||||
|
||||
// UserFind makes sure that we never mis-identify the user account because of
|
||||
// sudo
|
||||
func UserFind() string {
|
||||
if os.Geteuid() == 0 {
|
||||
str := os.Getenv("SUDO_USER")
|
||||
@ -148,7 +167,8 @@ func CheckI2PUserName() (string, error) {
|
||||
|
||||
// GetFirewallPort finds the configured UDP port of your I2P router to help
|
||||
// configure firewalls. It does this by finding the router.config and reading
|
||||
// it.
|
||||
// it. This function will not work on I2Pd routers yet but it should be easy
|
||||
// to add support once I get some more time to test and research it.
|
||||
func GetFirewallPort() (string, error) {
|
||||
log.Println(I2P_ASUSER_HOME_LOCATION)
|
||||
file, err := ioutil.ReadFile(I2P_ASUSER_HOME_LOCATION + "/router.config")
|
||||
@ -198,3 +218,39 @@ func FindI2PIsInstalledDefaultLocation() (string, error) {
|
||||
}
|
||||
return "", fmt.Errorf("i2p router not found.")
|
||||
}
|
||||
|
||||
// ConditionallyLaunchI2P If an already-installed I2P router is present, then
|
||||
// make sure that it is started, i.e. launch the router *only* if it is not
|
||||
// already running.
|
||||
func ConditionallyLaunchI2P() (bool, error) {
|
||||
ok, err := CheckI2PIsInstalledDefaultLocation()
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
if ok {
|
||||
ok, err := CheckI2PIsRunning()
|
||||
if err == nil {
|
||||
if !ok {
|
||||
path, err := FindI2PIsInstalledDefaultLocation()
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
if strings.HasSuffix(path, "i2prouter") {
|
||||
cmd := exec.Command(path, "start")
|
||||
if err := cmd.Start(); err != nil {
|
||||
return false, fmt.Errorf("I2P router startup failure %s", err)
|
||||
}
|
||||
} else {
|
||||
cmd := exec.Command(path, "--daemon")
|
||||
if err := cmd.Start(); err != nil {
|
||||
return false, fmt.Errorf("I2P router startup failure %s", err)
|
||||
}
|
||||
}
|
||||
return true, nil
|
||||
}
|
||||
return true, nil
|
||||
}
|
||||
return false, err
|
||||
}
|
||||
return false, fmt.Errorf("I2P is not a default location, please set $I2P environment variable")
|
||||
}
|
||||
|
8
cmd.sh
Normal file
8
cmd.sh
Normal file
@ -0,0 +1,8 @@
|
||||
BOOST_ROOT=$WORK_DIR/boost cmake -G 'Unix Makefiles' $WORK_DIR/i2pd/build \
|
||||
-DBUILD_TYPE=Release \
|
||||
-DCMAKE_TOOLCHAIN_FILE=$WORK_DIR/toolchain-mingw.cmake \
|
||||
-DWITH_AESNI=ON -DWITH_STATIC=ON -DWITH_HARDENING=ON -DWITH_LIBRARY=OFF \
|
||||
-DCMAKE_INSTALL_PREFIX:PATH=$WORK_DIR/i2pd/i2pd-mingw-64-static \
|
||||
-DZLIB_ROOT=$WORK_DIR/stage \
|
||||
-DBOOST_LIBRARYDIR:PATH=$WORK_DIR/boost/stage-mingw-64/lib \
|
||||
-DOPENSSL_ROOT_DIR:PATH=$WORK_DIR/stage
|
82
controlcheck/checki2pcontrol.go
Normal file
82
controlcheck/checki2pcontrol.go
Normal file
@ -0,0 +1,82 @@
|
||||
package checki2pcontrol
|
||||
|
||||
import (
|
||||
"github.com/eyedeekay/go-i2pcontrol"
|
||||
)
|
||||
|
||||
// CheckI2PControlEcho attempts a connection and an echo command on it.
|
||||
// it returns true if the command is successful and false, with an error,
|
||||
// if not.
|
||||
func CheckI2PControlEcho(host, port, password, path string) (bool, error) {
|
||||
if host == "" {
|
||||
host = "127.0.0.1"
|
||||
}
|
||||
if port == "" {
|
||||
port = "7650"
|
||||
}
|
||||
if password == "" {
|
||||
password = "itoopie"
|
||||
}
|
||||
i2pcontrol.Initialize(host, port, path)
|
||||
var finalError error
|
||||
if _, err := i2pcontrol.Authenticate(password); err != nil {
|
||||
finalError = err
|
||||
}
|
||||
if _, err := i2pcontrol.Echo("Hello I2PControl"); err != nil {
|
||||
finalError = err
|
||||
}
|
||||
if finalError == nil {
|
||||
return true, nil
|
||||
}
|
||||
finalError = nil
|
||||
port = "7657"
|
||||
password = "itoopie"
|
||||
path = "jsonrpc"
|
||||
i2pcontrol.Initialize(host, port, path)
|
||||
if _, err := i2pcontrol.Authenticate(password); err != nil {
|
||||
finalError = err
|
||||
}
|
||||
if _, err := i2pcontrol.Echo("Hello I2PControl"); err != nil {
|
||||
finalError = err
|
||||
}
|
||||
if finalError == nil {
|
||||
return true, nil
|
||||
}
|
||||
return false, finalError
|
||||
}
|
||||
|
||||
// GetDefaultI2PControlPath probes default locations for the I2PControl API, returning
|
||||
// either a working I2PControl API and no error, or the defaults of the embedded router
|
||||
// and an error
|
||||
func GetDefaultI2PControlPath() (string, string, string, error) {
|
||||
host := "127.0.0.1"
|
||||
port := "7650"
|
||||
password := "itoopie"
|
||||
path := ""
|
||||
i2pcontrol.Initialize(host, port, path)
|
||||
var finalError error
|
||||
if _, err := i2pcontrol.Authenticate(password); err != nil {
|
||||
finalError = err
|
||||
}
|
||||
if _, err := i2pcontrol.Echo("Hello I2PControl"); err != nil {
|
||||
finalError = err
|
||||
}
|
||||
if finalError == nil {
|
||||
return host, port, path, nil
|
||||
}
|
||||
finalError = nil
|
||||
port = "7657"
|
||||
password = "itoopie"
|
||||
path = "jsonrpc"
|
||||
i2pcontrol.Initialize(host, port, path)
|
||||
if _, err := i2pcontrol.Authenticate(password); err != nil {
|
||||
finalError = err
|
||||
}
|
||||
if _, err := i2pcontrol.Echo("Hello I2PControl"); err != nil {
|
||||
finalError = err
|
||||
}
|
||||
if finalError == nil {
|
||||
return host, port, path, nil
|
||||
}
|
||||
return "127.0.0.1", "4450", "", nil
|
||||
}
|
18
controlcheck/checki2pcontrol_test.go
Normal file
18
controlcheck/checki2pcontrol_test.go
Normal file
@ -0,0 +1,18 @@
|
||||
package checki2pcontrol
|
||||
|
||||
import "testing"
|
||||
|
||||
func TestCheckI2PControlEcho(t *testing.T) {
|
||||
if works, err := CheckI2PControlEcho("", "", "", ""); works {
|
||||
t.Log("Proxy success")
|
||||
} else if err != nil {
|
||||
t.Fatal(err)
|
||||
} else {
|
||||
t.Fatal("Proxy not found")
|
||||
}
|
||||
if host, port, path, err := GetDefaultI2PControlPath(); err != nil {
|
||||
t.Fatal("I2PControl Not found")
|
||||
} else {
|
||||
t.Log("I2Pcontrol found at", host, port, path)
|
||||
}
|
||||
}
|
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
|
BIN
go-i2pd/go-i2pd
Executable file
BIN
go-i2pd/go-i2pd
Executable file
Binary file not shown.
BIN
go-i2pd/go-i2pd-32.exe
Executable file
BIN
go-i2pd/go-i2pd-32.exe
Executable file
Binary file not shown.
58
go-i2pd/i2pd.conf
Normal file
58
go-i2pd/i2pd.conf
Normal file
@ -0,0 +1,58 @@
|
||||
## Configuration file for a typical i2pd user
|
||||
## See https://i2pd.readthedocs.org/en/latest/configuration.html
|
||||
## for more options you can use in this file.
|
||||
|
||||
#log = file
|
||||
#logfile = ./i2pd.log
|
||||
|
||||
ipv4 = true
|
||||
ipv6 = true
|
||||
|
||||
[precomputation]
|
||||
elgamal = true
|
||||
|
||||
[upnp]
|
||||
enabled = true
|
||||
name = goI2Pd
|
||||
|
||||
[reseed]
|
||||
verify = true
|
||||
|
||||
[addressbook]
|
||||
subscriptions = http://inr.i2p/export/alive-hosts.txt,http://identiguy.i2p/hosts.txt,http://stats.i2p/cgi-bin/newhosts.txt,http://i2p-projekt.i2p/hosts.txt
|
||||
|
||||
### REASONING FOR CHANGING DEFAULT CONSOLE PORT
|
||||
##
|
||||
[http]
|
||||
enabled = true
|
||||
address = 127.0.0.1
|
||||
port = 7472
|
||||
|
||||
### REASONING FOR CHANGING DEFAULT HTTP PROXY PORT and DISABLING HTTP PROXY
|
||||
##
|
||||
[httpproxy]
|
||||
enabled = false
|
||||
#address = 127.0.0.1
|
||||
#port = 4454
|
||||
|
||||
### REASONING FOR CHANGING DEFAULT SOCKS PROXY PORT and DISABLING SOCKS PROXY
|
||||
##
|
||||
[socksproxy]
|
||||
enabled = false
|
||||
#address = 127.0.0.1
|
||||
#port = 4457
|
||||
|
||||
### REASONING FOR NOT CHANGING DEFAULT SAM PORT
|
||||
##
|
||||
[sam]
|
||||
enabled = true
|
||||
address = 127.0.0.1
|
||||
port = 7656
|
||||
|
||||
### REASONING FOR ENABLING I2PCONTROL and NOT CHANGING DEFAULT I2PCONTROL PORT
|
||||
##
|
||||
[i2pcontrol]
|
||||
enabled = true
|
||||
address = 127.0.0.1
|
||||
port = 7650
|
||||
#password = itoopie
|
31
go-i2pd/i2pd.go
Normal file
31
go-i2pd/i2pd.go
Normal file
@ -0,0 +1,31 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"flag"
|
||||
"log"
|
||||
|
||||
"github.com/eyedeekay/checki2cp/i2pdbundle"
|
||||
)
|
||||
|
||||
func main() {
|
||||
boolPtr := flag.Bool("force", false, "Force an embedded I2Pd router to start")
|
||||
flag.Parse()
|
||||
if err := i2pd.UnpackI2Pd(); err != nil {
|
||||
log.Println(err)
|
||||
}
|
||||
if path, err := i2pd.FindI2Pd(); err != nil {
|
||||
log.Println(err)
|
||||
} else {
|
||||
log.Println(path)
|
||||
}
|
||||
if !*boolPtr {
|
||||
// if cmd, err := i2pd.LaunchI2Pd(); err != nil {
|
||||
if _, err := i2pd.LaunchI2Pd(); err != nil {
|
||||
log.Println(err)
|
||||
}
|
||||
} else {
|
||||
if _, err := i2pd.LaunchI2PdForce(); err != nil {
|
||||
log.Println(err)
|
||||
}
|
||||
}
|
||||
}
|
BIN
go-i2pd/i2pd.tar.gz
Normal file
BIN
go-i2pd/i2pd.tar.gz
Normal file
Binary file not shown.
BIN
go-i2pd/lib.tar.gz
Normal file
BIN
go-i2pd/lib.tar.gz
Normal file
Binary file not shown.
BIN
go-i2pd/router.info
Normal file
BIN
go-i2pd/router.info
Normal file
Binary file not shown.
3
go-i2pd/tunnels.conf
Normal file
3
go-i2pd/tunnels.conf
Normal file
@ -0,0 +1,3 @@
|
||||
#
|
||||
# tunnels.conf file intentionally left blank
|
||||
#
|
20
go.mod
20
go.mod
@ -2,4 +2,22 @@ module github.com/eyedeekay/checki2cp
|
||||
|
||||
go 1.13
|
||||
|
||||
require github.com/eyedeekay/go-i2cp v0.0.0-20190716135428-6d41bed718b0
|
||||
require (
|
||||
github.com/andybalholm/brotli v1.0.0 // indirect
|
||||
github.com/eyedeekay/go-i2cp v0.0.0-20190716135428-6d41bed718b0
|
||||
github.com/eyedeekay/go-i2pcontrol v0.0.0-20200110011336-510cca77e350
|
||||
github.com/eyedeekay/sam3 v0.32.2
|
||||
github.com/golang/gddo v0.0.0-20200324184333-3c2cc9a6329d // indirect
|
||||
github.com/klauspost/compress v1.10.5 // indirect
|
||||
github.com/klauspost/pgzip v1.2.3 // indirect
|
||||
github.com/kr/fs v0.1.0
|
||||
github.com/majestrate/i2p-tools v0.0.0-20170507194519-afc8e46afa95
|
||||
github.com/mholt/archiver v3.1.1+incompatible // indirect
|
||||
github.com/mholt/archiver/v3 v3.3.0
|
||||
github.com/nwaples/rardecode v1.1.0 // indirect
|
||||
github.com/pierrec/lz4 v2.5.2+incompatible // indirect
|
||||
github.com/shurcooL/httpfs v0.0.0-20190707220628-8d4bc4ba7749
|
||||
github.com/ulikunitz/xz v0.5.7 // indirect
|
||||
github.com/ybbus/jsonrpc v2.1.2+incompatible // indirect
|
||||
github.com/zserge/lorca v0.1.9 // indirect
|
||||
)
|
||||
|
111
go.sum
Normal file
111
go.sum
Normal file
@ -0,0 +1,111 @@
|
||||
cloud.google.com/go v0.16.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw=
|
||||
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
|
||||
github.com/andybalholm/brotli v0.0.0-20190621154722-5f990b63d2d6 h1:bZ28Hqta7TFAK3Q08CMvv8y3/8ATaEqv2nGoc6yff6c=
|
||||
github.com/andybalholm/brotli v0.0.0-20190621154722-5f990b63d2d6/go.mod h1:+lx6/Aqd1kLJ1GQfkvOnaZ1WGmLpMpbprPuIOOZX30U=
|
||||
github.com/andybalholm/brotli v1.0.0 h1:7UCwP93aiSfvWpapti8g88vVVGp2qqtGyePsSuDafo4=
|
||||
github.com/andybalholm/brotli v1.0.0/go.mod h1:loMXtMfwqflxFJPmdbJO0a3KNoPuLBgiu3qAvBg8x/Y=
|
||||
github.com/bradfitz/gomemcache v0.0.0-20170208213004-1952afaa557d/go.mod h1:PmM6Mmwb0LSuEubjR8N7PtNe1KxZLtOUHtbeikc5h60=
|
||||
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||
github.com/dsnet/compress v0.0.1 h1:PlZu0n3Tuv04TzpfPbrnI0HW/YwodEXDS+oPKahKF0Q=
|
||||
github.com/dsnet/compress v0.0.1/go.mod h1:Aw8dCMJ7RioblQeTqt88akK31OvO8Dhf5JflhBbQEHo=
|
||||
github.com/dsnet/golib v0.0.0-20171103203638-1ea166775780/go.mod h1:Lj+Z9rebOhdfkVLjJ8T6VcRQv3SXugXy999NBtR9aFY=
|
||||
github.com/eyedeekay/go-i2cp v0.0.0-20190716135428-6d41bed718b0 h1:rnn9OlD/3+tATEZNuiMR1C84O5CX8bZL2qqgttprKrw=
|
||||
github.com/eyedeekay/go-i2cp v0.0.0-20190716135428-6d41bed718b0/go.mod h1:+P0fIhkqIYjo7exMJRTlSteRMbRyHbiBiKw+YlPWk+c=
|
||||
github.com/eyedeekay/go-i2pcontrol v0.0.0-20200110011336-510cca77e350 h1:LxSh6dLIeiDfXxex1B+jFh7YyI7OuBza+IXS+SFzuLQ=
|
||||
github.com/eyedeekay/go-i2pcontrol v0.0.0-20200110011336-510cca77e350/go.mod h1:bhIQsVpbNNXMtcoZ9UF4hLQleOjaCgKGXiRRhNc8TOA=
|
||||
github.com/eyedeekay/ramp v0.0.0-20190429201811-305b382042ab h1:EfTRHxGSbiaEyxNzvKRBWVIDw3mD8xXGxj4gvwFzY7Q=
|
||||
github.com/eyedeekay/ramp v0.0.0-20190429201811-305b382042ab/go.mod h1:h7mvUAMgZ/rtRDUOkvKTK+8LnDMeUhJSoa5EPdB51fc=
|
||||
github.com/eyedeekay/sam3 v0.32.2 h1:xODDY5nBVg0oK7KaYk7ofkXFoHPsmI1umhSv1TZlS7s=
|
||||
github.com/eyedeekay/sam3 v0.32.2/go.mod h1:Y3igFVzN4ybqkkpfUWULGhw7WRp8lieq0ORXbLBbcZM=
|
||||
github.com/fsnotify/fsnotify v1.4.3-0.20170329110642-4da3e2cfbabc/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo=
|
||||
github.com/garyburd/redigo v1.1.1-0.20170914051019-70e1b1943d4f/go.mod h1:NR3MbYisc3/PwhQ00EMzDiPmrwpPxAn5GI05/YaO1SY=
|
||||
github.com/go-stack/stack v1.6.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY=
|
||||
github.com/golang/gddo v0.0.0-20190419222130-af0f2af80721 h1:KRMr9A3qfbVM7iV/WcLY/rL5LICqwMHLhwRXKu99fXw=
|
||||
github.com/golang/gddo v0.0.0-20190419222130-af0f2af80721/go.mod h1:xEhNfoBDX1hzLm2Nf80qUvZ2sVwoMZ8d6IE2SrsQfh4=
|
||||
github.com/golang/gddo v0.0.0-20200324184333-3c2cc9a6329d/go.mod h1:sam69Hju0uq+5uvLJUMDlsKlQ21Vrs1Kd/1YFPNYdOU=
|
||||
github.com/golang/lint v0.0.0-20170918230701-e5d664eb928e/go.mod h1:tluoj9z5200jBnyusfRPU2LqT6J+DAorxEvtC7LHB+E=
|
||||
github.com/golang/protobuf v1.3.1/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
|
||||
github.com/golang/snappy v0.0.0-20170215233205-553a64147049/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q=
|
||||
github.com/golang/snappy v0.0.1 h1:Qgr9rKW7uDUkrbSmQeiDsGa8SjGyCOGtuasMWwvp2P4=
|
||||
github.com/golang/snappy v0.0.1/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q=
|
||||
github.com/google/go-cmp v0.1.1-0.20171103154506-982329095285/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M=
|
||||
github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU=
|
||||
github.com/googleapis/gax-go v2.0.0+incompatible/go.mod h1:SFVmujtThgffbyetf+mdk2eWhX2bMyUtNHzFKcPA9HY=
|
||||
github.com/gregjones/httpcache v0.0.0-20170920190843-316c5e0ff04e/go.mod h1:FecbI9+v66THATjSRHfNgh1IVFe/9kFxbXtjV0ctIMA=
|
||||
github.com/hashicorp/hcl v0.0.0-20170914154624-68e816d1c783/go.mod h1:oZtUIOe8dh44I2q6ScRibXws4Ajl+d+nod3AaR9vL5w=
|
||||
github.com/inconshreveable/log15 v0.0.0-20170622235902-74a0988b5f80/go.mod h1:cOaXtrgN4ScfRrD9Bre7U1thNq5RtJ8ZoP4iXVGRj6o=
|
||||
github.com/klauspost/compress v1.4.1/go.mod h1:RyIbtBH6LamlWaDj8nUwkbUhJ87Yi3uG0guNDohfE1A=
|
||||
github.com/klauspost/compress v1.9.2 h1:LfVyl+ZlLlLDeQ/d2AqfGIIH4qEDu0Ed2S5GyhCWIWY=
|
||||
github.com/klauspost/compress v1.9.2/go.mod h1:RyIbtBH6LamlWaDj8nUwkbUhJ87Yi3uG0guNDohfE1A=
|
||||
github.com/klauspost/compress v1.10.5 h1:7q6vHIqubShURwQz8cQK6yIe/xC3IF0Vm7TGfqjewrc=
|
||||
github.com/klauspost/compress v1.10.5/go.mod h1:aoV0uJVorq1K+umq18yTdKaF57EivdYsUV+/s2qKfXs=
|
||||
github.com/klauspost/cpuid v1.2.0/go.mod h1:Pj4uuM528wm8OyEC2QMXAi2YiTZ96dNQPGgoMS4s3ek=
|
||||
github.com/klauspost/pgzip v1.2.1 h1:oIPZROsWuPHpOdMVWLuJZXwgjhrW8r1yEX8UqMyeNHM=
|
||||
github.com/klauspost/pgzip v1.2.1/go.mod h1:Ch1tH69qFZu15pkjo5kYi6mth2Zzwzt50oCQKQE9RUs=
|
||||
github.com/klauspost/pgzip v1.2.3 h1:Ce2to9wvs/cuJ2b86/CKQoTYr9VHfpanYosZ0UBJqdw=
|
||||
github.com/klauspost/pgzip v1.2.3/go.mod h1:Ch1tH69qFZu15pkjo5kYi6mth2Zzwzt50oCQKQE9RUs=
|
||||
github.com/kr/fs v0.1.0 h1:Jskdu9ieNAYnjxsi0LbQp1ulIKZV1LAFgK1tWhpZgl8=
|
||||
github.com/kr/fs v0.1.0/go.mod h1:FFnZGqtBN9Gxj7eW1uZ42v5BccTP0vu6NEaFoC2HwRg=
|
||||
github.com/kr/pretty v0.2.0/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI=
|
||||
github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
|
||||
github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
|
||||
github.com/magiconair/properties v1.7.4-0.20170902060319-8d7837e64d3c/go.mod h1:PppfXfuXeibc/6YijjN8zIbojt8czPbwD3XqdrwzmxQ=
|
||||
github.com/majestrate/i2p-tools v0.0.0-20170507194519-afc8e46afa95 h1:0gOlqFaTE6hucF8xnutcIlWjuWAQ58kTFkvhKb8pE4g=
|
||||
github.com/majestrate/i2p-tools v0.0.0-20170507194519-afc8e46afa95/go.mod h1:e/TZ1O6X9t0qitnKc3xvHq8VXDpm/FmYuFf21epEkUc=
|
||||
github.com/mattn/go-colorable v0.0.10-0.20170816031813-ad5389df28cd/go.mod h1:9vuHe8Xs5qXnSaW/c/ABM9alt+Vo+STaOChaDxuIBZU=
|
||||
github.com/mattn/go-isatty v0.0.2/go.mod h1:M+lRXTBqGeGNdLjl/ufCoiOlB5xdOkqRJdNxMWT7Zi4=
|
||||
github.com/mholt/archiver v1.1.2 h1:xukR55YIrnhDHp10lrNtRSsAK5THpWrOCuviweNSBw4=
|
||||
github.com/mholt/archiver v3.1.1+incompatible h1:1dCVxuqs0dJseYEhi5pl7MYPH9zDa1wBi7mF09cbNkU=
|
||||
github.com/mholt/archiver v3.1.1+incompatible/go.mod h1:Dh2dOXnSdiLxRiPoVfIr/fI1TwETms9B8CTWfeh7ROU=
|
||||
github.com/mholt/archiver/v3 v3.3.0 h1:vWjhY8SQp5yzM9P6OJ/eZEkmi3UAbRrxCq48MxjAzig=
|
||||
github.com/mholt/archiver/v3 v3.3.0/go.mod h1:YnQtqsp+94Rwd0D/rk5cnLrxusUBUXg+08Ebtr1Mqao=
|
||||
github.com/mitchellh/mapstructure v0.0.0-20170523030023-d0303fe80992/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y=
|
||||
github.com/nwaples/rardecode v1.0.0 h1:r7vGuS5akxOnR4JQSkko62RJ1ReCMXxQRPtxsiFMBOs=
|
||||
github.com/nwaples/rardecode v1.0.0/go.mod h1:5DzqNKiOdpKKBH87u8VlvAnPZMXcGRhxWkRpHbbfGS0=
|
||||
github.com/nwaples/rardecode v1.1.0 h1:vSxaY8vQhOcVr4mm5e8XllHWTiM4JF507A0Katqw7MQ=
|
||||
github.com/nwaples/rardecode v1.1.0/go.mod h1:5DzqNKiOdpKKBH87u8VlvAnPZMXcGRhxWkRpHbbfGS0=
|
||||
github.com/pelletier/go-toml v1.0.1-0.20170904195809-1d6b12b7cb29/go.mod h1:5z9KED0ma1S8pY6P1sdut58dfprrGBbd/94hg7ilaic=
|
||||
github.com/pierrec/lz4 v2.0.5+incompatible h1:2xWsjqPFWcplujydGg4WmhC/6fZqK42wMM8aXeqhl0I=
|
||||
github.com/pierrec/lz4 v2.0.5+incompatible/go.mod h1:pdkljMzZIN41W+lC3N2tnIh5sFi+IEE17M5jbnwPHcY=
|
||||
github.com/pierrec/lz4 v2.5.2+incompatible h1:WCjObylUIOlKy/+7Abdn34TLIkXiA4UWUMhxq9m9ZXI=
|
||||
github.com/pierrec/lz4 v2.5.2+incompatible/go.mod h1:pdkljMzZIN41W+lC3N2tnIh5sFi+IEE17M5jbnwPHcY=
|
||||
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
|
||||
github.com/shurcooL/httpfs v0.0.0-20190707220628-8d4bc4ba7749 h1:bUGsEnyNbVPw06Bs80sCeARAlK8lhwqGyi6UT8ymuGk=
|
||||
github.com/shurcooL/httpfs v0.0.0-20190707220628-8d4bc4ba7749/go.mod h1:ZY1cvUeJuFPAdZ/B6v7RHavJWZn2YPVFQ1OSXhCGOkg=
|
||||
github.com/spf13/afero v0.0.0-20170901052352-ee1bd8ee15a1/go.mod h1:j4pytiNVoe2o6bmDsKpLACNPDBIoEAkihy7loJ1B0CQ=
|
||||
github.com/spf13/cast v1.1.0/go.mod h1:r2rcYCSwa1IExKTDiTfzaxqT2FNHs8hODu4LnUfgKEg=
|
||||
github.com/spf13/jwalterweatherman v0.0.0-20170901151539-12bd96e66386/go.mod h1:cQK4TGJAtQXfYWX+Ddv3mKDzgVb68N+wFjFa4jdeBTo=
|
||||
github.com/spf13/pflag v1.0.1-0.20170901120850-7aff26db30c1/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnInEg4=
|
||||
github.com/spf13/viper v1.0.0/go.mod h1:A8kyI5cUJhb8N+3pkfONlcEcZbueH6nhAm0Fq7SrnBM=
|
||||
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
|
||||
github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4=
|
||||
github.com/ulikunitz/xz v0.5.6 h1:jGHAfXawEGZQ3blwU5wnWKQJvAraT7Ftq9EXjnXYgt8=
|
||||
github.com/ulikunitz/xz v0.5.6/go.mod h1:2bypXElzHzzJZwzH67Y6wb67pO62Rzfn7BSiF4ABRW8=
|
||||
github.com/ulikunitz/xz v0.5.7 h1:YvTNdFzX6+W5m9msiYg/zpkSURPPtOlzbqYjrFn7Yt4=
|
||||
github.com/ulikunitz/xz v0.5.7/go.mod h1:nbz6k7qbPmH4IRqmfOplQw/tblSgqTqBwxkY0oWt/14=
|
||||
github.com/xi2/xz v0.0.0-20171230120015-48954b6210f8 h1:nIPpBwaJSVYIxUFsDv3M8ofmx9yWTog9BfvIu0q41lo=
|
||||
github.com/xi2/xz v0.0.0-20171230120015-48954b6210f8/go.mod h1:HUYIGzjTL3rfEspMxjDjgmT5uz5wzYJKVo23qUhYTos=
|
||||
github.com/ybbus/jsonrpc v1.1.1 h1:43DAq5ijbxDPEXmlNpAwT74vFBR5VxQRqRWhWQPz9O0=
|
||||
github.com/ybbus/jsonrpc v2.1.2+incompatible h1:V4mkE9qhbDQ92/MLMIhlhMSbz8jNXdagC3xBR5NDwaQ=
|
||||
github.com/ybbus/jsonrpc v2.1.2+incompatible/go.mod h1:XJrh1eMSzdIYFbM08flv0wp5G35eRniyeGut1z+LSiE=
|
||||
github.com/zserge/lorca v0.1.9 h1:vbDdkqdp2/rmeg8GlyCewY2X8Z+b0s7BqWyIQL/gakc=
|
||||
github.com/zserge/lorca v0.1.9/go.mod h1:bVmnIbIRlOcoV285KIRSe4bUABKi7R7384Ycuum6e4A=
|
||||
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
|
||||
golang.org/x/net v0.0.0-20190603091049-60506f45cf65/go.mod h1:HSz+uSET+XFnRR8LxR5pz3Of3rY3CfYBVs4xY44aLks=
|
||||
golang.org/x/net v0.0.0-20200222125558-5a598a2470a0 h1:MsuvTghUPjX762sGLnGsxC3HM0B5r83wEtYcYR8/vRs=
|
||||
golang.org/x/net v0.0.0-20200222125558-5a598a2470a0/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
|
||||
golang.org/x/oauth2 v0.0.0-20170912212905-13449ad91cb2/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=
|
||||
golang.org/x/sync v0.0.0-20170517211232-f52d1811a629/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
||||
golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk=
|
||||
golang.org/x/time v0.0.0-20170424234030-8be79e1e0910/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
|
||||
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
|
||||
google.golang.org/api v0.0.0-20170921000349-586095a6e407/go.mod h1:4mhQ8q/RsB7i+udVvVy5NUi08OU8ZlA0gRVgrF7VFY0=
|
||||
google.golang.org/appengine v1.6.5/go.mod h1:8WjMMxjGQR8xUklV/ARdw2HLXBOI7O7uCIDZVag1xfc=
|
||||
google.golang.org/genproto v0.0.0-20170918111702-1e559d0a00ee/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc=
|
||||
google.golang.org/grpc v1.2.1-0.20170921194603-d4b75ebd4f9f/go.mod h1:yo6s7OP7yaDglbqo1J04qKzAhqBH6lvTonzMVmEdcZw=
|
||||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||
gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||
gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
Binary file not shown.
BIN
i2cpcheck/i2cpcheck.exe
Executable file
BIN
i2cpcheck/i2cpcheck.exe
Executable file
Binary file not shown.
@ -1,20 +1,45 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"github.com/eyedeekay/checki2cp"
|
||||
"fmt"
|
||||
"log"
|
||||
"os"
|
||||
|
||||
"github.com/eyedeekay/checki2cp"
|
||||
"github.com/eyedeekay/checki2cp/proxycheck"
|
||||
"github.com/eyedeekay/checki2cp/samcheck"
|
||||
)
|
||||
|
||||
func main() {
|
||||
ok, err := checki2p.CheckI2PIsRunning()
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
// CheckI2PRunning returns true if I2P is running. That's all.
|
||||
func CheckI2PRunning(needI2CP, needProxy, needSAM bool) (bool, error) {
|
||||
if needI2CP {
|
||||
if notRunning, inError := checki2p.CheckI2PIsRunning(); inError != nil {
|
||||
return false, fmt.Errorf("A strange error occurred: %s", inError)
|
||||
} else if notRunning {
|
||||
return true, fmt.Errorf("I2P is already running with an open I2CP port")
|
||||
}
|
||||
}
|
||||
if ok {
|
||||
log.Println("I2P is running, successfully confirmed I2CP")
|
||||
} else {
|
||||
log.Println("I2P is not running, further testing is needed")
|
||||
if needProxy {
|
||||
if checkproxy.ProxyDotI2P() {
|
||||
return true, fmt.Errorf("I2P is already running with an open HTTP proxy")
|
||||
}
|
||||
}
|
||||
if needSAM {
|
||||
if checksam.CheckSAMAvailable("") {
|
||||
return true, fmt.Errorf("I2P is already running with an open SAM API")
|
||||
}
|
||||
}
|
||||
return false, fmt.Errorf("I2P is not running.")
|
||||
}
|
||||
|
||||
func main() {
|
||||
ok, err := CheckI2PRunning(true, true, true)
|
||||
if err != nil {
|
||||
if ok {
|
||||
log.Println(err)
|
||||
} else {
|
||||
log.Fatal(err)
|
||||
}
|
||||
}
|
||||
firewallport, err := checki2p.GetFirewallPort()
|
||||
if err != nil {
|
||||
|
69
i2pdbundle/assets_darwin.go
Normal file
69
i2pdbundle/assets_darwin.go
Normal file
File diff suppressed because one or more lines are too long
66
i2pdbundle/assets_linux_amd64.go
Normal file
66
i2pdbundle/assets_linux_amd64.go
Normal file
File diff suppressed because one or more lines are too long
65
i2pdbundle/assets_windows_386.go
Normal file
65
i2pdbundle/assets_windows_386.go
Normal file
File diff suppressed because one or more lines are too long
65
i2pdbundle/assets_windows_amd64.go
Normal file
65
i2pdbundle/assets_windows_amd64.go
Normal file
File diff suppressed because one or more lines are too long
214
i2pdbundle/common.go
Normal file
214
i2pdbundle/common.go
Normal file
@ -0,0 +1,214 @@
|
||||
package i2pd
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"io"
|
||||
"io/ioutil"
|
||||
"log"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
|
||||
"github.com/mholt/archiver/v3"
|
||||
"github.com/shurcooL/httpfs/vfsutil"
|
||||
)
|
||||
|
||||
var configFile = `## Configuration file for a typical i2pd user
|
||||
## See https://i2pd.readthedocs.org/en/latest/configuration.html
|
||||
## for more options you can use in this file.
|
||||
|
||||
#log = file
|
||||
#logfile = ./i2pd.log
|
||||
|
||||
ipv4 = true
|
||||
ipv6 = true
|
||||
|
||||
[precomputation]
|
||||
elgamal = true
|
||||
|
||||
[upnp]
|
||||
enabled = true
|
||||
name = goI2Pd
|
||||
|
||||
[reseed]
|
||||
verify = true
|
||||
|
||||
[addressbook]
|
||||
subscriptions = http://inr.i2p/export/alive-hosts.txt,http://identiguy.i2p/hosts.txt,http://stats.i2p/cgi-bin/newhosts.txt,http://i2p-projekt.i2p/hosts.txt
|
||||
|
||||
### REASONING FOR CHANGING DEFAULT CONSOLE PORT
|
||||
## We want to co-exist with other router projects peacefully inluding those that are on the same machine. This is a UI
|
||||
## improvement project, not a router improvement project, and as such we will allow the use of any underlying I2P router.
|
||||
[http]
|
||||
enabled = true
|
||||
address = 127.0.0.1
|
||||
port = 7472
|
||||
|
||||
### REASONING FOR CHANGING DEFAULT HTTP PROXY PORT and DISABLING HTTP PROXY
|
||||
## We want to co-exist with other router projects peacefully inluding those that are on the same machine. Disabling is
|
||||
## the primary method of deferring to the parent router's SOCKS port. We change it in the example in case people using
|
||||
## the embedded router want to re-enable it.
|
||||
[httpproxy]
|
||||
enabled = false
|
||||
#address = 127.0.0.1
|
||||
#port = 4454
|
||||
|
||||
### REASONING FOR CHANGING DEFAULT SOCKS PROXY PORT and DISABLING SOCKS PROXY
|
||||
## We want to co-exist with other router projects peacefully inluding those that are on the same machine. Disabling is
|
||||
## the primary method of deferring to the parent router's SOCKS port. We change it in the example in case people using
|
||||
## the embedded router want to re-enable it.
|
||||
[socksproxy]
|
||||
enabled = false
|
||||
#address = 127.0.0.1
|
||||
#port = 4457
|
||||
|
||||
### REASONING FOR NOT CHANGING DEFAULT SAM PORT
|
||||
## SAM clients do not normally require a password, so if a SAM hanshake can happen, it will more ofthen than not,
|
||||
## succeed, causing the bundle start to fail if SAM is available. Regardless, we need a SAM on this port to run, leaving
|
||||
## it here leaves us router-agnostic.
|
||||
[sam]
|
||||
enabled = true
|
||||
address = 127.0.0.1
|
||||
port = 7656
|
||||
|
||||
### REASONING FOR ENABLING I2PCONTROL and CHANGING DEFAULT I2PCONTROL PORT
|
||||
## Java I2P provides I2PControl via an embedded application which is available under localhost 7657, whereas I2Pd
|
||||
## makes it available at localhost:7650 as it's own service. In order to resolve this, our application will need to
|
||||
## proxy requests to the underlying router or probe for it anyway. The port can't matter to the client behind the proxy
|
||||
## probe thingy, but we need to guarantee i2pcontrol if we need to start an embedded router because of a SAM
|
||||
## availability issue
|
||||
[i2pcontrol]
|
||||
enabled = true
|
||||
address = 127.0.0.1
|
||||
port = 4450
|
||||
#password = itoopie
|
||||
`
|
||||
|
||||
var tunnelFile = `#
|
||||
# tunnels.conf file intentionally left blank
|
||||
#`
|
||||
|
||||
// I2P_DIRECTORY_PATH Sets the environment variable I2P_DIRECTORY_PATH to override the path returned by UnpackI2PdDir
|
||||
var I2P_DIRECTORY_PATH = ""
|
||||
|
||||
// FileOK Returns nil if a file exists and an error for everything else. Used to check for file existence.
|
||||
func FileOK(path string) error {
|
||||
if _, err := os.Stat(path); err == nil {
|
||||
return nil
|
||||
} else if os.IsNotExist(err) {
|
||||
return err
|
||||
} else {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
var walkFn = func(path string, fi os.FileInfo, r io.ReadSeeker, err error) error {
|
||||
if err != nil {
|
||||
log.Printf("can't stat file %s: %v\n", path, err)
|
||||
return nil
|
||||
}
|
||||
fmt.Println(path)
|
||||
if !fi.IsDir() {
|
||||
b, err := ioutil.ReadAll(r)
|
||||
if err != nil {
|
||||
log.Printf("can't read file %s: %v\n", path, err)
|
||||
return err
|
||||
}
|
||||
dir, err := UnpackI2PdDir()
|
||||
if err != nil {
|
||||
log.Printf("can't find path: %v\n", err)
|
||||
return err
|
||||
}
|
||||
err = ioutil.WriteFile(filepath.Join(dir, path), b, fi.Mode())
|
||||
if err != nil {
|
||||
log.Printf("can't write file %s: %v\n", filepath.Join(dir, path), err)
|
||||
return err
|
||||
}
|
||||
dirpath := strings.Split(path, ".")[0]
|
||||
log.Printf("wrote file %s: %v", filepath.Join(dir, path), fi.Mode())
|
||||
err = archiver.Unarchive(filepath.Join(dir, path), filepath.Join(dir, dirpath))
|
||||
if err != nil {
|
||||
log.Printf("can't unarchive file %s: %v\n", filepath.Join(dir, path), err)
|
||||
return err
|
||||
}
|
||||
log.Printf("unpacked file %s", filepath.Join(dir, path))
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// WriteConfOptions generates a default config file for the bundle
|
||||
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 {
|
||||
return err
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// WritetunnelOptions generates a default tunnel config file for the bundle
|
||||
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 {
|
||||
return err
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// WriteAllFiles generates an I2Pd installation and configuration for the bundle
|
||||
var WriteAllFiles = writeAllFiles
|
||||
|
||||
func writeAllFiles(targetdir string) error {
|
||||
if err := vfsutil.WalkFiles(FS, "/", walkFn); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := WriteConfOptions(targetdir); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := WriteTunnelOptions(targetdir); err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// UnpackI2PdPath tells the bundle where to unpack I2Pd and resolves to the
|
||||
// calling app's Dir+/i2pd
|
||||
func UnpackI2PdPath() (string, error) {
|
||||
dirPath, err := UnpackI2PdDir()
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
ri2pd := filepath.Join(dirPath, "i2pd")
|
||||
return ri2pd, nil
|
||||
}
|
||||
|
||||
// UnpackI2PdLibPath tells the bundle where to unpack I2Pd library dependencies
|
||||
// on Linux and resolves to the calling apps Dir+/i2pd
|
||||
func UnpackI2PdLibPath() (string, error) {
|
||||
dirPath, err := UnpackI2PdDir()
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
rlib := filepath.Join(dirPath, "lib")
|
||||
return rlib, nil
|
||||
}
|
||||
|
||||
// UnpackI2PdDir tells the bundle where the I2Pd-bundling app exists
|
||||
func UnpackI2PdDir() (string, error) {
|
||||
if I2P_DIRECTORY_PATH != "" {
|
||||
return I2P_DIRECTORY_PATH, nil
|
||||
}
|
||||
executablePath, err := os.Executable()
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
ri2pd := filepath.Dir(executablePath)
|
||||
return ri2pd, nil
|
||||
}
|
14
i2pdbundle/gen.go
Normal file
14
i2pdbundle/gen.go
Normal file
@ -0,0 +1,14 @@
|
||||
//+build generate
|
||||
|
||||
package main
|
||||
|
||||
import "github.com/zserge/lorca"
|
||||
|
||||
func main() {
|
||||
lorca.Embed("i2pd", "assets_darwin.go", "mac")
|
||||
lorca.Embed("i2pd", "assets_linux_amd64.go", "linux_amd64")
|
||||
lorca.Embed("i2pd", "assets_windows_amd64.go", "win_amd64")
|
||||
lorca.Embed("i2pd", "assets_windows_386.go", "win_386")
|
||||
/* lorca.Embed("i2pd", "assets_linux_i386.go", "linux_i386")*/
|
||||
lorca.Embed("i2pdtest", "test_files/test_assets.go", "test")
|
||||
}
|
1
i2pdbundle/launch_darwin.go
Normal file
1
i2pdbundle/launch_darwin.go
Normal file
@ -0,0 +1 @@
|
||||
package i2pd
|
105
i2pdbundle/launch_linux.go
Normal file
105
i2pdbundle/launch_linux.go
Normal file
@ -0,0 +1,105 @@
|
||||
package i2pd
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"log"
|
||||
"os"
|
||||
"os/exec"
|
||||
"path/filepath"
|
||||
|
||||
"github.com/eyedeekay/checki2cp"
|
||||
"github.com/eyedeekay/checki2cp/proxycheck"
|
||||
"github.com/eyedeekay/checki2cp/samcheck"
|
||||
)
|
||||
|
||||
// FindI2Pd returns the absolute path to the i2pd executable
|
||||
func FindI2Pd() (string, error) {
|
||||
path, err := UnpackI2PdPath()
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
if err := FileOK(filepath.Join(path, "i2pd")); err != nil {
|
||||
return "", err
|
||||
}
|
||||
return filepath.Join(path, "i2pd"), nil
|
||||
}
|
||||
|
||||
// UnpackI2Pd unpacks a working version of i2pd and some supporting libraries to a the directory of the executable
|
||||
// that will start i2pd
|
||||
func UnpackI2Pd() error {
|
||||
dir, err := UnpackI2PdPath()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
err = WriteAllFiles(dir)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// LaunchI2PdConditional will check for specific services and if they are not found, start a standalone router
|
||||
func LaunchI2PdConditional(needI2CP, needProxy, needSAM bool) (*exec.Cmd, error) {
|
||||
if needI2CP {
|
||||
if notRunning, inError := checki2p.CheckI2PIsRunning(); inError != nil {
|
||||
return nil, inError
|
||||
} else if notRunning {
|
||||
return nil, fmt.Errorf("I2P is already running with an open I2CP port")
|
||||
}
|
||||
}
|
||||
if needProxy {
|
||||
if checkproxy.ProxyDotI2P() {
|
||||
return nil, fmt.Errorf("I2P is already running with an open HTTP proxy")
|
||||
}
|
||||
}
|
||||
if needSAM {
|
||||
if checksam.CheckSAMAvailable("") {
|
||||
return nil, fmt.Errorf("I2P is already running with an open SAM API")
|
||||
}
|
||||
}
|
||||
return LaunchI2PdForce()
|
||||
}
|
||||
|
||||
// LaunchI2Pd will look for a running I2P router and if one is not found, it will start the embedded I2P router
|
||||
func LaunchI2Pd() (*exec.Cmd, error) {
|
||||
return LaunchI2PdConditional(true, true, true)
|
||||
}
|
||||
|
||||
// LaunchI2PdForce attempts to launch the embedded I2P router no matter what.
|
||||
func LaunchI2PdForce() (*exec.Cmd, error) {
|
||||
libPath, err := UnpackI2PdLibPath()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if err := FileOK(libPath); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
i2pd, err := FindI2Pd()
|
||||
if err := FileOK(i2pd); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
err = os.Setenv("LD_LIBRARY_PATH", libPath)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
log.Println(i2pd)
|
||||
runDir, err := UnpackI2PdDir()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
cmd := exec.Command(
|
||||
i2pd,
|
||||
"--datadir="+runDir,
|
||||
"--conf="+filepath.Join(runDir, "i2pd.conf"),
|
||||
"--tunconf="+filepath.Join(runDir, "tunnels.conf"),
|
||||
"--log=none",
|
||||
)
|
||||
cmd.Env = append(os.Environ(),
|
||||
"LD_LIBRARY_PATH="+libPath, // ignored
|
||||
)
|
||||
log.Printf("running command: %v %s", cmd.Env, cmd.String())
|
||||
if err := cmd.Start(); err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
return cmd, nil
|
||||
}
|
28
i2pdbundle/launch_test.go
Normal file
28
i2pdbundle/launch_test.go
Normal file
@ -0,0 +1,28 @@
|
||||
package i2pd
|
||||
|
||||
import (
|
||||
"os/exec"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestUnpackI2PDPath(t *testing.T) {
|
||||
out, err := UnpackI2PdDir()
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
t.Log("Testing output in:", out)
|
||||
err = WriteAllFiles(FS, out)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
t.Log("Listing output in parent", "ls", "-lahR", out)
|
||||
err = exec.Command("ls", "-lahR", out).Run()
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
err = UnpackI2Pd()
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
}
|
91
i2pdbundle/launch_windows.go
Normal file
91
i2pdbundle/launch_windows.go
Normal file
@ -0,0 +1,91 @@
|
||||
package i2pd
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"log"
|
||||
//"os"
|
||||
"os/exec"
|
||||
"path/filepath"
|
||||
|
||||
"github.com/eyedeekay/checki2cp"
|
||||
"github.com/eyedeekay/checki2cp/proxycheck"
|
||||
"github.com/eyedeekay/checki2cp/samcheck"
|
||||
)
|
||||
|
||||
// FindI2P returns the absolute path to the i2pd executable
|
||||
func FindI2Pd() (string, error) {
|
||||
path, err := UnpackI2PdPath()
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
if err := FileOK(filepath.Join(path, "i2pd.exe")); err != nil {
|
||||
return "", err
|
||||
}
|
||||
return filepath.Join(path, "i2pd.exe"), nil
|
||||
}
|
||||
|
||||
// UnpackI2Pd unpacks a working version of i2pd and some supporting libraries to the directory of the executable
|
||||
// that will start i2pd
|
||||
func UnpackI2Pd() error {
|
||||
dir, err := UnpackI2PdPath()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
err = WriteAllFiles(dir)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// LaunchI2PdConditional will check for specific services and if they are not found, start a standalone router
|
||||
func LaunchI2PdConditional(needI2CP, needProxy, needSAM bool) (*exec.Cmd, error) {
|
||||
if needI2CP {
|
||||
if notRunning, inError := checki2p.CheckI2PIsRunning(); inError != nil {
|
||||
return nil, inError
|
||||
} else if notRunning {
|
||||
return nil, fmt.Errorf("I2P is already running with an open I2CP port")
|
||||
}
|
||||
}
|
||||
if needProxy {
|
||||
if checkproxy.ProxyDotI2P() {
|
||||
return nil, fmt.Errorf("I2P is already running with an open HTTP proxy")
|
||||
}
|
||||
}
|
||||
if needSAM {
|
||||
if checksam.CheckSAMAvailable("") {
|
||||
return nil, fmt.Errorf("I2P is already running with an open SAM API")
|
||||
}
|
||||
}
|
||||
return LaunchI2PdForce()
|
||||
}
|
||||
|
||||
// LaunchI2Pd will look for a running I2P router and if one is not found, it will start the embedded I2P router
|
||||
func LaunchI2Pd() (*exec.Cmd, error) {
|
||||
return LaunchI2PdConditional(true, true, true)
|
||||
}
|
||||
|
||||
// LaunchI2PdForce attempts to launch the embedded I2P router no matter what.
|
||||
func LaunchI2PdForce() (*exec.Cmd, error) {
|
||||
i2pd, err := FindI2Pd()
|
||||
if err := FileOK(i2pd); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
log.Println(i2pd)
|
||||
runDir, err := UnpackI2PdDir()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
cmd := exec.Command(
|
||||
i2pd,
|
||||
"--datadir="+runDir,
|
||||
"--conf="+filepath.Join(runDir, "i2pd.conf"),
|
||||
"--tunconf="+filepath.Join(runDir, "tunnels.conf"),
|
||||
"--log=none",
|
||||
)
|
||||
log.Printf("running command: %v %s", cmd.Env, cmd.String())
|
||||
if err := cmd.Start(); err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
return cmd, nil
|
||||
}
|
BIN
i2pdbundle/mac.tar.gz
Normal file
BIN
i2pdbundle/mac.tar.gz
Normal file
Binary file not shown.
BIN
i2pdbundle/win_386.zip
Normal file
BIN
i2pdbundle/win_386.zip
Normal file
Binary file not shown.
BIN
i2pdbundle/win_amd64.zip
Normal file
BIN
i2pdbundle/win_amd64.zip
Normal file
Binary file not shown.
41
proxycheck/checkproxy.go
Normal file
41
proxycheck/checkproxy.go
Normal file
@ -0,0 +1,41 @@
|
||||
package checkproxy
|
||||
|
||||
import (
|
||||
"io/ioutil"
|
||||
"log"
|
||||
"net/http"
|
||||
"os"
|
||||
)
|
||||
|
||||
// ProxyDotI2P makes a request to proxy.i2p. If HTTP_PROXY is unset, then it defaults to using localhost 4444
|
||||
func ProxyDotI2P() bool {
|
||||
return ProxyGetSite("http://proxy.i2p")
|
||||
}
|
||||
|
||||
// ProxyGetSite fetches a URL via the I2P HTTP Proxy. The desired site must include the http(s):// protocol prefix
|
||||
func ProxyGetSite(url string) bool {
|
||||
if prox := os.Getenv("HTTP_PROXY"); prox == "" {
|
||||
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
|
||||
}
|
||||
}
|
||||
// make a sample HTTP GET request
|
||||
// check for response error
|
||||
res, err := http.Get(url)
|
||||
if err != nil {
|
||||
return false
|
||||
}
|
||||
// close response body
|
||||
defer res.Body.Close()
|
||||
// read all response body
|
||||
data, err := ioutil.ReadAll(res.Body)
|
||||
if err != nil {
|
||||
return false
|
||||
}
|
||||
// print `data` as a string
|
||||
log.Printf("%s\n", data)
|
||||
return true
|
||||
}
|
11
proxycheck/checkproxy_test.go
Normal file
11
proxycheck/checkproxy_test.go
Normal file
@ -0,0 +1,11 @@
|
||||
package checkproxy
|
||||
|
||||
import "testing"
|
||||
|
||||
func TestProxyDotI2P(t *testing.T) {
|
||||
if ProxyDotI2P() {
|
||||
t.Log("Proxy success")
|
||||
} else {
|
||||
t.Fatal("Proxy not found")
|
||||
}
|
||||
}
|
21
samcheck/samcheck.go
Normal file
21
samcheck/samcheck.go
Normal file
@ -0,0 +1,21 @@
|
||||
package checksam
|
||||
|
||||
import (
|
||||
"github.com/eyedeekay/sam3"
|
||||
)
|
||||
|
||||
// CheckSAMAvailable tries a SAM connection and returns true if it succeeds.
|
||||
func CheckSAMAvailable(yoursam string) bool {
|
||||
if yoursam == "" {
|
||||
yoursam = "127.0.0.1:7656"
|
||||
}
|
||||
sam, err := sam3.NewSAM(yoursam)
|
||||
if err != nil {
|
||||
return false
|
||||
}
|
||||
defer sam.Close()
|
||||
if _, err := sam.NewKeys(); err != nil {
|
||||
return false
|
||||
}
|
||||
return true
|
||||
}
|
11
samcheck/samcheck_test.go
Normal file
11
samcheck/samcheck_test.go
Normal file
@ -0,0 +1,11 @@
|
||||
package checksam
|
||||
|
||||
import "testing"
|
||||
|
||||
func TestCheckSAMAvailable(t *testing.T) {
|
||||
if CheckSAMAvailable("") {
|
||||
t.Log("SAM success")
|
||||
} else {
|
||||
t.Fatal("SAM not found")
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user