mirror of
https://git.tartarus.org/simon/putty.git
synced 2025-07-05 21:42:47 -05:00
Been meaning to do this for years: introduce a configuration option
to manually tweak the host name and port number under which the SSH host key is read and written. I've put it in the cross-platform Connection panel. Partly under the flimsy pretext that other backends _can_ use it if they so wish (and in fact it overrides the host name for title-bar purposes in all network backends, though it has no other effect in anything but SSH); but mostly because the SSH panel was too full already :-) [originally from svn r8033]
This commit is contained in:
36
ssh.c
36
ssh.c
@ -2837,12 +2837,30 @@ static const char *connect_to_host(Ssh ssh, char *host, int port,
|
||||
SockAddr addr;
|
||||
const char *err;
|
||||
|
||||
ssh->savedhost = snewn(1 + strlen(host), char);
|
||||
strcpy(ssh->savedhost, host);
|
||||
if (*ssh->cfg.loghost) {
|
||||
char *colon;
|
||||
|
||||
if (port < 0)
|
||||
port = 22; /* default ssh port */
|
||||
ssh->savedport = port;
|
||||
ssh->savedhost = dupstr(ssh->cfg.loghost);
|
||||
ssh->savedport = 22; /* default ssh port */
|
||||
|
||||
/*
|
||||
* A colon suffix on savedhost also lets us affect
|
||||
* savedport.
|
||||
*
|
||||
* (FIXME: do something about IPv6 address literals here.)
|
||||
*/
|
||||
colon = strrchr(ssh->savedhost, ':');
|
||||
if (colon) {
|
||||
*colon++ = '\0';
|
||||
if (*colon)
|
||||
ssh->savedport = atoi(colon);
|
||||
}
|
||||
} else {
|
||||
ssh->savedhost = dupstr(host);
|
||||
if (port < 0)
|
||||
port = 22; /* default ssh port */
|
||||
ssh->savedport = port;
|
||||
}
|
||||
|
||||
/*
|
||||
* Try to find host.
|
||||
@ -2880,6 +2898,14 @@ static const char *connect_to_host(Ssh ssh, char *host, int port,
|
||||
ssh_send_verstring(ssh, NULL);
|
||||
}
|
||||
|
||||
/*
|
||||
* loghost, if configured, overrides realhost.
|
||||
*/
|
||||
if (*ssh->cfg.loghost) {
|
||||
sfree(*realhost);
|
||||
*realhost = dupstr(ssh->cfg.loghost);
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user