@ -1,7 +1,6 @@
@@ -1,7 +1,6 @@
# include <ctime>
# include <iomanip>
# include <boost/bind.hpp>
# include <boost/lexical_cast.hpp>
# include <boost/date_time/posix_time/posix_time.hpp>
# include "Base.h"
# include "FS.h"
@ -24,7 +23,6 @@ namespace i2p
@@ -24,7 +23,6 @@ namespace i2p
{
namespace util
{
const std : : string HTTPConnection : : itoopieImage =
" <img alt= \" ICToopie Icon \" src= \" data:image/png;base64, "
" iVBORw0KGgoAAAANSUhEUgAAAIAAAACACAYAAADDPmHLAAAABmJLR0QAAAAAAAD5Q7t/AAAACXBIWXM "
@ -206,7 +204,6 @@ namespace util
@@ -206,7 +204,6 @@ namespace util
const char HTTP_COMMAND_JUMPSERVICES [ ] = " jumpservices= " ;
const char HTTP_PARAM_ADDRESS [ ] = " address " ;
namespace misc_strings
{
@ -831,7 +828,7 @@ namespace util
@@ -831,7 +828,7 @@ namespace util
if ( ! i2p : : client : : context . GetAddressBook ( ) . GetIdentHash ( address , destination ) )
{
LogPrint ( eLogWarning , " HTTPServer: Unknown address " , address ) ;
SendReply ( " <html> " + itoopieImage + " <br> \r \n Unknown address " + address + " </html> " , 404 ) ;
SendError ( " Unknown address " + address ) ;
return ;
}
@ -855,11 +852,13 @@ namespace util
@@ -855,11 +852,13 @@ namespace util
if ( ecode ! = boost : : asio : : error : : operation_aborted )
{
auto leaseSet = i2p : : client : : context . GetSharedLocalDestination ( ) - > FindLeaseSet ( destination ) ;
if ( leaseSet & & ! leaseSet - > IsExpired ( ) )
if ( leaseSet & & ! leaseSet - > IsExpired ( ) ) {
SendToDestination ( leaseSet , port , buf , len ) ;
else
// still no LeaseSet
SendReply ( leaseSet ? " <html> " + itoopieImage + " <br> \r \n Leases expired</html> " : " <html> " + itoopieImage + " LeaseSet not found</html> " , 504 ) ;
} else if ( leaseSet ) {
SendError ( " LeaseSet expired " ) ;
} else {
SendError ( " LeaseSet not found " ) ;
}
}
}
@ -893,7 +892,7 @@ namespace util
@@ -893,7 +892,7 @@ namespace util
else
{
if ( ecode = = boost : : asio : : error : : timed_out )
SendReply ( " <html> " + itoopieImage + " <br> \r \n Not responding</html> " , 504 ) ;
SendError ( " Host not responding " ) ;
else if ( ecode ! = boost : : asio : : error : : operation_aborted )
Terminate ( ) ;
}
@ -911,7 +910,7 @@ namespace util
@@ -911,7 +910,7 @@ namespace util
m_Reply . headers [ 0 ] . name = " Date " ;
m_Reply . headers [ 0 ] . value = std : : string ( time_buff ) ;
m_Reply . headers [ 1 ] . name = " Content-Length " ;
m_Reply . headers [ 1 ] . value = boo st: : lexical_cast < std : : string > ( m_Reply . content . size ( ) ) ;
m_Reply . headers [ 1 ] . value = std : : to_string ( m_Reply . content . size ( ) ) ;
m_Reply . headers [ 2 ] . name = " Content-Type " ;
m_Reply . headers [ 2 ] . value = " text/html " ;
}
@ -920,6 +919,11 @@ namespace util
@@ -920,6 +919,11 @@ namespace util
std : : bind ( & HTTPConnection : : HandleWriteReply , shared_from_this ( ) , std : : placeholders : : _1 ) ) ;
}
void HTTPConnection : : SendError ( const std : : string & content )
{
SendReply ( " <html> " + itoopieImage + " <br> \r \n " + content + " </html> " , 504 ) ;
}
HTTPServer : : HTTPServer ( const std : : string & address , int port ) :
m_Thread ( nullptr ) , m_Work ( m_Service ) ,
m_Acceptor ( m_Service , boost : : asio : : ip : : tcp : : endpoint ( boost : : asio : : ip : : address : : from_string ( address ) , port ) )
@ -978,6 +982,3 @@ namespace util
@@ -978,6 +982,3 @@ namespace util
}
}
}