diff options
| author | Loyalsoldier <[email protected]> | 2025-01-31 12:13:04 +0800 |
|---|---|---|
| committer | Loyalsoldier <[email protected]> | 2025-01-31 12:47:42 +0800 |
| commit | d9ccff71c634dae0ed85608d37b2d0c2d732fa1a (patch) | |
| tree | c2be47037421000cd05e1bd08d0c3aadbb47ba6f /lib | |
| parent | ebc3b252c97455b32f1cdb3fbba92fff6d6fe6c9 (diff) | |
Feat: support to generate pure ASN data202501310448
when using maxmindGeoLite2ASNCSV as input format
Diffstat (limited to 'lib')
| -rw-r--r-- | lib/common.go | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/lib/common.go b/lib/common.go index 51fd6b24..ed7c2e02 100644 --- a/lib/common.go +++ b/lib/common.go @@ -1,6 +1,7 @@ package lib import ( + "encoding/json" "fmt" "io" "net/http" @@ -32,3 +33,30 @@ func GetRemoteURLReader(url string) (io.ReadCloser, error) { return resp.Body, nil } + +type WantedListExtended struct { + TypeSlice []string + TypeMap map[string][]string +} + +func (w *WantedListExtended) UnmarshalJSON(data []byte) error { + if len(data) == 0 { + return nil + } + + slice := make([]string, 0) + mapMap := make(map[string][]string, 0) + + err := json.Unmarshal(data, &slice) + if err != nil { + err2 := json.Unmarshal(data, &mapMap) + if err2 != nil { + return err2 + } + } + + w.TypeSlice = slice + w.TypeMap = mapMap + + return nil +} |
