Skip to content

Rust bindings #40

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

Open
wants to merge 32 commits into
base: main
Choose a base branch
from
Open

Rust bindings #40

wants to merge 32 commits into from

Conversation

chrishayen
Copy link

I'm rewriting my tailscale-based cluster from go to rust and would like to get this in if possible. It implements all of the major functions and contains the echo example. All of the tsnet crates on crates.io are outdated and broken.

Please take a look. Thank you thank you.

Copy link

review-ai-agent bot commented May 23, 2025

Pull Request Revisions

RevisionDescription
r8
Rust Tailscale networking API refactoredUpdated Rust Tailscale networking library to use OwnedFd and BorrowedFd instead of raw file descriptors, improving type safety
r7
Added Rust bindings for Tailscale libraryIntroduced a new Rust project in rust/tsnet with Cargo configuration, build script, and library implementation to create Rust bindings for the Tailscale network library, including GitHub Actions workflow and necessary configuration files
r6
Refactored GitHub Actions Rust workflowAdded workflow name, simplified trigger, and corrected YAML indentation for Rust build job
r5
Fixed GitHub Actions workflow indentationCorrected indentation of the steps block in the Rust workflow YAML configuration
r4
Added GitHub Actions workflow for RustCreated a new GitHub Actions workflow to build Rust project in tsnet directory on push and pull requests
r3
Added error message retrieval functionIntroduced new function to retrieve last error message from Tailscale instance using a pre-allocated buffer
r2
Modify tailscale error message handlingReplace specific error message retrieval with generic "Unknown error" string when error occurs
r1
Added Rust bindings for libtailscaleCreated a new Rust project in rust/tsnet with Cargo configuration, build script, and initial library implementation to provide Rust bindings for the Tailscale C library

☑️ AI review skipped after 5 revisions, comment with `/review` to review again
Help React with emojis to give feedback on AI-generated reviews:
  • 👍 means the feedback was helpful and actionable
  • 👎 means the feedback was incorrect or unhelpful
💬 Replying to feedback with a comment helps us improve the system. Your input also contributes to shaping future interactions with the AI reviewer.

We'd love to hear from you—reach out anytime at [email protected].

@raggi raggi self-requested a review May 23, 2025 20:13
@raggi raggi self-assigned this May 23, 2025
@raggi
Copy link
Member

raggi commented May 23, 2025

I may not have time to review immediately today, but in principle this will be great to have so I hope to get back to the PR ASAP.

@chrishayen
Copy link
Author

I may not have time to review immediately today, but in principle this will be great to have so I hope to get back to the PR ASAP.

Awesome. Thank you.

@chrishayen
Copy link
Author

@raggi Poke  🙂

@chrishayen
Copy link
Author

chrishayen commented Jun 1, 2025

@raggi Hey, actually don't merge this. I'm leaking file descriptors using dial. Any hints you can give me about the internal implementation of file descriptors? I get an error setting non blocking on them so I'm guessing there's maybe something non-standard going on. Even when I close the file descriptors on the rust side, while looping and using dial, I'm still seeing a steady increase of open file descriptors in lsof for my process. I didn't see anything to explicitly close file descriptors in tailscale.h, but I think I may have seen one of the other libraries using tailscale_close(fd).

I'm going to start digging through tailscale code but maybe you can give me a hint when you get a chance. Thanks.

@chrishayen
Copy link
Author

@raggi All good. I updated the code to use rust's OwnedFd and BorrowedFd instead of i32 for passing file descriptors. The leak ended up being something in the app I was importing the library with, so it wasn't 100% necessary, but it's cleaner.

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 this pull request may close these issues.

2 participants