TotalFreedomMod/src/main/java/me/totalfreedom/totalfreedommod/httpd/module/Module_logs.java

30 lines
930 B
Java

package me.totalfreedom.totalfreedommod.httpd.module;
import java.io.File;
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
import me.totalfreedom.totalfreedommod.httpd.NanoHTTPD;
import me.totalfreedom.totalfreedommod.util.FLog;
public class Module_logs extends Module_file
{
public Module_logs(NanoHTTPD.HTTPSession session)
{
super(session);
}
@Override
public NanoHTTPD.Response getResponse()
{
if (ConfigEntry.LOGS_SECRET.getString().equals(params.get("password")) && !ConfigEntry.LOGS_SECRET.getString().isEmpty())
{
FLog.info(session.getSocket().getInetAddress() + " is downloading latest.log.");
return serveFile("latest.log", params, new File("./logs"));
}
else
{
return new NanoHTTPD.Response(NanoHTTPD.Response.Status.FORBIDDEN, NanoHTTPD.MIME_PLAINTEXT, "Incorrect password.");
}
}
}