@@ -629,6 +629,7 @@ void MyFrameMain::onVNCConnIncomingConnectionNotify(wxCommandEvent& event)
629629 encodings = encodings.AfterFirst (' ' );
630630
631631 if (!c->Init (wxEmptyString,
632+ 5900 ,
632633 -1 ,
633634 wxEmptyString,
634635 wxSecretValue (), // Creates an empty secret value (not the same as an empty password).
@@ -1099,13 +1100,14 @@ void MyFrameMain::conn_spawn(const wxString& service, int listenPort)
10991100 {
11001101 wxString user, host, ssh_user, ssh_host, ssh_fingerprint, ssh_priv_key_filename, x509_fingerprint;
11011102 wxSecretValue password, ssh_password, ssh_priv_key_password;
1102- int repeaterId = -1 , ssh_port = 22 ;
1103+ int repeaterId = -1 , port = 5900 , ssh_port = 22 ;
11031104
11041105 wxString vncUriScheme = " vnc://" ;
11051106 if (service.substr (0 , vncUriScheme.length ()) == vncUriScheme) {
11061107 // vnc:// URI
11071108 wxURI uri (service);
1108- host = uri.GetServer () + " :" + uri.GetPort ();
1109+ host = uri.GetServer ();
1110+ uri.GetPort ().ToInt (&port);
11091111 user = getQueryValue (uri, " VncUsername" ); // RFC 7869
11101112 if (user.IsEmpty ()) {
11111113 user = uri.GetUserInfo (); // fallback
@@ -1148,23 +1150,27 @@ void MyFrameMain::conn_spawn(const wxString& service, int listenPort)
11481150 x509_fingerprint.MakeLower (); // now lowercase hex
11491151 if (x509_fingerprint.IsEmpty ()) {
11501152 // if no fingerprint given, use the one from our internal known_hosts
1151- x509_fingerprint = x509_known_hosts_load (uri.GetServer (), uri. GetPort (). IsEmpty () ? " 5900 " : uri. GetPort () );
1153+ x509_fingerprint = x509_known_hosts_load (uri.GetServer (), wxString () << port );
11521154 }
11531155 }
11541156 } else {
11551157 // user@host:port notation
11561158 user = service.Contains (" @" ) ? service.BeforeFirst (' @' ) : " " ;
1157- host = service.Contains (" @" ) ? service.AfterFirst (' @' ) : service;
1159+ char *tmp;
1160+ parseHostString ((service.Contains (" @" ) ? service.AfterFirst (' @' ) : service).mb_str (), 5900 , &tmp, &port);
1161+ host = wxString (tmp);
1162+ free (tmp);
11581163
11591164 // this notation cannot give a fingerprint, use the one from our internal known_hosts
1160- x509_fingerprint = x509_known_hosts_load (host. BeforeFirst ( ' : ' ), host. Contains ( ' : ' ) ? host. AfterLast ( ' : ' ) : " 5900 " );
1165+ x509_fingerprint = x509_known_hosts_load (host, wxString () << port );
11611166 }
11621167
11631168 // add to notebook, needs to be after connections list add
11641169 notebook_connections->AddPage (win, wxString::Format (_ (" Connecting to %s..." ), host), true );
11651170 wxLogStatus (_ (" Connecting to %s..." ), host);
11661171
11671172 if (!c->Init (host,
1173+ port,
11681174 repeaterId,
11691175 user,
11701176 password,
@@ -1615,7 +1621,12 @@ void MyFrameMain::machine_connect(wxCommandEvent &event)
16151621 if (dialog_new_connection.ShowModal () == wxID_OK && dialog_new_connection.getVncServer () != wxEmptyString) {
16161622 pConfig->Write (K_LASTSERVER, dialog_new_connection.getVncServer ());
16171623 pConfig->Write (K_LASTPORT, dialog_new_connection.getVncPort ());
1618- conn_spawn (" vnc://" + dialog_new_connection.getVncServer ()
1624+ wxString server = dialog_new_connection.getVncServer ();
1625+ if (server.Contains (" :" )) {
1626+ // IPv6 address, need brackets as per RFC 2732
1627+ server = " [" + server + " ]" ;
1628+ }
1629+ conn_spawn (" vnc://" + server
16191630 + wxString (dialog_new_connection.getVncPort ().IsEmpty () ? " " : " :" + dialog_new_connection.getVncPort ())
16201631 + " ?RepeaterId=" + wxString::Format (" %i" , dialog_new_connection.getRepeaterId ())
16211632 + " &SshHost=" + dialog_new_connection.getSshServer ()
0 commit comments