Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10.2 9/3/84 (WLS Mods); site astrovax.UUCP Path: utzoo!watmath!clyde!burl!ulysses!allegra!princeton!astrovax!wls From: wls@astrovax.UUCP (William L. Sebok) Newsgroups: net.sources.bugs,net.news.b Subject: optimized network paths for news 2.10.2 Message-ID: <470@astrovax.UUCP> Date: Mon, 15-Oct-84 02:07:20 EDT Article-I.D.: astrovax.470 Posted: Mon Oct 15 02:07:20 1984 Date-Received: Tue, 16-Oct-84 03:16:13 EDT Distribution: net Organization: Princeton Univ. Astrophysics Lines: 273 Xref: princeton net.sources.bugs:16 net.news.b:101 The following addition to news 2.10.2 has been posted before but it is so important that I think it needs reiterating. This addition implements a C pre-processor variable NETPATHS that causes the reply command of readnews and vnews to use optimized network paths rather than the roundabout news arrival path. NETPATHS is defined in defs.h to be the name of a dbm-style file. This file, uses site names as keys, and under these keys stores the path to the site with a %s in place of a name of a user at that site. For example, under the key "sitename" might be stored the string: site1!site2!sitename!%s A file of this form can be generated with pathalias. If a site is not found in the database the path up to the first site in the news path present in the database is used. I have a somewhat different philosophy here than Chuq Von Rospach, who has optimization invoked by a -o option. Optimization is the default. It is the naive user I want make use the optimized paths. For the sophisticated user I have provided the News-path: field in the header which contains the convoluted news path. This sophisticated user can edit the full path back by hand if he/she is so inclined. I have intentionally made the user have to go to some extra work to get un-optimized paths. It is my strong belief that these additions or some other hooks for path optimizing should be part of the "official distribution". After all it is an option. With the posting of the Uucp map I do not believe that there is any excuse for replies with long paths bouncing around the net. If some hooks for path optimization are not included in the official distribution there will be no justification for the net powers to complain about the money wasted by replies passing through large numbers of sites. Bill Sebok Princeton University, Astrophysics {allegra,akgua,burl,cbosgd,decvax,ihnp4,noao,princeton,vax135}!astrovax!wls *** defs.h.ORIG Mon Oct 15 01:19:25 1984 --- defs.h Mon Oct 15 01:18:13 1984 *************** *** 47,52 /* the .newsrc */ #define ZAPNOTES /* if you want old style notes headers moved /* into the headers */ #define BSD4_2 /* if you are running 4.2 BSD */ /* #define BSD4_1C /* if you are running 4.1c BSD */ #define SENDMAIL "/usr/lib/sendmail -oi -oem" /* command line to run --- 47,54 ----- /* the .newsrc */ #define ZAPNOTES /* if you want old style notes headers moved /* into the headers */ + #define NETPATHS "/usr/lib/uucp/alpath" /* compiles in pathalias optimizing */ + /* code to read,vnews */ #define BSD4_2 /* if you are running 4.2 BSD */ /* #define BSD4_1C /* if you are running 4.1c BSD */ #define SENDMAIL "/usr/lib/sendmail -oi -oem" /* command line to run *** visual.c.ORIG Sat Oct 6 20:44:48 1984 --- visual.c Sun Oct 14 23:47:19 1984 *************** *** 17,22 #include#include "rparams.h" #if defined(BSD4_2) || defined(BSD4_1C) #include #else --- 17,28 ----- #include #include "rparams.h" + #ifdef NETPATHS + # include + # ifdef NULL + # undef NULL + # endif NULL + #endif NETPATHS #if defined(BSD4_2) || defined(BSD4_1C) #include #else *************** *** 811,816 char *replyname(); struct stat statb; time_t creatm; /* Put the user in the editor to create the body of the reply. */ ed = getenv("EDITOR"); --- 839,852 ----- char *replyname(); struct stat statb; time_t creatm; + #ifdef NETPATHS + /* stuff for finding paths in pathalias database */ + static dbmopen = 0; + static char newspaths[] = NETPATHS; + datum key, result; + register char *p1, *p2; + char sitename[100]; + #endif NETPATHS /* Put the user in the editor to create the body of the reply. */ ed = getenv("EDITOR"); *************** *** 843,851 else #endif p = replyname(h); ! fprintf(rfp, "To: %s\n", p); ! fprintf(rfp, "Subject: %s\n", subj); ! fprintf(rfp, "In-reply-to: your article %s\n", h->ident); sprintf(rcbuf, "%s -t < %s; rm -f %s", MAILPARSER, tf, tf); nogomsg = "Mail not sent"; putc('\n', rfp); --- 879,917 ----- else #endif p = replyname(h); ! #ifdef NETPATHS ! /* Use data Base to Find a reply a Path to a site */ ! if (dbmopen==0) ! dbmopen = (dbminit(newspaths)==0) ? 1 : -1 ; ! ! result.dptr = NULL; ! if (dbmopen>0) { ! for(p1 = p; (p2 = index(p1,'!'))!=NULL; p1 = p2+1); ! if (p != p1) { ! key.dptr = sitename; ! p1--; ! do { ! for (p2=p1; (p1!=p) && (*--p1!='!'); ); ! key.dsize = p2 - p1 ; ! strncpy(sitename, p1+1, key.dsize); ! sitename[key.dsize-1] = '\0'; ! result = fetch(key); ! } while ( (p1 != p) && result.dptr == NULL); ! } ! } ! if (dbmopen > 0 && result.dptr != NULL) { ! fprintf(rfp, "To: "); ! fprintf(rfp, result.dptr, p2+1); ! fprintf(rfp, "\nSubject: %s\n", subj); ! fprintf(rfp, "In-reply-to: your article %s\n", h->ident); ! fprintf(rfp, "News-path: %s\n", p); ! } else ! #endif NETPATHS ! { ! fprintf(rfp, "To: %s\n", p); ! fprintf(rfp, "Subject: %s\n", subj); ! fprintf(rfp, "In-reply-to: your article %s\n", h->ident); ! } sprintf(rcbuf, "%s -t < %s; rm -f %s", MAILPARSER, tf, tf); nogomsg = "Mail not sent"; putc('\n', rfp); ******************** *** readr.c.ORIG Sat Oct 6 20:13:40 1984 --- readr.c Sun Oct 14 23:48:24 1984 *************** *** 7,12 #endif !lint #include "rparams.h" #if defined(BSD4_2) || defined(BSD4_1C) #include #else --- 7,20 ----- #endif !lint #include "rparams.h" + + #ifdef NETPATHS + # include + # ifdef NULL + # undef NULL + # endif NULL + #endif NETPATHS + #if defined(BSD4_2) || defined(BSD4_1C) #include #else *************** *** 616,621 char folbuf[BUFLEN]; struct stat statb; long creatm; hptr = h; while (*bptr && index("d-", *bptr)) { --- 644,657 ----- char folbuf[BUFLEN]; struct stat statb; long creatm; + #ifdef NETPATHS + /* stuff for finding paths from pathalias database */ + static int dbmopen = 0; + static char newspaths[] = NETPATHS; + datum key, result; + register char *p1, *p2; + char sitename[100]; + #endif NETPATHS hptr = h; *************** *** 649,654 *rcbuf = '\0'; pathptr = replyname(hptr);; for (ptr1 = address, ptr2 = pathptr; *ptr2; ptr1++, ptr2++) { if (index("\"\\$", *ptr2)) *ptr1++ = '\\'; --- 686,717 ----- *rcbuf = '\0'; pathptr = replyname(hptr);; + #ifdef NETPATHS + /* Use data Base to Find a reply a Path to a site --- W. Sebok */ + if (dbmopen==0) + dbmopen = (dbminit(newspaths)==0) ? 1 : -1 ; + + result.dptr = NULL; + if (dbmopen>0) { + for(p1 = pathptr; (p2 = index(p1,'!')) != NULL; p1 = p2+1); + if (pathptr != p1) { + key.dptr = sitename; + p1--; + do { + for ( p2=p1; (p1!=pathptr) && (*--p1 != '!'); ); + key.dsize = p2 - p1 ; + strncpy(sitename, p1+1, key.dsize); + sitename[key.dsize-1] = '\0'; + result = fetch(key); + } while ( (p1 != pathptr) && result.dptr==NULL); + } + } + if (result.dptr != NULL) { + sprintf(sitename, result.dptr, p2+1); + p1 = pathptr; + pathptr = sitename; + } + #endif NETPATHS for (ptr1 = address, ptr2 = pathptr; *ptr2; ptr1++, ptr2++) { if (index("\"\\$", *ptr2)) *ptr1++ = '\\'; *************** *** 695,700 } else { fprintf(tfp, "To: %s\n", pathptr); fprintf(tfp, "Subject: %s\n", subj); fprintf(tfp, "References: %s\n\n", folbuf); fstat(fileno(tfp), &statb); creatm = statb.st_mtime; --- 758,767 ----- } else { fprintf(tfp, "To: %s\n", pathptr); fprintf(tfp, "Subject: %s\n", subj); + #ifdef NETPATHS + if (dbmopen > 0 && result.dptr != NULL) + fprintf(tfp,"News-path: %s\n",p1); + #endif NETPATHS fprintf(tfp, "References: %s\n\n", folbuf); fstat(fileno(tfp), &statb); creatm = statb.st_mtime; ************ -- Bill Sebok Princeton University, Astrophysics {allegra,akgua,burl,cbosgd,decvax,ihnp4,noao,princeton,vax135}!astrovax!wls