|
@@ -7,7 +7,6 @@
|
|
|
#include "BBS2chProxyAuth.h"
|
|
|
#include "BBS2chProxyHttpHeaders.h"
|
|
|
#include "BBS2chProxyConnection.h"
|
|
|
-#include "BBS2chProxyFormData.h"
|
|
|
#include "hmac.h"
|
|
|
|
|
|
#define SID_UPDATE_INTERVAL (60*60)
|
|
@@ -30,11 +29,11 @@ static size_t write_callback_download(char *buffer, size_t size, size_t nitems,
|
|
|
{
|
|
|
std::vector<char> *data = static_cast<std::vector<char> *>(userdata);
|
|
|
size_t downloaded = size*nitems;
|
|
|
- data->insert(data->end(), buffer, buffer+downloaded);
|
|
|
+ if (data) data->insert(data->end(), buffer, buffer+downloaded);
|
|
|
return downloaded;
|
|
|
}
|
|
|
|
|
|
-static size_t header_callback_download(char *buffer, size_t size, size_t nitems, void *userdata)
|
|
|
+static size_t header_callback_acorn(char *buffer, size_t size, size_t nitems, void *userdata)
|
|
|
{
|
|
|
std::string *acornCookie = static_cast<std::string *>(userdata);
|
|
|
if (acornCookie && acornCookie->empty()) {
|
|
@@ -52,6 +51,53 @@ static size_t header_callback_download(char *buffer, size_t size, size_t nitems,
|
|
|
return size*nitems;
|
|
|
}
|
|
|
|
|
|
+static size_t header_callback_be(char *buffer, size_t size, size_t nitems, void *userdata)
|
|
|
+{
|
|
|
+ std::pair<std::string, std::string> *beCookies = static_cast<std::pair<std::string, std::string> *>(userdata);
|
|
|
+ if (beCookies) {
|
|
|
+ PBBS2chProxyHttpHeaderEntry parsedHeader = BBS2chProxyHttpHeaders::parse(buffer, size*nitems);
|
|
|
+ if (parsedHeader && parsedHeader->getLowercasedName() == "set-cookie") {
|
|
|
+ if (beCookies->first.empty()) {
|
|
|
+ const std::string dmdmStr = "DMDM=";
|
|
|
+ const std::string &value = parsedHeader->getValue();
|
|
|
+ if (std::equal(dmdmStr.begin(), dmdmStr.end(), value.begin())) {
|
|
|
+ size_t pos = value.find(";");
|
|
|
+ if (pos == std::string::npos) beCookies->first = value.substr(5);
|
|
|
+ else beCookies->first = value.substr(5, pos-5);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (beCookies->second.empty()) {
|
|
|
+ const std::string mdmdStr = "MDMD=";
|
|
|
+ const std::string &value = parsedHeader->getValue();
|
|
|
+ if (std::equal(mdmdStr.begin(), mdmdStr.end(), value.begin())) {
|
|
|
+ size_t pos = value.find(";");
|
|
|
+ if (pos == std::string::npos) beCookies->second = value.substr(5);
|
|
|
+ else beCookies->second = value.substr(5, pos-5);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return size*nitems;
|
|
|
+}
|
|
|
+
|
|
|
+static size_t header_callback_uplift(char *buffer, size_t size, size_t nitems, void *userdata)
|
|
|
+{
|
|
|
+ std::string *sidCookie = static_cast<std::string *>(userdata);
|
|
|
+ if (sidCookie && sidCookie->empty()) {
|
|
|
+ PBBS2chProxyHttpHeaderEntry parsedHeader = BBS2chProxyHttpHeaders::parse(buffer, size*nitems);
|
|
|
+ if (parsedHeader && parsedHeader->getLowercasedName() == "set-cookie") {
|
|
|
+ const std::string sidStr = "sid=";
|
|
|
+ const std::string &value = parsedHeader->getValue();
|
|
|
+ if (std::equal(sidStr.begin(), sidStr.end(), value.begin())) {
|
|
|
+ size_t pos = value.find(";");
|
|
|
+ if (pos == std::string::npos) *sidCookie = value.substr(4);
|
|
|
+ else *sidCookie = value.substr(4, pos-4);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return size*nitems;
|
|
|
+}
|
|
|
+
|
|
|
bool BBS2chProxyAuth::updateSID(CURL *curl)
|
|
|
{
|
|
|
time_t ct = time(0);
|
|
@@ -171,30 +217,41 @@ const std::string& BBS2chProxyAuth::getSID()
|
|
|
return sid;
|
|
|
}
|
|
|
|
|
|
-bool BBS2chProxyAcornAuth::login()
|
|
|
+void IBBS2chProxyCookieAuth::prepareForLogin(CURL *curl, const std::string &authURL, BBS2chProxyFormData &requestBody)
|
|
|
{
|
|
|
- bool ret = false;
|
|
|
- CURL *curl = curl_easy_init();
|
|
|
- std::vector<char> data;
|
|
|
- std::string cookie;
|
|
|
- std::string body = "email=";
|
|
|
- body += BBS2chProxyFormData::encodeURIComponent(_mail.data(), _mail.size(), false);
|
|
|
- body += "&pass=";
|
|
|
- body += BBS2chProxyFormData::encodeURIComponent(_passwd.data(), _passwd.size(), false);
|
|
|
- curl_slist *headersForCurl = curl_slist_append(NULL, "Accept:");
|
|
|
- headersForCurl = curl_slist_append(headersForCurl, "Expect:");
|
|
|
- curl_easy_setopt(curl, CURLOPT_URL, "https://donguri.5ch.net/login");
|
|
|
- if (user_agent) curl_easy_setopt(curl, CURLOPT_USERAGENT, user_agent);
|
|
|
+
|
|
|
+ curl_easy_setopt(curl, CURLOPT_URL, authURL.c_str());
|
|
|
curl_easy_setopt(curl, CURLOPT_ENCODING, "");
|
|
|
curl_easy_setopt(curl, CURLOPT_NOSIGNAL, 1L);
|
|
|
curl_easy_setopt(curl, CURLOPT_TIMEOUT, timeout);
|
|
|
curl_easy_setopt(curl, CURLOPT_POST, 1L);
|
|
|
- curl_easy_setopt(curl, CURLOPT_POSTFIELDS, body.c_str());
|
|
|
+ curl_easy_setopt(curl, CURLOPT_POSTFIELDS, requestBody.toString().c_str());
|
|
|
curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, write_callback_download);
|
|
|
- curl_easy_setopt(curl, CURLOPT_WRITEDATA, &data);
|
|
|
- curl_easy_setopt(curl, CURLOPT_HEADERFUNCTION, header_callback_download);
|
|
|
+ curl_easy_setopt(curl, CURLOPT_WRITEDATA, NULL);
|
|
|
+ curl_easy_setopt(curl, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1);
|
|
|
+ curl_easy_setopt(curl, CURLOPT_SSL_VERIFYHOST, 0L);
|
|
|
+ curl_easy_setopt(curl, CURLOPT_SSL_VERIFYPEER, 0L);
|
|
|
+ if (curl_share) curl_easy_setopt(curl, CURLOPT_SHARE, curl_share);
|
|
|
+ if (user_agent) curl_easy_setopt(curl, CURLOPT_USERAGENT, user_agent);
|
|
|
+ if (force_ipv4) curl_easy_setopt(curl, CURLOPT_IPRESOLVE, CURL_IPRESOLVE_V4);
|
|
|
+ if (proxy_server) {
|
|
|
+ curl_easy_setopt(curl, CURLOPT_PROXY, proxy_server);
|
|
|
+ curl_easy_setopt(curl, CURLOPT_PROXYPORT, proxy_port);
|
|
|
+ curl_easy_setopt(curl, CURLOPT_PROXYTYPE, proxy_type);
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+bool BBS2chProxyAcornAuth::login()
|
|
|
+{
|
|
|
+ bool ret = false;
|
|
|
+ CURL *curl = curl_easy_init();
|
|
|
+ std::string cookie;
|
|
|
+ BBS2chProxyFormData requestBody;
|
|
|
+ requestBody.append("email", _mail);
|
|
|
+ requestBody.append("pass", _passwd);
|
|
|
+ prepareForLogin(curl, "https://donguri.5ch.net/login", requestBody);
|
|
|
+ curl_easy_setopt(curl, CURLOPT_HEADERFUNCTION, header_callback_acorn);
|
|
|
curl_easy_setopt(curl, CURLOPT_HEADERDATA, &cookie);
|
|
|
- curl_easy_setopt(curl, CURLOPT_HTTPHEADER, headersForCurl);
|
|
|
CURLcode res = curl_easy_perform(curl);
|
|
|
if (res == CURLE_OK) {
|
|
|
long statusCode;
|
|
@@ -222,7 +279,7 @@ bool BBS2chProxyAcornAuth::login()
|
|
|
return ret;
|
|
|
}
|
|
|
|
|
|
-int BBS2chProxyAcornAuth::login(const std::string &mail, const std::string &passwd)
|
|
|
+int IBBS2chProxyCookieAuth::loginWith(const std::string &mail, const std::string &passwd)
|
|
|
{
|
|
|
pthread_mutex_lock(&_mutex);
|
|
|
if (!_isUpdating) {
|
|
@@ -248,15 +305,15 @@ void BBS2chProxyAcornAuth::logout()
|
|
|
|
|
|
static void *doLogin(void *auth)
|
|
|
{
|
|
|
- ((BBS2chProxyAcornAuth *)auth)->login();
|
|
|
+ ((IBBS2chProxyCookieAuth *)auth)->login();
|
|
|
return NULL;
|
|
|
}
|
|
|
|
|
|
-void BBS2chProxyAcornAuth::update(bool force)
|
|
|
+void IBBS2chProxyCookieAuth::update(bool force)
|
|
|
{
|
|
|
- if (_cookie.empty()) return;
|
|
|
+ if (!isLoggedIn()) return;
|
|
|
pthread_mutex_lock(&_mutex);
|
|
|
- if (!_isUpdating && (force || time(NULL) >= _lastUpdated + 60*60*12)) {
|
|
|
+ if (!_isUpdating && (force || time(NULL) >= _lastUpdated + _updateInterval)) {
|
|
|
_isUpdating = true;
|
|
|
pthread_t thread;
|
|
|
pthread_create(&thread, NULL, &doLogin, this);
|
|
@@ -265,11 +322,11 @@ void BBS2chProxyAcornAuth::update(bool force)
|
|
|
pthread_mutex_unlock(&_mutex);
|
|
|
}
|
|
|
|
|
|
-void BBS2chProxyAcornAuth::syncCookie(BBS2chProxyKeyManager::CookieJar &jar)
|
|
|
+bool BBS2chProxyAcornAuth::syncCookie(BBS2chProxyKeyManager::CookieJar &jar)
|
|
|
{
|
|
|
if (jar.timeAcornSynced >= _lastUpdated) {
|
|
|
update(false);
|
|
|
- return;
|
|
|
+ return false;
|
|
|
}
|
|
|
BBS2chProxyKeyManager::Cookie cookie;
|
|
|
cookie.name = "acorn";
|
|
@@ -280,40 +337,244 @@ void BBS2chProxyAcornAuth::syncCookie(BBS2chProxyKeyManager::CookieJar &jar)
|
|
|
jar.set(cookie);
|
|
|
jar.timeAcornSynced = _lastUpdated;
|
|
|
jar.unlock();
|
|
|
- BBS2chProxyConnection::keyManager.flushCookies();
|
|
|
+ return true;
|
|
|
}
|
|
|
|
|
|
-std::string BBS2chProxyAcornAuth::responseHTML()
|
|
|
+std::string IBBS2chProxyCookieAuth::responseHTML()
|
|
|
{
|
|
|
std::string html;
|
|
|
- html += "<!DOCTYPE html><html lang=\"ja\"><head>";
|
|
|
- html += "<meta http-equiv=\"content-type\" content=\"text/html; charset=UTF-8\">";
|
|
|
- html += "<meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\"><style>";
|
|
|
- html += ".container { width: 300px; margin: 0 auto; padding: 20px; border: 1px solid #ccc; border-radius: 5px; }";
|
|
|
- html += "h3 { text-align: center; margin-bottom: 20px; margin-top: 0px; }";
|
|
|
- html += "input[type=\"text\"], input[type=\"password\"] { width: 93%; padding: 10px; margin-bottom: 10px; border: 1px solid #ccc; border-radius: 4px; }";
|
|
|
- html += "button[type=\"submit\"] { width: 100%; padding: 10px; background-color: #4CAF50; color: #ffffff; border: none; border-radius: 4px; cursor: pointer; }";
|
|
|
- html += "</style></head><body>";
|
|
|
- if (_cookie.empty()) {
|
|
|
- html += "<div class=\"container\"><h3>どんぐりシステムにログイン</h3>";
|
|
|
- html += "<form action=\"donguri\" method=\"POST\">";
|
|
|
+ html += "<div class=\"container\"><h3>";
|
|
|
+ html += _headerTitle;
|
|
|
+ html += "にログイン</h3>";
|
|
|
+ if (!isLoggedIn()) {
|
|
|
+ html += "<form id=\"";
|
|
|
+ html += _uniqueId;
|
|
|
+ html += "-login\"action=\"accounts\" method=\"POST\">";
|
|
|
html += "<input type=\"text\" name=\"mail\" placeholder=\"メールアドレス\">";
|
|
|
html += "<input type=\"password\" name=\"pass\" placeholder=\"パスワード\">";
|
|
|
html += "<input type=\"hidden\" name=\"action\" value=\"login\">";
|
|
|
- html += "<button type=\"submit\">ログイン</button></form></div>";
|
|
|
+ html += "<input type=\"hidden\" name=\"service\" value=\"";
|
|
|
+ html += _uniqueId;
|
|
|
+ html += "\"><button type=\"submit\">ログイン</button></form></div>";
|
|
|
} else {
|
|
|
std::ostringstream ss;
|
|
|
time_t ago = time(NULL) - _lastUpdated;
|
|
|
html += "<p>";
|
|
|
- if (ago < 3600) ss << ago/60 << " 分前に";
|
|
|
- else ss << ago/3600 << " 時間前に";
|
|
|
+ if (ago < 3600) ss << ago/60 << " 分前にログイン済みです。</p>";
|
|
|
+ else ss << ago/3600 << " 時間前にログイン済みです。</p>";
|
|
|
html += ss.str();
|
|
|
- html += "どんぐりシステムにログイン済みです。</p>";
|
|
|
- html += "<div class=\"container\">";
|
|
|
- html += "<form action=\"donguri\" method=\"POST\">";
|
|
|
+ html += "<form action=\"accounts\" method=\"POST\">";
|
|
|
html += "<input type=\"hidden\" name=\"action\" value=\"logout\">";
|
|
|
- html += "<button type=\"submit\">ログアウト</button></form></div>";
|
|
|
+ html += "<input type=\"hidden\" name=\"service\" value=\"";
|
|
|
+ html += _uniqueId;
|
|
|
+ html += "\"><button type=\"submit\">ログアウト</button></form>";
|
|
|
+ }
|
|
|
+ html += "</div>";
|
|
|
+ return html;
|
|
|
+}
|
|
|
+
|
|
|
+bool BBS2chProxyAcornAuth::isLoggedIn()
|
|
|
+{
|
|
|
+ return !_cookie.empty();
|
|
|
+}
|
|
|
+
|
|
|
+bool BBS2chProxyBeAuth::login()
|
|
|
+{
|
|
|
+ bool ret = false;
|
|
|
+ CURL *curl = curl_easy_init();
|
|
|
+ std::pair<std::string, std::string> cookies;
|
|
|
+ BBS2chProxyFormData requestBody;
|
|
|
+ requestBody.append("mail", _mail);
|
|
|
+ requestBody.append("pass", _passwd);
|
|
|
+ prepareForLogin(curl, "https://be.5ch.net/log", requestBody);
|
|
|
+ curl_easy_setopt(curl, CURLOPT_HEADERFUNCTION, header_callback_be);
|
|
|
+ curl_easy_setopt(curl, CURLOPT_HEADERDATA, &cookies);
|
|
|
+ CURLcode res = curl_easy_perform(curl);
|
|
|
+ if (res == CURLE_OK) {
|
|
|
+ long statusCode;
|
|
|
+ curl_easy_getinfo(curl, CURLINFO_RESPONSE_CODE, &statusCode);
|
|
|
+ if (statusCode == 302) {
|
|
|
+ if (!cookies.first.empty() && !cookies.second.empty()) {
|
|
|
+ log_printf(0, "Logged in to be successfully.\n");
|
|
|
+ log_printf(1, "New cookie is: DMDM=%s, MDMD=%s\n", cookies.first.c_str(), cookies.second.c_str());
|
|
|
+ pthread_mutex_lock(&_mutex);
|
|
|
+ _dmdm = cookies.first;
|
|
|
+ _mdmd = cookies.second;
|
|
|
+ _lastUpdated = time(NULL);
|
|
|
+ pthread_mutex_unlock(&_mutex);
|
|
|
+ ret = true;
|
|
|
+ }
|
|
|
+ else log_printf(0, "Cannot login to be (maybe incorrect user/password).\n");
|
|
|
+ } else {
|
|
|
+ log_printf(0, "Cannot login to be: server returned %ld\n", statusCode);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ log_printf(0, "curl error: %s\n", curl_easy_strerror(res));
|
|
|
+ }
|
|
|
+ curl_easy_cleanup(curl);
|
|
|
+ pthread_mutex_lock(&_mutex);
|
|
|
+ _isUpdating = false;
|
|
|
+ pthread_mutex_unlock(&_mutex);
|
|
|
+ return ret;
|
|
|
+}
|
|
|
+
|
|
|
+void BBS2chProxyBeAuth::logout()
|
|
|
+{
|
|
|
+ pthread_mutex_lock(&_mutex);
|
|
|
+ _mail.clear();
|
|
|
+ _passwd.clear();
|
|
|
+ _dmdm.clear();
|
|
|
+ _mdmd.clear();
|
|
|
+ _lastUpdated = time(NULL);
|
|
|
+ pthread_mutex_unlock(&_mutex);
|
|
|
+}
|
|
|
+
|
|
|
+bool BBS2chProxyBeAuth::syncCookie(BBS2chProxyKeyManager::CookieJar &jar)
|
|
|
+{
|
|
|
+ if (jar.timeBeSynced >= _lastUpdated) {
|
|
|
+ update(false);
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ BBS2chProxyKeyManager::Cookie dmdm, mdmd;
|
|
|
+ dmdm.name = "DMDM";
|
|
|
+ dmdm.value = _dmdm;
|
|
|
+ dmdm.domain = ".5ch.net";
|
|
|
+ if (_dmdm.empty()) dmdm.expires = "1";
|
|
|
+ mdmd.name = "MDMD";
|
|
|
+ mdmd.value = _mdmd;
|
|
|
+ mdmd.domain = ".5ch.net";
|
|
|
+ if (_mdmd.empty()) mdmd.expires = "1";
|
|
|
+ jar.lock();
|
|
|
+ jar.set(dmdm);
|
|
|
+ jar.set(mdmd);
|
|
|
+ jar.timeBeSynced = _lastUpdated;
|
|
|
+ jar.unlock();
|
|
|
+ return true;
|
|
|
+}
|
|
|
+
|
|
|
+bool BBS2chProxyBeAuth::isLoggedIn()
|
|
|
+{
|
|
|
+ return !_dmdm.empty() && !_mdmd.empty();
|
|
|
+}
|
|
|
+
|
|
|
+bool BBS2chProxyUpliftAuth::login()
|
|
|
+{
|
|
|
+ bool ret = false;
|
|
|
+ CURL *curl = curl_easy_init();
|
|
|
+ std::string cookie;
|
|
|
+ BBS2chProxyFormData requestBody;
|
|
|
+ requestBody.append("usr", _mail);
|
|
|
+ requestBody.append("pwd", _passwd);
|
|
|
+ prepareForLogin(curl, "http://uplift.5ch.net/log", requestBody);
|
|
|
+ curl_easy_setopt(curl, CURLOPT_HEADERFUNCTION, header_callback_uplift);
|
|
|
+ curl_easy_setopt(curl, CURLOPT_HEADERDATA, &cookie);
|
|
|
+ CURLcode res = curl_easy_perform(curl);
|
|
|
+ if (res == CURLE_OK) {
|
|
|
+ long statusCode;
|
|
|
+ curl_easy_getinfo(curl, CURLINFO_RESPONSE_CODE, &statusCode);
|
|
|
+ if (!cookie.empty()) {
|
|
|
+ log_printf(0, "Logged in to uplift successfully.\n");
|
|
|
+ log_printf(1, "New cookie is: %s\n", cookie.c_str());
|
|
|
+ pthread_mutex_lock(&_mutex);
|
|
|
+ _cookie = cookie;
|
|
|
+ _lastUpdated = time(NULL);
|
|
|
+ pthread_mutex_unlock(&_mutex);
|
|
|
+ ret = true;
|
|
|
+ } else {
|
|
|
+ if (statusCode == 200) log_printf(0, "Cannot login to uplift (maybe incorrect user/password).\n");
|
|
|
+ else log_printf(0, "Cannot login to uplift: server returned %ld\n", statusCode);
|
|
|
+ }
|
|
|
}
|
|
|
+ else {
|
|
|
+ log_printf(0, "curl error: %s\n", curl_easy_strerror(res));
|
|
|
+ }
|
|
|
+ curl_easy_cleanup(curl);
|
|
|
+ pthread_mutex_lock(&_mutex);
|
|
|
+ _isUpdating = false;
|
|
|
+ pthread_mutex_unlock(&_mutex);
|
|
|
+ return ret;
|
|
|
+}
|
|
|
+
|
|
|
+void BBS2chProxyUpliftAuth::logout()
|
|
|
+{
|
|
|
+ pthread_mutex_lock(&_mutex);
|
|
|
+ _mail.clear();
|
|
|
+ _passwd.clear();
|
|
|
+ _cookie.clear();
|
|
|
+ _lastUpdated = time(NULL);
|
|
|
+ pthread_mutex_unlock(&_mutex);
|
|
|
+}
|
|
|
+
|
|
|
+bool BBS2chProxyUpliftAuth::syncCookie(BBS2chProxyKeyManager::CookieJar &jar)
|
|
|
+{
|
|
|
+ if (jar.timeBeSynced >= _lastUpdated) {
|
|
|
+ update(false);
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ BBS2chProxyKeyManager::Cookie for5ch, forPink;
|
|
|
+ for5ch.name = "sid";
|
|
|
+ for5ch.value = _cookie;
|
|
|
+ for5ch.domain = ".5ch.net";
|
|
|
+ forPink.name = "sid";
|
|
|
+ forPink.value = _cookie;
|
|
|
+ forPink.domain = ".bbspink.com";
|
|
|
+ if (_cookie.empty()) {
|
|
|
+ for5ch.expires = "1";
|
|
|
+ forPink.expires = "1";
|
|
|
+ }
|
|
|
+ jar.lock();
|
|
|
+ jar.set(for5ch);
|
|
|
+ jar.set(forPink);
|
|
|
+ jar.timeUpliftSynced = _lastUpdated;
|
|
|
+ jar.unlock();
|
|
|
+ return true;
|
|
|
+}
|
|
|
+
|
|
|
+bool BBS2chProxyUpliftAuth::isLoggedIn()
|
|
|
+{
|
|
|
+ return !_cookie.empty();
|
|
|
+}
|
|
|
+
|
|
|
+int BBS2chProxyCookieAuthManager::loginWith(const std::string &service, const std::string &mail, const std::string &passwd)
|
|
|
+{
|
|
|
+ if (service == "donguri") return _acornAuth.loginWith(mail, passwd);
|
|
|
+ else if (service == "be") return _beAuth.loginWith(mail, passwd);
|
|
|
+ else if (service == "uplift") return _upliftAuth.loginWith(mail, passwd);
|
|
|
+ return 2;
|
|
|
+}
|
|
|
+
|
|
|
+void BBS2chProxyCookieAuthManager::logout(const std::string &service)
|
|
|
+{
|
|
|
+ if (service == "donguri") _acornAuth.logout();
|
|
|
+ else if (service == "be") _beAuth.logout();
|
|
|
+ else if (service == "uplift") _upliftAuth.logout();
|
|
|
+}
|
|
|
+
|
|
|
+void BBS2chProxyCookieAuthManager::syncCookies(BBS2chProxyKeyManager::CookieJar &jar)
|
|
|
+{
|
|
|
+ bool shouldFlush = false;
|
|
|
+ if (_acornAuth.syncCookie(jar)) shouldFlush = true;
|
|
|
+ if (_beAuth.syncCookie(jar)) shouldFlush = true;
|
|
|
+ if (_upliftAuth.syncCookie(jar)) shouldFlush = true;
|
|
|
+ if (shouldFlush) BBS2chProxyConnection::keyManager.flushCookies();
|
|
|
+}
|
|
|
+
|
|
|
+std::string BBS2chProxyCookieAuthManager::responseHTML()
|
|
|
+{
|
|
|
+ std::string html;
|
|
|
+ html += "<!DOCTYPE html><html lang=\"ja\"><head>";
|
|
|
+ html += "<title>proxy2ch: アカウント管理</title>";
|
|
|
+ html += "<meta http-equiv=\"content-type\" content=\"text/html; charset=UTF-8\">";
|
|
|
+ html += "<meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\"><style>";
|
|
|
+ html += ".container { width: 300px; margin: 0 auto; padding: 20px; border: 1px solid #ccc; border-radius: 5px; margin-bottom: 10px; }";
|
|
|
+ html += "h3 { text-align: center; margin-bottom: 20px; margin-top: 0px; }";
|
|
|
+ html += "input[type=\"text\"], input[type=\"password\"] { width: 93%; padding: 10px; margin-bottom: 10px; border: 1px solid #ccc; border-radius: 4px; }";
|
|
|
+ html += "button[type=\"submit\"] { width: 100%; padding: 10px; background-color: #4CAF50; color: #ffffff; border: none; border-radius: 4px; cursor: pointer; }";
|
|
|
+ html += "</style></head><body>";
|
|
|
+ html += _acornAuth.responseHTML();
|
|
|
+ html += _beAuth.responseHTML();
|
|
|
+ html += _upliftAuth.responseHTML();
|
|
|
html += "</body></html>\n";
|
|
|
return html;
|
|
|
}
|