home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #16 / NN_1992_16.iso / spool / alt / gopher / 1126 < prev    next >
Encoding:
Text File  |  1992-07-30  |  20.0 KB  |  740 lines

  1. Newsgroups: alt.gopher
  2. Path: sparky!uunet!stanford.edu!leland.Stanford.EDU!schemers
  3. From: schemers@leland.Stanford.EDU (Roland Schemers)
  4. Subject: go4gw.shar HOSED! 
  5. Message-ID: <1992Jul30.191211.28273@leland.Stanford.EDU>
  6. Sender: news@leland.Stanford.EDU (Mr News)
  7. Organization: Distributed Computing Group, Stanford University
  8. References: <Bs687G.8Cp@knot.ccs.queensu.ca> <1992Jul30.002659.17260@leland.Stanford.EDU> <1992Jul30.074045.15852@leland.Stanford.EDU>
  9. Date: Thu, 30 Jul 92 19:12:11 GMT
  10. Lines: 728
  11.  
  12. Sorry! go4gw.shar was hosed on boombox and my previous posting.  A couple
  13. of files had an imcomplete last line (no \n at the end) and thus they
  14. really hosed up shar!
  15.  
  16. Sorry! Here is a shar file that really works! I was up TOO late last night :-)
  17.  
  18. Roland
  19.  
  20.  
  21. #! /bin/sh
  22. # This is a shell archive.  Remove anything before this line, then unpack
  23. # it by saving it into a file and typing "sh file".  To overwrite existing
  24. # files, type "sh file -c".  You can also feed this as standard input via
  25. # unshar, or by typing "sh <file", e.g..  If this archive is complete, you
  26. # will see the following message at the end:
  27. #        "End of shell archive."
  28. # Contents:  README go4gw go4gw.conf g2nntp g2nntp_groups g2whois
  29. #   g2webster
  30. # Wrapped by schemers@Slapshot.Stanford.EDU on Thu Jul 30 12:07:33 1992
  31. PATH=/bin:/usr/bin:/usr/ucb ; export PATH
  32. if test -f 'README' -a "${1}" != "-c" ; then 
  33.   echo shar: Will not clobber existing file \"'README'\"
  34. else
  35. echo shar: Extracting \"'README'\" \(4450 characters\)
  36. sed "s/^X//" >'README' <<'END_OF_FILE'
  37. X
  38. Xgo4gw is a daemon which can handle many different gopher gateways
  39. Xwritten in perl. It should be started from inetd.
  40. X
  41. XYou need to put the following line in /etc/services:
  42. X
  43. Xgo4gw         4320/tcp
  44. X
  45. XAnd the following line in /etc/inetd.conf (depending on your system type):
  46. X
  47. Xgo4gw  stream  tcp     nowait  /usr/local/etc/go4gw  go4gw
  48. X
  49. XThe go4gw script has a few variables you might want to change:
  50. X
  51. X$Gconf_file = "/usr/local/etc/go4gw.conf"; # configuration file
  52. X$Gport=4320;                               # port THIS daemon is running on
  53. X$Ghost="Slapshot.Stanford.EDU";            # host THIS daemon is running on
  54. X
  55. XYou need to set Gport to the same port as in /etc/services, and Ghost to
  56. Xyour fully qualified host name.
  57. X
  58. XWhy aren't these two auto-magically figured out?
  59. XMainly for speed, but also because some `hostname` commands don't
  60. Xhave the domain, some do, etc. Its easier just to define them here.
  61. XSince all the other gateways are run in the context of this perl script,
  62. Xthe gateways don't need any of this stuff in them.
  63. X
  64. XGconf_file should be set to the location of your go4gw.conf file. The
  65. Xformat of this file is:
  66. X
  67. X#
  68. X# format
  69. X# gateway : user : module : gopher title
  70. X#
  71. Xwhois:-2:/usr/local/etc/g2whois:Whois:
  72. Xnntp:-2:/usr/local/etc/g2nntp:USENET News:
  73. Xwebster:-2:/usr/local/etc/g2webster:Webster:
  74. X#
  75. X
  76. XWhere gateway is the name of the gateway, user is either a numeric uid
  77. Xor name,  module is the name of the perl script that go4gw will dynamically 
  78. Xload, and title is the title that will show up in the gopher menu if go4gw 
  79. Xis sent the string "". If the gateway doesn't take an empty string, the title
  80. Xshould be "" and it won't show up in the menu. By writing all your gateways so
  81. Xthey take a "" command, you can point a link at the go4gw daemon with
  82. Xpath set to "" and get a menu of all your gateways. The menu order will
  83. Xbe the same order as the go4gw.conf file.
  84. X
  85. XWriting go4gw gateways
  86. X-----------------------
  87. Xgo4gw gateways need to a follow a few simple conventions:
  88. X
  89. XYou need to have a routine called "${gateway}_main", where gateway
  90. Xis the name of your gateway. For example, if your gateway is called 
  91. Xwhois, then you need:
  92. X
  93. Xwhois_main {
  94. X  local($_) = @_;
  95. X  ...
  96. X}
  97. X
  98. XIn your module (/usr/local/etc/g2whois for example).
  99. X
  100. XYour *_main will be passed the string sent to go4gw WITHOUT your gateway 
  101. Xprefix. For example, if someone sends the following string to go4gw:
  102. X
  103. Xnntp ls su.jobs
  104. X
  105. XThen go4gw will call &nntp_main("ls su.jobs"),  after loading g2nntp.
  106. X
  107. XYou should define any variables that users might have to change at the
  108. Xfront of your script, and prefix them with your gateway name. 
  109. X
  110. XWhen your gateway has to return selector string, hostname, and port, it
  111. Xshould use the following variables:
  112. X
  113. X$Ggw    -> name of this gateway
  114. X$Gport  -> port this gateway is running on
  115. X$Ghost  -> host this gateway is running on
  116. X
  117. XFor example, nntp might do the following:
  118. X
  119. X&Greply("0$Subject\t$Ggw article $group $article\t$Ghost\t$Gport");
  120. X
  121. XSo when the user selects this they will send:
  122. X
  123. Xnntp article su.jobs 104
  124. X
  125. XBack to the go4gw daemon, which will figure out that "article su.jobs 104"
  126. Xneeds to get passed to g2nntp.
  127. X
  128. XThe following variables and routines are defined in go4gw, and can be used 
  129. Xby gateways:
  130. X
  131. X$GnotServer    You can define this in perl scripts that want to include
  132. X               the go4gw script without running the server. See the
  133. X               g2nntp_groups script.
  134. X
  135. X$Ggw           Can be used by gateway routines to determine their gateway     
  136. X               name.
  137. X
  138. X$Gport         Can be used by gateway routines to determine which port go4gw
  139. X               is running on.
  140. X
  141. X$Ghost         Can be used by gateway routines to determine which host go4gw
  142. X               is running on.
  143. X
  144. XGSERVER        File handle which is opened when GopenServer is called.
  145. X
  146. X&Greply(reply) Sends string back to gopher client with \r\n on the end.
  147. X
  148. X&Gabort(mess)  Sends error message back to gopher client with 
  149. X               "3mess\r\n.\r\n" on end.
  150. X              
  151. X&GopenServer(server,port)
  152. X               Opens TCP port at server or calls Gabort.
  153. X
  154. X&GcloseServer  Closes server.
  155. X
  156. X$Gdebug        define this to turn on debugging in &Gsend and &Grecv.
  157. X
  158. X&Gsend(cmd)    Sends "cmd\r\n" to GSERVER.
  159. X
  160. X$_ = &Grecv;   Gets response from GSERVER and strips \r and \n.
  161. X
  162. X&Gsorry        Sends message about data that cannot be delivered due to
  163. X               restrictions.
  164. X
  165. XOther "standard" routines and variables may be added. They will start
  166. Xwith a 'G'.
  167. X
  168. XRoland
  169. END_OF_FILE
  170. if test 4450 -ne `wc -c <'README'`; then
  171.     echo shar: \"'README'\" unpacked with wrong size!
  172. fi
  173. # end of 'README'
  174. fi
  175. if test -f 'go4gw' -a "${1}" != "-c" ; then 
  176.   echo shar: Will not clobber existing file \"'go4gw'\"
  177. else
  178. echo shar: Extracting \"'go4gw'\" \(2497 characters\)
  179. sed "s/^X//" >'go4gw' <<'END_OF_FILE'
  180. X#!/usr/local/bin/perl
  181. X#----------------------------------------------------------------------
  182. X# variables to change
  183. X
  184. X$Gconf_file = "/usr/local/etc/go4gw.conf"; # configuration file
  185. X$Gport=4320;                               # port THIS daemon is running on
  186. X$Ghost="Slapshot.Stanford.EDU";            # host THIS daemon is running on
  187. X
  188. X#----------------------------------------------------------------------
  189. X
  190. X&go4gw_main if (!defined($GnotServer));
  191. X
  192. Xsub go4gw_main {
  193. X
  194. X# get command
  195. X$_ = <STDIN>; s/\r//; s/\n//;
  196. X
  197. X($gw,$args) = /^(\w+)\s*(.*)$/ if (!/^$/);
  198. X
  199. Xopen(CONF,$Gconf_file) || &Gabort("$Gconf_file: $!");
  200. Xwhile(<CONF>) { 
  201. X     chop;
  202. X     next if /^#/ || /^$/;
  203. X     ($gateway,$user,$module,$title) = split(/:/);
  204. X     if ($gw eq '') { &Greply("1$title\t$gateway\t$Ghost\t$Gport"); }
  205. X     elsif ($gw eq $gateway) { &launch_gateway($user,$gateway,$module,$args); }
  206. X}
  207. X
  208. Xif ($gw eq '') { &Greply("."); exit; }
  209. Xelse { &Gabort("3No such gateway: $gw"); }
  210. X
  211. X}
  212. Xsub launch_gateway {
  213. X   local($user,$gateway,$module,$args) = @_;
  214. X
  215. X   if ($user =~ /^\-?\d+$/) { $Guid = $user; }
  216. X   elsif ($user eq '') { $Guid = -2; }
  217. X   else {           
  218. X       ($n,$pw,$Guid) = getpwnam($user);
  219. X       if ($Guid eq '') { $Guid = "-2"; }
  220. X   }
  221. X
  222. X  ($<,$>) = ($Guid,$Guid) unless $>;
  223. X   &Gabort("Can't load gateway: $module") if (! -e $module);
  224. X   require "$module";
  225. X   $main = "${gateway}_main";
  226. X   $Ggw = $gateway;
  227. X   &$main($args);
  228. X   &Greply(".");  # shouldn't really get here, but what the hack!
  229. X   exit;
  230. X}
  231. X
  232. X#
  233. X# standard routines
  234. X#
  235. X
  236. Xsub Greply { print "$_[0]\r\n"; }
  237. X
  238. Xsub Gabort { print "3$_[0]\r\n.\r\n"; exit; }
  239. X
  240. Xsub GopenServer {
  241. X
  242. X local($server,$port) = @_;
  243. X $sockaddr = 'S n a4 x8';
  244. X (($name, $aliases, $type, $len, $saddr) = gethostbyname($server))
  245. X        || &Gabort("3Can't get address of: $server");
  246. X $sin = pack($sockaddr, 2, $port, $saddr);
  247. X socket(GSERVER, 2, 1, 0) || &Gabort("Can't create socket: $!");
  248. X connect(GSERVER, $sin)   || &Gabort("Can't connect to server: $!");
  249. X select(GSERVER); $| = 1; select(STDOUT); $| = 1;
  250. X}
  251. X
  252. Xsub GcloseServer {
  253. X  close(GSERVER);
  254. X}
  255. X
  256. Xsub Gsend { 
  257. X     print "send -> |$_[0]|\n" if (defined($Gdebug));
  258. X     print GSERVER "$_[0]\r\n"; 
  259. X}
  260. X
  261. Xsub Grecv { 
  262. X   local ($_); 
  263. X   $_= <GSERVER>; 
  264. X   s/\n$//;
  265. X   s/\r$//;
  266. X   print "recv -> |$_|\n" if (defined($Gdebug));
  267. X   return $_; 
  268. X}
  269. X
  270. Xsub Gsorry {
  271. X
  272. Xprint<<EOF;
  273. X
  274. XSorry! You have selected information that cannot be delivered off
  275. Xof campus due to restrictions.
  276. X
  277. X   -- The Mole Hole Guardian
  278. X
  279. XEOF
  280. X
  281. X&Greply(".");
  282. Xexit;
  283. X
  284. X}
  285. X
  286. X1;  # for require
  287. END_OF_FILE
  288. if test 2497 -ne `wc -c <'go4gw'`; then
  289.     echo shar: \"'go4gw'\" unpacked with wrong size!
  290. fi
  291. chmod +x 'go4gw'
  292. # end of 'go4gw'
  293. fi
  294. if test -f 'go4gw.conf' -a "${1}" != "-c" ; then 
  295.   echo shar: Will not clobber existing file \"'go4gw.conf'\"
  296. else
  297. echo shar: Extracting \"'go4gw.conf'\" \(194 characters\)
  298. sed "s/^X//" >'go4gw.conf' <<'END_OF_FILE'
  299. X#
  300. X# format
  301. X# gateway : username (or uid):module : gopher title
  302. X#
  303. Xwhois:-2:/usr/local/etc/g2whois:Whois:
  304. Xnntp:-2:/usr/local/etc/g2nntp:USENET News:
  305. Xwebster:-2:/usr/local/etc/g2webster:Webster:
  306. X#
  307. END_OF_FILE
  308. if test 194 -ne `wc -c <'go4gw.conf'`; then
  309.     echo shar: \"'go4gw.conf'\" unpacked with wrong size!
  310. fi
  311. chmod +x 'go4gw.conf'
  312. # end of 'go4gw.conf'
  313. fi
  314. if test -f 'g2nntp' -a "${1}" != "-c" ; then 
  315.   echo shar: Will not clobber existing file \"'g2nntp'\"
  316. else
  317. echo shar: Extracting \"'g2nntp'\" \(4088 characters\)
  318. sed "s/^X//" >'g2nntp' <<'END_OF_FILE'
  319. X#!/usr/local/bin/perl
  320. X
  321. X#----------------------------------------------------------------------
  322. X# variables you might have to change:
  323. X
  324. X$nntp_server = "leland.stanford.edu";
  325. X$nntp_port   = 119;
  326. X$nntp_groups = "/usr/local/etc/newsgroups.gopher"; # could be active file
  327. X$nntp_reverse = 0;  # to list articles in reverse order
  328. X
  329. X#----------------------------------------------------------------------
  330. X
  331. X@nntp_acl=(
  332. X#     ipaddress  group    access + = allow, - = deny    
  333. X     '^36\.      .*       +',
  334. X     '.*         ^clari   -',
  335. X     '.*         .*       +'
  336. X  );
  337. X# end of variables
  338. X
  339. X# Commands this server responds to:
  340. X# 
  341. X# ""                         -> list top level groups
  342. X# ls $group                  -> list group's articles and sub-groups
  343. X# article $group $number     -> get 1 article
  344. X# sorry                      -> send sorry message
  345. X#
  346. X
  347. Xsub nntp_main {
  348. X  local($_) = @_;
  349. X
  350. X  &do_ls("") if /^$/;
  351. X  &do_ls($1) if /^ls\s+(.*)/i;
  352. X  &do_article($1,$2) if /^article\s+(\S+)\s+(\d+)/i;
  353. X  &Gsorry if /^sorry$/;
  354. X  &Gabort("Unknown command!");
  355. X  exit;
  356. X}
  357. X
  358. Xsub do_article {
  359. X  local($group,$number) = @_;
  360. X
  361. X  if (&check_access($group) eq '-')  { &Gsorry; }
  362. X  &open_nntp;
  363. X
  364. X  &Gsend("GROUP $group");
  365. X  $_ = &Grecv;
  366. X  &Gabort($_) if !/^211/;
  367. X
  368. X  &Gsend("ARTICLE $number");
  369. X  $_ = &Grecv;
  370. X  &Gabort($_) if !/^220/;
  371. X  while(<GSERVER>) {
  372. X    print;
  373. X    last if /^\.\r\n$/;
  374. X  }
  375. X
  376. X  &close_nntp;
  377. X  exit;
  378. X}
  379. X
  380. Xsub list_group {
  381. X  local($group) = @_;
  382. X
  383. X  &Gsend("GROUP $group");
  384. X  $_ = &Grecv;
  385. X  &Gabort($_) if !/^211/;
  386. X
  387. X  ($n,$f,$l) = /211\s+(\d+)\s+(\d+)\s+(\d+)/;
  388. X
  389. X  &Gsend("XHDR Subject $f-$l");
  390. X  $_ = &Grecv;
  391. X  &Gabort($_) if !/^221/;
  392. X  while(<GSERVER>) {
  393. X    chop; chop;
  394. X    last if /^\.$/;
  395. X    ($article,$subject) = /^(\d+)\s+(.*)/;
  396. X    $subject =~ s/\t/ /g; # just in case!
  397. X    if ($nntp_reverse) {
  398. X       push(@reply,"0$subject\t$Ggw article $group $article\t$Ghost\t$Gport");
  399. X    } else {
  400. X       &Greply("0$subject\t$Ggw article $group $article\t$Ghost\t$Gport");
  401. X    }
  402. X  }
  403. X
  404. X  if ($nntp_reverse) {
  405. X    for ($i=$#reply; $i!= -1; $i--) { &Greply($reply[$i]); } 
  406. X  }
  407. X
  408. X  &Greply(".");
  409. X  &close_nntp;
  410. X  exit;
  411. X}
  412. X
  413. Xsub do_ls {
  414. X  local($prefix) = @_;
  415. X
  416. X  if (&check_access($prefix) eq '-') {
  417. X      &Greply("0Sorry! No access off of campus!\t$Ggw sorry\t$Ghost\t$Gport");
  418. X      &Greply("."); 
  419. X      exit; 
  420. X  }
  421. X
  422. X  &open_nntp;
  423. X  &get_groups;
  424. X
  425. X  foreach ( sort @groups) {
  426. X    if ($_ eq $prefix) { $do_list_group = $_; }
  427. X    elsif (/^$prefix\.([^.]*)\.?/) {
  428. X      $leaf=$1;
  429. X      $save{"$prefix.$leaf"} = "1$leaf\t$Ggw ls $prefix.$leaf\t$Ghost\t$Gport";
  430. X    }
  431. X    elsif ($prefix eq '' && /([^.]*)/) {
  432. X         $save{"$1"} = "1$1\t$Ggw ls $1\t$Ghost\t$Gport";
  433. X    }
  434. X  }
  435. X
  436. X  foreach ( sort keys %save) { &Greply($save{$_}); }
  437. X  &list_group($do_list_group) if ($do_list_group);
  438. X
  439. X  &Greply(".");
  440. X  &close_nntp;
  441. X  exit;
  442. X}
  443. X
  444. Xsub open_nntp {
  445. X  local($_);
  446. X  &GopenServer($nntp_server,$nntp_port);
  447. X  $_ = &Grecv;
  448. X  &Gabort($_) if !/^2/;
  449. X}
  450. X
  451. Xsub close_nntp {
  452. X  &Gsend("QUIT");
  453. X  close(GSERVER);
  454. X}
  455. X
  456. Xsub get_groups {
  457. X if (open(GROUPS,$nntp_groups)) {
  458. X      while(<GROUPS>) {
  459. X          chop;
  460. X          ($grp) = /^(\S+)/;
  461. X          push(@groups,$grp);
  462. X      }
  463. X      close(GROUPS);
  464. X } else {                  # can't open file, get list from server!
  465. X  &load_groups;
  466. X }
  467. X}
  468. X
  469. Xsub load_groups {
  470. X
  471. X  &open_nntp;
  472. X  &Gsend("LIST");
  473. X  $_ = &Grecv;
  474. X  &Gabort($_) if !/^215/;
  475. X
  476. X  while(<GSERVER>) {
  477. X    chop; chop;
  478. X    last if /^\.$/;
  479. X    s/^(\S+).*/$1/;
  480. X    push(@groups,$_);
  481. X  }
  482. X
  483. X}
  484. X
  485. Xsub create_groups { 
  486. X  &load_groups;
  487. X  open(GROUPS,">$nntp_groups") || die "$nntp_groups: $!";
  488. X  foreach (@groups) { print GROUPS "$_\n"; }
  489. X  close GROUPS;
  490. X  &close_nntp;
  491. X  exit;
  492. X}
  493. X
  494. Xsub check_access {
  495. X   local($group)=@_;
  496. X
  497. X   return 1 if (-t STDIN);
  498. X   $sockaddr = 'S n a4 x8';
  499. X   $mysockaddr = getpeername(STDIN);
  500. X   ($ramily,$rport,$raddr) = unpack($sockaddr,$mysockaddr);
  501. X   ($a,$b,$c,$d) = unpack('C4',$raddr);
  502. X   $ipaddress = "$a.$b.$c.$d";
  503. X
  504. X   foreach (@nntp_acl) {
  505. X      ($ipacl,$groupacl,$access)=split;
  506. X      return $access if  ($ipaddress =~ /$ipacl/) && ($group =~ /$groupacl/);
  507. X   }
  508. X   return '-'; #default is to restrict access
  509. X}
  510. X
  511. X1; # for require
  512. END_OF_FILE
  513. if test 4088 -ne `wc -c <'g2nntp'`; then
  514.     echo shar: \"'g2nntp'\" unpacked with wrong size!
  515. fi
  516. chmod +x 'g2nntp'
  517. # end of 'g2nntp'
  518. fi
  519. if test -f 'g2nntp_groups' -a "${1}" != "-c" ; then 
  520.   echo shar: Will not clobber existing file \"'g2nntp_groups'\"
  521. else
  522. echo shar: Extracting \"'g2nntp_groups'\" \(428 characters\)
  523. sed "s/^X//" >'g2nntp_groups' <<'END_OF_FILE'
  524. X#!/usr/local/bin/perl
  525. X
  526. X#----------------------------------------------------------------------
  527. X# variables you might have to change
  528. X
  529. X$g2nntp = "/usr/local/etc/g2nntp";
  530. X$go4gw  = "/usr/local/etc/go4gw";
  531. X
  532. X#----------------------------------------------------------------------
  533. X
  534. X$GnotServer=1;  # so go4gw doesn't think its a server!
  535. X
  536. Xrequire "$go4gw";
  537. Xrequire "$g2nntp";
  538. X
  539. X#create the group file listed in g2nntp.
  540. X
  541. X&create_groups;
  542. END_OF_FILE
  543. if test 428 -ne `wc -c <'g2nntp_groups'`; then
  544.     echo shar: \"'g2nntp_groups'\" unpacked with wrong size!
  545. fi
  546. chmod +x 'g2nntp_groups'
  547. # end of 'g2nntp_groups'
  548. fi
  549. if test -f 'g2whois' -a "${1}" != "-c" ; then 
  550.   echo shar: Will not clobber existing file \"'g2whois'\"
  551. else
  552. echo shar: Extracting \"'g2whois'\" \(1425 characters\)
  553. sed "s/^X//" >'g2whois' <<'END_OF_FILE'
  554. X#!/usr/local/bin/perl
  555. X
  556. X#----------------------------------------------------------------------
  557. X# variables you should change:
  558. X
  559. X$whois_server = "stanford.edu";   
  560. X$whois_port   = 43;
  561. X
  562. X#----------------------------------------------------------------------
  563. X
  564. Xsub whois_main {
  565. X local($_) = @_;
  566. X
  567. X if (/^$/) {
  568. X    &Greply("0Whois Help\thelp\t$whois_server\t$whois_port");
  569. X    &Greply("7Query Whois\t$Ggw\t$Ghost\t$Gport");
  570. X    &Greply(".");
  571. X    exit(0);
  572. X }
  573. X
  574. X $query = $_;
  575. X &GopenServer($whois_server,$whois_port);
  576. X &Gsend($query);
  577. X
  578. X  while(<GSERVER>) {
  579. X        chop; chop;
  580. X        push(@lines,$_);
  581. X  }
  582. X
  583. X  &Greply("0Raw search results\t$query\t$whois_server\t$whois_port");
  584. X
  585. X  if ($lines[$#lines] eq '') {
  586. X        foreach (@lines) {
  587. X           if (/^\s+name:\s+(.*)/) {
  588. X               &Greply("0$1\t$query\t$whois_server\t$whois_port");
  589. X               &Greply(".");
  590. X               exit(0);
  591. X           }
  592. X        }
  593. X    } elsif ($lines[$#lines] eq 'NO MATCH') {
  594. X       &Greply("0No Match Was Found!\thelp\t$gopher_server\t$gopher_port");
  595. X    } elsif ($lines[$#lines] =~ /^\(returned/) {
  596. X       foreach (@lines) {
  597. X           if (/(.*)<(.*)>.*\s+(.*)$/) {
  598. X               $text=$1; $handle=$2; $rest = $3;
  599. X               $text =~ s/\s+$//;
  600. X               $rest =~ s/\s+/ /g;
  601. X               &Greply("0$text ($rest)\t!$handle\t$whois_server\t$whois_port");
  602. X           }
  603. X        }
  604. X    }
  605. X    &Greply(".");
  606. X    exit(0);
  607. X}
  608. X
  609. X
  610. X
  611. X
  612. X1; # for require
  613. END_OF_FILE
  614. if test 1425 -ne `wc -c <'g2whois'`; then
  615.     echo shar: \"'g2whois'\" unpacked with wrong size!
  616. fi
  617. chmod +x 'g2whois'
  618. # end of 'g2whois'
  619. fi
  620. if test -f 'g2webster' -a "${1}" != "-c" ; then 
  621.   echo shar: Will not clobber existing file \"'g2webster'\"
  622. else
  623. echo shar: Extracting \"'g2webster'\" \(2573 characters\)
  624. sed "s/^X//" >'g2webster' <<'END_OF_FILE'
  625. X#!/usr/local/bin/perl
  626. X
  627. X#----------------------------------------------------------------------
  628. X# variables you can change:
  629. X
  630. X#$webster_server  = "webster.lcs.mit.edu";
  631. X#$webster_port    = 103;
  632. X
  633. X$webster_server = "webster-server.stanford.edu";
  634. X$webster_port   = 765;
  635. X
  636. X@webster_acl=(
  637. X#     ipaddress  access + = allow, - = deny    
  638. X     '^36\.      +',
  639. X     '.*         -'
  640. X  );
  641. X
  642. X#----------------------------------------------------------------------
  643. X
  644. Xsub webster_main {
  645. X local($_ )= @_;
  646. X
  647. X &Gsorry if /^sorry$/;
  648. X
  649. X  if (&check_access() eq '-') {
  650. X      &Greply("0Sorry! No access off of campus!\t$Ggw sorry\t$Ghost\t$Gport");
  651. X      &Greply("."); 
  652. X      exit; 
  653. X  }
  654. X
  655. X if (/^$/) {
  656. X  &Greply("7Lookup word in dictionary\t$Ggw default SPELL\t$Ghost\t$Gport");
  657. X  &Greply("7Lookup word in dictionary (phonetic match)\t$Ggw default PSPELL\t$Ghost\t$Gport");
  658. X  &Greply("7Search text of entire dictionary\t$Ggw dictionary-full SPELL\t$Ghost\t$Gport");
  659. X  &Greply("7Show words that start with\t$Ggw default ENDINGS\t$Ghost\t$Gport");
  660. X  &Greply("7Thesaurus\t$Ggw thesaurus SPELL\t$Ghost\t$Gport");
  661. X  &Greply(".");
  662. X  exit(0);
  663. X }
  664. X
  665. X ($index,$cmd,$query) = /^(\S+)\s+(\S+)\s+(.+)$/;
  666. X
  667. X  &GopenServer($webster_server,$webster_port);
  668. X
  669. X  &Gsend("INDEX $index") if ($index ne 'default');
  670. X
  671. X  if ($cmd eq "PSPELL") {                     # phonetic lookup
  672. X       &Gsend("SPELL $query ?");
  673. X  } else {
  674. X       &Gsend("$cmd $query");
  675. X  }
  676. X
  677. X$_ = &Grecv;
  678. X
  679. X  if (/^SPELLING 0/ || /^WILD 0/) {
  680. X        &Greply(".");
  681. X   } elsif (/^SPELLING 1/) {
  682. X      &Greply("0$query\t$Ggw $index DEFINE $query\t$Ghost\t$Gport"); 
  683. X      &Greply(".");
  684. X   } elsif (/^SPELLING$/ || /^MATCHS$/ || /^WILD/) {
  685. X        $/ = "\200";
  686. X        $buf = <GSERVER>;
  687. X        $buf =~ s/[\r\200]//g;
  688. X        foreach (split(/\n/,$buf)) { /\d+\s+(\S+)/; $words{$1}=""; }
  689. X        foreach (sort keys %words) { 
  690. X               &Greply("0$_\t$Ggw $index DEFINE $_\t$Ghost\t$Gport"); 
  691. X        }
  692. X        &Greply(".");
  693. X   } elsif (/^DEFINITION/) {
  694. X        $/ = "\200";
  695. X        $buf = <GSERVER>;
  696. X        $buf =~ s/[\r\200]//g;
  697. X        print $buf;
  698. X   } else {
  699. X        &Greply(".");
  700. X   }
  701. X  &Gsend("QUIT");
  702. X  &GcloseServer;
  703. X  exit;
  704. X}
  705. X
  706. Xsub check_access {
  707. X
  708. X   return 1 if (-t STDIN);
  709. X   $sockaddr = 'S n a4 x8';
  710. X   $mysockaddr = getpeername(STDIN);
  711. X   ($ramily,$rport,$raddr) = unpack($sockaddr,$mysockaddr);
  712. X   ($a,$b,$c,$d) = unpack('C4',$raddr);
  713. X   $ipaddress = "$a.$b.$c.$d";
  714. X
  715. X   foreach (@webster_acl) {
  716. X      ($ipacl,$access)=split;
  717. X      return $access if  ($ipaddress =~ /$ipacl/);
  718. X   }
  719. X   return '-'; #default is to restrict access
  720. X}
  721. X
  722. X1; # for require
  723. END_OF_FILE
  724. if test 2573 -ne `wc -c <'g2webster'`; then
  725.     echo shar: \"'g2webster'\" unpacked with wrong size!
  726. fi
  727. chmod +x 'g2webster'
  728. # end of 'g2webster'
  729. fi
  730. echo shar: End of shell archive.
  731. exit 0
  732.  
  733. -- 
  734. Roland J. Schemers III              |            Networking Systems
  735. Systems Programmer                  |            168 Pine Hall   (415)-723-6740
  736. Distributed Computing Group         |            Stanford, CA 94305-4122
  737. Stanford University                 |            schemers@Slapshot.Stanford.EDU
  738.