-
Notifications
You must be signed in to change notification settings - Fork 125
feat(dns): enhance dns hijack with fake IP enabled #730
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
Conversation
|
@Watfaq/clash-rs-devs Define a struct named AppConext where we store states that maybe global struct AppConext {
mark: u64
name: String
tun: tunState
}
static GLOBAL_CONTEXT: ArcSwapOption<AppConext> = todo!()
// or ...
static GLOBAL_CONTEXT: RwLock<AppConext> = todo!()
// if we want more fine-grained lock
struct AppConext {
mark: AtomicU64
name: ArcSwap<String>
other: RwLock<AnotherState>
}
static GLOBAL_CONTEXT: Lazy<AppConext> = todo!()Where we use global states: fn apply_socket_opts(){
apply_socket_opts_with_ctx(GLOBAL_CONTEXT.get())
}
fn apply_socket_opts_with_ctx(ctx: AppContext){
todo!()
}when we use
fn bind_interface(){
bind_interface_with_ctx(GLOBAL_CONTEXT.get())
}
fn bind_interface_with_ctx(ctx: AppContext){
todo!()
}
// we must caller's Context
#[test]
fn test_1(){
GLOBAL_CONTEXT.init(AppConext { mark:41 })
apply_socket_opts()
}
#[test]
fn test_2(){
GLOBAL_CONTEXT.init(AppConext { mark:34 })
apply_socket_opts()
}
// that may cause
// 1. panic due to multi init if we use lazy
// 2. actual GLOBAL_CONTEXT not clear, `mark` maybe 34 in test_1 or 41 in test_2
#[test]
fn test_1(){
let ctx = AppConext { mark:41 }
apply_socket_opts_with_ctx(ctx)
}
#[test]
fn test_2(){
let ctx = AppConext { mark:34 }
apply_socket_opts_with_ctx(ctx)
}when we use funtcions without Actually saying... I dont know, we could pass fn main(){
let ctx = AppContext {
..
}
func_1_ctx(ctx);
func_2_ctx(ctx);
}
fn func_1_with_ctx(ctx:Context){
}
fn func_2_with_ctx(ctx:Context){
}or we dont use ctx only in top-level? fn main(){
let ctx = AppContext {
..
}
GLOBAL_CONTEXT.init(ctx);
func_1();
func_2();
} |
|
Sure. That's def a more elegant solution. There's probably some issues with the current tun udp handling concurrent reqs that I'm still trying to figure out. |
TUN UDP + FAKE-IP + DNS hijack ? |
|
Likely. Haven't test other scenarios tho. |
|
On android TUN + dns-hijack works well (master branch). It might be route problems? |
|
I'll make another PR to apply the global state refactor |
I think we can just pass |
Welcome to Codecov 🎉Once you merge this PR into your default branch, you're all set! Codecov will compare coverage reports and display results in all future pull requests. Thanks for integrating Codecov - We've got you covered ☂️ |
🤔 This is a ...
🔗 Related issue link
💡 Background and solution
📝 Changelog
☑️ Self-Check before Merge