Module protocolinfo

Module protocolinfo 

Source
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

MethodDescription
NULLNo authentication required
HASHEDPASSWORDPassword authentication
COOKIECookie file authentication
SAFECOOKIEHMAC-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

Structs§

ProtocolInfoResponse
Parsed response from the PROTOCOLINFO command.

Enums§

AuthMethod
Authentication methods supported by Tor’s control protocol.