File: doh.rs

package info (click to toggle)
rust-curl 0.4.44-5
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 704 kB
  • sloc: sh: 16; makefile: 2
file content (17 lines) | stat: -rw-r--r-- 372 bytes parent folder | download | duplicates (10)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
use curl::easy::Easy;
use std::io::{stdout, Write};

fn main() -> Result<(), curl::Error> {
    let mut curl = Easy::new();

    curl.url("https://example.com")?;
    curl.doh_url(Some("https://cloudflare-dns.com/dns-query"))?;
    curl.write_function(|data| {
        stdout().write_all(data).unwrap();
        Ok(data.len())
    })?;

    curl.perform()?;

    Ok(())
}