From c994950aafbb41d1f8bb0534f403484a963b3217 Mon Sep 17 00:00:00 2001 From: asokolov Date: Fri, 9 Nov 2018 17:42:04 +0300 Subject: [PATCH] default webroot in config, webroot in automatic redirect instead of request path --- contrib/i2pd.conf | 2 ++ daemon/HTTPServer.cpp | 6 ++++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/contrib/i2pd.conf b/contrib/i2pd.conf index 40949cc1..7bd2c90f 100644 --- a/contrib/i2pd.conf +++ b/contrib/i2pd.conf @@ -93,6 +93,8 @@ ipv6 = false ## Address and port service will listen on address = 127.0.0.1 port = 7070 +## Path to web console, default "/" +# webroot = / ## Uncomment following lines to enable Web Console authentication # auth = true # user = i2pd diff --git a/daemon/HTTPServer.cpp b/daemon/HTTPServer.cpp index d8dc8719..ccf2640c 100644 --- a/daemon/HTTPServer.cpp +++ b/daemon/HTTPServer.cpp @@ -1032,10 +1032,12 @@ namespace http { ShowError(s, "Unknown command: " + cmd); return; } + std::string webroot; i2p::config::GetOption("http.webroot", webroot); + std::string redirect = "5; url=" + webroot + "?page=commands"; s << "SUCCESS: Command accepted

\r\n"; - s << "Back to commands list
\r\n"; + s << "Back to commands list
\r\n"; s << "

You will be redirected in 5 seconds"; - res.add_header("Refresh", std::string("5; url=" + url.path + "?page=commands").c_str()); + res.add_header("Refresh", redirect.c_str()); } void HTTPConnection::SendReply (HTTPRes& reply, std::string& content)