From 633c9becd919d8d8ac73a80fd04d9de081b6eea1 Mon Sep 17 00:00:00 2001 From: Meeh Date: Fri, 31 Jan 2014 01:39:16 +0100 Subject: [PATCH 1/3] Adding more to the option parser. Adding instruction on how to test it. --- README.md | 30 ++++++++++++++++++++++++++++++ i2p.cpp | 5 ++++- util.cpp | 8 ++++---- util.h | 3 ++- 4 files changed, 40 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index ab64cb4d..32eec060 100644 --- a/README.md +++ b/README.md @@ -8,3 +8,33 @@ Requires gcc 4.6 and higher, boost 1.46 and higher, crypto++ on Windows Requires msvs2013, boost 1.46 and higher, crypto++ + + +Testing +------- + +First, build it. + +$ cd i2pd +$ make + +Now, copy your netDb folder from your Java I2P config dir. (The one with r0, r1, r2, ... folders in it) to the source folder where your i2p binary is. + +Next, find out your public ip. (find it for example at http://www.whatismyip.com/) + +Then, run it with: + +$ ./i2p --host=YOUR_PUBLIC_IP + + +Other options: +--port= - The port to listen on +--httpport= - The http port to listen on + + +To visit an I2P page, you need to find the b32 address of your destination. +After that, go to the webconsole and add it behind the url. (Remove http:// and b32.i2p from the address) + +This should resulting in for example: +http://localhost:7070/4oes3rlgrpbkmzv4lqcfili23h3cvpwslqcfjlk6vvguxyggspwa + diff --git a/i2p.cpp b/i2p.cpp index 67408fa6..5c0bd378 100644 --- a/i2p.cpp +++ b/i2p.cpp @@ -14,7 +14,7 @@ int main( int argc, char* argv[] ) { - i2p::util::ParseArguments(argc,argv); + i2p::util::OptionParser(argc,argv); #ifdef _WIN32 setlocale(LC_CTYPE, ""); SetConsoleCP(1251); @@ -22,6 +22,9 @@ int main( int argc, char* argv[] ) setlocale(LC_ALL, "Russian"); #endif + //TODO: This is an ugly workaround. fix it. + //TODO: Autodetect public IP. + i2p::context.OverrideNTCPAddress(i2p::util::GetCharArg("--host", "127.0.0.1"), i2p::util::GetIntArg("--port", 17070)); int httpport = i2p::util::GetIntArg("--httpport", 7070); i2p::util::HTTPServer httpServer (httpport); diff --git a/util.cpp b/util.cpp index 1f000f50..676fddd1 100644 --- a/util.cpp +++ b/util.cpp @@ -6,7 +6,7 @@ namespace util { std::map mapArgs; -void ParseArguments(int argc, const char* const argv[]) +void OptionParser(int argc, const char* const argv[]) { mapArgs.clear(); for (int i = 1; i < argc; i++) @@ -33,11 +33,11 @@ int GetIntArg(const std::string& strArg, int nDefault) return nDefault; } -std::string GetStringArg(const std::string& strArg, std::string nDefault) +const char* GetCharArg(const std::string& strArg, const std::string& nDefault) { if (mapArgs.count(strArg)) - return mapArgs[strArg]; - return nDefault; + return mapArgs[strArg].c_str(); + return nDefault.c_str(); } diff --git a/util.h b/util.h index ef015ded..fb3597e6 100644 --- a/util.h +++ b/util.h @@ -9,8 +9,9 @@ namespace i2p namespace util { extern std::map mapArgs; - void ParseArguments(int argc, const char* const argv[]); + void OptionParser(int argc, const char* const argv[]); int GetIntArg(const std::string& strArg, int nDefault); + const char* GetCharArg(const std::string& strArg, const std::string& nDefault); } } From e6ccffcf77d65978d8350817a26ca0904b4e8ad0 Mon Sep 17 00:00:00 2001 From: Meeh Date: Fri, 31 Jan 2014 01:42:27 +0100 Subject: [PATCH 2/3] Update README.md --- README.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 32eec060..3117f52a 100644 --- a/README.md +++ b/README.md @@ -15,8 +15,8 @@ Testing First, build it. -$ cd i2pd -$ make +* $ cd i2pd +* $ make Now, copy your netDb folder from your Java I2P config dir. (The one with r0, r1, r2, ... folders in it) to the source folder where your i2p binary is. @@ -28,8 +28,8 @@ $ ./i2p --host=YOUR_PUBLIC_IP Other options: ---port= - The port to listen on ---httpport= - The http port to listen on +* --port= - The port to listen on +* --httpport= - The http port to listen on To visit an I2P page, you need to find the b32 address of your destination. From b4e2c7ee87e8987ec63fdd4f3e960d478b1d124b Mon Sep 17 00:00:00 2001 From: Meeh Date: Fri, 31 Jan 2014 02:49:06 +0100 Subject: [PATCH 3/3] Updating Makefile to collect build objects in a folder --- .gitignore | 2 +- Makefile | 18 ++++++++++-------- 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/.gitignore b/.gitignore index 2cb9ea10..0e609a70 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,5 @@ # i2pd -*.o +obj/*.o router.info router.keys i2p diff --git a/Makefile b/Makefile index abe4238d..5a3e6336 100644 --- a/Makefile +++ b/Makefile @@ -1,26 +1,28 @@ CC = g++ CFLAGS = -g -Wall -std=c++0x -OBJECTS = i2p.o base64.o NTCPSession.o RouterInfo.o Transports.o RouterContext.o \ - NetDb.o LeaseSet.o Tunnel.o TunnelEndpoint.o TunnelGateway.o TransitTunnel.o \ - I2NPProtocol.o Log.o Garlic.o HTTPServer.o Streaming.o Identity.o SSU.o util.o +OBJECTS = obj/i2p.o obj/base64.o obj/NTCPSession.o obj/RouterInfo.o obj/Transports.o \ + obj/RouterContext.o obj/NetDb.o obj/LeaseSet.o obj/Tunnel.o obj/TunnelEndpoint.o \ + obj/TunnelGateway.o obj/TransitTunnel.o obj/I2NPProtocol.o obj/Log.o obj/Garlic.o \ + obj/HTTPServer.o obj/Streaming.o obj/Identity.o obj/SSU.o obj/util.o INCFLAGS = LDFLAGS = -Wl,-rpath,/usr/local/lib -lcryptopp -lboost_system -lboost_filesystem -lpthread LIBS = all: i2p -i2p: $(OBJECTS) - $(CC) -o i2p $(OBJECTS) $(LDFLAGS) $(LIBS) +i2p: $(OBJECTS:obj/%=obj/%) + $(CC) -o $@ $^ $(LDFLAGS) $(LIBS) .SUFFIXES: .SUFFIXES: .c .cc .C .cpp .o -.cpp.o : - $(CC) -o $@ -c $(CFLAGS) $< $(INCFLAGS) +obj/%.o : %.cpp + mkdir -p obj + $(CC) -o $@ $< -c $(CFLAGS) $(INCFLAGS) clean: - rm -f *.o + rm -fr obj .PHONY: all .PHONY: clean