mirror of
https://github.com/PurpleI2P/i2pd.git
synced 2025-01-22 04:04:16 +00:00
Merge pull request #19 from meeh420/master
Updates on option parser & testing
This commit is contained in:
commit
31bad3e869
2
.gitignore
vendored
2
.gitignore
vendored
@ -1,5 +1,5 @@
|
|||||||
# i2pd
|
# i2pd
|
||||||
*.o
|
obj/*.o
|
||||||
router.info
|
router.info
|
||||||
router.keys
|
router.keys
|
||||||
i2p
|
i2p
|
||||||
|
18
Makefile
18
Makefile
@ -1,26 +1,28 @@
|
|||||||
|
|
||||||
CC = g++
|
CC = g++
|
||||||
CFLAGS = -g -Wall -std=c++0x
|
CFLAGS = -g -Wall -std=c++0x
|
||||||
OBJECTS = i2p.o base64.o NTCPSession.o RouterInfo.o Transports.o RouterContext.o \
|
OBJECTS = obj/i2p.o obj/base64.o obj/NTCPSession.o obj/RouterInfo.o obj/Transports.o \
|
||||||
NetDb.o LeaseSet.o Tunnel.o TunnelEndpoint.o TunnelGateway.o TransitTunnel.o \
|
obj/RouterContext.o obj/NetDb.o obj/LeaseSet.o obj/Tunnel.o obj/TunnelEndpoint.o \
|
||||||
I2NPProtocol.o Log.o Garlic.o HTTPServer.o Streaming.o Identity.o SSU.o util.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 =
|
INCFLAGS =
|
||||||
LDFLAGS = -Wl,-rpath,/usr/local/lib -lcryptopp -lboost_system -lboost_filesystem -lpthread
|
LDFLAGS = -Wl,-rpath,/usr/local/lib -lcryptopp -lboost_system -lboost_filesystem -lpthread
|
||||||
LIBS =
|
LIBS =
|
||||||
|
|
||||||
all: i2p
|
all: i2p
|
||||||
|
|
||||||
i2p: $(OBJECTS)
|
i2p: $(OBJECTS:obj/%=obj/%)
|
||||||
$(CC) -o i2p $(OBJECTS) $(LDFLAGS) $(LIBS)
|
$(CC) -o $@ $^ $(LDFLAGS) $(LIBS)
|
||||||
|
|
||||||
.SUFFIXES:
|
.SUFFIXES:
|
||||||
.SUFFIXES: .c .cc .C .cpp .o
|
.SUFFIXES: .c .cc .C .cpp .o
|
||||||
|
|
||||||
.cpp.o :
|
obj/%.o : %.cpp
|
||||||
$(CC) -o $@ -c $(CFLAGS) $< $(INCFLAGS)
|
mkdir -p obj
|
||||||
|
$(CC) -o $@ $< -c $(CFLAGS) $(INCFLAGS)
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
rm -f *.o
|
rm -fr obj
|
||||||
|
|
||||||
.PHONY: all
|
.PHONY: all
|
||||||
.PHONY: clean
|
.PHONY: clean
|
||||||
|
30
README.md
30
README.md
@ -8,3 +8,33 @@ Requires gcc 4.6 and higher, boost 1.46 and higher, crypto++
|
|||||||
on Windows
|
on Windows
|
||||||
|
|
||||||
Requires msvs2013, boost 1.46 and higher, crypto++
|
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
|
||||||
|
|
||||||
|
5
i2p.cpp
5
i2p.cpp
@ -14,7 +14,7 @@
|
|||||||
|
|
||||||
int main( int argc, char* argv[] )
|
int main( int argc, char* argv[] )
|
||||||
{
|
{
|
||||||
i2p::util::ParseArguments(argc,argv);
|
i2p::util::OptionParser(argc,argv);
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
setlocale(LC_CTYPE, "");
|
setlocale(LC_CTYPE, "");
|
||||||
SetConsoleCP(1251);
|
SetConsoleCP(1251);
|
||||||
@ -22,6 +22,9 @@ int main( int argc, char* argv[] )
|
|||||||
setlocale(LC_ALL, "Russian");
|
setlocale(LC_ALL, "Russian");
|
||||||
#endif
|
#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);
|
int httpport = i2p::util::GetIntArg("--httpport", 7070);
|
||||||
|
|
||||||
i2p::util::HTTPServer httpServer (httpport);
|
i2p::util::HTTPServer httpServer (httpport);
|
||||||
|
8
util.cpp
8
util.cpp
@ -6,7 +6,7 @@ namespace util
|
|||||||
{
|
{
|
||||||
std::map<std::string, std::string> mapArgs;
|
std::map<std::string, std::string> mapArgs;
|
||||||
|
|
||||||
void ParseArguments(int argc, const char* const argv[])
|
void OptionParser(int argc, const char* const argv[])
|
||||||
{
|
{
|
||||||
mapArgs.clear();
|
mapArgs.clear();
|
||||||
for (int i = 1; i < argc; i++)
|
for (int i = 1; i < argc; i++)
|
||||||
@ -33,11 +33,11 @@ int GetIntArg(const std::string& strArg, int nDefault)
|
|||||||
return 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))
|
if (mapArgs.count(strArg))
|
||||||
return mapArgs[strArg];
|
return mapArgs[strArg].c_str();
|
||||||
return nDefault;
|
return nDefault.c_str();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
3
util.h
3
util.h
@ -9,8 +9,9 @@ namespace i2p
|
|||||||
namespace util
|
namespace util
|
||||||
{
|
{
|
||||||
extern std::map<std::string, std::string> mapArgs;
|
extern std::map<std::string, std::string> 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);
|
int GetIntArg(const std::string& strArg, int nDefault);
|
||||||
|
const char* GetCharArg(const std::string& strArg, const std::string& nDefault);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user