Changeset View
Changeset View
Standalone View
Standalone View
src/rpc/protocol.cpp
Show First 20 Lines • Show All 66 Lines • ▼ Show 20 Lines | |||||
static const std::string COOKIEAUTH_FILE = ".cookie"; | static const std::string COOKIEAUTH_FILE = ".cookie"; | ||||
/** Get name of RPC authentication cookie file */ | /** Get name of RPC authentication cookie file */ | ||||
static fs::path GetAuthCookieFile(bool temp = false) { | static fs::path GetAuthCookieFile(bool temp = false) { | ||||
std::string arg = gArgs.GetArg("-rpccookiefile", COOKIEAUTH_FILE); | std::string arg = gArgs.GetArg("-rpccookiefile", COOKIEAUTH_FILE); | ||||
if (temp) { | if (temp) { | ||||
arg += ".tmp"; | arg += ".tmp"; | ||||
} | } | ||||
fs::path path(arg); | return AbsPathForConfigVal(fs::path(arg)); | ||||
if (!path.is_complete()) { | |||||
path = GetDataDir() / path; | |||||
} | |||||
return path; | |||||
} | } | ||||
bool GenerateAuthCookie(std::string *cookie_out) { | bool GenerateAuthCookie(std::string *cookie_out) { | ||||
const size_t COOKIE_SIZE = 32; | const size_t COOKIE_SIZE = 32; | ||||
uint8_t rand_pwd[COOKIE_SIZE]; | uint8_t rand_pwd[COOKIE_SIZE]; | ||||
GetRandBytes(rand_pwd, COOKIE_SIZE); | GetRandBytes(rand_pwd, COOKIE_SIZE); | ||||
std::string cookie = | std::string cookie = | ||||
COOKIEAUTH_USER + ":" + HexStr(rand_pwd, rand_pwd + COOKIE_SIZE); | COOKIEAUTH_USER + ":" + HexStr(rand_pwd, rand_pwd + COOKIE_SIZE); | ||||
▲ Show 20 Lines • Show All 73 Lines • Show Last 20 Lines |