Browse Source

auto update script executed

Toby Chui 1 year ago
parent
commit
fdbb0e4244
2 changed files with 22 additions and 21 deletions
  1. 10 11
      mod/geodb/geodb.go
  2. 12 10
      mod/geodb/geoloader.go

+ 10 - 11
mod/geodb/geodb.go

@@ -6,7 +6,6 @@ import (
 	"net"
 	"net/http"
 	"strings"
-	"sync"
 
 	"imuslab.com/zoraxy/mod/database"
 )
@@ -15,11 +14,11 @@ import (
 var geoipv4 []byte //Original embedded csv file
 
 type Store struct {
-	Enabled    bool
-	geodb      [][]string //Parsed geodb list
-	geoipCache sync.Map
-	geotrie    *trie
-	sysdb      *database.Database
+	Enabled bool
+	geodb   [][]string //Parsed geodb list
+	//geoipCache sync.Map
+	geotrie *trie
+	sysdb   *database.Database
 }
 
 type CountryInfo struct {
@@ -55,11 +54,11 @@ func NewGeoDb(sysdb *database.Database) (*Store, error) {
 	}
 
 	return &Store{
-		Enabled:    blacklistEnabled,
-		geodb:      parsedGeoData,
-		geoipCache: sync.Map{},
-		geotrie:    constrctTrieTree(parsedGeoData),
-		sysdb:      sysdb,
+		Enabled: blacklistEnabled,
+		geodb:   parsedGeoData,
+		//geoipCache: sync.Map{},
+		geotrie: constrctTrieTree(parsedGeoData),
+		sysdb:   sysdb,
 	}, nil
 }
 

+ 12 - 10
mod/geodb/geoloader.go

@@ -16,19 +16,21 @@ func (s *Store) search(ip string) string {
 		ip = strings.TrimSpace(ip)
 	}
 	//See if there are cached country code for this ip
-	ccc, ok := s.geoipCache.Load(ip)
-	if ok {
-		return ccc.(string)
-	}
+	/*
+		ccc, ok := s.geoipCache.Load(ip)
+		if ok {
+			return ccc.(string)
+		}
+	*/
 
 	//Search in geotrie tree
 	cc := s.geotrie.search(ip)
-	if cc != "" {
-		s.geoipCache.Store(ip, cc)
-	}
-
-	//Not found
-	return ""
+	/*
+		if cc != "" {
+			s.geoipCache.Store(ip, cc)
+		}
+	*/
+	return cc
 }
 
 // Construct the trie data structure for quick lookup