Expand description
PROTOCOLINFO response parsing.
This module parses responses from the PROTOCOLINFO command, which provides
information about available authentication methods and the Tor version.
This is typically the first command sent after connecting to determine
how to authenticate.
§Response Format
A typical PROTOCOLINFO response:
250-PROTOCOLINFO 1
250-AUTH METHODS=COOKIE,SAFECOOKIE COOKIEFILE="/home/user/.tor/control_auth_cookie"
250-VERSION Tor="0.4.7.1"
250 OK§Authentication Methods
| Method | Description |
|---|---|
NULL | No authentication required |
HASHEDPASSWORD | Password authentication |
COOKIE | Cookie file authentication |
SAFECOOKIE | HMAC-based cookie authentication (most secure) |
§Example
use stem_rs::response::{ControlMessage, ProtocolInfoResponse, AuthMethod};
let response_text = "250-PROTOCOLINFO 1\r\n\
250-AUTH METHODS=COOKIE,SAFECOOKIE COOKIEFILE=\"/tmp/cookie\"\r\n\
250-VERSION Tor=\"0.4.7.1\"\r\n\
250 OK\r\n";
let msg = ControlMessage::from_str(response_text, None, false).unwrap();
let response = ProtocolInfoResponse::from_message(&msg).unwrap();
assert_eq!(response.protocol_version, 1);
assert!(response.auth_methods.contains(&AuthMethod::Cookie));
assert!(response.auth_methods.contains(&AuthMethod::SafeCookie));§See Also
crate::auth::get_protocol_info: High-level API for getting protocol infocrate::auth::authenticate: Uses this response to select auth method- Tor Control Protocol: PROTOCOLINFO
Structs§
- Protocol
Info Response - Parsed response from the PROTOCOLINFO command.
Enums§
- Auth
Method - Authentication methods supported by Tor’s control protocol.