• R/O
  • HTTP
  • SSH
  • HTTPS

Commit

Tags
No Tags

Frequently used words (click to add to your profile)

javaandroidc++objective-ccocoa誰得c#gamebathyscaphephplinuxrubyqtpythoncomegat翻訳windowstwitterguiframeworkbtronvb.netdirectxtestdom計画中(planning stage)previewerpukiwikimruby

Tera Termの個人的な作業用リポジトリ


Commit MetaInfo

Revisione52e8b937ed61e2a287c4ed73a9c1381d943acd2 (tree)
Time2018-03-08 13:15:26
AuthorIWAMOTO Kouichi <sue@iwmt...>
CommiterIWAMOTO Kouichi

Log Message

Remoto unix-domain socket to local tcp port の転送テスト

RtoL の転送で、bind address に unix-domain socket のパスを、
remote port に 0 を指定すると unix-domain socket の転送と見做す。

Change Summary

Incremental Difference

--- a/ttssh2/ttxssh/fwdui.c
+++ b/ttssh2/ttxssh/fwdui.c
@@ -406,7 +406,7 @@ static int parse_port_from_buf(char * buf)
406406 if (buf[0] >= '0' && buf[0] <= '9') {
407407 int result = atoi(buf);
408408
409- if (result < 1 || result > 65535) {
409+ if (result < 0 || result > 65535) {
410410 return -1;
411411 } else {
412412 return result;
@@ -1317,7 +1317,7 @@ static BOOL end_fwd_edit_dlg(PTInstVar pvar, FWDRequestSpec *spec, HWND dlg)
13171317 }
13181318
13191319 new_spec.from_port = parse_port_from_buf(new_spec.from_port_name);
1320- if (new_spec.from_port < 0) {
1320+ if (new_spec.from_port < 0 || new_spec.from_port == 0 && (type != FWD_REMOTE_TO_LOCAL || new_spec.bind_address[0] != '/')) {
13211321 UTIL_get_lang_msg("MSG_INVALID_PORT_ERROR", pvar,
13221322 "Port \"%s\" is not a valid port number.\n"
13231323 "Either choose a port name from the list, or enter a number between 1 and 65535.");
@@ -1329,7 +1329,7 @@ static BOOL end_fwd_edit_dlg(PTInstVar pvar, FWDRequestSpec *spec, HWND dlg)
13291329
13301330 if (type == FWD_LOCAL_TO_REMOTE || type == FWD_REMOTE_TO_LOCAL) {
13311331 new_spec.to_port = parse_port_from_buf(new_spec.to_port_name);
1332- if (new_spec.to_port < 0) {
1332+ if (new_spec.to_port < 1) {
13331333 UTIL_get_lang_msg("MSG_INVALID_PORT_ERROR", pvar,
13341334 "Port \"%s\" is not a valid port number.\n"
13351335 "Either choose a port name from the list, or enter a number between 1 and 65535.");
--- a/ttssh2/ttxssh/ssh.c
+++ b/ttssh2/ttxssh/ssh.c
@@ -3733,12 +3733,21 @@ void SSH_request_forwarding(PTInstVar pvar, char *bind_address, int from_server_
37333733 logputs(LOG_LEVEL_ERROR, __FUNCTION__ ": buffer_init returns NULL.");
37343734 return;
37353735 }
3736- req = "tcpip-forward";
3737- buffer_put_string(msg, req, strlen(req)); // ctype
3738- buffer_put_char(msg, 1); // want reply
3739- buffer_put_string(msg, bind_address, strlen(bind_address));
37403736
3741- buffer_put_int(msg, from_server_port); // listening port
3737+ if (bind_address[0] == '/' && from_server_port == 0) {
3738+ req = "streamlocal-forward@openssh.com";
3739+ buffer_put_string(msg, req, strlen(req)); // ctype
3740+ buffer_put_char(msg, 1); // want reply
3741+ buffer_put_string(msg, bind_address, strlen(bind_address));
3742+ }
3743+ else {
3744+ req = "tcpip-forward";
3745+ buffer_put_string(msg, req, strlen(req)); // ctype
3746+ buffer_put_char(msg, 1); // want reply
3747+ buffer_put_string(msg, bind_address, strlen(bind_address));
3748+
3749+ buffer_put_int(msg, from_server_port); // listening port
3750+ }
37423751
37433752 len = buffer_len(msg);
37443753 outmsg = begin_send_packet(pvar, SSH2_MSG_GLOBAL_REQUEST, len);
@@ -9004,6 +9013,41 @@ static BOOL handle_SSH2_channel_open(PTInstVar pvar)
90049013 free(listen_addr);
90059014 free(orig_addr);
90069015
9016+ }
9017+ else if (strcmp(ctype, "forwarded-streamlocal@openssh.com") == 0) {
9018+ char *socket_path, *reserved_str;
9019+
9020+ logprintf(LOG_LEVEL_VERBOSE, __FUNCTION__ ": channel type=%s", ctype);
9021+
9022+ socket_path = buffer_get_string(&data, &buflen);
9023+ reserved_str = buffer_get_string(&data, &buflen);
9024+
9025+ if (socket_path && reserved_str) {
9026+ logprintf(LOG_LEVEL_VERBOSE, __FUNCTION__
9027+ ": %s: socket_path=%s, reserved_str=%s",
9028+ ctype, socket_path, reserved_str);
9029+ FWD_open(pvar, remote_id, socket_path, 0, socket_path, 0, &chan_num);
9030+
9031+ c = ssh2_channel_new(CHAN_TCP_WINDOW_DEFAULT, CHAN_TCP_PACKET_DEFAULT, TYPE_PORTFWD, chan_num);
9032+ if (c == NULL) {
9033+ FWD_free_channel(pvar, chan_num);
9034+ UTIL_get_lang_msg("MSG_SSH_NO_FREE_CHANNEL", pvar,
9035+ "Could not open new channel. TTSSH is already opening too many channels.");
9036+ notify_nonfatal_error(pvar, pvar->ts->UIMsg);
9037+ return FALSE;
9038+ }
9039+ c->remote_id = remote_id;
9040+ c->remote_window = remote_window;
9041+ c->remote_maxpacket = remote_maxpacket;
9042+ }
9043+ else {
9044+ logprintf(LOG_LEVEL_ERROR, __FUNCTION__ ": %s: buffer_get_string returns NULL. "
9045+ "socket_path=%s, reserved_str=%s",
9046+ ctype, NonNull(socket_path), NonNull(reserved_str));
9047+ }
9048+ free(socket_path);
9049+ free(reserved_str);
9050+
90079051 } else if (strcmp(ctype, "x11") == 0) { // port-forwarding(X11)
90089052 // X applicationをターミナル上で実行すると、SSH2_MSG_CHANNEL_OPEN が送られてくる。
90099053 char *orig_str;