Split reply line in the form 'AUTH METHODS=...' into a type * 'AUTH' and arguments 'METHODS=...'. * Grammar is implicitly defined in https://spec.torproject.org/control-spec by * the server reply formats for PROTOCOLINFO (S3.21) and AUTHCHALLENGE (S3.24). */
| 194 | * the server reply formats for PROTOCOLINFO (S3.21) and AUTHCHALLENGE (S3.24). |
| 195 | */ |
| 196 | std::pair<std::string,std::string> SplitTorReplyLine(const std::string &s) |
| 197 | { |
| 198 | size_t ptr=0; |
| 199 | std::string type; |
| 200 | while (ptr < s.size() && s[ptr] != ' ') { |
| 201 | type.push_back(s[ptr]); |
| 202 | ++ptr; |
| 203 | } |
| 204 | if (ptr < s.size()) |
| 205 | ++ptr; // skip ' ' |
| 206 | return make_pair(type, s.substr(ptr)); |
| 207 | } |
| 208 | |
| 209 | /** Parse reply arguments in the form 'METHODS=COOKIE,SAFECOOKIE COOKIEFILE=".../control_auth_cookie"'. |
| 210 | * Returns a map of keys to values, or an empty map if there was an error. |