From 784327b17b844b44ae98049476f740f5496b1db5 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: Sat, 14 Oct 2023 23:10:13 +0700 Subject: [PATCH 1/2] fix compilation --- Makefile | 4 ++-- eepget.cpp | 5 +++++ i2psam.cpp | 8 +++++++- 3 files changed, 14 insertions(+), 3 deletions(-) diff --git a/Makefile b/Makefile index bc1912c..25133f5 100644 --- a/Makefile +++ b/Makefile @@ -5,11 +5,11 @@ OBJS=$(SRCS:.cpp=.o) TARGET=libi2psam.a $(TARGET): $(OBJS) - $(AR) $(ARFLAGS) $(TARGET) $(OBJS) + $(AR) $(ARFLAGS) $(TARGET) $(OBJS) LOADLIBES=-L./ -li2psam eepget: eepget.cpp $(TARGET) clean: - $(RM) $(TARGET) $(OBJS) eepget + $(RM) $(TARGET) $(OBJS) eepget diff --git a/eepget.cpp b/eepget.cpp index 17137d8..91f6460 100644 --- a/eepget.cpp +++ b/eepget.cpp @@ -22,6 +22,11 @@ int main(int argc, char **argv) auto lookupResult = s.namingLookup(target); auto connResult = s.connect(lookupResult.value, false); auto conn = connResult.value.get(); + if (conn == nullptr) + { + std::cerr << "Check your SAM port" << std::endl; + return 1; + } conn->write("GET / HTTP/1.1\r\n\r\n"); auto reply = conn->read(); diff --git a/i2psam.cpp b/i2psam.cpp index 2d5806a..f94e98b 100644 --- a/i2psam.cpp +++ b/i2psam.cpp @@ -197,7 +197,13 @@ void I2pSocket::close() } } -bool I2pSocket::isOk() const { return socket_ != INVALID_SOCKET; } +bool I2pSocket::isOk() const { + // Segmentation fault if not open SAMPOrt_ + // socket_ type is u_int + std::cout << "print a socket" << std::endl; + std::cout << socket_ << std::endl; + return socket_ != INVALID_SOCKET; +} const std::string &I2pSocket::getHost() const { return SAMHost_; } From 88e7672b519fd0c9139a497081a4d644fd222af3 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: Sat, 14 Oct 2023 23:11:31 +0700 Subject: [PATCH 2/2] fix compilation --- i2psam.cpp | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/i2psam.cpp b/i2psam.cpp index f94e98b..2d5806a 100644 --- a/i2psam.cpp +++ b/i2psam.cpp @@ -197,13 +197,7 @@ void I2pSocket::close() } } -bool I2pSocket::isOk() const { - // Segmentation fault if not open SAMPOrt_ - // socket_ type is u_int - std::cout << "print a socket" << std::endl; - std::cout << socket_ << std::endl; - return socket_ != INVALID_SOCKET; -} +bool I2pSocket::isOk() const { return socket_ != INVALID_SOCKET; } const std::string &I2pSocket::getHost() const { return SAMHost_; }