diff options
author | 1998-04-27 15:45:47 +0000 | |
---|---|---|
committer | 1998-04-27 15:45:47 +0000 | |
commit | e33816fe1a5525445e251e1f79e10f37413d2210 (patch) | |
tree | cb8b2922fe3d42137934cd2936a2f7ddf0cf0a48 | |
parent | make the appropriate audio devices (diff) | |
download | wireguard-openbsd-e33816fe1a5525445e251e1f79e10f37413d2210.tar.xz wireguard-openbsd-e33816fe1a5525445e251e1f79e10f37413d2210.zip |
Historically, talk pays no attention to hostnames, so if you've typed
'talk aaa@b' and are waiting for a response, and user aaa@c tries to talk
to you, you'll be transparently connected. Now, talk will print the hostname
of the remote party if it's not the same host that you asked for.
-rw-r--r-- | usr.bin/talk/Makefile | 6 | ||||
-rw-r--r-- | usr.bin/talk/invite.c | 40 | ||||
-rw-r--r-- | usr.bin/talk/io.c | 8 | ||||
-rw-r--r-- | usr.bin/talk/talk.1 | 6 |
4 files changed, 46 insertions, 14 deletions
diff --git a/usr.bin/talk/Makefile b/usr.bin/talk/Makefile index 4548b7a59fd..42cc2c0f6d4 100644 --- a/usr.bin/talk/Makefile +++ b/usr.bin/talk/Makefile @@ -1,8 +1,8 @@ -# $OpenBSD: Makefile,v 1.4 1997/09/21 11:51:06 deraadt Exp $ +# $OpenBSD: Makefile,v 1.5 1998/04/27 15:45:47 pjanzen Exp $ PROG= talk -DPADD= ${LIBCURSES} ${LIBTERMLIB} ${LIBCOMPAT} -LDADD= -lcurses -ltermlib -lcompat +DPADD= ${LIBCURSES} ${LIBTERMLIB} +LDADD= -lcurses -ltermlib SRCS= ctl.c ctl_transact.c display.c get_addrs.c get_names.c \ init_disp.c invite.c io.c look_up.c msgs.c talk.c diff --git a/usr.bin/talk/invite.c b/usr.bin/talk/invite.c index db0bc5427e6..b57f1f1c970 100644 --- a/usr.bin/talk/invite.c +++ b/usr.bin/talk/invite.c @@ -1,4 +1,4 @@ -/* $OpenBSD: invite.c,v 1.3 1996/06/26 05:40:23 deraadt Exp $ */ +/* $OpenBSD: invite.c,v 1.4 1998/04/27 15:45:49 pjanzen Exp $ */ /* $NetBSD: invite.c,v 1.3 1994/12/09 02:14:18 jtc Exp $ */ /* @@ -38,7 +38,7 @@ #if 0 static char sccsid[] = "@(#)invite.c 8.1 (Berkeley) 6/6/93"; #endif -static char rcsid[] = "$OpenBSD: invite.c,v 1.3 1996/06/26 05:40:23 deraadt Exp $"; +static char rcsid[] = "$OpenBSD: invite.c,v 1.4 1998/04/27 15:45:49 pjanzen Exp $"; #endif /* not lint */ #include <sys/types.h> @@ -46,12 +46,15 @@ static char rcsid[] = "$OpenBSD: invite.c,v 1.3 1996/06/26 05:40:23 deraadt Exp #include <sys/time.h> #include <signal.h> #include <netinet/in.h> +#include <netdb.h> #include <protocols/talkd.h> #include <errno.h> #include <setjmp.h> #include "talk_ctl.h" #include "talk.h" +#define STRING_LENGTH 158 + /* * There wasn't an invitation waiting, so send a request containing * our sockt address to the remote talk daemon so it can invite @@ -73,6 +76,10 @@ invite_remote() int nfd, read_mask, template, new_sockt; struct itimerval itimer; CTL_RESPONSE response; + struct sockaddr rp; + int rplen = sizeof(struct sockaddr); + struct hostent *rphost; + char rname[STRING_LENGTH]; itimer.it_value.tv_sec = RING_WAIT; itimer.it_value.tv_usec = 0; @@ -91,14 +98,17 @@ invite_remote() announce_invite(); /* * Shut off the automatic messages for a while, - * so we can use the interupt timer to resend the invitation + * so we can use the interrupt timer to resend the invitation. + * We no longer turn automatic messages back on to avoid a bonus + * message after we've connected; this is okay even though end_msgs() + * gets called again in main(). */ end_msgs(); setitimer(ITIMER_REAL, &itimer, (struct itimerval *)0); message("Waiting for your party to respond"); signal(SIGALRM, re_invite); (void) setjmp(invitebuf); - while ((new_sockt = accept(sockt, 0, 0)) < 0) { + while ((new_sockt = accept(sockt, &rp, &rplen)) < 0) { if (errno == EINTR) continue; p_error("Unable to connect with your party"); @@ -110,14 +120,30 @@ invite_remote() * Have the daemons delete the invitations now that we * have connected. */ - current_state = "Waiting for your party to respond"; - start_msgs(); - msg.id_num = htonl(local_id); ctl_transact(my_machine_addr, msg, DELETE, &response); msg.id_num = htonl(remote_id); ctl_transact(his_machine_addr, msg, DELETE, &response); invitation_waiting = 0; + + /* + * Check to see if the other guy is coming from the machine + * we expect. + */ + if (his_machine_addr.s_addr != + ((struct sockaddr_in *)&rp)->sin_addr.s_addr) { + rphost = gethostbyaddr((char *) &((struct sockaddr_in + *)&rp)->sin_addr, sizeof(struct in_addr), AF_INET); + if (rphost) + snprintf(rname, STRING_LENGTH, + "Answering talk request from %s@%s", msg.r_name, + rphost->h_name); + else + snprintf(rname, STRING_LENGTH, + "Answering talk request from %s@%s", msg.r_name, + inet_ntoa(((struct sockaddr_in *)&rp)->sin_addr)); + message(rname); + } } /* diff --git a/usr.bin/talk/io.c b/usr.bin/talk/io.c index a39c34d4bd8..e1ddb6ec4bd 100644 --- a/usr.bin/talk/io.c +++ b/usr.bin/talk/io.c @@ -1,4 +1,4 @@ -/* $OpenBSD: io.c,v 1.3 1996/06/26 05:40:23 deraadt Exp $ */ +/* $OpenBSD: io.c,v 1.4 1998/04/27 15:45:50 pjanzen Exp $ */ /* $NetBSD: io.c,v 1.4 1994/12/09 02:14:20 jtc Exp $ */ /* @@ -38,7 +38,7 @@ #if 0 static char sccsid[] = "@(#)io.c 8.1 (Berkeley) 6/6/93"; #endif -static char rcsid[] = "$OpenBSD: io.c,v 1.3 1996/06/26 05:40:23 deraadt Exp $"; +static char rcsid[] = "$OpenBSD: io.c,v 1.4 1998/04/27 15:45:50 pjanzen Exp $"; #endif /* not lint */ /* @@ -70,9 +70,13 @@ talk() #ifdef NCURSES_VERSION message("Connection established"); + /* + * beep() doesn't flush output on its own. + */ beep(); beep(); beep(); + refresh(); #else message("Connection established\007\007\007"); #endif diff --git a/usr.bin/talk/talk.1 b/usr.bin/talk/talk.1 index e197d4462b7..40d6e09b43a 100644 --- a/usr.bin/talk/talk.1 +++ b/usr.bin/talk/talk.1 @@ -1,4 +1,4 @@ -.\" $OpenBSD: talk.1,v 1.2 1996/06/26 05:40:25 deraadt Exp $ +.\" $OpenBSD: talk.1,v 1.3 1998/04/27 15:45:51 pjanzen Exp $ .\" $NetBSD: talk.1,v 1.3 1994/12/09 02:14:23 jtc Exp $ .\" .\" Copyright (c) 1983, 1990, 1993 @@ -84,7 +84,9 @@ of the message should reply by typing .Dl talk \ your_name@your_machine .Pp It doesn't matter from which machine the recipient replies, as -long as his login-name is the same. Once communication is established, +long as his login-name is the same. If the machine is not the one to which +the talk request was sent, it is noted on the screen. +Once communication is established, the two parties may type simultaneously, with their output appearing in separate windows. Typing control-L .Ql ^L |