mirror of
https://github.com/XTLS/Xray-core.git
synced 2025-04-30 09:18:34 +00:00
DNS: Support returning upstream TTL to clients (#4526)
Closes https://github.com/XTLS/Xray-core/issues/4527
This commit is contained in:
parent
2d3210e4b8
commit
4afe2d0cff
24 changed files with 168 additions and 157 deletions
|
@ -38,14 +38,15 @@ type IPRecord struct {
|
|||
RawHeader *dnsmessage.Header
|
||||
}
|
||||
|
||||
func (r *IPRecord) getIPs() ([]net.Address, error) {
|
||||
func (r *IPRecord) getIPs() ([]net.Address, uint32, error) {
|
||||
if r == nil || r.Expire.Before(time.Now()) {
|
||||
return nil, errRecordNotFound
|
||||
return nil, 0, errRecordNotFound
|
||||
}
|
||||
if r.RCode != dnsmessage.RCodeSuccess {
|
||||
return nil, dns_feature.RCodeError(r.RCode)
|
||||
return nil, 0, dns_feature.RCodeError(r.RCode)
|
||||
}
|
||||
return r.IP, nil
|
||||
ttl := uint32(time.Until(r.Expire) / time.Second)
|
||||
return r.IP, ttl, nil
|
||||
}
|
||||
|
||||
func isNewer(baseRec *IPRecord, newRec *IPRecord) bool {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue