mirror of
				https://github.com/PurpleI2P/i2pd.git
				synced 2025-11-04 08:30:46 +00:00 
			
		
		
		
	perfecting qt status page
This commit is contained in:
		
							parent
							
								
									11dca2b352
								
							
						
					
					
						commit
						7225231814
					
				
					 4 changed files with 342 additions and 326 deletions
				
			
		| 
						 | 
				
			
			@ -198,7 +198,10 @@ namespace http {
 | 
			
		|||
		s << "<b>ERROR:</b> " << string << "<br>\r\n";
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	void ShowStatus (std::stringstream& s, bool includeHiddenContent)
 | 
			
		||||
    void ShowStatus (
 | 
			
		||||
            std::stringstream& s,
 | 
			
		||||
            bool includeHiddenContent,
 | 
			
		||||
            i2p::http::OutputFormatEnum outputFormat)
 | 
			
		||||
	{
 | 
			
		||||
		s << "<b>Uptime:</b> ";
 | 
			
		||||
		ShowUptime(s, i2p::context.GetUptime ());
 | 
			
		||||
| 
						 | 
				
			
			@ -245,9 +248,12 @@ namespace http {
 | 
			
		|||
		ShowTraffic (s, i2p::transport::transports.GetTotalTransitTransmittedBytes ());
 | 
			
		||||
		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'><label for='slide-info'>Hidden content. Press on text to see.</label>\r\n<input type='checkbox' id='slide-info'/>\r\n<p class='content'>\r\n";
 | 
			
		||||
		if(includeHiddenContent) {
 | 
			
		||||
			s << "<b>Router Ident:</b> " << i2p::context.GetRouterInfo().GetIdentHashBase64() << "<br>\r\n";
 | 
			
		||||
        s << "<div class='slide'>";
 | 
			
		||||
        if((outputFormat==OutputFormatEnum::forWebConsole)||!includeHiddenContent) {
 | 
			
		||||
            s << "<label for='slide-info'>Hidden content. Press on text to see.</label>\r\n<input type='checkbox' id='slide-info'/>\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" ;
 | 
			
		||||
| 
						 | 
				
			
			@ -272,9 +278,12 @@ namespace http {
 | 
			
		|||
				}
 | 
			
		||||
				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(outputFormat==OutputFormatEnum::forQtUi) {
 | 
			
		||||
            s << "<br>";
 | 
			
		||||
        }
 | 
			
		||||
        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";
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -285,15 +294,17 @@ namespace http {
 | 
			
		|||
		s << "<b>Client Tunnels:</b> " << std::to_string(clientTunnelCount) << " ";
 | 
			
		||||
		s << "<b>Transit Tunnels:</b> " << std::to_string(transitTunnelCount) << "<br>\r\n<br>\r\n";
 | 
			
		||||
 | 
			
		||||
		s << "<table><caption>Services</caption><tr><th>Service</th><th>State</th></tr>\r\n";
 | 
			
		||||
		s << "<tr><td>" << "HTTP Proxy"		<< "</td><td><div class='" << ((i2p::client::context.GetHttpProxy ())			? "enabled" : "disabled") << "'></div></td></tr>\r\n";
 | 
			
		||||
		s << "<tr><td>" << "SOCKS Proxy"	<< "</td><td><div class='" << ((i2p::client::context.GetSocksProxy ())			? "enabled" : "disabled") << "'></div></td></tr>\r\n";
 | 
			
		||||
		s << "<tr><td>" << "BOB"			<< "</td><td><div class='" << ((i2p::client::context.GetBOBCommandChannel ())	? "enabled" : "disabled") << "'></div></td></tr>\r\n";
 | 
			
		||||
		s << "<tr><td>" << "SAM"			<< "</td><td><div class='" << ((i2p::client::context.GetSAMBridge ())			? "enabled" : "disabled") << "'></div></td></tr>\r\n";
 | 
			
		||||
		s << "<tr><td>" << "I2CP"			<< "</td><td><div class='" << ((i2p::client::context.GetI2CPServer ())			? "enabled" : "disabled") << "'></div></td></tr>\r\n";
 | 
			
		||||
		bool i2pcontrol; i2p::config::GetOption("i2pcontrol.enabled", i2pcontrol);
 | 
			
		||||
		s << "<tr><td>" << "I2PControl"		<< "</td><td><div class='" << ((i2pcontrol) 									? "enabled" : "disabled") << "'></div></td></tr>\r\n";
 | 
			
		||||
		s << "</table>\r\n";
 | 
			
		||||
        if(outputFormat==OutputFormatEnum::forWebConsole) {
 | 
			
		||||
            s << "<table><caption>Services</caption><tr><th>Service</th><th>State</th></tr>\r\n";
 | 
			
		||||
            s << "<tr><td>" << "HTTP Proxy"		<< "</td><td><div class='" << ((i2p::client::context.GetHttpProxy ())			? "enabled" : "disabled") << "'></div></td></tr>\r\n";
 | 
			
		||||
            s << "<tr><td>" << "SOCKS Proxy"	<< "</td><td><div class='" << ((i2p::client::context.GetSocksProxy ())			? "enabled" : "disabled") << "'></div></td></tr>\r\n";
 | 
			
		||||
            s << "<tr><td>" << "BOB"			<< "</td><td><div class='" << ((i2p::client::context.GetBOBCommandChannel ())	? "enabled" : "disabled") << "'></div></td></tr>\r\n";
 | 
			
		||||
            s << "<tr><td>" << "SAM"			<< "</td><td><div class='" << ((i2p::client::context.GetSAMBridge ())			? "enabled" : "disabled") << "'></div></td></tr>\r\n";
 | 
			
		||||
            s << "<tr><td>" << "I2CP"			<< "</td><td><div class='" << ((i2p::client::context.GetI2CPServer ())			? "enabled" : "disabled") << "'></div></td></tr>\r\n";
 | 
			
		||||
            bool i2pcontrol; i2p::config::GetOption("i2pcontrol.enabled", i2pcontrol);
 | 
			
		||||
            s << "<tr><td>" << "I2PControl"		<< "</td><td><div class='" << ((i2pcontrol) 									? "enabled" : "disabled") << "'></div></td></tr>\r\n";
 | 
			
		||||
            s << "</table>\r\n";
 | 
			
		||||
        }
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	void ShowLocalDestinations (std::stringstream& s)
 | 
			
		||||
| 
						 | 
				
			
			@ -863,7 +874,7 @@ namespace http {
 | 
			
		|||
		} else if (req.uri.find("cmd=") != std::string::npos) {
 | 
			
		||||
			HandleCommand (req, res, s);
 | 
			
		||||
		} else {
 | 
			
		||||
			ShowStatus (s, true);
 | 
			
		||||
            ShowStatus (s, true, i2p::http::OutputFormatEnum::forWebConsole);
 | 
			
		||||
			res.add_header("Refresh", "10");
 | 
			
		||||
		}
 | 
			
		||||
		ShowPageTail (s);
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -80,7 +80,8 @@ namespace http
 | 
			
		|||
	};
 | 
			
		||||
 | 
			
		||||
    //all the below functions are also used by Qt GUI, see mainwindow.cpp -> getStatusPageHtml
 | 
			
		||||
    void ShowStatus (std::stringstream& s, bool includeHiddenContent);
 | 
			
		||||
    enum OutputFormatEnum { forWebConsole, forQtUi };
 | 
			
		||||
    void ShowStatus (std::stringstream& s, bool includeHiddenContent, OutputFormatEnum outputFormat);
 | 
			
		||||
    void ShowLocalDestinations (std::stringstream& s);
 | 
			
		||||
    void ShowLeasesSets(std::stringstream& s);
 | 
			
		||||
    void ShowTunnels (std::stringstream& s);
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -177,7 +177,9 @@ HEADERS  += DaemonQT.h mainwindow.h \
 | 
			
		|||
    textbrowsertweaked1.h \
 | 
			
		||||
    pagewithbackbutton.h \
 | 
			
		||||
    widgetlock.h \
 | 
			
		||||
    widgetlockregistry.h
 | 
			
		||||
    widgetlockregistry.h \
 | 
			
		||||
    i2pd.rc \
 | 
			
		||||
    i2pd.rc
 | 
			
		||||
 | 
			
		||||
INCLUDEPATH += ../../libi2pd
 | 
			
		||||
INCLUDEPATH += ../../libi2pd_client
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -349,7 +349,9 @@ QString MainWindow::getStatusPageHtml(bool showHiddenInfo) {
 | 
			
		|||
    s << "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0//EN\" \"http://www.w3.org/TR/REC-html40/strict.dtd\">";
 | 
			
		||||
 | 
			
		||||
    switch (statusPage) {
 | 
			
		||||
    case main_page: i2p::http::ShowStatus(s, showHiddenInfo);break;
 | 
			
		||||
    case main_page:
 | 
			
		||||
        i2p::http::ShowStatus(s, showHiddenInfo, i2p::http::OutputFormatEnum::forQtUi);
 | 
			
		||||
        break;
 | 
			
		||||
    case commands: break;
 | 
			
		||||
    case local_destinations: i2p::http::ShowLocalDestinations(s);break;
 | 
			
		||||
    case leasesets: i2p::http::ShowLeasesSets(s); break;
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue