| 1605 |
pvar->protocol_major = atoi(ID + 4); |
pvar->protocol_major = atoi(ID + 4); |
| 1606 |
pvar->protocol_minor = atoi(str + 1); |
pvar->protocol_minor = atoi(str + 1); |
| 1607 |
|
|
|
// for SSH2(yutaka) |
|
|
// 1.99ならSSH2での接続を行う |
|
|
if (pvar->protocol_major == 1 && pvar->protocol_minor == 99) { |
|
|
// ユーザが SSH2 を選択しているのならば |
|
|
if (pvar->settings.ssh_protocol_version == 2) { |
|
|
pvar->protocol_major = 2; |
|
|
pvar->protocol_minor = 0; |
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
// SSH バージョンを teraterm 側にセットする |
|
|
// SCP コマンドのため (2008.2.3 maya) |
|
|
pvar->cv->isSSH = pvar->protocol_major; |
|
|
|
|
| 1608 |
for (str = str + 1; *str >= '0' && *str <= '9'; str++) { |
for (str = str + 1; *str >= '0' && *str <= '9'; str++) { |
| 1609 |
} |
} |
| 1610 |
|
|
| 1616 |
protocol number. We replace the fields with the protocol number we will |
protocol number. We replace the fields with the protocol number we will |
| 1617 |
actually use, or return FALSE if there is no usable protocol version. |
actually use, or return FALSE if there is no usable protocol version. |
| 1618 |
*/ |
*/ |
| 1619 |
static BOOL negotiate_protocol(PTInstVar pvar) |
static int negotiate_protocol(PTInstVar pvar) |
| 1620 |
{ |
{ |
| 1621 |
switch (pvar->protocol_major) { |
switch (pvar->protocol_major) { |
| 1622 |
case 1: |
case 1: |
| 1623 |
|
if (pvar->protocol_minor == 99 && |
| 1624 |
|
pvar->settings.ssh_protocol_version == 2) { |
| 1625 |
|
// サーバが 1.99 でユーザが SSH2 を選択しているのならば |
| 1626 |
|
// 2.0 接続とする |
| 1627 |
|
pvar->protocol_major = 2; |
| 1628 |
|
pvar->protocol_minor = 0; |
| 1629 |
|
return 0; |
| 1630 |
|
} |
| 1631 |
|
|
| 1632 |
|
if (pvar->settings.ssh_protocol_version == 2) { |
| 1633 |
|
// バージョン違い |
| 1634 |
|
return -1; |
| 1635 |
|
} |
| 1636 |
|
|
| 1637 |
if (pvar->protocol_minor > 5) { |
if (pvar->protocol_minor > 5) { |
| 1638 |
pvar->protocol_minor = 5; |
pvar->protocol_minor = 5; |
| 1639 |
} |
} |
| 1640 |
|
|
| 1641 |
return TRUE; |
return 0; |
| 1642 |
|
|
| 1643 |
// for SSH2(yutaka) |
// for SSH2(yutaka) |
| 1644 |
case 2: |
case 2: |
| 1645 |
return TRUE; // SSH2 support |
if (pvar->settings.ssh_protocol_version == 1) { |
| 1646 |
|
// バージョン違い |
| 1647 |
|
return -1; |
| 1648 |
|
} |
| 1649 |
|
|
| 1650 |
|
return 0; // SSH2 support |
| 1651 |
|
|
| 1652 |
default: |
default: |
| 1653 |
return FALSE; |
return 1; |
| 1654 |
} |
} |
| 1655 |
} |
} |
| 1656 |
|
|
| 1709 |
BOOL SSH_handle_server_ID(PTInstVar pvar, char FAR * ID, int ID_len) |
BOOL SSH_handle_server_ID(PTInstVar pvar, char FAR * ID, int ID_len) |
| 1710 |
{ |
{ |
| 1711 |
static char prefix[64]; |
static char prefix[64]; |
| 1712 |
|
int negotiate; |
| 1713 |
|
char uimsg[MAX_UIMSG]; |
| 1714 |
|
|
| 1715 |
// initialize SSH2 memory dump (2005.3.7 yutaka) |
// initialize SSH2 memory dump (2005.3.7 yutaka) |
| 1716 |
init_memdump(); |
init_memdump(); |
| 1759 |
|
|
| 1760 |
pvar->ssh_state.server_ID = _strdup(ID); |
pvar->ssh_state.server_ID = _strdup(ID); |
| 1761 |
|
|
| 1762 |
if (!parse_protocol_ID(pvar, ID) || !negotiate_protocol(pvar)) { |
if (!parse_protocol_ID(pvar, ID)) { |
| 1763 |
UTIL_get_lang_msg("MSG_SSH_VERSION_ERROR", pvar, |
UTIL_get_lang_msg("MSG_SSH_VERSION_ERROR", pvar, |
| 1764 |
"This program does not understand the server's version of the protocol."); |
"This program does not understand the server's version of the protocol."); |
| 1765 |
notify_fatal_error(pvar, pvar->ts->UIMsg); |
notify_fatal_error(pvar, pvar->ts->UIMsg); |
| 1766 |
} else { |
} |
| 1767 |
|
else if ((negotiate = negotiate_protocol(pvar)) == 1) { |
| 1768 |
|
UTIL_get_lang_msg("MSG_SSH_VERSION_ERROR", pvar, |
| 1769 |
|
"This program does not understand the server's version of the protocol."); |
| 1770 |
|
notify_fatal_error(pvar, pvar->ts->UIMsg); |
| 1771 |
|
} |
| 1772 |
|
else if (negotiate == -1) { |
| 1773 |
|
UTIL_get_lang_msg("MSG_SSH_VERSION_MISMATCH", pvar, |
| 1774 |
|
"Protocol version mismatch. server:%d.%d client:%d"); |
| 1775 |
|
_snprintf_s(uimsg, sizeof(uimsg), _TRUNCATE, pvar->ts->UIMsg, |
| 1776 |
|
pvar->protocol_major, pvar->protocol_minor, pvar->settings.ssh_protocol_version); |
| 1777 |
|
notify_fatal_error(pvar, uimsg); |
| 1778 |
|
} |
| 1779 |
|
else { |
| 1780 |
char TTSSH_ID[1024]; |
char TTSSH_ID[1024]; |
| 1781 |
int TTSSH_ID_len; |
int TTSSH_ID_len; |
| 1782 |
int a, b, c, d; |
int a, b, c, d; |
| 1783 |
|
|
| 1784 |
|
// SSH バージョンを teraterm 側にセットする |
| 1785 |
|
// SCP コマンドのため (2008.2.3 maya) |
| 1786 |
|
pvar->cv->isSSH = pvar->protocol_major; |
| 1787 |
|
|
| 1788 |
// 自分自身のバージョンを取得する (2005.3.3 yutaka) |
// 自分自身のバージョンを取得する (2005.3.3 yutaka) |
| 1789 |
get_file_version("ttxssh.dll", &a, &b, &c, &d); |
get_file_version("ttxssh.dll", &a, &b, &c, &d); |
| 1790 |
|
|