tech-userlevel archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

ftp: verboselevel 1/2



Hi,

for domain names that resolve to multiple addresses, our ftp 
when verbose displays them when trying to connect to them.

When not verbose, it only ever displays the hostname if at all.

Sometimes, it is necessary to find out what exactly did work in
the recent past or sometimes, as much as what doesn't work now.

I have a patch lying around that adds peer address display to
the "connected" messages if (!verbose && interactive) (see below);
do we want that in-tree?

Regards,
	-is


Index: ftp.c
===================================================================
RCS file: /cvsroot/src/usr.bin/ftp/ftp.c,v
retrieving revision 1.166
diff -u -r1.166 ftp.c
--- ftp.c	13 Dec 2015 14:06:13 -0000	1.166
+++ ftp.c	27 Aug 2016 11:28:09 -0000
@@ -271,6 +271,23 @@
 	}
 	if (verbose)
 		fprintf(ttyout, "Connected to %s.\n", hostname);
+	else if (interactive) {
+		char	hname[NI_MAXHOST];
+		char	sname[NI_MAXSERV];
+
+		if (getnameinfo((struct sockaddr *)&hisctladdr.si_su,
+		    hisctladdr.su_len, hname, sizeof(hname), sname,
+		    sizeof(sname), NI_NUMERICHOST | NI_NUMERICSERV) != 0) {
+
+			strlcpy(hname, "?", sizeof(hname));
+			strlcpy(sname, "?", sizeof(sname));
+		}
+
+		fprintf(ttyout, "Connected to %s ([%s]:%s).\n", hostname,
+			hname, sname);
+	}
+	
+
 	if (getreply(0) > 2) {	/* read startup message from server */
 		if (cin)
 			(void)fclose(cin);


Home | Main Index | Thread Index | Old Index