From 92989e649af4a3fe1e31889189bde8883456afea Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=92=D0=B0=D1=88=D0=B5=20=D0=B8=D0=BC=D1=8F=D1=8D?= Date: Tue, 5 Sep 2023 15:45:03 +0700 Subject: [PATCH] o2 flag + fedora depedencies support + #92 issue --- Makefile | 2 +- dependencies.sh | 83 +++++++++++++++++++++++++------------------------ vain.cpp | 9 ++---- vanity.hpp | 5 +++ 4 files changed, 51 insertions(+), 48 deletions(-) diff --git a/Makefile b/Makefile index 19130fd..050eff9 100755 --- a/Makefile +++ b/Makefile @@ -7,7 +7,7 @@ LIBI2PD_PATH = $(I2PD_PATH)/libi2pd LIBI2PD_CLIENT_PATH = $(I2PD_PATH)/libi2pd_client CXX ?= g++ -CXXFLAGS = -Wall -std=c++17 +CXXFLAGS = -Wall -std=c++17 -O2 INCFLAGS = -I$(LIBI2PD_PATH) -I$(LIBI2PD_CLIENT_PATH) DEFINES = -DOPENSSL_SUPPRESS_DEPRECATED diff --git a/dependencies.sh b/dependencies.sh index d44f3dd..aaddcaf 100755 --- a/dependencies.sh +++ b/dependencies.sh @@ -8,61 +8,64 @@ dependNix="libboost-chrono-dev \ libboost-thread-dev \ libssl-dev \ zlib1g-dev" - dependWin="mingw-w64-x86_64-boost \ mingw-w64-x86_64-openssl \ mingw-w64-x86_64-zlib" -kernel=`uname -a` -function isLsbReleaseExists() { - if which lsb_release > /dev/null; # do whereis can be too? - then - return 0 - else - return 1 - fi +kernel=$(uname -a) + +function anotherDistr() { + echo "Just install libboost and libopenssl dev packages on your pc" + return 0 } -function anotherDistr(){ - echo "Just install libboost and libopenssl dev packages on your pc"; - return 0 +function installDnf() { + sudo dnf install boost-devel g++ } -function installDeb(){ - sudo apt-get install $dependNix; - return 0 +function installDeb() { + sudo apt-get install $dependNix + return 0 } -function installOnGentoo(){ - sudo emerge --deep --newuse dev-libs/boost dev-libs/openssl; - return 0 + +function installOnGentoo() { + sudo emerge --deep --newuse dev-libs/boost dev-libs/openssl + return 0 } + function installOnWin() { - pacman -S $depenWin; - return 0 + pacman -S $dependWin + return 0 } function doInstallDepencies() { -case "$1" in - *Ubuntu*|*Debian*) - installDeb - ;; - *gentoo*) - installOnGentoo - ;; - *MINGW64*) - installOnWin - ;; - *) - anotherDistr - ;; -esac + case "$1" in + *Ubuntu* | *Debian*) + installDeb + ;; + *gentoo*) + installOnGentoo + ;; + *MINGW64*) + installOnWin + ;; + *dnf*) + installDnf + ;; + *) + anotherDistr + ;; + esac } -if isLsbReleaseExists ; -then - distr=`lsb_release -i` - doInstallDepencies "$distr" -else # - doInstallDepencies "$kernel" +isLsbReleaseExists=$(which lsb_release > /dev/null 2>&1; echo $?) +if [ $isLsbReleaseExists -eq 0 ]; then + distr=$(lsb_release -i) + doInstallDepencies "$distr" +elif test -e /etc/fedora-release || which dnf > /dev/null; then + printf "Like you use fedora/redhat distr\n" + doInstallDepencies "dnf" +else + doInstallDepencies "$kernel" fi diff --git a/vain.cpp b/vain.cpp index 4d2993b..148d33f 100755 --- a/vain.cpp +++ b/vain.cpp @@ -404,10 +404,7 @@ int main (int argc, char * argv[]) { //keys = i2p::data::PrivateKeys::CreateRandomKeys (options.signature); //RAND_bytes( KeyBuf+MutateByte , 90 ); // FoundNonce is - - for (unsigned i = options.threads-1;i--;) - delete [] KeyBufs[i]; - delete [] KeyBufs; + DELKEYBUFS(options.threads); std::cout << "(Generate a new keypair) Attempts #" << ++attempts << std::endl; return 1; } @@ -445,9 +442,7 @@ int main (int argc, char * argv[]) if (f) { f.write ((char *)KeyBuf, keys_len); - for (unsigned i = options.threads-1;i--;) - delete [] KeyBufs[i]; - delete [] KeyBufs; + DELKEYBUFS(options.threads); } else std::cout << "Can't create file " << options.outputpath << std::endl; diff --git a/vanity.hpp b/vanity.hpp index bc9b8f9..6ba379e 100755 --- a/vanity.hpp +++ b/vanity.hpp @@ -84,3 +84,8 @@ const uint8_t lastBlock[64] = 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0C, 0x38 // 3128 bits (391 bytes) }; + +#define DELKEYBUFS(S) {\ +for (unsigned i = S-1;i--;) \ + delete [] KeyBufs[i];\ +delete [] KeyBufs;}