Fix target for console webapp

needs a / or will redirect and fail
This commit is contained in:
zzz
2022-01-01 14:37:13 -05:00
parent 0f6dc2293e
commit 2c3db1eff4
2 changed files with 14 additions and 2 deletions

2
README
View File

@ -26,6 +26,8 @@ To start it, go to http://localhost:7657/configwebapps and start the
and click "Save WebApp Configuration".
You MUST change itoopie's "I2P Node port" to 7657 to connect to the jsonrpc webapp.
itoopie will automatically use http for port 7657.
If the console is on another port, it is assumed to be HTTPS, and you
must add "server.target=jsonrpc/" to the config file ~/.itoopie/itoopie.conf
Version 1 API specification:

View File

@ -47,8 +47,18 @@ public class JSONRPC2Interface {
String srvHost = _conf.getConf("server.hostname", "localhost");
int srvPort = _conf.getConf("server.port", 7650);
String srvTarget = _conf.getConf("server.target", "jsonrpc");
// Use HTTP for the xmlrpc webapp in the HTTP router console
String method = srvPort == 7657 ? "http" : "https";
String method;
if (srvPort == 7657) {
// Use HTTP for the xmlrpc webapp in the HTTP router console
method = "http";
// target MUST contain a /, or else console will redirect
// jsonrpc to jsonrpc/ which will be fetched as a GET
// and will return the HTML password form.
if (!srvTarget.contains("/"))
srvTarget += "/";
} else {
method = "https";
}
try {
srvURL = new URL(method + "://" + srvHost + ":" + srvPort + "/"
+ srvTarget);