Skip to content
This repository has been archived by the owner on Sep 25, 2019. It is now read-only.

Commit

Permalink
fix dns bin, fix hello-world code for resolv event
Browse files Browse the repository at this point in the history
  • Loading branch information
jeromegn committed Nov 1, 2018
1 parent 6ce47f5 commit cfb31f3
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion hello-world.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ addEventListener("resolv", event => {
event.respondWith(function () {
return new DNSResponse([
{
name: event.request.queries[0].name,
name: event.request.name,
type: DNSRecordType.TXT,
ttl: 5,
data: { data: [new TextEncoder().encode("helloworld"), new TextEncoder().encode("helloworld2")] }
Expand Down
10 changes: 5 additions & 5 deletions src/bin/dns/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,11 @@ fn main() {
.index(1),
).get_matches();

let main_el = tokio::runtime::Runtime::new().unwrap();
unsafe {
EVENT_LOOP_HANDLE = Some(main_el.executor());
};

let runtime = {
let rt = Runtime::new(None);
rt.eval_file(matches.value_of("input").unwrap());
Expand All @@ -86,11 +91,6 @@ fn main() {
let udp_socket = UdpSocket::bind(&addr).expect(&format!("udp bind failed: {}", addr));
info!("Listener bound on address: {}", addr);

let main_el = tokio::runtime::Runtime::new().unwrap();
unsafe {
EVENT_LOOP_HANDLE = Some(main_el.executor());
};

let _ = main_el.block_on_all(future::lazy(move || -> Result<(), ()> {
server.register_socket(udp_socket);
Ok(())
Expand Down

0 comments on commit cfb31f3

Please sign in to comment.