mirror of
https://github.com/PurpleI2P/i2pd.git
synced 2025-01-14 17:08:09 +00:00
commit
e2df00bb2e
13
HTTP.cpp
13
HTTP.cpp
@ -72,11 +72,8 @@ namespace http {
|
|||||||
bool URL::parse(const std::string& url) {
|
bool URL::parse(const std::string& url) {
|
||||||
std::size_t pos_p = 0; /* < current parse position */
|
std::size_t pos_p = 0; /* < current parse position */
|
||||||
std::size_t pos_c = 0; /* < work position */
|
std::size_t pos_c = 0; /* < work position */
|
||||||
if (url.at(0) == '/' && url.find("/http://") == 0) {
|
|
||||||
/* special case for i2p.rocks inproxy */
|
|
||||||
pos_p ++;
|
|
||||||
}
|
|
||||||
if(url.at(0) != '/' || pos_p > 0) {
|
if(url.at(0) != '/' || pos_p > 0) {
|
||||||
|
std::size_t pos_s = 0;
|
||||||
/* schema */
|
/* schema */
|
||||||
pos_c = url.find("://");
|
pos_c = url.find("://");
|
||||||
if (pos_c != std::string::npos) {
|
if (pos_c != std::string::npos) {
|
||||||
@ -84,9 +81,9 @@ namespace http {
|
|||||||
pos_p = pos_c + 3;
|
pos_p = pos_c + 3;
|
||||||
}
|
}
|
||||||
/* user[:pass] */
|
/* user[:pass] */
|
||||||
pos_c = url.find('@', pos_p);
|
pos_s = url.find('/', pos_p); /* find first slash */
|
||||||
std::size_t pos_slash = url.find('/', pos_p);
|
pos_c = url.find('@', pos_p); /* find end of 'user' or 'user:pass' part */
|
||||||
if (pos_c != std::string::npos && (pos_slash == std::string::npos || pos_slash > pos_c)) {
|
if (pos_c != std::string::npos && (pos_s == std::string::npos || pos_s > pos_c)) {
|
||||||
std::size_t delim = url.find(':', pos_p);
|
std::size_t delim = url.find(':', pos_p);
|
||||||
if (delim != std::string::npos && delim < pos_c) {
|
if (delim != std::string::npos && delim < pos_c) {
|
||||||
user = url.substr(pos_p, delim - pos_p);
|
user = url.substr(pos_p, delim - pos_p);
|
||||||
@ -95,7 +92,7 @@ namespace http {
|
|||||||
} else {
|
} else {
|
||||||
user = url.substr(pos_p, pos_c - pos_p);
|
user = url.substr(pos_p, pos_c - pos_p);
|
||||||
}
|
}
|
||||||
pos_p = pos_c + 1;
|
pos_p = pos_c + 1;
|
||||||
}
|
}
|
||||||
/* hostname[:port][/path] */
|
/* hostname[:port][/path] */
|
||||||
pos_c = url.find_first_of(":/", pos_p);
|
pos_c = url.find_first_of(":/", pos_p);
|
||||||
|
@ -50,7 +50,7 @@ HEADERS += DaemonQT.h mainwindow.h \
|
|||||||
../../Streaming.h ../../Timestamp.h ../../TransitTunnel.h ../../Transports.h \
|
../../Streaming.h ../../Timestamp.h ../../TransitTunnel.h ../../Transports.h \
|
||||||
../../TransportSession.h ../../Tunnel.h ../../TunnelBase.h ../../TunnelConfig.h \
|
../../TransportSession.h ../../Tunnel.h ../../TunnelBase.h ../../TunnelConfig.h \
|
||||||
../../TunnelEndpoint.h ../../TunnelGateway.h ../../TunnelPool.h ../../UPnP.h \
|
../../TunnelEndpoint.h ../../TunnelGateway.h ../../TunnelPool.h ../../UPnP.h \
|
||||||
../../util.h ../../version.h ..//../Gzip.h ../../Tag.h
|
../../util.h ../../version.h ../../Gzip.h ../../Tag.h
|
||||||
|
|
||||||
FORMS += mainwindow.ui
|
FORMS += mainwindow.ui
|
||||||
|
|
||||||
|
@ -104,6 +104,18 @@ int main() {
|
|||||||
assert(url->query == "");
|
assert(url->query == "");
|
||||||
delete url;
|
delete url;
|
||||||
|
|
||||||
|
url = new URL;
|
||||||
|
assert(url->parse("http://user:password@site.com:84/asdasd/@17#frag") == true);
|
||||||
|
assert(url->schema == "http");
|
||||||
|
assert(url->user == "user");
|
||||||
|
assert(url->pass == "password");
|
||||||
|
assert(url->host == "site.com");
|
||||||
|
assert(url->port == 84);
|
||||||
|
assert(url->path == "/asdasd/@17");
|
||||||
|
assert(url->query == "");
|
||||||
|
assert(url->frag == "frag");
|
||||||
|
delete url;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
2
util.cpp
2
util.cpp
@ -419,7 +419,7 @@ namespace net
|
|||||||
{
|
{
|
||||||
#ifdef WIN32
|
#ifdef WIN32
|
||||||
LogPrint(eLogError, "NetIface: cannot get address by interface name, not implemented on WIN32");
|
LogPrint(eLogError, "NetIface: cannot get address by interface name, not implemented on WIN32");
|
||||||
return boost::asio::ip::from_string("127.0.0.1");
|
return boost::asio::ip::address::from_string("127.0.0.1");
|
||||||
#else
|
#else
|
||||||
int af = (ipv6 ? AF_INET6 : AF_INET);
|
int af = (ipv6 ? AF_INET6 : AF_INET);
|
||||||
ifaddrs * addrs = nullptr;
|
ifaddrs * addrs = nullptr;
|
||||||
|
Loading…
Reference in New Issue
Block a user