Add fallback local DNS server for iOS

This commit is contained in:
世界 2025-02-20 17:18:47 +08:00
parent cc294c4616
commit 05fea2a199
No known key found for this signature in database
GPG key ID: CD109927C34A63C4
11 changed files with 293 additions and 45 deletions

View file

@ -1,33 +1,17 @@
package dns
import F "github.com/sagernet/sing/common/format"
const (
RCodeSuccess RCodeError = 0 // NoError
RCodeFormatError RCodeError = 1 // FormErr
RCodeServerFailure RCodeError = 2 // ServFail
RCodeNameError RCodeError = 3 // NXDomain
RCodeNotImplemented RCodeError = 4 // NotImp
RCodeRefused RCodeError = 5 // Refused
import (
mDNS "github.com/miekg/dns"
)
type RCodeError uint16
const (
RcodeFormatError RcodeError = mDNS.RcodeFormatError
RcodeNameError RcodeError = mDNS.RcodeNameError
RcodeRefused RcodeError = mDNS.RcodeRefused
)
func (e RCodeError) Error() string {
switch e {
case RCodeSuccess:
return "success"
case RCodeFormatError:
return "format error"
case RCodeServerFailure:
return "server failure"
case RCodeNameError:
return "name error"
case RCodeNotImplemented:
return "not implemented"
case RCodeRefused:
return "refused"
default:
return F.ToString("unknown error: ", uint16(e))
}
type RcodeError int
func (e RcodeError) Error() string {
return mDNS.RcodeToString[int(e)]
}