Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add ip or domain filter support #44

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
try fix tokio in tokio problem
Signed-off-by: andrewmatilde <[email protected]>
  • Loading branch information
Andrewmatilde committed May 7, 2022
commit f82e9587704963388e0135449dbab7332b65112d
9 changes: 8 additions & 1 deletion chaos-tproxy-controller/src/proxy/config.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
use std::convert::TryFrom;
use std::net::{IpAddr, Ipv4Addr};
use std::sync::mpsc::channel;

use anyhow::{anyhow, Result, Error};
use trust_dns_resolver::Resolver;
Expand Down Expand Up @@ -30,7 +31,13 @@ impl TryFrom<RawConfig> for Config {
.map(|domain| {
let (config,opt) = read_system_conf()?;
let resolver = Resolver::new(config, opt)?;
let rsp = resolver.lookup_ip(domain)?;

let (sender, receiver) = channel();
std::thread::spawn(move || {
sender.send(resolver.lookup_ip(domain));
}).join();

let rsp = receiver.recv()??;
let ips:Vec<Ipv4Addr> = rsp.iter().filter_map(|ip| {
match ip {
IpAddr::V4(ipv4) => Some(ipv4),
Expand Down