mirror of
https://github.com/PurpleI2P/i2pd.git
synced 2025-01-22 04:04:16 +00:00
check if i2p address to call jump service
This commit is contained in:
parent
3afb1922bb
commit
56699a9f89
@ -39,6 +39,7 @@ namespace proxy
|
|||||||
void HTTPRequestFailed(/*std::string message*/);
|
void HTTPRequestFailed(/*std::string message*/);
|
||||||
void RedirectToJumpService();
|
void RedirectToJumpService();
|
||||||
void ExtractRequest();
|
void ExtractRequest();
|
||||||
|
bool IsI2PAddress();
|
||||||
bool ValidateHTTPRequest();
|
bool ValidateHTTPRequest();
|
||||||
void HandleJumpServices();
|
void HandleJumpServices();
|
||||||
bool CreateHTTPRequest(uint8_t *http_buff, std::size_t len);
|
bool CreateHTTPRequest(uint8_t *http_buff, std::size_t len);
|
||||||
@ -176,6 +177,16 @@ namespace proxy
|
|||||||
m_path.erase(addressHelperPos);
|
m_path.erase(addressHelperPos);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool HTTPProxyHandler::IsI2PAddress()
|
||||||
|
{
|
||||||
|
auto pos = m_address.rfind (".i2p");
|
||||||
|
if (pos != std::string::npos && (pos+4) == m_address.length ())
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
bool HTTPProxyHandler::CreateHTTPRequest(uint8_t *http_buff, std::size_t len)
|
bool HTTPProxyHandler::CreateHTTPRequest(uint8_t *http_buff, std::size_t len)
|
||||||
{
|
{
|
||||||
ExtractRequest(); //TODO: parse earlier
|
ExtractRequest(); //TODO: parse earlier
|
||||||
@ -183,10 +194,14 @@ namespace proxy
|
|||||||
HandleJumpServices();
|
HandleJumpServices();
|
||||||
|
|
||||||
i2p::data::IdentHash identHash;
|
i2p::data::IdentHash identHash;
|
||||||
if (!i2p::client::context.GetAddressBook ().GetIdentHash (m_address, identHash)){
|
if (IsI2PAddress ())
|
||||||
RedirectToJumpService();
|
{
|
||||||
return false;
|
if (!i2p::client::context.GetAddressBook ().GetIdentHash (m_address, identHash)){
|
||||||
|
RedirectToJumpService();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
m_request = m_method;
|
m_request = m_method;
|
||||||
m_request.push_back(' ');
|
m_request.push_back(' ');
|
||||||
|
Loading…
x
Reference in New Issue
Block a user