MCPcopy Create free account
hub / github.com/ElementsProject/elements / SplitTorReplyLine

Function SplitTorReplyLine

src/torcontrol.cpp:196–207  ·  view source on GitHub ↗

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). */

Source from the content-addressed store, hash-verified

194 * the server reply formats for PROTOCOLINFO (S3.21) and AUTHCHALLENGE (S3.24).
195 */
196std::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.

Callers 3

authchallenge_cbMethod · 0.85
protocolinfo_cbMethod · 0.85
CheckSplitTorReplyLineFunction · 0.85

Calls 2

sizeMethod · 0.45
push_backMethod · 0.45

Tested by 1

CheckSplitTorReplyLineFunction · 0.68