Increase usefulness of telnet(1) as a protocol tester. By prepending
"+" to the port number, disable option negotiation and allow transferring of data with high bit set. OKed by: markm (maintainer) PR: 52032 Submitted by: Valentin Nechayev <netch maybe-at netch stop kiev stop ua> MFC After: 2 weeks
This commit is contained in:
parent
d1a67300e2
commit
3a44a4c33e
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=142790
@ -2299,6 +2299,9 @@ tn(int argc, char *argv[])
|
|||||||
} else if (*portp == '-') {
|
} else if (*portp == '-') {
|
||||||
portp++;
|
portp++;
|
||||||
telnetport = 1;
|
telnetport = 1;
|
||||||
|
} else if (*portp == '+') {
|
||||||
|
portp++;
|
||||||
|
telnetport = -1;
|
||||||
} else
|
} else
|
||||||
telnetport = 0;
|
telnetport = 0;
|
||||||
|
|
||||||
|
@ -591,9 +591,10 @@ Prints out help information for the
|
|||||||
command.
|
command.
|
||||||
.El
|
.El
|
||||||
.It Xo
|
.It Xo
|
||||||
.Ic open Ar host
|
.Ic open
|
||||||
.Op Fl l Ar user
|
.Op Fl l Ar user
|
||||||
.Op Oo Fl Oc Ns Ar port
|
.Op Ar host
|
||||||
|
.Op Oo Fl /+ Oc Ns Ar port
|
||||||
.Xc
|
.Xc
|
||||||
Open a connection to the named host.
|
Open a connection to the named host.
|
||||||
If no port number
|
If no port number
|
||||||
@ -620,6 +621,13 @@ omits any automatic initiation of
|
|||||||
options.
|
options.
|
||||||
When the port number is preceded by a minus sign,
|
When the port number is preceded by a minus sign,
|
||||||
the initial option negotiation is done.
|
the initial option negotiation is done.
|
||||||
|
When, however, the port number
|
||||||
|
is preceded by a plus sign,
|
||||||
|
any option negotiation and understanding is prohibited,
|
||||||
|
making telnet dumb client for POP3/SMTP/NNTP/HTTP-like
|
||||||
|
protocols with any data including
|
||||||
|
.Tn TELNET
|
||||||
|
IAC character (0xff).
|
||||||
After establishing a connection, the file
|
After establishing a connection, the file
|
||||||
.Pa \&.telnetrc
|
.Pa \&.telnetrc
|
||||||
in the
|
in the
|
||||||
|
@ -217,6 +217,8 @@ send_do(int c, int init)
|
|||||||
set_my_want_state_do(c);
|
set_my_want_state_do(c);
|
||||||
do_dont_resp[c]++;
|
do_dont_resp[c]++;
|
||||||
}
|
}
|
||||||
|
if (telnetport < 0)
|
||||||
|
return;
|
||||||
NET2ADD(IAC, DO);
|
NET2ADD(IAC, DO);
|
||||||
NETADD(c);
|
NETADD(c);
|
||||||
printoption("SENT", DO, c);
|
printoption("SENT", DO, c);
|
||||||
@ -232,6 +234,8 @@ send_dont(int c, int init)
|
|||||||
set_my_want_state_dont(c);
|
set_my_want_state_dont(c);
|
||||||
do_dont_resp[c]++;
|
do_dont_resp[c]++;
|
||||||
}
|
}
|
||||||
|
if (telnetport < 0)
|
||||||
|
return;
|
||||||
NET2ADD(IAC, DONT);
|
NET2ADD(IAC, DONT);
|
||||||
NETADD(c);
|
NETADD(c);
|
||||||
printoption("SENT", DONT, c);
|
printoption("SENT", DONT, c);
|
||||||
@ -247,6 +251,8 @@ send_will(int c, int init)
|
|||||||
set_my_want_state_will(c);
|
set_my_want_state_will(c);
|
||||||
will_wont_resp[c]++;
|
will_wont_resp[c]++;
|
||||||
}
|
}
|
||||||
|
if (telnetport < 0)
|
||||||
|
return;
|
||||||
NET2ADD(IAC, WILL);
|
NET2ADD(IAC, WILL);
|
||||||
NETADD(c);
|
NETADD(c);
|
||||||
printoption("SENT", WILL, c);
|
printoption("SENT", WILL, c);
|
||||||
@ -262,6 +268,8 @@ send_wont(int c, int init)
|
|||||||
set_my_want_state_wont(c);
|
set_my_want_state_wont(c);
|
||||||
will_wont_resp[c]++;
|
will_wont_resp[c]++;
|
||||||
}
|
}
|
||||||
|
if (telnetport < 0)
|
||||||
|
return;
|
||||||
NET2ADD(IAC, WONT);
|
NET2ADD(IAC, WONT);
|
||||||
NETADD(c);
|
NETADD(c);
|
||||||
printoption("SENT", WONT, c);
|
printoption("SENT", WONT, c);
|
||||||
@ -1651,7 +1659,7 @@ telrcv(void)
|
|||||||
/* FALLTHROUGH */
|
/* FALLTHROUGH */
|
||||||
|
|
||||||
case TS_DATA:
|
case TS_DATA:
|
||||||
if (c == IAC) {
|
if (c == IAC && telnetport >= 0) {
|
||||||
telrcv_state = TS_IAC;
|
telrcv_state = TS_IAC;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -2069,7 +2077,7 @@ telnet(char *user __unusedhere)
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
if (telnetport) {
|
if (telnetport > 0) {
|
||||||
#ifdef AUTHENTICATION
|
#ifdef AUTHENTICATION
|
||||||
if (autologin)
|
if (autologin)
|
||||||
send_will(TELOPT_AUTHENTICATION, 1);
|
send_will(TELOPT_AUTHENTICATION, 1);
|
||||||
|
Loading…
Reference in New Issue
Block a user