multi-server fixes

This commit is contained in:
Neale Pickett 2014-08-13 04:57:39 +00:00
parent de2bff69da
commit 027929559d
3 changed files with 7 additions and 5 deletions

View File

@ -10,6 +10,7 @@
<div id="foraButtons"></div>
<div id="foraText"></div>
<form id="command">
<input type="hidden" name="server" value="slashnet" id="server">
<input type="hidden" name="auth" value="" id="authtok">
<input type="hidden" name="type" value="command">
<input type="hidden" name="target" id="target">

View File

@ -84,12 +84,12 @@ func handleCommand(w http.ResponseWriter, text string, target string) {
func (h Handler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
// XXX: I'm not happy with this irc.basedir file
BaseDir := ReadString("irc.basedir")
BaseDir := "servers"
DefaultDir := path.Join(BaseDir, "default")
ServerDir = path.Join(BaseDir, r.FormValue("server"))
if m, _ := path.Match(path.Join(BaseDir, "*"), ServerDir); ! m {
ServerDir = path.Join(BaseDir, "default")
if path.Dir(DefaultDir) != path.Dir(ServerDir) {
ServerDir = DefaultDir
}
authtok := ReadString(path.Join(ServerDir, "authtok"))

View File

@ -180,10 +180,11 @@ function handleCommand(event) {
}
function init() {
var server = document.getElementById("server").value;
var authtok = prompt("Auth token", "");
document.getElementById("authtok").value = authtok;
var source = new EventSource("wirc.cgi?auth=" + authtok);
var source = new EventSource("wirc.cgi?server=" + server + "&auth=" + authtok);
source.onmessage = newmsg;
document.getElementById("command").onsubmit = handleCommand;