FIX: [STUDIO-4522] hide passwd of media url from log
Change-Id: Ib4da577ea39cca9fb34d920101a81f1708a6934e Jira: STUDIO-4522
This commit is contained in:
parent
f183058b20
commit
52b816b657
|
@ -410,6 +410,8 @@ void MediaFilePanel::modeChanged(wxCommandEvent& e1)
|
||||||
m_last_mode = mode;
|
m_last_mode = mode;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
extern wxString hide_passwd(wxString url, std::vector<std::string> const &passwords);
|
||||||
|
|
||||||
void MediaFilePanel::fetchUrl(boost::weak_ptr<PrinterFileSystem> wfs)
|
void MediaFilePanel::fetchUrl(boost::weak_ptr<PrinterFileSystem> wfs)
|
||||||
{
|
{
|
||||||
boost::shared_ptr fs(wfs.lock());
|
boost::shared_ptr fs(wfs.lock());
|
||||||
|
@ -446,7 +448,7 @@ void MediaFilePanel::fetchUrl(boost::weak_ptr<PrinterFileSystem> wfs)
|
||||||
if (agent) {
|
if (agent) {
|
||||||
agent->get_camera_url(m_machine,
|
agent->get_camera_url(m_machine,
|
||||||
[this, wfs, m = m_machine, v = m_dev_ver](std::string url) {
|
[this, wfs, m = m_machine, v = m_dev_ver](std::string url) {
|
||||||
BOOST_LOG_TRIVIAL(info) << "MediaFilePanel::fetchUrl: camera_url: " << url;
|
BOOST_LOG_TRIVIAL(info) << "MediaFilePanel::fetchUrl: camera_url: " << hide_passwd(url, {"authkey=", "passwd="});
|
||||||
CallAfter([=] {
|
CallAfter([=] {
|
||||||
boost::shared_ptr fs(wfs.lock());
|
boost::shared_ptr fs(wfs.lock());
|
||||||
if (!fs || fs != m_image_grid->GetFileSystem()) return;
|
if (!fs || fs != m_image_grid->GetFileSystem()) return;
|
||||||
|
|
|
@ -41,7 +41,23 @@ MediaPlayCtrl::MediaPlayCtrl(wxWindow *parent, wxMediaCtrl2 *media_ctrl, const w
|
||||||
wxLaunchDefaultBrowser(url);
|
wxLaunchDefaultBrowser(url);
|
||||||
});
|
});
|
||||||
|
|
||||||
Bind(wxEVT_RIGHT_UP, [this](auto & e) { wxClipboard & c = *wxTheClipboard; if (c.Open()) { c.SetData(new wxTextDataObject(m_url)); c.Close(); } });
|
Bind(wxEVT_RIGHT_UP, [this](auto & e) {
|
||||||
|
wxClipboard & c = *wxTheClipboard;
|
||||||
|
if (c.Open()) {
|
||||||
|
if (wxGetKeyState(WXK_SHIFT)) {
|
||||||
|
if (c.IsSupported(wxDF_TEXT)) {
|
||||||
|
wxTextDataObject data;
|
||||||
|
c.GetData(data);
|
||||||
|
Stop();
|
||||||
|
m_url = data.GetText();
|
||||||
|
load();
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
c.SetData(new wxTextDataObject(m_url));
|
||||||
|
}
|
||||||
|
c.Close();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
wxBoxSizer * sizer = new wxBoxSizer(wxHORIZONTAL);
|
wxBoxSizer * sizer = new wxBoxSizer(wxHORIZONTAL);
|
||||||
sizer->Add(m_button_play, 0, wxEXPAND | wxALL, 0);
|
sizer->Add(m_button_play, 0, wxEXPAND | wxALL, 0);
|
||||||
|
@ -123,6 +139,23 @@ void MediaPlayCtrl::SetMachineObject(MachineObject* obj)
|
||||||
SetStatus("", false);
|
SetStatus("", false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
wxString hide_passwd(wxString url, std::vector<std::string> const &passwords)
|
||||||
|
{
|
||||||
|
for (auto &p : passwords) {
|
||||||
|
auto i = url.find(p);
|
||||||
|
auto j = i + p.length();
|
||||||
|
if (p[p.length() - 1] == '=') {
|
||||||
|
i = j;
|
||||||
|
j = url.find('&', i);
|
||||||
|
if (j == wxString::npos) j = url.length();
|
||||||
|
}
|
||||||
|
auto l = size_t(j - i);
|
||||||
|
if (j == url.length() || url[j] == '@' || url[j] == '&')
|
||||||
|
url.replace(i, l, l, wxUniChar('*'));
|
||||||
|
}
|
||||||
|
return url;
|
||||||
|
}
|
||||||
|
|
||||||
void MediaPlayCtrl::Play()
|
void MediaPlayCtrl::Play()
|
||||||
{
|
{
|
||||||
if (!m_next_retry.IsValid() || wxDateTime::Now() < m_next_retry)
|
if (!m_next_retry.IsValid() || wxDateTime::Now() < m_next_retry)
|
||||||
|
@ -166,22 +199,8 @@ void MediaPlayCtrl::Play()
|
||||||
m_url += "&device=" + m_machine;
|
m_url += "&device=" + m_machine;
|
||||||
m_url += "&version=" + agent_version;
|
m_url += "&version=" + agent_version;
|
||||||
m_url += "&dev_ver=" + m_dev_ver;
|
m_url += "&dev_ver=" + m_dev_ver;
|
||||||
BOOST_LOG_TRIVIAL(info) << "MediaPlayCtrl: " << m_url.substr(0, 16);
|
BOOST_LOG_TRIVIAL(info) << "MediaPlayCtrl: " << hide_passwd(m_url, {m_lan_passwd} );
|
||||||
m_last_state = MEDIASTATE_LOADING;
|
load();
|
||||||
SetStatus(_L("Loading..."));
|
|
||||||
if (wxGetApp().app_config->get("internal_developer_mode") == "true") {
|
|
||||||
std::string file_h264 = data_dir() + "/video.h264";
|
|
||||||
std::string file_info = data_dir() + "/video.info";
|
|
||||||
BOOST_LOG_TRIVIAL(info) << "MediaPlayCtrl dump video to " << file_h264;
|
|
||||||
// closed by BambuSource
|
|
||||||
FILE *dump_h264_file = boost::nowide::fopen(file_h264.c_str(), "wb");
|
|
||||||
FILE *dump_info_file = boost::nowide::fopen(file_info.c_str(), "wb");
|
|
||||||
m_url = m_url + "&dump_h264=" + boost::lexical_cast<std::string>(dump_h264_file);
|
|
||||||
m_url = m_url + "&dump_info=" + boost::lexical_cast<std::string>(dump_info_file);
|
|
||||||
}
|
|
||||||
boost::unique_lock lock(m_mutex);
|
|
||||||
m_tasks.push_back(m_url);
|
|
||||||
m_cond.notify_all();
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -213,7 +232,7 @@ void MediaPlayCtrl::Play()
|
||||||
url += "&version=" + v;
|
url += "&version=" + v;
|
||||||
url += "&dev_ver=" + dv;
|
url += "&dev_ver=" + dv;
|
||||||
}
|
}
|
||||||
BOOST_LOG_TRIVIAL(info) << "MediaPlayCtrl: " << url.substr(0, 16) << ", machine: " << m_machine;
|
BOOST_LOG_TRIVIAL(info) << "MediaPlayCtrl: " << hide_passwd(url, {"authkey=", "passwd="}) << ", machine: " << m_machine;
|
||||||
CallAfter([this, m, url] {
|
CallAfter([this, m, url] {
|
||||||
if (m != m_machine) {
|
if (m != m_machine) {
|
||||||
BOOST_LOG_TRIVIAL(info) << "MediaPlayCtrl drop late ttcode for machine: " << m;
|
BOOST_LOG_TRIVIAL(info) << "MediaPlayCtrl drop late ttcode for machine: " << m;
|
||||||
|
@ -225,15 +244,7 @@ void MediaPlayCtrl::Play()
|
||||||
m_failed_code = 3;
|
m_failed_code = 3;
|
||||||
Stop(wxString::Format(_L("Initialize failed (%s)!"), url.empty() ? _L("Network unreachable") : from_u8(url)));
|
Stop(wxString::Format(_L("Initialize failed (%s)!"), url.empty() ? _L("Network unreachable") : from_u8(url)));
|
||||||
} else {
|
} else {
|
||||||
m_last_state = MEDIASTATE_LOADING;
|
load();
|
||||||
SetStatus(_L("Loading..."));
|
|
||||||
if (wxGetApp().app_config->get("internal_developer_mode") == "true") {
|
|
||||||
BOOST_LOG_TRIVIAL(info) << "MediaPlayCtrl dump video to " << boost::filesystem::current_path();
|
|
||||||
m_url = m_url + "&dump=video.h264";
|
|
||||||
}
|
|
||||||
boost::unique_lock lock(m_mutex);
|
|
||||||
m_tasks.push_back(m_url);
|
|
||||||
m_cond.notify_all();
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
BOOST_LOG_TRIVIAL(info) << "MediaPlayCtrl drop late ttcode for state: " << m_last_state;
|
BOOST_LOG_TRIVIAL(info) << "MediaPlayCtrl drop late ttcode for state: " << m_last_state;
|
||||||
|
@ -395,7 +406,7 @@ void MediaPlayCtrl::ToggleStream()
|
||||||
url = "bambu:///rtsp___" + m_lan_user + ":" + m_lan_passwd + "@" + m_lan_ip + "/streaming/live/1?proto=rtsp";
|
url = "bambu:///rtsp___" + m_lan_user + ":" + m_lan_passwd + "@" + m_lan_ip + "/streaming/live/1?proto=rtsp";
|
||||||
url += "&device=" + m_machine;
|
url += "&device=" + m_machine;
|
||||||
url += "&dev_ver=" + m_dev_ver;
|
url += "&dev_ver=" + m_dev_ver;
|
||||||
BOOST_LOG_TRIVIAL(info) << "MediaPlayCtrl::ToggleStream: " << url.substr(0, 16);
|
BOOST_LOG_TRIVIAL(info) << "MediaPlayCtrl::ToggleStream: " << hide_passwd(url, {m_lan_passwd});
|
||||||
std::string file_url = data_dir() + "/cameratools/url.txt";
|
std::string file_url = data_dir() + "/cameratools/url.txt";
|
||||||
boost::nowide::ofstream file(file_url);
|
boost::nowide::ofstream file(file_url);
|
||||||
auto url2 = encode_path(url.c_str());
|
auto url2 = encode_path(url.c_str());
|
||||||
|
@ -411,7 +422,7 @@ void MediaPlayCtrl::ToggleStream()
|
||||||
url += "&version=" + v;
|
url += "&version=" + v;
|
||||||
url += "&dev_ver=" + dv;
|
url += "&dev_ver=" + dv;
|
||||||
}
|
}
|
||||||
BOOST_LOG_TRIVIAL(info) << "MediaPlayCtrl::ToggleStream: " << url.substr(0, 16);
|
BOOST_LOG_TRIVIAL(info) << "MediaPlayCtrl::ToggleStream: " << hide_passwd(url, {"authkey=", "passwd="});
|
||||||
CallAfter([this, m, url] {
|
CallAfter([this, m, url] {
|
||||||
if (m != m_machine) return;
|
if (m != m_machine) return;
|
||||||
if (url.empty() || !boost::algorithm::starts_with(url, "bambu:///")) {
|
if (url.empty() || !boost::algorithm::starts_with(url, "bambu:///")) {
|
||||||
|
@ -509,6 +520,25 @@ void MediaPlayCtrl::SetStatus(wxString const &msg2, bool hyperlink)
|
||||||
|
|
||||||
bool MediaPlayCtrl::IsStreaming() const { return m_streaming; }
|
bool MediaPlayCtrl::IsStreaming() const { return m_streaming; }
|
||||||
|
|
||||||
|
void MediaPlayCtrl::load()
|
||||||
|
{
|
||||||
|
m_last_state = MEDIASTATE_LOADING;
|
||||||
|
SetStatus(_L("Loading..."));
|
||||||
|
if (wxGetApp().app_config->get("internal_developer_mode") == "true") {
|
||||||
|
std::string file_h264 = data_dir() + "/video.h264";
|
||||||
|
std::string file_info = data_dir() + "/video.info";
|
||||||
|
BOOST_LOG_TRIVIAL(info) << "MediaPlayCtrl dump video to " << file_h264;
|
||||||
|
// closed by BambuSource
|
||||||
|
FILE *dump_h264_file = boost::nowide::fopen(file_h264.c_str(), "wb");
|
||||||
|
FILE *dump_info_file = boost::nowide::fopen(file_info.c_str(), "wb");
|
||||||
|
m_url = m_url + "&dump_h264=" + boost::lexical_cast<std::string>(dump_h264_file);
|
||||||
|
m_url = m_url + "&dump_info=" + boost::lexical_cast<std::string>(dump_info_file);
|
||||||
|
}
|
||||||
|
boost::unique_lock lock(m_mutex);
|
||||||
|
m_tasks.push_back(m_url);
|
||||||
|
m_cond.notify_all();
|
||||||
|
}
|
||||||
|
|
||||||
void MediaPlayCtrl::on_show_hide(wxShowEvent &evt)
|
void MediaPlayCtrl::on_show_hide(wxShowEvent &evt)
|
||||||
{
|
{
|
||||||
evt.Skip();
|
evt.Skip();
|
||||||
|
@ -528,7 +558,7 @@ void MediaPlayCtrl::media_proc()
|
||||||
}
|
}
|
||||||
wxString url = m_tasks.front();
|
wxString url = m_tasks.front();
|
||||||
if (m_tasks.size() >= 2 && !url.IsEmpty() && url[0] != '<' && m_tasks[1] == "<stop>") {
|
if (m_tasks.size() >= 2 && !url.IsEmpty() && url[0] != '<' && m_tasks[1] == "<stop>") {
|
||||||
BOOST_LOG_TRIVIAL(info) << "MediaPlayCtrl: busy skip url" << url;
|
BOOST_LOG_TRIVIAL(info) << "MediaPlayCtrl: busy skip url: " << hide_passwd(url, {"authkey=", "passwd=", m_lan_passwd});
|
||||||
m_tasks.pop_front();
|
m_tasks.pop_front();
|
||||||
m_tasks.pop_front();
|
m_tasks.pop_front();
|
||||||
continue;
|
continue;
|
||||||
|
|
|
@ -54,6 +54,8 @@ protected:
|
||||||
void SetStatus(wxString const &msg, bool hyperlink = true);
|
void SetStatus(wxString const &msg, bool hyperlink = true);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
void load();
|
||||||
|
|
||||||
void on_show_hide(wxShowEvent & evt);
|
void on_show_hide(wxShowEvent & evt);
|
||||||
|
|
||||||
void media_proc();
|
void media_proc();
|
||||||
|
|
|
@ -1217,6 +1217,10 @@ void PrinterFileSystem::HandleResponse(boost::unique_lock<boost::mutex> &l, Bamb
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
namespace Slic3r { namespace GUI {
|
||||||
|
extern wxString hide_passwd(wxString url, std::vector<std::string> const &passwords);
|
||||||
|
}}
|
||||||
|
|
||||||
void PrinterFileSystem::Reconnect(boost::unique_lock<boost::mutex> &l, int result)
|
void PrinterFileSystem::Reconnect(boost::unique_lock<boost::mutex> &l, int result)
|
||||||
{
|
{
|
||||||
if (m_session.tunnel) {
|
if (m_session.tunnel) {
|
||||||
|
@ -1258,7 +1262,7 @@ void PrinterFileSystem::Reconnect(boost::unique_lock<boost::mutex> &l, int resul
|
||||||
wxLogMessage("PrinterFileSystem::Reconnect Initialize failed: %s", wxString::FromUTF8(url));
|
wxLogMessage("PrinterFileSystem::Reconnect Initialize failed: %s", wxString::FromUTF8(url));
|
||||||
m_last_error = atoi(url.c_str());
|
m_last_error = atoi(url.c_str());
|
||||||
} else {
|
} else {
|
||||||
wxLogMessage("PrinterFileSystem::Reconnect Initialized: %s", wxString::FromUTF8(url));
|
wxLogMessage("PrinterFileSystem::Reconnect Initialized: %s", Slic3r::GUI::hide_passwd(wxString::FromUTF8(url), {"authkey=", "passwd="}));
|
||||||
l.unlock();
|
l.unlock();
|
||||||
m_status = Status::Connecting;
|
m_status = Status::Connecting;
|
||||||
wxLogMessage("PrinterFileSystem::Reconnect Connecting");
|
wxLogMessage("PrinterFileSystem::Reconnect Connecting");
|
||||||
|
|
Loading…
Reference in New Issue