summary refs log tree commit diff stats
path: root/cache.go
diff options
context:
space:
mode:
authorBen Morrison <ben@gbmor.dev>2019-05-21 18:49:43 -0400
committerBen Morrison <ben@gbmor.dev>2019-05-21 18:59:56 -0400
commit4f0847bb24a5df77f88c883461491a2f6fd955d7 (patch)
tree0f9e2eef1f6bfa4f3a09370730ad8351c1ce24dd /cache.go
parent61e81ea7acfc01e8b7ea33156a36c15b0674c79f (diff)
downloadgetwtxt-4f0847bb24a5df77f88c883461491a2f6fd955d7.tar.gz
runtime bugs related to api output
Diffstat (limited to 'cache.go')
-rw-r--r--cache.go8
1 files changed, 4 insertions, 4 deletions
diff --git a/cache.go b/cache.go
index be3d7d3..6220b26 100644
--- a/cache.go
+++ b/cache.go
@@ -78,11 +78,11 @@ func pushDatabase() error {
 	// be done at one time rather than
 	// per entry.
 	twtxtCache.Mu.RLock()
-	var dbBasket *leveldb.Batch
+	var dbBasket = &leveldb.Batch{}
 	for k, v := range twtxtCache.Reg {
 		dbBasket.Put([]byte(k+"*Nick"), []byte(v.Nick))
 		dbBasket.Put([]byte(k+"*URL"), []byte(v.URL))
-		dbBasket.Put([]byte(k+"*IP"), []byte(v.IP))
+		dbBasket.Put([]byte(k+"*IP"), []byte(v.IP.String()))
 		dbBasket.Put([]byte(k+"*Date"), []byte(v.Date))
 		for i, e := range v.Status {
 			rfc := i.Format(time.RFC3339)
@@ -151,7 +151,7 @@ func pullDatabase() {
 			for i := 0; i < ref.NumField(); i++ {
 
 				f := ref.Field(i)
-				if f.String() == field {
+				if strings.Contains(f.String(), field) {
 					f.Set(reflect.ValueOf(val))
 					break
 				}
@@ -161,7 +161,7 @@ func pullDatabase() {
 			// If we're looking at a Status entry in the DB,
 			// parse the time then add it to the TimeMap under
 			// data.Status
-			thetime, err := time.Parse("RFC3339", split[2])
+			thetime, err := time.Parse(time.RFC3339, split[2])
 			if err != nil {
 				log.Printf("%v\n", err)
 			}