home *** CD-ROM | disk | FTP | other *** search
/ InfoMagic Internet Tools 1993 July / Internet Tools.iso / RockRidge / info-service / gopher / Unix / go4gw1.1 / README < prev    next >
Encoding:
Text File  |  1993-04-30  |  4.6 KB  |  145 lines

  1. go4gw version 1.01
  2. ------------------
  3.  
  4. go4gw is a daemon which can handle many different gopher gateways
  5. written in perl. It should be started from inetd.
  6.  
  7. Bugs to gopher@boombox.micro.umn.edu
  8.  
  9. INSTALLATION
  10. ------------
  11.  
  12. You need to put the following line in /etc/services:
  13.  
  14. go4gw         4320/tcp
  15.  
  16. And the following line in /etc/inetd.conf (depending on your system type):
  17.  
  18. go4gw  stream  tcp     nowait  nobody /usr/local/etc/go4gw  go4gw
  19.  
  20. The go4gw script has a few variables you might want to change:
  21.  
  22. $Gconf_file = "/usr/local/etc/go4gw.conf"; # configuration file
  23. $Gport=4320;                               # port THIS daemon is running on
  24. $Ghost="Slapshot.Stanford.EDU";            # host THIS daemon is running on
  25.  
  26. You need to set Gport to the same port as in /etc/services, and Ghost to
  27. your fully qualified host name.
  28.  
  29. Why aren't these two auto-magically figured out?
  30. Mainly for speed, but also because some `hostname` commands don't
  31. have the domain, some do, etc. Its easier just to define them here.
  32. Since all the other gateways are run in the context of this perl script,
  33. the gateways don't need any of this stuff in them.
  34.  
  35. Gconf_file should be set to the location of your go4gw.conf file. The
  36. format of this file is:
  37.  
  38. #
  39. # format
  40. # gateway : user : module : gopher title
  41. #
  42. whois:-2:/usr/local/etc/g2whois:Whois:
  43. nntp:-2:/usr/local/etc/g2nntp:USENET News:
  44. webster:-2:/usr/local/etc/g2webster:Webster:
  45. #
  46.  
  47. Where gateway is the name of the gateway, user is either a numeric uid
  48. or name,  module is the name of the perl script that go4gw will dynamically 
  49. load, and title is the title that will show up in the gopher menu if go4gw 
  50. is sent the string "". If the gateway doesn't take an empty string, the title
  51. should be "" and it won't show up in the menu. By writing all your gateways so
  52. they take a "" command, you can point a link at the go4gw daemon with
  53. path set to "" and get a menu of all your gateways. The menu order will
  54. be the same order as the go4gw.conf file.
  55.  
  56. Once you've done all this configuration you'll want to try HUP inetd.
  57. Then you can test it out by running a gopher client to the newly
  58. created port..
  59.  
  60.  
  61. Writing go4gw gateways
  62. -----------------------
  63. go4gw gateways need to a follow a few simple conventions:
  64.  
  65. You need to have a routine called "${gateway}_main", where gateway
  66. is the name of your gateway. For example, if your gateway is called 
  67. whois, then you need:
  68.  
  69. whois_main {
  70.   local($_) = @_;
  71.   ...
  72. }
  73.  
  74. In your module (/usr/local/etc/g2whois for example).
  75.  
  76. Your *_main will be passed the string sent to go4gw WITHOUT your gateway 
  77. prefix. For example, if someone sends the following string to go4gw:
  78.  
  79. nntp ls su.jobs
  80.  
  81. Then go4gw will call &nntp_main("ls su.jobs"),  after loading g2nntp.
  82.  
  83. You should define any variables that users might have to change at the
  84. front of your script, and prefix them with your gateway name. 
  85.  
  86. When your gateway has to return selector string, hostname, and port, it
  87. should use the following variables:
  88.  
  89. $Ggw    -> name of this gateway
  90. $Gport  -> port this gateway is running on
  91. $Ghost  -> host this gateway is running on
  92.  
  93. For example, nntp might do the following:
  94.  
  95. &Greply("0$Subject\t$Ggw article $group $article\t$Ghost\t$Gport");
  96.  
  97. So when the user selects this they will send:
  98.  
  99. nntp article su.jobs 104
  100.  
  101. Back to the go4gw daemon, which will figure out that "article su.jobs 104"
  102. needs to get passed to g2nntp.
  103.  
  104. The following variables and routines are defined in go4gw, and can be used 
  105. by gateways:
  106.  
  107. $GnotServer    You can define this in perl scripts that want to include
  108.                the go4gw script without running the server. See the
  109.                g2nntp_groups script.
  110.  
  111. $Ggw           Can be used by gateway routines to determine their gateway     
  112.                name.
  113.  
  114. $Gport         Can be used by gateway routines to determine which port go4gw
  115.                is running on.
  116.  
  117. $Ghost         Can be used by gateway routines to determine which host go4gw
  118.                is running on.
  119.  
  120. GSERVER        File handle which is opened when GopenServer is called.
  121.  
  122. &Greply(reply) Sends string back to gopher client with \r\n on the end.
  123.  
  124. &Gabort(mess)  Sends error message back to gopher client with 
  125.                "3mess\r\n.\r\n" on end.
  126.               
  127. &GopenServer(server,port)
  128.                Opens TCP port at server or calls Gabort.
  129.  
  130. &GcloseServer  Closes server.
  131.  
  132. $Gdebug        define this to turn on debugging in &Gsend and &Grecv.
  133.  
  134. &Gsend(cmd)    Sends "cmd\r\n" to GSERVER.
  135.  
  136. $_ = &Grecv;   Gets response from GSERVER and strips \r and \n.
  137.  
  138. &Gsorry        Sends message about data that cannot be delivered due to
  139.                restrictions.
  140.  
  141. Other "standard" routines and variables may be added. They will start
  142. with a 'G'.
  143.  
  144. Roland
  145.