MCPcopy Create free account
hub / github.com/ClassicOldSong/Apollo / init

Function init

src/httpcommon.cpp:46–68  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

44 net::net_e origin_web_ui_allowed;
45
46 int init() {
47 bool clean_slate = config::sunshine.flags[config::flag::FRESH_STATE];
48 origin_web_ui_allowed = net::from_enum_string(config::nvhttp.origin_web_ui_allowed);
49
50 if (clean_slate) {
51 uuid = uuid_util::uuid_t::generate();
52 unique_id = uuid.string();
53 auto dir = std::filesystem::temp_directory_path() / "Sunshine"sv;
54 config::nvhttp.cert = (dir / ("cert-"s + unique_id)).string();
55 config::nvhttp.pkey = (dir / ("pkey-"s + unique_id)).string();
56 }
57
58 if ((!fs::exists(config::nvhttp.pkey) || !fs::exists(config::nvhttp.cert)) &&
59 create_creds(config::nvhttp.pkey, config::nvhttp.cert)) {
60 return -1;
61 }
62 if (!user_creds_exist(config::sunshine.credentials_file)) {
63 BOOST_LOG(info) << "Open the Web UI to set your new username and password and getting started";
64 } else if (reload_user_creds(config::sunshine.credentials_file)) {
65 return -1;
66 }
67 return 0;
68 }
69
70 int save_user_creds(const std::string &file, const std::string &username, const std::string &password, bool run_our_mouth) {
71 pt::ptree outputTree;

Callers

nothing calls this directly

Calls 5

from_enum_stringFunction · 0.85
generateFunction · 0.85
create_credsFunction · 0.85
user_creds_existFunction · 0.85
reload_user_credsFunction · 0.85

Tested by

no test coverage detected