mirror of
https://github.com/denoland/deno.git
synced 2024-11-21 15:04:11 -05:00
feat(ext/net): support full SOA
record interface (#14617)
This commit is contained in:
parent
f5c31b56e3
commit
38e0a2ec1b
3 changed files with 23 additions and 3 deletions
7
cli/dts/lib.deno.ns.d.ts
vendored
7
cli/dts/lib.deno.ns.d.ts
vendored
|
@ -2983,6 +2983,11 @@ declare namespace Deno {
|
|||
export interface SOARecord {
|
||||
mname: string;
|
||||
rname: string;
|
||||
serial: number;
|
||||
refresh: number;
|
||||
retry: number;
|
||||
expire: number;
|
||||
minimum: number;
|
||||
}
|
||||
|
||||
/** If `resolveDns` is called with "SRV" record type specified, it will return an array of this interface. */
|
||||
|
@ -3044,5 +3049,5 @@ declare namespace Deno {
|
|||
query: string,
|
||||
recordType: RecordType,
|
||||
options?: ResolveDnsOptions,
|
||||
): Promise<string[] | MXRecord[] | SRVRecord[] | string[][]>;
|
||||
): Promise<string[] | MXRecord[] | SOARecord[] | SRVRecord[] | string[][]>;
|
||||
}
|
||||
|
|
2
cli/tests/testdata/resolve_dns.ts.out
vendored
2
cli/tests/testdata/resolve_dns.ts.out
vendored
|
@ -13,7 +13,7 @@ NS
|
|||
PTR
|
||||
["www.example.com.","alias.example.com."]
|
||||
SOA
|
||||
[{"mname":"net.example.com.","rname":"admin\\.domain.example.com."}]
|
||||
[{"mname":"net.example.com.","rname":"admin\\.domain.example.com.","serial":20,"refresh":7200,"retry":600,"expire":3600000,"minimum":60}]
|
||||
SRV
|
||||
[{"priority":0,"weight":100,"port":1234,"target":"srv.example.com."}]
|
||||
TXT
|
||||
|
|
|
@ -584,6 +584,11 @@ pub enum DnsReturnRecord {
|
|||
Soa {
|
||||
mname: String,
|
||||
rname: String,
|
||||
serial: u32,
|
||||
refresh: i32,
|
||||
retry: i32,
|
||||
expire: i32,
|
||||
minimum: u32,
|
||||
},
|
||||
Srv {
|
||||
priority: u16,
|
||||
|
@ -743,6 +748,11 @@ fn rdata_to_return_record(
|
|||
SOA => r.as_soa().map(|soa| DnsReturnRecord::Soa {
|
||||
mname: soa.mname().to_string(),
|
||||
rname: soa.rname().to_string(),
|
||||
serial: soa.serial(),
|
||||
refresh: soa.refresh(),
|
||||
retry: soa.retry(),
|
||||
expire: soa.expire(),
|
||||
minimum: soa.minimum(),
|
||||
}),
|
||||
SRV => r.as_srv().map(|srv| DnsReturnRecord::Srv {
|
||||
priority: srv.priority(),
|
||||
|
@ -858,7 +868,12 @@ mod tests {
|
|||
func(&rdata),
|
||||
Some(DnsReturnRecord::Soa {
|
||||
mname: "".to_string(),
|
||||
rname: "".to_string()
|
||||
rname: "".to_string(),
|
||||
serial: 0,
|
||||
refresh: i32::MAX,
|
||||
retry: i32::MAX,
|
||||
expire: i32::MAX,
|
||||
minimum: 0,
|
||||
})
|
||||
);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue