@ -58,9 +58,9 @@ namespace http {
@@ -58,9 +58,9 @@ namespace http {
" .left { float: left; position: absolute; } \r \n "
" .right { float: left; font-size: 1em; margin-left: 13em; max-width: 46em; overflow: auto; } \r \n "
" .tunnel.established { color: #56B734; } \r \n "
" .tunnel.expiring { color: #D3AE3F; } \r \n "
" .tunnel.failed { color: #D33F3F; } \r \n "
" .tunnel.another { color: #434343; } \r \n "
" .tunnel.expiring { color: #D3AE3F; } \r \n "
" .tunnel.failed { color: #D33F3F; } \r \n "
" .tunnel.another { color: #434343; } \r \n "
" caption { font-size: 1.5em; text-align: center; color: #894C84; } \r \n "
" table { width: 100%; border-collapse: collapse; text-align: center; } \r \n "
" .private { background: black; color: black; } .private:hover { background: black; color: white } \r \n "
@ -125,11 +125,11 @@ namespace http {
@@ -125,11 +125,11 @@ namespace http {
std : : string state ;
switch ( eState ) {
case i2p : : tunnel : : eTunnelStateBuildReplyReceived :
case i2p : : tunnel : : eTunnelStatePending : state = " building " ; break ;
case i2p : : tunnel : : eTunnelStatePending : state = " building " ; break ;
case i2p : : tunnel : : eTunnelStateBuildFailed :
case i2p : : tunnel : : eTunnelStateTestFailed :
case i2p : : tunnel : : eTunnelStateFailed : state = " failed " ; break ;
case i2p : : tunnel : : eTunnelStateExpiring : state = " expiring " ; break ;
case i2p : : tunnel : : eTunnelStateFailed : state = " failed " ; break ;
case i2p : : tunnel : : eTunnelStateExpiring : state = " expiring " ; break ;
case i2p : : tunnel : : eTunnelStateEstablished : state = " established " ; break ;
default : state = " unknown " ; break ;
}
@ -185,7 +185,7 @@ namespace http {
@@ -185,7 +185,7 @@ namespace http {
s < < " <b>ERROR:</b> " < < string < < " <br> \r \n " ;
}
void ShowStatus ( std : : stringstream & s , bool includeHiddenContent )
void ShowStatus ( std : : stringstream & s , bool includeHiddenContent )
{
s < < " <b>Uptime:</b> " ;
ShowUptime ( s , i2p : : context . GetUptime ( ) ) ;
@ -233,35 +233,35 @@ namespace http {
@@ -233,35 +233,35 @@ namespace http {
s < < " ( " < < ( double ) i2p : : transport : : transports . GetTransitBandwidth ( ) / 1024 < < " KiB/s)<br> \r \n " ;
s < < " <b>Data path:</b> " < < i2p : : fs : : GetDataDir ( ) < < " <br> \r \n " ;
s < < " <div class='slide' \r \n ><label for='slide1'>Hidden content. Press on text to see.</label> \r \n <input type='checkbox' id='slide1'/> \r \n <p class='content'> \r \n " ;
if ( includeHiddenContent ) {
s < < " <b>Router Ident:</b> " < < i2p : : context . GetRouterInfo ( ) . GetIdentHashBase64 ( ) < < " <br> \r \n " ;
s < < " <b>Router Family:</b> " < < i2p : : context . GetRouterInfo ( ) . GetProperty ( " family " ) < < " <br> \r \n " ;
s < < " <b>Router Caps:</b> " < < i2p : : context . GetRouterInfo ( ) . GetProperty ( " caps " ) < < " <br> \r \n " ;
s < < " <b>Our external address:</b> " < < " <br> \r \n " ;
for ( const auto & address : i2p : : context . GetRouterInfo ( ) . GetAddresses ( ) )
{
switch ( address - > transportStyle )
{
case i2p : : data : : RouterInfo : : eTransportNTCP :
if ( address - > host . is_v6 ( ) )
s < < " NTCP6 " ;
else
s < < " NTCP " ;
break ;
case i2p : : data : : RouterInfo : : eTransportSSU :
if ( address - > host . is_v6 ( ) )
s < < " SSU6 " ;
else
s < < " SSU " ;
break ;
default :
s < < " Unknown " ;
}
s < < address - > host . to_string ( ) < < " : " < < address - > port < < " <br> \r \n " ;
}
}
s < < " </p> \r \n </div> \r \n " ;
s < < " <b>Routers:</b> " < < i2p : : data : : netdb . GetNumRouters ( ) < < " " ;
if ( includeHiddenContent ) {
s < < " <b>Router Ident:</b> " < < i2p : : context . GetRouterInfo ( ) . GetIdentHashBase64 ( ) < < " <br> \r \n " ;
s < < " <b>Router Family:</b> " < < i2p : : context . GetRouterInfo ( ) . GetProperty ( " family " ) < < " <br> \r \n " ;
s < < " <b>Router Caps:</b> " < < i2p : : context . GetRouterInfo ( ) . GetProperty ( " caps " ) < < " <br> \r \n " ;
s < < " <b>Our external address:</b> " < < " <br> \r \n " ;
for ( const auto & address : i2p : : context . GetRouterInfo ( ) . GetAddresses ( ) )
{
switch ( address - > transportStyle )
{
case i2p : : data : : RouterInfo : : eTransportNTCP :
if ( address - > host . is_v6 ( ) )
s < < " NTCP6 " ;
else
s < < " NTCP " ;
break ;
case i2p : : data : : RouterInfo : : eTransportSSU :
if ( address - > host . is_v6 ( ) )
s < < " SSU6 " ;
else
s < < " SSU " ;
break ;
default :
s < < " Unknown " ;
}
s < < address - > host . to_string ( ) < < " : " < < address - > port < < " <br> \r \n " ;
}
}
s < < " </p> \r \n </div> \r \n " ;
s < < " <b>Routers:</b> " < < i2p : : data : : netdb . GetNumRouters ( ) < < " " ;
s < < " <b>Floodfills:</b> " < < i2p : : data : : netdb . GetNumFloodfills ( ) < < " " ;
s < < " <b>LeaseSets:</b> " < < i2p : : data : : netdb . GetNumLeaseSets ( ) < < " <br> \r \n " ;
@ -273,7 +273,7 @@ namespace http {
@@ -273,7 +273,7 @@ namespace http {
s < < " <b>Transit Tunnels:</b> " < < std : : to_string ( transitTunnelCount ) < < " <br> \r \n " ;
}
void ShowLocalDestinations ( std : : stringstream & s )
void ShowLocalDestinations ( std : : stringstream & s )
{
s < < " <b>Local Destinations:</b><br> \r \n <br> \r \n " ;
for ( auto & it : i2p : : client : : context . GetDestinations ( ) )
@ -341,7 +341,7 @@ namespace http {
@@ -341,7 +341,7 @@ namespace http {
s < < " <br> " < < std : : endl ;
}
void ShowLocalDestination ( std : : stringstream & s , const std : : string & b32 )
void ShowLocalDestination ( std : : stringstream & s , const std : : string & b32 )
{
s < < " <b>Local Destination:</b><br> \r \n <br> \r \n " ;
i2p : : data : : IdentHash ident ;
@ -378,12 +378,12 @@ namespace http {
@@ -378,12 +378,12 @@ namespace http {
s < < " <td> " < < it - > GetWindowSize ( ) < < " </td> " ;
s < < " <td> " < < ( int ) it - > GetStatus ( ) < < " </td> " ;
s < < " </tr><br> \r \n " < < std : : endl ;
}
}
s < < " </table> " ;
}
}
static void ShowI2CPLocalDestination ( std : : stringstream & s , const std : : string & id )
static void ShowI2CPLocalDestination ( std : : stringstream & s , const std : : string & id )
{
auto i2cpServer = i2p : : client : : context . GetI2CPServer ( ) ;
if ( i2cpServer )
@ -399,7 +399,7 @@ namespace http {
@@ -399,7 +399,7 @@ namespace http {
ShowError ( s , " I2CP is not enabled " ) ;
}
void ShowLeasesSets ( std : : stringstream & s )
void ShowLeasesSets ( std : : stringstream & s )
{
s < < " <div id='leasesets'><b>LeaseSets (click on to show info):</b></div><br> \r \n " ;
int counter = 1 ;
@ -432,7 +432,7 @@ namespace http {
@@ -432,7 +432,7 @@ namespace http {
// end for each lease set
}
void ShowTunnels ( std : : stringstream & s )
void ShowTunnels ( std : : stringstream & s )
{
s < < " <b>Queue size:</b> " < < i2p : : tunnel : : tunnels . GetQueueSize ( ) < < " <br> \r \n " ;
@ -454,7 +454,7 @@ namespace http {
@@ -454,7 +454,7 @@ namespace http {
s < < " <br> \r \n " ;
}
static void ShowCommands ( std : : stringstream & s , uint32_t token )
static void ShowCommands ( std : : stringstream & s , uint32_t token )
{
/* commands */
s < < " <b>Router Commands</b><br> \r \n " ;
@ -469,14 +469,16 @@ namespace http {
@@ -469,14 +469,16 @@ namespace http {
s < < " <a href= \" /?cmd= " < < HTTP_COMMAND_SHUTDOWN_CANCEL < < " &token= " < < token < < " \" >Cancel graceful shutdown</a><br> " ;
else
s < < " <a href= \" /?cmd= " < < HTTP_COMMAND_SHUTDOWN_START < < " &token= " < < token < < " \" >Start graceful shutdown</a><br> \r \n " ;
# endif
# ifdef WIN32_APP
s < < " <a href= \" /?cmd= " < < HTTP_COMMAND_SHUTDOWN_START < < " &token= " < < token < < " \" >Graceful shutdown</a><br> \r \n " ;
# elif defined(WIN32_APP)
if ( i2p : : util : : DaemonWin32 : : Instance ( ) . isGraceful )
s < < " <a href= \" /?cmd= " < < HTTP_COMMAND_SHUTDOWN_CANCEL < < " &token= " < < token < < " \" >Cancel graceful shutdown</a><br> " ;
else
s < < " <a href= \" /?cmd= " < < HTTP_COMMAND_SHUTDOWN_START < < " &token= " < < token < < " \" >Graceful shutdown</a><br> \r \n " ;
# endif
s < < " <a href= \" /?cmd= " < < HTTP_COMMAND_SHUTDOWN_NOW < < " &token= " < < token < < " \" >Force shutdown</a><br> \r \n " ;
}
void ShowTransitTunnels ( std : : stringstream & s )
void ShowTransitTunnels ( std : : stringstream & s )
{
s < < " <b>Transit tunnels:</b><br> \r \n <br> \r \n " ;
for ( const auto & it : i2p : : tunnel : : tunnels . GetTransitTunnels ( ) )
@ -491,7 +493,7 @@ namespace http {
@@ -491,7 +493,7 @@ namespace http {
}
}
void ShowTransports ( std : : stringstream & s )
void ShowTransports ( std : : stringstream & s )
{
s < < " <b>Transports:</b><br> \r \n <br> \r \n " ;
auto ntcpServer = i2p : : transport : : transports . GetNTCPServer ( ) ;
@ -577,7 +579,7 @@ namespace http {
@@ -577,7 +579,7 @@ namespace http {
}
}
void ShowSAMSessions ( std : : stringstream & s )
void ShowSAMSessions ( std : : stringstream & s )
{
auto sam = i2p : : client : : context . GetSAMBridge ( ) ;
if ( ! sam ) {
@ -624,7 +626,7 @@ namespace http {
@@ -624,7 +626,7 @@ namespace http {
}
}
void ShowI2PTunnels ( std : : stringstream & s )
void ShowI2PTunnels ( std : : stringstream & s )
{
s < < " <b>Client Tunnels:</b><br> \r \n <br> \r \n " ;
for ( auto & it : i2p : : client : : context . GetClientTunnels ( ) )
@ -756,8 +758,8 @@ namespace http {
@@ -756,8 +758,8 @@ namespace http {
}
/* method #2: 'Authorization' header sent */
auto provided = req . GetHeader ( " Authorization " ) ;
if ( provided . length ( ) > 0 )
{
if ( provided . length ( ) > 0 )
{
bool result = false ;
std : : string expected = user + " : " + pass ;
@ -802,7 +804,7 @@ namespace http {
@@ -802,7 +804,7 @@ namespace http {
} else if ( req . uri . find ( " cmd= " ) ! = std : : string : : npos ) {
HandleCommand ( req , res , s ) ;
} else {
ShowStatus ( s , true ) ;
ShowStatus ( s , true ) ;
res . add_header ( " Refresh " , " 10 " ) ;
}
ShowPageTail ( s ) ;
@ -814,7 +816,7 @@ namespace http {
@@ -814,7 +816,7 @@ namespace http {
std : : map < uint32_t , uint32_t > HTTPConnection : : m_Tokens ;
void HTTPConnection : : HandlePage ( const HTTPReq & req , HTTPRes & res , std : : stringstream & s )
{
{
std : : map < std : : string , std : : string > params ;
std : : string page ( " " ) ;
URL url ;
@ -864,7 +866,7 @@ namespace http {
@@ -864,7 +866,7 @@ namespace http {
ShowError ( s , " Unknown page: " + page ) ;
return ;
}
}
}
void HTTPConnection : : HandleCommand ( const HTTPReq & req , HTTPRes & res , std : : stringstream & s )
{
@ -894,14 +896,15 @@ namespace http {
@@ -894,14 +896,15 @@ namespace http {
i2p : : context . SetAcceptsTunnels ( false ) ;
# if (!defined(WIN32) && !defined(QT_GUI_LIB) && !defined(ANDROID))
Daemon . gracefulShutdownInterval = 10 * 60 ;
# endif
# ifdef WIN32_APP
# elif defined(WIN32_APP)
i2p : : win32 : : GracefulShutdown ( ) ;
# endif
} else if ( cmd = = HTTP_COMMAND_SHUTDOWN_CANCEL ) {
i2p : : context . SetAcceptsTunnels ( true ) ;
# if (!defined(WIN32) && !defined(QT_GUI_LIB) && !defined(ANDROID))
Daemon . gracefulShutdownInterval = 0 ;
# elif defined(WIN32_APP)
i2p : : win32 : : StopGracefulShutdown ( ) ;
# endif
} else if ( cmd = = HTTP_COMMAND_SHUTDOWN_NOW ) {
Daemon . running = false ;
@ -940,7 +943,7 @@ namespace http {
@@ -940,7 +943,7 @@ namespace http {
void HTTPServer : : Start ( )
{
bool needAuth ; i2p : : config : : GetOption ( " http.auth " , needAuth ) ;
bool needAuth ; i2p : : config : : GetOption ( " http.auth " , needAuth ) ;
std : : string user ; i2p : : config : : GetOption ( " http.user " , user ) ;
std : : string pass ; i2p : : config : : GetOption ( " http.pass " , pass ) ;
/* generate pass if needed */