@@ -574,7 +574,15 @@ void TorController::protocolinfo_cb(TorControlConnection& conn, const TorControl
574
574
* password: "password"
575
575
*/
576
576
std::string torpassword = GetArg (" -torpassword" , " " );
577
- if (methods.count (" NULL" )) {
577
+ if (!torpassword.empty ()) {
578
+ if (methods.count (" HASHEDPASSWORD" )) {
579
+ LogPrint (" tor" , " tor: Using HASHEDPASSWORD authentication\n " );
580
+ boost::replace_all (torpassword, " \" " , " \\\" " );
581
+ conn.Command (" AUTHENTICATE \" " + torpassword + " \" " , boost::bind (&TorController::auth_cb, this , _1, _2));
582
+ } else {
583
+ LogPrintf (" tor: Password provided with -torpassword, but HASHEDPASSWORD authentication is not available\n " );
584
+ }
585
+ } else if (methods.count (" NULL" )) {
578
586
LogPrint (" tor" , " tor: Using NULL authentication\n " );
579
587
conn.Command (" AUTHENTICATE" , boost::bind (&TorController::auth_cb, this , _1, _2));
580
588
} else if (methods.count (" SAFECOOKIE" )) {
@@ -595,13 +603,7 @@ void TorController::protocolinfo_cb(TorControlConnection& conn, const TorControl
595
603
}
596
604
}
597
605
} else if (methods.count (" HASHEDPASSWORD" )) {
598
- if (!torpassword.empty ()) {
599
- LogPrint (" tor" , " tor: Using HASHEDPASSWORD authentication\n " );
600
- boost::replace_all (torpassword, " \" " , " \\\" " );
601
- conn.Command (" AUTHENTICATE \" " + torpassword + " \" " , boost::bind (&TorController::auth_cb, this , _1, _2));
602
- } else {
603
- LogPrintf (" tor: Password authentication required, but no password provided with -torpassword\n " );
604
- }
606
+ LogPrintf (" tor: The only supported authentication mechanism left is password, but no password provided with -torpassword\n " );
605
607
} else {
606
608
LogPrintf (" tor: No supported authentication method\n " );
607
609
}
0 commit comments