|
|
4055a3 |
diff -up screen/src/doc/screen.1.ipv6 screen/src/doc/screen.1
|
|
|
4055a3 |
--- screen/src/doc/screen.1.ipv6 2010-11-11 03:47:46.000000000 +0100
|
|
|
4055a3 |
+++ screen/src/doc/screen.1 2011-02-03 16:05:35.957087079 +0100
|
|
|
4055a3 |
@@ -398,6 +398,12 @@ Send the specified command to a running
|
|
|
4055a3 |
the \fB-d\fP or \fB-r\fP option to tell screen to look only for
|
|
|
4055a3 |
attached or detached screen sessions. Note that this command doesn't
|
|
|
4055a3 |
work if the session is password protected.
|
|
|
4055a3 |
+.TP 5
|
|
|
4055a3 |
+.B \-4
|
|
|
4055a3 |
+Resolve hostnames only to IPv4 addresses.
|
|
|
4055a3 |
+.TP 5
|
|
|
4055a3 |
+.B \-6
|
|
|
4055a3 |
+Resolve hostnames only to IPv6 addresses.
|
|
|
4055a3 |
|
|
|
4055a3 |
.SH "DEFAULT KEY BINDINGS"
|
|
|
4055a3 |
.ta 12n 26n
|
|
|
4055a3 |
diff -up screen/src/extern.h.ipv6 screen/src/extern.h
|
|
|
4055a3 |
--- screen/src/extern.h.ipv6 2010-11-11 03:47:46.000000000 +0100
|
|
|
4055a3 |
+++ screen/src/extern.h 2011-02-03 16:04:35.995743620 +0100
|
|
|
4055a3 |
@@ -455,8 +455,7 @@ extern void ExitOverlayPage __P((void))
|
|
|
4055a3 |
|
|
|
4055a3 |
/* teln.c */
|
|
|
4055a3 |
#ifdef BUILTIN_TELNET
|
|
|
4055a3 |
-extern int TelOpen __P((char **));
|
|
|
4055a3 |
-extern int TelConnect __P((struct win *));
|
|
|
4055a3 |
+extern int TelOpenAndConnect __P((struct win *));
|
|
|
4055a3 |
extern int TelIsline __P((struct win *p));
|
|
|
4055a3 |
extern void TelProcessLine __P((char **, int *));
|
|
|
4055a3 |
extern int DoTelnet __P((char *, int *, int));
|
|
|
4055a3 |
diff -up screen/src/help.c.ipv6 screen/src/help.c
|
|
|
4055a3 |
--- screen/src/help.c.ipv6 2010-11-11 03:47:46.000000000 +0100
|
|
|
4055a3 |
+++ screen/src/help.c 2011-02-03 16:04:35.992744154 +0100
|
|
|
4055a3 |
@@ -66,6 +66,10 @@ char *myname, *message, *arg;
|
|
|
4055a3 |
{
|
|
|
4055a3 |
printf("Use: %s [-opts] [cmd [args]]\n", myname);
|
|
|
4055a3 |
printf(" or: %s -r [host.tty]\n\nOptions:\n", myname);
|
|
|
4055a3 |
+#ifdef BUILTIN_TELNET
|
|
|
4055a3 |
+ printf("-4 Resolve hostnames only to IPv4 addresses.\n");
|
|
|
4055a3 |
+ printf("-6 Resolve hostnames only to IPv6 addresses.\n");
|
|
|
4055a3 |
+#endif
|
|
|
4055a3 |
printf("-a Force all capabilities into each window's termcap.\n");
|
|
|
4055a3 |
printf("-A -[r|R] Adapt all windows to the new display width & height.\n");
|
|
|
4055a3 |
printf("-c file Read configuration file instead of '.screenrc'.\n");
|
|
|
4055a3 |
diff -up screen/src/screen.c.ipv6 screen/src/screen.c
|
|
|
4055a3 |
--- screen/src/screen.c.ipv6 2010-11-11 03:47:46.000000000 +0100
|
|
|
4055a3 |
+++ screen/src/screen.c 2011-02-03 16:04:35.994743798 +0100
|
|
|
4055a3 |
@@ -248,8 +248,9 @@ struct layer *flayer;
|
|
|
4055a3 |
struct win *fore;
|
|
|
4055a3 |
struct win *windows;
|
|
|
4055a3 |
struct win *console_window;
|
|
|
4055a3 |
-
|
|
|
4055a3 |
-
|
|
|
4055a3 |
+#ifdef BUILTIN_TELNET
|
|
|
4055a3 |
+int af;
|
|
|
4055a3 |
+#endif
|
|
|
4055a3 |
|
|
|
4055a3 |
/*
|
|
|
4055a3 |
* Do this last
|
|
|
4055a3 |
@@ -507,6 +508,9 @@ char **av;
|
|
|
4055a3 |
nwin = nwin_undef;
|
|
|
4055a3 |
nwin_options = nwin_undef;
|
|
|
4055a3 |
strcpy(screenterm, "screen");
|
|
|
4055a3 |
+#ifdef BUILTIN_TELNET
|
|
|
4055a3 |
+ af = AF_UNSPEC;
|
|
|
4055a3 |
+#endif
|
|
|
4055a3 |
|
|
|
4055a3 |
logreopen_register(lf_secreopen);
|
|
|
4055a3 |
|
|
|
4055a3 |
@@ -541,6 +545,14 @@ char **av;
|
|
|
4055a3 |
{
|
|
|
4055a3 |
switch (*ap)
|
|
|
4055a3 |
{
|
|
|
4055a3 |
+#ifdef BUILTIN_TELNET
|
|
|
4055a3 |
+ case '4':
|
|
|
4055a3 |
+ af = AF_INET;
|
|
|
4055a3 |
+ break;
|
|
|
4055a3 |
+ case '6':
|
|
|
4055a3 |
+ af = AF_INET6;
|
|
|
4055a3 |
+ break;
|
|
|
4055a3 |
+#endif
|
|
|
4055a3 |
case 'a':
|
|
|
4055a3 |
nwin_options.aflag = 1;
|
|
|
4055a3 |
break;
|
|
|
4055a3 |
diff -up screen/src/teln.c.ipv6 screen/src/teln.c
|
|
|
4055a3 |
--- screen/src/teln.c.ipv6 2010-11-11 03:47:46.000000000 +0100
|
|
|
4055a3 |
+++ screen/src/teln.c 2011-02-03 16:04:35.992744154 +0100
|
|
|
4055a3 |
@@ -30,6 +30,7 @@
|
|
|
4055a3 |
#include <sys/socket.h>
|
|
|
4055a3 |
#include <fcntl.h>
|
|
|
4055a3 |
#include <netdb.h>
|
|
|
4055a3 |
+#include <stdio.h>
|
|
|
4055a3 |
|
|
|
4055a3 |
#include "config.h"
|
|
|
4055a3 |
|
|
|
4055a3 |
@@ -42,12 +43,13 @@ extern struct win *fore;
|
|
|
4055a3 |
extern struct layer *flayer;
|
|
|
4055a3 |
extern int visual_bell;
|
|
|
4055a3 |
extern char screenterm[];
|
|
|
4055a3 |
+extern int af;
|
|
|
4055a3 |
|
|
|
4055a3 |
static void TelReply __P((struct win *, char *, int));
|
|
|
4055a3 |
static void TelDocmd __P((struct win *, int, int));
|
|
|
4055a3 |
static void TelDosub __P((struct win *));
|
|
|
4055a3 |
-
|
|
|
4055a3 |
-#define TEL_DEFPORT 23
|
|
|
4055a3 |
+// why TEL_DEFPORT has "
|
|
|
4055a3 |
+#define TEL_DEFPORT "23"
|
|
|
4055a3 |
#define TEL_CONNECTING (-2)
|
|
|
4055a3 |
|
|
|
4055a3 |
#define TC_IAC 255
|
|
|
4055a3 |
@@ -105,86 +107,78 @@ char *data;
|
|
|
4055a3 |
}
|
|
|
4055a3 |
|
|
|
4055a3 |
int
|
|
|
4055a3 |
-TelOpen(args)
|
|
|
4055a3 |
-char **args;
|
|
|
4055a3 |
-{
|
|
|
4055a3 |
- int fd;
|
|
|
4055a3 |
- int on = 1;
|
|
|
4055a3 |
-
|
|
|
4055a3 |
- if ((fd = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP)) == -1)
|
|
|
4055a3 |
- {
|
|
|
4055a3 |
- Msg(errno, "TelOpen: socket");
|
|
|
4055a3 |
- return -1;
|
|
|
4055a3 |
- }
|
|
|
4055a3 |
- if (setsockopt(fd, SOL_SOCKET, SO_OOBINLINE, (char *)&on, sizeof(on)))
|
|
|
4055a3 |
- Msg(errno, "TelOpen: setsockopt SO_OOBINLINE");
|
|
|
4055a3 |
- return fd;
|
|
|
4055a3 |
-}
|
|
|
4055a3 |
-
|
|
|
4055a3 |
-int
|
|
|
4055a3 |
-TelConnect(p)
|
|
|
4055a3 |
-struct win *p;
|
|
|
4055a3 |
-{
|
|
|
4055a3 |
- int port = TEL_DEFPORT;
|
|
|
4055a3 |
- struct hostent *hp;
|
|
|
4055a3 |
- char **args;
|
|
|
4055a3 |
+TelOpenAndConnect(struct win *p) {
|
|
|
4055a3 |
+ int fd, on = 1;
|
|
|
4055a3 |
char buf[256];
|
|
|
4055a3 |
|
|
|
4055a3 |
- args = p->w_cmdargs + 1;
|
|
|
4055a3 |
-
|
|
|
4055a3 |
- if (!*args)
|
|
|
4055a3 |
- {
|
|
|
4055a3 |
- Msg(0, "Usage: screen //telnet host [port]");
|
|
|
4055a3 |
- return -1;
|
|
|
4055a3 |
- }
|
|
|
4055a3 |
- if (args[1])
|
|
|
4055a3 |
- port = atoi(args[1]);
|
|
|
4055a3 |
- p->w_telsa.sin_family = AF_INET;
|
|
|
4055a3 |
- if((p->w_telsa.sin_addr.s_addr = inet_addr(*args)) == -1)
|
|
|
4055a3 |
- {
|
|
|
4055a3 |
- if ((hp = gethostbyname(*args)) == NULL)
|
|
|
4055a3 |
- {
|
|
|
4055a3 |
- Msg(0, "unknown host: %s", *args);
|
|
|
4055a3 |
- return -1;
|
|
|
4055a3 |
- }
|
|
|
4055a3 |
- if (hp->h_length != sizeof(p->w_telsa.sin_addr.s_addr) || hp->h_addrtype != AF_INET)
|
|
|
4055a3 |
- {
|
|
|
4055a3 |
- Msg(0, "Bad address type for %s", hp->h_name);
|
|
|
4055a3 |
- return -1;
|
|
|
4055a3 |
- }
|
|
|
4055a3 |
- bcopy((char *)hp->h_addr,(char *)&p->w_telsa.sin_addr.s_addr, hp->h_length);
|
|
|
4055a3 |
- p->w_telsa.sin_family = hp->h_addrtype;
|
|
|
4055a3 |
- }
|
|
|
4055a3 |
- p->w_telsa.sin_port = htons(port);
|
|
|
4055a3 |
- if (port != TEL_DEFPORT)
|
|
|
4055a3 |
- sprintf(buf, "Trying %s %d...", inet_ntoa(p->w_telsa.sin_addr), port);
|
|
|
4055a3 |
- else
|
|
|
4055a3 |
- sprintf(buf, "Trying %s...", inet_ntoa(p->w_telsa.sin_addr));
|
|
|
4055a3 |
- WriteString(p, buf, strlen(buf));
|
|
|
4055a3 |
- if (connect(p->w_ptyfd, (struct sockaddr *)&p->w_telsa, sizeof(p->w_telsa)))
|
|
|
4055a3 |
- {
|
|
|
4055a3 |
- if (errno == EINPROGRESS)
|
|
|
4055a3 |
- {
|
|
|
4055a3 |
- p->w_telstate = TEL_CONNECTING;
|
|
|
4055a3 |
- p->w_telconnev.fd = p->w_ptyfd;
|
|
|
4055a3 |
- p->w_telconnev.handler = tel_connev_fn;
|
|
|
4055a3 |
- p->w_telconnev.data = (char *)p;
|
|
|
4055a3 |
- p->w_telconnev.type = EV_WRITE;
|
|
|
4055a3 |
- p->w_telconnev.pri = 1;
|
|
|
4055a3 |
- debug("telnet connect in progress...\n");
|
|
|
4055a3 |
- evenq(&p->w_telconnev);
|
|
|
4055a3 |
- }
|
|
|
4055a3 |
- else
|
|
|
4055a3 |
- {
|
|
|
4055a3 |
- Msg(errno, "TelOpen: connect");
|
|
|
4055a3 |
- return -1;
|
|
|
4055a3 |
- }
|
|
|
4055a3 |
- }
|
|
|
4055a3 |
- else
|
|
|
4055a3 |
- WriteString(p, "connected.\r\n", 12);
|
|
|
4055a3 |
- if (port == TEL_DEFPORT)
|
|
|
4055a3 |
- TelReply(p, (char *)tn_init, sizeof(tn_init));
|
|
|
4055a3 |
- return 0;
|
|
|
4055a3 |
+ struct addrinfo hints, *res0, *res;
|
|
|
4055a3 |
+
|
|
|
4055a3 |
+ if (!(p->w_cmdargs[1])) {
|
|
|
4055a3 |
+ Msg(0, "Usage: screen //telnet host [port]");
|
|
|
4055a3 |
+ return -1;
|
|
|
4055a3 |
+ }
|
|
|
4055a3 |
+
|
|
|
4055a3 |
+ memset(&hints, 0, sizeof(hints));
|
|
|
4055a3 |
+ hints.ai_family = af;
|
|
|
4055a3 |
+ hints.ai_socktype = SOCK_STREAM;
|
|
|
4055a3 |
+ hints.ai_protocol = IPPROTO_TCP;
|
|
|
4055a3 |
+ if(getaddrinfo(p->w_cmdargs[1], p->w_cmdargs[2] ? p->w_cmdargs[2] : TEL_DEFPORT,
|
|
|
4055a3 |
+ &hints, &res0)) {
|
|
|
4055a3 |
+ Msg(0, "unknown host: %s", p->w_cmdargs[1]);
|
|
|
4055a3 |
+ return -1;
|
|
|
4055a3 |
+ }
|
|
|
4055a3 |
+
|
|
|
4055a3 |
+ for(res = res0; res; res = res->ai_next) {
|
|
|
4055a3 |
+ if((fd = socket(res->ai_family, res->ai_socktype, res->ai_protocol)) == -1) {
|
|
|
4055a3 |
+ if(res->ai_next)
|
|
|
4055a3 |
+ continue;
|
|
|
4055a3 |
+ else {
|
|
|
4055a3 |
+ Msg(errno, "TelOpenAndConnect: socket");
|
|
|
4055a3 |
+ freeaddrinfo(res0);
|
|
|
4055a3 |
+ return -1;
|
|
|
4055a3 |
+ }
|
|
|
4055a3 |
+ }
|
|
|
4055a3 |
+
|
|
|
4055a3 |
+ if (setsockopt(fd, SOL_SOCKET, SO_OOBINLINE, (char *)&on, sizeof(on)))
|
|
|
4055a3 |
+ Msg(errno, "TelOpenAndConnect: setsockopt SO_OOBINLINE");
|
|
|
4055a3 |
+
|
|
|
4055a3 |
+ if (p->w_cmdargs[2] && strcmp(p->w_cmdargs[2], TEL_DEFPORT))
|
|
|
4055a3 |
+ snprintf(buf, 256, "Trying %s %s...", p->w_cmdargs[1], p->w_cmdargs[2]);
|
|
|
4055a3 |
+ else
|
|
|
4055a3 |
+ snprintf(buf, 256, "Trying %s...", p->w_cmdargs[1]);
|
|
|
4055a3 |
+ WriteString(p, buf, strlen(buf));
|
|
|
4055a3 |
+ if (connect(fd, res->ai_addr, res->ai_addrlen)) {
|
|
|
4055a3 |
+ if (errno == EINPROGRESS) {
|
|
|
4055a3 |
+ p->w_telstate = TEL_CONNECTING;
|
|
|
4055a3 |
+ p->w_telconnev.fd = fd;
|
|
|
4055a3 |
+ p->w_telconnev.handler = tel_connev_fn;
|
|
|
4055a3 |
+ p->w_telconnev.data = (char *)p;
|
|
|
4055a3 |
+ p->w_telconnev.type = EV_WRITE;
|
|
|
4055a3 |
+ p->w_telconnev.pri = 1;
|
|
|
4055a3 |
+ debug("telnet connect in progress...\n");
|
|
|
4055a3 |
+ evenq(&p->w_telconnev);
|
|
|
4055a3 |
+ }
|
|
|
4055a3 |
+ else {
|
|
|
4055a3 |
+ close(fd);
|
|
|
4055a3 |
+ if(res->ai_next)
|
|
|
4055a3 |
+ continue;
|
|
|
4055a3 |
+ else {
|
|
|
4055a3 |
+ Msg(errno, "TelOpenAndConnect: connect");
|
|
|
4055a3 |
+ freeaddrinfo(res0);
|
|
|
4055a3 |
+ return -1;
|
|
|
4055a3 |
+ }
|
|
|
4055a3 |
+ }
|
|
|
4055a3 |
+ }
|
|
|
4055a3 |
+ else
|
|
|
4055a3 |
+ WriteString(p, "connected.\r\n", 12);
|
|
|
4055a3 |
+ if (!(p->w_cmdargs[2] && strcmp(p->w_cmdargs[2], TEL_DEFPORT)))
|
|
|
4055a3 |
+ TelReply(p, (char *)tn_init, sizeof(tn_init));
|
|
|
4055a3 |
+ p->w_ptyfd = fd;
|
|
|
4055a3 |
+ memcpy(&p->w_telsa, &res->ai_addr, sizeof(res->ai_addr));
|
|
|
4055a3 |
+ freeaddrinfo(res0);
|
|
|
4055a3 |
+ return 0;
|
|
|
4055a3 |
+ }
|
|
|
4055a3 |
+ return -1;
|
|
|
4055a3 |
}
|
|
|
4055a3 |
|
|
|
4055a3 |
int
|
|
|
4055a3 |
diff -up screen/src/window.c.ipv6 screen/src/window.c
|
|
|
4055a3 |
--- screen/src/window.c.ipv6 2010-11-11 03:47:46.000000000 +0100
|
|
|
4055a3 |
+++ screen/src/window.c 2011-02-03 16:30:56.900750293 +0100
|
|
|
4055a3 |
@@ -605,6 +605,13 @@ struct NewWindow *newwin;
|
|
|
4055a3 |
n = pp - wtab;
|
|
|
4055a3 |
debug1("Makewin creating %d\n", n);
|
|
|
4055a3 |
|
|
|
4055a3 |
+#ifdef BUILTIN_TELNET
|
|
|
4055a3 |
+ if(!strcmp(nwin.args[0], "//telnet")) {
|
|
|
4055a3 |
+ type = W_TYPE_TELNET;
|
|
|
4055a3 |
+ TtyName = "telnet";
|
|
|
4055a3 |
+ }
|
|
|
4055a3 |
+ else
|
|
|
4055a3 |
+#endif
|
|
|
4055a3 |
if ((f = OpenDevice(nwin.args, nwin.lflag, &type, &TtyName)) < 0)
|
|
|
4055a3 |
return -1;
|
|
|
4055a3 |
if (type == W_TYPE_GROUP)
|
|
|
4055a3 |
@@ -766,7 +773,7 @@ struct NewWindow *newwin;
|
|
|
4055a3 |
#ifdef BUILTIN_TELNET
|
|
|
4055a3 |
if (type == W_TYPE_TELNET)
|
|
|
4055a3 |
{
|
|
|
4055a3 |
- if (TelConnect(p))
|
|
|
4055a3 |
+ if (TelOpenAndConnect(p))
|
|
|
4055a3 |
{
|
|
|
4055a3 |
FreeWindow(p);
|
|
|
4055a3 |
return -1;
|
|
|
4055a3 |
@@ -878,6 +885,13 @@ struct win *p;
|
|
|
4055a3 |
int lflag, f;
|
|
|
4055a3 |
|
|
|
4055a3 |
lflag = nwin_default.lflag;
|
|
|
4055a3 |
+#ifdef BUILTIN_TELNET
|
|
|
4055a3 |
+ if(!strcmp(p->w_cmdargs[0], "//telnet")) {
|
|
|
4055a3 |
+ p->w_type = W_TYPE_TELNET;
|
|
|
4055a3 |
+ TtyName = "telnet";
|
|
|
4055a3 |
+ }
|
|
|
4055a3 |
+ else
|
|
|
4055a3 |
+#endif
|
|
|
4055a3 |
if ((f = OpenDevice(p->w_cmdargs, lflag, &p->w_type, &TtyName)) < 0)
|
|
|
4055a3 |
return -1;
|
|
|
4055a3 |
|
|
|
4055a3 |
@@ -909,7 +923,7 @@ struct win *p;
|
|
|
4055a3 |
#ifdef BUILTIN_TELNET
|
|
|
4055a3 |
if (p->w_type == W_TYPE_TELNET)
|
|
|
4055a3 |
{
|
|
|
4055a3 |
- if (TelConnect(p))
|
|
|
4055a3 |
+ if (TelOpenAndConnect(p))
|
|
|
4055a3 |
return -1;
|
|
|
4055a3 |
}
|
|
|
4055a3 |
else
|
|
|
4055a3 |
@@ -1068,16 +1082,6 @@ char **namep;
|
|
|
4055a3 |
*namep = "telnet";
|
|
|
4055a3 |
return 0;
|
|
|
4055a3 |
}
|
|
|
4055a3 |
-#ifdef BUILTIN_TELNET
|
|
|
4055a3 |
- if (strcmp(arg, "//telnet") == 0)
|
|
|
4055a3 |
- {
|
|
|
4055a3 |
- f = TelOpen(args + 1);
|
|
|
4055a3 |
- lflag = 0;
|
|
|
4055a3 |
- *typep = W_TYPE_TELNET;
|
|
|
4055a3 |
- *namep = "telnet";
|
|
|
4055a3 |
- }
|
|
|
4055a3 |
- else
|
|
|
4055a3 |
-#endif
|
|
|
4055a3 |
if (strncmp(arg, "//", 2) == 0)
|
|
|
4055a3 |
{
|
|
|
4055a3 |
Msg(0, "Invalid argument '%s'", arg);
|
|
|
4055a3 |
diff -up screen/src/window.h.ipv6 screen/src/window.h
|
|
|
4055a3 |
--- screen/src/window.h.ipv6 2010-11-11 03:47:46.000000000 +0100
|
|
|
4055a3 |
+++ screen/src/window.h 2011-02-03 16:04:35.989744687 +0100
|
|
|
4055a3 |
@@ -268,7 +268,7 @@ struct win
|
|
|
4055a3 |
struct display *w_zdisplay;
|
|
|
4055a3 |
#endif
|
|
|
4055a3 |
#ifdef BUILTIN_TELNET
|
|
|
4055a3 |
- struct sockaddr_in w_telsa;
|
|
|
4055a3 |
+ struct sockaddr_storage w_telsa;
|
|
|
4055a3 |
char w_telbuf[IOSIZE];
|
|
|
4055a3 |
int w_telbufl;
|
|
|
4055a3 |
char w_telmopts[256];
|