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

Miss example rust program in LOCAL.md dock #918

Closed
yanickxia opened this issue Apr 12, 2024 · 3 comments · Fixed by #1014
Closed

Miss example rust program in LOCAL.md dock #918

yanickxia opened this issue Apr 12, 2024 · 3 comments · Fixed by #1014

Comments

@yanickxia
Copy link

in LOCAL.md has

INPOD_UDS=/tmp/ztunnel cargo run --example inpodserver -- pod1

but example folder miss it

@daixiang0
Copy link
Member

Actually, I do not find inpodserver.rs in the git log.

ping @yuval-k

@yuval-k
Copy link
Contributor

yuval-k commented Apr 15, 2024

my bad, will open a pr shortly

@yuval-k
Copy link
Contributor

yuval-k commented Apr 15, 2024

in the mean time, this is the code for it:


#[cfg(target_os = "linux")]
fn main() {
    use std::os::fd::AsRawFd;
    use ztunnel::test_helpers::inpod::start_ztunnel_server;

    let uds = std::env::var("INPOD_UDS").unwrap();
    let netns = std::env::args().nth(1).unwrap();
    let mut netns_base_dir = std::path::PathBuf::from("/var/run/netns");
    netns_base_dir.push(netns);
    let netns_file = std::fs::File::open(netns_base_dir).unwrap();

    let fd = netns_file.as_raw_fd();

    let (default_node_server, mut default_node_server_ack) = start_ztunnel_server(uds);

    default_node_server.blocking_send(fd).unwrap();
    default_node_server_ack.blocking_recv().unwrap();
}

#[cfg(not(target_os = "linux"))]
fn main() {}

i'll need to validate this still works against main

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants