Compare commits
3 Commits
Author | SHA1 | Date | |
---|---|---|---|
fcb1a7813a | |||
6f1bc3d65b | |||
2b93c9d4c9 |
@ -131,12 +131,14 @@ func (r *Resolver) resolveIP(m *D.Msg) (msg *D.Msg, err error) {
|
||||
return nil, errors.New("GeoIP can't use")
|
||||
}
|
||||
|
||||
ips, _ := r.msgToIP(res.Msg)
|
||||
if record, _ := mmdb.Country(ips[0]); record.Country.IsoCode == "CN" || record.Country.IsoCode == "" {
|
||||
// release channel
|
||||
go func() { <-fallbackMsg }()
|
||||
msg = res.Msg
|
||||
return
|
||||
ips, err := r.msgToIP(res.Msg)
|
||||
if err == nil {
|
||||
if record, _ := mmdb.Country(ips[0]); record.Country.IsoCode == "CN" || record.Country.IsoCode == "" {
|
||||
// release channel
|
||||
go func() { <-fallbackMsg }()
|
||||
msg = res.Msg
|
||||
return msg, err
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -172,20 +174,12 @@ func (r *Resolver) msgToIP(msg *D.Msg) ([]net.IP, error) {
|
||||
var ips []net.IP
|
||||
|
||||
for _, answer := range msg.Answer {
|
||||
if r.ipv6 {
|
||||
ans, ok := answer.(*D.AAAA)
|
||||
if !ok {
|
||||
continue
|
||||
}
|
||||
switch ans := answer.(type) {
|
||||
case *D.AAAA:
|
||||
ips = append(ips, ans.AAAA)
|
||||
continue
|
||||
case *D.A:
|
||||
ips = append(ips, ans.A)
|
||||
}
|
||||
|
||||
ans, ok := answer.(*D.A)
|
||||
if !ok {
|
||||
continue
|
||||
}
|
||||
ips = append(ips, ans.A)
|
||||
}
|
||||
|
||||
if len(ips) == 0 {
|
||||
|
@ -36,7 +36,7 @@ func Start(addr string, secret string) {
|
||||
|
||||
cors := cors.New(cors.Options{
|
||||
AllowedOrigins: []string{"*"},
|
||||
AllowedMethods: []string{"GET", "POST", "PUT", "DELETE", "OPTIONS"},
|
||||
AllowedMethods: []string{"GET", "POST", "PUT", "PATCH", "DELETE", "OPTIONS"},
|
||||
AllowedHeaders: []string{"Content-Type", "Authorization"},
|
||||
MaxAge: 300,
|
||||
})
|
||||
|
Reference in New Issue
Block a user