Skip to content

Commit ac1c34a

Browse files
committed
MyFrameMain: enable saving/loading fingerprints of IPv6 hosts
1 parent 97a1f8d commit ac1c34a

File tree

1 file changed

+24
-4
lines changed

1 file changed

+24
-4
lines changed

src/gui/MyFrameMain.cpp

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2328,7 +2328,12 @@ void MyFrameMain::bookmarks_secrets_delete(const wxString& bookmarkName) {
23282328

23292329
void MyFrameMain::ssh_known_hosts_save(const wxString& host, const wxString& port, const wxString& fingerprint) {
23302330
wxConfigBase *cfg = wxConfigBase::Get();
2331-
wxString name = host + ":" + port;
2331+
wxString name;
2332+
if (host.Contains(':')) {
2333+
name = "[" + host + "]" + ":" + port;
2334+
} else {
2335+
name = host + ":" + port;
2336+
}
23322337
if(name != wxEmptyString) {
23332338
cfg->SetPath(G_SSH_KNOWN_HOSTS + name);
23342339
cfg->Write(K_SSH_KNOWN_HOSTS_FINGERPRINT, fingerprint);
@@ -2341,7 +2346,12 @@ void MyFrameMain::ssh_known_hosts_save(const wxString& host, const wxString& por
23412346
wxString MyFrameMain::ssh_known_hosts_load(const wxString& host, const wxString& port) {
23422347
wxString fingerprint;
23432348
wxConfigBase *cfg = wxConfigBase::Get();
2344-
wxString name = host + ":" + port;
2349+
wxString name;
2350+
if (host.Contains(':')) {
2351+
name = "[" + host + "]" + ":" + port;
2352+
} else {
2353+
name = host + ":" + port;
2354+
}
23452355
cfg->SetPath(G_SSH_KNOWN_HOSTS + name);
23462356
cfg->Read(K_SSH_KNOWN_HOSTS_FINGERPRINT, &fingerprint);
23472357
//reset path
@@ -2372,7 +2382,12 @@ wxString MyFrameMain::hex_to_base64(const wxString& hex) {
23722382

23732383
void MyFrameMain::x509_known_hosts_save(const wxString& host, const wxString& port, const wxString& fingerprint) {
23742384
wxConfigBase *cfg = wxConfigBase::Get();
2375-
wxString name = host + ":" + port;
2385+
wxString name;
2386+
if (host.Contains(':')) {
2387+
name = "[" + host + "]" + ":" + port;
2388+
} else {
2389+
name = host + ":" + port;
2390+
}
23762391
if(name != wxEmptyString) {
23772392
cfg->SetPath(G_X509_KNOWN_HOSTS + name);
23782393
cfg->Write(K_X509_KNOWN_HOSTS_FINGERPRINT, fingerprint);
@@ -2385,7 +2400,12 @@ void MyFrameMain::x509_known_hosts_save(const wxString& host, const wxString& po
23852400
wxString MyFrameMain::x509_known_hosts_load(const wxString& host, const wxString& port) {
23862401
wxString fingerprint;
23872402
wxConfigBase *cfg = wxConfigBase::Get();
2388-
wxString name = host + ":" + port;
2403+
wxString name;
2404+
if (host.Contains(':')) {
2405+
name = "[" + host + "]" + ":" + port;
2406+
} else {
2407+
name = host + ":" + port;
2408+
}
23892409
cfg->SetPath(G_X509_KNOWN_HOSTS + name);
23902410
cfg->Read(K_X509_KNOWN_HOSTS_FINGERPRINT, &fingerprint);
23912411
//reset path

0 commit comments

Comments
 (0)