|
@@ -8,7 +8,7 @@ import (
|
|
"github.com/dgraph-io/badger"
|
|
"github.com/dgraph-io/badger"
|
|
"github.com/op/go-logging"
|
|
"github.com/op/go-logging"
|
|
"gopkg.in/natefinch/lumberjack.v2"
|
|
"gopkg.in/natefinch/lumberjack.v2"
|
|
- "io/ioutil"
|
|
|
|
|
|
+// "io/ioutil"
|
|
"net/http"
|
|
"net/http"
|
|
"net/http/fcgi"
|
|
"net/http/fcgi"
|
|
"os"
|
|
"os"
|
|
@@ -84,8 +84,10 @@ func main() {
|
|
|
|
|
|
log.Info("gosl started and logging is set up. Proceeding to test KV database.")
|
|
log.Info("gosl started and logging is set up. Proceeding to test KV database.")
|
|
|
|
|
|
|
|
+ var err error
|
|
Opt = badger.DefaultOptions
|
|
Opt = badger.DefaultOptions
|
|
- Opt.Dir, _ = ioutil.TempDir("", "goslkv")
|
|
|
|
|
|
+ Opt.Dir, err = os.Getwd()
|
|
|
|
+ checkErr(err)
|
|
Opt.ValueDir = Opt.Dir
|
|
Opt.ValueDir = Opt.Dir
|
|
kv, err := badger.NewKV(&Opt)
|
|
kv, err := badger.NewKV(&Opt)
|
|
checkErr(err) // should probably panic
|
|
checkErr(err) // should probably panic
|
|
@@ -165,6 +167,7 @@ func handler(w http.ResponseWriter, r *http.Request) {
|
|
}
|
|
}
|
|
name := r.Form.Get("name") // can be empty
|
|
name := r.Form.Get("name") // can be empty
|
|
key := r.Form.Get("key") // can be empty
|
|
key := r.Form.Get("key") // can be empty
|
|
|
|
+ compat := r.Form.Get("compat") // compatibility mode with W-Hat
|
|
messageToSL := "" // this is what we send back to SL - defined here due to scope issues.
|
|
messageToSL := "" // this is what we send back to SL - defined here due to scope issues.
|
|
if name != "" {
|
|
if name != "" {
|
|
if key != "" {
|
|
if key != "" {
|
|
@@ -177,7 +180,11 @@ func handler(w http.ResponseWriter, r *http.Request) {
|
|
} else {
|
|
} else {
|
|
// we just received the name: look up its UUID key.
|
|
// we just received the name: look up its UUID key.
|
|
key = searchKV(name)
|
|
key = searchKV(name)
|
|
- messageToSL += "UUID for '" + name + "' is: " + key
|
|
|
|
|
|
+ if compat == "false" {
|
|
|
|
+ messageToSL += "UUID for '" + name + "' is: " + key
|
|
|
|
+ } else { // empty also means true!
|
|
|
|
+ messageToSL += key
|
|
|
|
+ }
|
|
}
|
|
}
|
|
} else if key != "" {
|
|
} else if key != "" {
|
|
// in this scenario, we have the UUID key but no avatar name: do the equivalent of a llKey2Name
|
|
// in this scenario, we have the UUID key but no avatar name: do the equivalent of a llKey2Name
|
|
@@ -189,7 +196,11 @@ func handler(w http.ResponseWriter, r *http.Request) {
|
|
}
|
|
}
|
|
name = string(item.Value())
|
|
name = string(item.Value())
|
|
kv.Close()
|
|
kv.Close()
|
|
- messageToSL += "Avatar name for " + key + "' is '" + name + "'"
|
|
|
|
|
|
+ if compat == "false" {
|
|
|
|
+ messageToSL += "Avatar name for " + key + "' is '" + name + "'"
|
|
|
|
+ } else { // empty also means true!
|
|
|
|
+ messageToSL += name
|
|
|
|
+ }
|
|
} else {
|
|
} else {
|
|
// neither UUID key nor avatar received, this is an error
|
|
// neither UUID key nor avatar received, this is an error
|
|
logErrHTTP(w, http.StatusNotFound, "Empty avatar name and UUID key received, cannot proceed")
|
|
logErrHTTP(w, http.StatusNotFound, "Empty avatar name and UUID key received, cannot proceed")
|