• R/O
  • SSH
  • HTTPS

ttssh2: Commit


Commit MetaInfo

Revision6844 (tree)
Time2017-07-05 00:02:54
Authordoda

Log Message

SSH channel open 要求の結果を Forwarding Filter に渡すようにした。

SSH2_MSG_CHANNEL_OPEN_FAILURE を受けた時に FWD_failed_open() を呼ぶようにした。
FWD_free_channel() の呼び出しを削除。(FWD_failed_open() の中で呼ばれる)

Change Summary

Incremental Difference

--- trunk/ttssh2/ttxssh/fwd.c (revision 6843)
+++ trunk/ttssh2/ttxssh/fwd.c (revision 6844)
@@ -1517,11 +1517,27 @@
15171517 {
15181518 SOCKET s;
15191519 FWDChannel *channel;
1520+ FwdFilterResult action = FWD_FILTER_RETAIN;
15201521
15211522 if (!FWD_check_local_channel_num(pvar, local_channel_num))
15221523 return;
15231524
15241525 channel = pvar->fwd_state.channels + local_channel_num;
1526+
1527+ if (channel->filter != NULL) {
1528+ action = channel->filter(channel->filter_closure, FWD_FILTER_OPENCONFIRM, NULL, NULL);
1529+ switch (action) {
1530+ case FWD_FILTER_REMOVE:
1531+ channel->filter(channel->filter_closure, FWD_FILTER_CLEANUP, NULL, NULL);
1532+ channel->filter = NULL;
1533+ channel->filter_closure = NULL;
1534+ break;
1535+ case FWD_FILTER_CLOSECHANNEL:
1536+ closed_local_connection(pvar, local_channel_num);
1537+ break;
1538+ }
1539+ }
1540+
15251541 s = channel->local_socket;
15261542 if (s != INVALID_SOCKET) {
15271543 channel->remote_num = remote_channel_num;
@@ -1535,15 +1551,28 @@
15351551 }
15361552 }
15371553
1538-void FWD_failed_open(PTInstVar pvar, uint32 local_channel_num)
1554+void FWD_failed_open(PTInstVar pvar, uint32 local_channel_num, int reason)
15391555 {
1556+ FWDChannel *channel;
1557+ int r = reason;
1558+
15401559 if (!FWD_check_local_channel_num(pvar, local_channel_num))
15411560 return;
15421561
1543- UTIL_get_lang_msg("MSG_FWD_DENIED_BY_SERVER_ERROR", pvar,
1544- "A program on the local machine attempted to connect to a forwarded port.\n"
1545- "The forwarding request was denied by the server. The connection has been closed.");
1546- notify_nonfatal_error(pvar, pvar->ts->UIMsg);
1562+ channel = pvar->fwd_state.channels + local_channel_num;
1563+
1564+ // SSH2 では呼び出し元で既にポップアップを出しているので、
1565+ // ここでは SSH1 の時のみポップアップを出す
1566+ if (SSHv1(pvar)) {
1567+ UTIL_get_lang_msg("MSG_FWD_DENIED_BY_SERVER_ERROR", pvar,
1568+ "A program on the local machine attempted to connect to a forwarded port.\n"
1569+ "The forwarding request was denied by the server. The connection has been closed.");
1570+ notify_nonfatal_error(pvar, pvar->ts->UIMsg);
1571+ }
1572+
1573+ if (channel->filter != NULL) {
1574+ channel->filter(channel->filter_closure, FWD_FILTER_OPENFAILURE, &r, NULL);
1575+ }
15471576 FWD_free_channel(pvar, local_channel_num);
15481577 }
15491578
--- trunk/ttssh2/ttxssh/fwd.h (revision 6843)
+++ trunk/ttssh2/ttxssh/fwd.h (revision 6844)
@@ -50,6 +50,8 @@
5050
5151 typedef enum {
5252 FWD_FILTER_CLEANUP,
53+ FWD_FILTER_OPENCONFIRM,
54+ FWD_FILTER_OPENFAILURE,
5355 FWD_FILTER_FROM_CLIENT,
5456 FWD_FILTER_FROM_SERVER
5557 } FwdFilterEvent;
@@ -143,7 +145,7 @@
143145 int *chan_num);
144146 void FWD_confirmed_open(PTInstVar pvar, uint32 local_channel_num,
145147 uint32 remote_channel_num);
146-void FWD_failed_open(PTInstVar pvar, uint32 local_channel_num);
148+void FWD_failed_open(PTInstVar pvar, uint32 local_channel_num, int reason);
147149 void FWD_received_data(PTInstVar pvar, uint32 local_channel_num,
148150 unsigned char *data, int length);
149151 void FWD_channel_input_eof(PTInstVar pvar, uint32 local_channel_num);
--- trunk/ttssh2/ttxssh/ssh.c (revision 6843)
+++ trunk/ttssh2/ttxssh/ssh.c (revision 6844)
@@ -1946,7 +1946,7 @@
19461946 static BOOL handle_channel_open_failure(PTInstVar pvar)
19471947 {
19481948 if (grab_payload(pvar, 4)) {
1949- FWD_failed_open(pvar, get_payload_uint32(pvar, 0));
1949+ FWD_failed_open(pvar, get_payload_uint32(pvar, 0), -1);
19501950 }
19511951 return FALSE;
19521952 }
@@ -7688,9 +7688,8 @@
76887688
76897689 free(cstring);
76907690
7691- // 転送チャネル内にあるソケットの解放漏れを修正 (2007.7.26 maya)
76927691 if (c->type == TYPE_PORTFWD) {
7693- FWD_free_channel(pvar, c->local_num);
7692+ FWD_failed_open(pvar, c->local_num, reason);
76947693 }
76957694
76967695 // チャネルの解放漏れを修正 (2007.5.1 maya)
Show on old repository browser