8000 Support Tor .onion address by levoncrypto · Pull Request #1642 · firoorg/firo · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Support Tor .onion address #1642

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 2 commits into
base: master
Choose a base branch
from
Open

Support Tor .onion address #1642

wants to merge 2 commits into from

Conversation

levoncrypto
Copy link
Contributor
@levoncrypto levoncrypto commented Jun 22, 2025

EDIT: Fixes #1545

Copy link
coderabbitai bot commented Jun 22, 2025

Walkthrough

The changes introduce explicit support for Tor v3 onion addresses in network address handling, including parsing, routability checks, string representation, and serialization. Tor hidden service key management is updated to use Ed25519 v3 keys instead of RSA1024. A protocol version constant for Tor v3 serialization was added.

Changes

Files/Group Change Summary
src/netaddress.cpp, src/netaddress.h Added isTorV3 and onionV3Addr members; updated SetSpecial, IsRoutable, and ToStringIP to support Tor v3 onions.
src/protocol.h Added ADDR_TOR_V3_VERSION constant; extended CAddress serialization to conditionally handle Tor v3 fields.
src/torcontrol.cpp Changed Tor hidden service key type from "NEW:RSA1024" to "NEW:ED25519-V3" for reading and generating keys.
src/clientversion.h Incremented CLIENT_VERSION_BUILD from 1 to 2.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant CNetAddr
    participant TorControl

    User->>CNetAddr: SetSpecial(onion address)
    alt v2 onion (16 chars)
        CNetAddr->>CNetAddr: Decode base32, set IP, isTorV3 = false
    else v3 onion (56 chars)
        CNetAddr->>CNetAddr: Store full address in onionV3Addr, isTorV3 = true
    end

    User->>CNetAddr: IsRoutable()
    alt isTorV3 or IsTor()
        CNetAddr-->>User: true
    else
        CNetAddr-->>User: Routability logic
    end

    User->>CNetAddr: ToStringIP()
    alt isTorV3
        CNetAddr-->>User: Return onionV3Addr
    else
        CNetAddr-->>User: Return standard representation
    end

    User->>TorControl: CreateHiddenService()
    TorControl->>TorControl: Use "NEW:ED25519-V3" key type
Loading

Poem

In tunnels deep where onions grow,
v2 and v3 now both can show!
Ed keys for Tor, a modern twist,
Serialization—nothing missed.
With every hop, the network sings,
As rabbits cheer for onion rings! 🧅🐇


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between f96cc0f and 9574826.

📒 Files selected for processing (3)
  • src/clientversion.h (1 hunks)
  • src/netaddress.h (1 hunks)
  • src/protocol.h (2 hunks)
✅ Files skipped from review due to trivial changes (1)
  • src/clientversion.h
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/netaddress.h
🧰 Additional context used
🧬 Code Graph Analysis (1)
src/protocol.h (1)
src/serialize.h (1)
  • nVersion (1223-1223)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (8)
  • GitHub Check: Build for macOS (CMake)
  • GitHub Check: Create Source Distribution
  • GitHub Check: Build for Windows (CMake)
  • GitHub Check: Build for Linux (CMake)
  • GitHub Check: Create Source Distribution
  • GitHub Check: Build for Linux (CMake)
  • GitHub Check: Build for macOS (CMake)
  • GitHub Check: Build for Windows (CMake)
🔇 Additional comments (2)
src/protocol.h (2)

305-305: Protocol version constant looks appropriate.

The constant ADDR_TOR_V3_VERSION with value 141401 follows the established pattern for protocol versioning. This threshold value will enable conditional serialization of Tor v3 address fields while maintaining backward compatibility.


333-349: Fields Confirmed in CNetAddr; No Action Needed

I’ve verified that CNetAddr (in src/netaddress.h) declares both

  • bool isTorV3
  • std::string onionV3Addr

The serialization logic in src/protocol.h correctly accesses these fields. No further changes are needed.

✨ Finishing Touches
  • 📝 Generate Docstrings

🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai gener 8000 ate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

src/netaddress.h Outdated

if (ser_action.ForRead()) {
bool v3Flag;
READWRITE(v3Flag);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it's not compatible with previously saved data, this read will throw an exception if there isn't more data to read. Where do we save IP addresses to (peers.dat, etc)?

@justanwar
Copy link
Member

image (3)
Last test (output of getnetworkinfo)

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.

firod does not get a tor .onion address
3 participants
0