-
Notifications
You must be signed in to change notification settings - Fork 15
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 Client Server role option #38
Add Client Server role option #38
Conversation
Signed-off-by: andrewmatilde <[email protected]>
Signed-off-by: andrewmatilde <[email protected]>
Signed-off-by: andrewmatilde <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here is my first time trying to review codes in chaos-tproxy.
Please point me the thing I missed if I give the misleading comments.
RawRole::Client => Role::Client(ipv4s[0]), | ||
RawRole::Server => Role::Server(ipv4s[0]), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It seems we could only resolve the first IP of the first NIC.
And there is nowhere to extend the place. Should we consider that?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The problem of we could only resolve the first NIC is caused by I have write a customed NIC function with some severe BUG , so I delete it. I will fix it later. I have leave a TODO for it.
I will fix the problem of we could only resolve the first IP , but that was a rare situation.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed.
match config.interface { | ||
None => {} | ||
Some(interface) => { | ||
self.net_env.set_ip_with_interface_name(&interface)?; | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
after that, there is nowhere to call the set_ip_with_interface_name
, maybe we could also remove that unused method?
Also there is nowhere to change NetEnv.ip
, I am not sure it would introduce unexpected situation or not.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree with you.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also there is nowhere to change NetEnv.ip, I am not sure it would introduce unexpected situation or not.
I will fix the problem later. Now the chaos-tproxy is only used in container networks , so , IMO , it is safe.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed.
Signed-off-by: andrewmatilde <[email protected]>
# Conflicts: # chaos-tproxy-controller/src/proxy/exec.rs
Signed-off-by: andrewmatilde <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
rest LGTM
PTAL @Andrewmatilde
fn role_ok(&self) -> bool { | ||
let role = match &self.config.role { | ||
None => return true, | ||
Some(r) => r.clone(), | ||
}; | ||
let remote_v4 = match self.remote.ip() { | ||
IpAddr::V4(ipv4) => ipv4, | ||
_ => return false, | ||
}; | ||
let target_v4 = match self.target.ip() { | ||
IpAddr::V4(ipv4) => ipv4, | ||
_ => return false, | ||
}; | ||
|
||
select_role(&remote_v4, &target_v4, &role) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I prefer to move this logic as a part of selector, in function select_role()
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed. Move some logical into select_role()
async fn handle(self, mut request: Request<Body>) -> Result<Response<Body>> { | ||
let log_key = format!("{{remote = {}, target = {} }}", self.remote, self.target); | ||
debug!("{} : Proxy is handling http request", log_key); | ||
|
||
let ok = self.role_ok(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok
-> role_ok
or role_matched
, role_selected
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed. ok
-> role_ok
# Conflicts: # chaos-tproxy-controller/src/proxy/config.rs # chaos-tproxy-controller/src/proxy/net/bridge.rs # chaos-tproxy-controller/src/raw_config.rs # chaos-tproxy-proxy/src/proxy/http/server.rs # chaos-tproxy-proxy/src/raw_config.rs
Signed-off-by: andrewmatilde <[email protected]>
Signed-off-by: andrewmatilde <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
Add a Client-Server role option.
When user set Client role in config, action will just apply when HTTP-TCP-source-IP == default IP.
When user set Server role in config, action will just apply when HTTP-TCP-dst-IP == default IP.
I also delete some interface option in proxy just because I find this option not really works & brings some BUGs.
related issue: #46