client: set random id correctly

* set_random_id won't work in WASM
This commit is contained in:
Peter Cai 2021-04-03 21:04:07 +08:00
parent d753db62b3
commit 19f53962e7
1 changed files with 3 additions and 1 deletions

View File

@ -44,7 +44,9 @@ impl Client {
// it first, and we also want to be able to do caching and overriding
fn build_query(questions: Vec<Question<ParsedDname>>) -> Result<Message, String> {
let mut builder = MessageBuilder::new_udp();
builder.header_mut().set_random_id();
builder
.header_mut()
.set_id((unsafe { Math::random() } * u16::MAX as f64) as u16);
for q in questions {
builder
.push(q)