chore: Add GeoIP result to metadata

This commit is contained in:
H1JK
2024-03-02 17:41:04 +08:00
parent 7eb16a098a
commit d27340867f
3 changed files with 31 additions and 13 deletions

View File

@@ -5,7 +5,6 @@ import (
"net"
"github.com/oschwald/maxminddb-golang"
"github.com/sagernet/sing/common"
)
type geoip2Country struct {
@@ -44,9 +43,11 @@ func (r Reader) LookupCode(ipAddress net.IP) []string {
case string:
return []string{record}
case []any: // lookup returned type of slice is []any
return common.Map(record, func(it any) string {
return it.(string)
})
result := make([]string, 0, len(record))
for _, item := range record {
result = append(result, item.(string))
}
return result
}
return []string{}