Module add_onion

Module add_onion 

Source
Expand description

ADD_ONION response parsing.

This module parses responses from the ADD_ONION command, which creates ephemeral (non-persistent) hidden services. These services exist only for the lifetime of the Tor connection and are not written to disk.

§Response Format

A successful ADD_ONION response contains:

250-ServiceID=<onion_address>
250-PrivateKey=<key_type>:<base64_key>  (if requested)
250-ClientAuth=<username>:<credential>  (if client auth enabled)
250 OK

§Example

use stem_rs::response::{ControlMessage, AddOnionResponse};

// Parse an ADD_ONION response
let response_text = "250-ServiceID=gfzprpioee3hoppz\r\n\
                     250-PrivateKey=RSA1024:MIICXgIBAAKBgQDZ...\r\n\
                     250 OK\r\n";
let msg = ControlMessage::from_str(response_text, None, false).unwrap();
let response = AddOnionResponse::from_message(&msg).unwrap();

println!("Service ID: {}", response.service_id);
if let Some(key) = &response.private_key {
    println!("Private key type: {:?}", response.private_key_type);
}

§See Also

Structs§

AddOnionResponse
Parsed response from the ADD_ONION command.