From c7ad2ca375e70c7442be3a72f59e7238030757d1 Mon Sep 17 00:00:00 2001 From: idk Date: Fri, 21 May 2021 20:39:15 -0400 Subject: [PATCH] Be a little more verbose about what router we're starting --- Makefile | 68 ----------------------------------------------- checki2cp.go | 9 +++++-- checki2cp_test.go | 14 +++++++++- 3 files changed, 20 insertions(+), 71 deletions(-) diff --git a/Makefile b/Makefile index bb637a8..87a22c4 100644 --- a/Makefile +++ b/Makefile @@ -68,74 +68,6 @@ zero-assets: 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" diff --git a/checki2cp.go b/checki2cp.go index 27b388d..2bbb80d 100644 --- a/checki2cp.go +++ b/checki2cp.go @@ -79,7 +79,7 @@ func CheckI2PIsRunning() (bool, error) { return false, err } if destination == nil { - return false, fmt.Errorf("") + return false, fmt.Errorf("Client connection was made bug no destination could be generated.") } client.Disconnect() log.Println("I2P is running.") @@ -238,14 +238,17 @@ func FindI2PIsInstalledDefaultLocation() (string, error) { // make sure that it is started, i.e. launch the router *only* if it is not // already running. func ConditionallyLaunchI2P() (bool, error) { + log.Println("Checking if I2P is installed at a default location.") ok, err := CheckI2PIsInstalledDefaultLocation() if err != nil { return false, err } + log.Println("I2P was found at a default location, continuing procedure on:", ok) if ok { ok, err := CheckI2PIsRunning() if err == nil { if !ok { + log.Println("Looking for an I2P router to start") path, err := FindI2PIsInstalledDefaultLocation() if err != nil { return false, err @@ -260,13 +263,15 @@ func ConditionallyLaunchI2P() (bool, error) { if err := cmd.Start(); err != nil { return false, fmt.Errorf("i2pd router startup failure %s", err) } - } else{ + } else { cmd := exec.Command(path) if err := cmd.Start(); err != nil { return false, fmt.Errorf("I2P Zero router startup failure %s", err) } } return true, nil + } else { + log.Println("I2P appears to be running, nothing to do.") } return true, nil } diff --git a/checki2cp_test.go b/checki2cp_test.go index c305cde..3db01f6 100644 --- a/checki2cp_test.go +++ b/checki2cp_test.go @@ -22,7 +22,19 @@ func TestRouter(t *testing.T) { t.Fatal(err) } if ok { - t.Log("I2P is installed, successfully confirmed") + t.Log("I2P is installed, successfully confirmed", ok) + } else { + t.Log("I2P is in a default location, user feedback is needed") + } +} + +func TestRouterPath(t *testing.T) { + ok, err := FindI2PIsInstalledDefaultLocation() + if err != nil { + t.Fatal(err) + } + if ok != "" { + t.Log("I2P is installed, successfully confirmed", ok) } else { t.Log("I2P is in a default location, user feedback is needed") }