<!doctype linuxdoc system>

<!-- LyX 1.1 created this file. For more info see http://www.lyx.org/ -->
<article>
<title>
Gnut Manual
</title>
<author>
Josh Pieper <url url="" name=""><htmlurl url="mailto:josh@nemonet.com" name="josh@nemonet.com">
</author>
<date>
May 4, 2000
</date>
<abstract>
This document describes what gnut is, how to use it, and gives detailed
 instructions for advanced users.
</abstract>
<toc>
<sect>
Administrivia
<sect1>
Where to Get
<p>
The main gnut home page is <htmlurl url="http://www.umr.edu/~jjp" name="http://www.umr.edu/~jjp">. Source package, binary releases, as well as
 the newest version of this document can be found there. The distribution can
 also be found at the <htmlurl url="http://gnutella.wego.com" name="Gnutella Portal"> under the section third party clients.
</p>
<sect1>
Requirements
<p>
Gnut will run under most unices which support POSIX threads. Under linux
 this requires that you have glibc-2.0 or greater. Win32 is supported through
 some simple wrappers. Readline, regular expression searching, and other niceties
 are supported if the compiling platform has them.
</p>
<sect1>
Most Recent Version
<p>
As of this writing the most recent version of gnut is 0.3.28. This changes
 on a regular basis, so it's always best to look at the web page for the newest
 version. A ChangeLog, as well as a README, are available at the web page as
 well.
</p>
<sect1>
Pre-compiled Binaries
<p>
A precompiled Win32 binary is available at the web page. A link to RPMs
 for i386 can also be found there. It is assumed that all other platforms have
 some way of compiling software, preferably with Gnu tools.
</p>
<sect1>
Acknowledgements
<p>
Thanks to everyone who has ever submitted a patch, or told me what they
 like and dislike. This document is based in part on the excellent tutorial
 written by Elijah <htmlurl url="mailto:eli@panix.com" name="eli@panix.com">. Also thanks to Erik Moeller for his great suggestions.
</p>
<sect>
Introduction
<sect1>
Gnutella
<p>
Gnutella is a distributed file sharing protocol. It has uses not dissimilar
 to those that other programs such as Napster, I-Mesh, and Scour provide. Despite
 this competition, gnutella has one strong point. It is distributed, there is
 no central authority, there is no forced port, and it's very hard to stop a
 gnutella network in action.
</p>
<p>
A gnutella client, more accurately called a servant, can connect to other
 clients, and accept connection from other clients. Queries and responses are
 then sent between the clients, so that a person is capable of searching from
 any node in the network, and reaching a large proportion of the other nodes
 throughout the world. As well as queries, other routing information is passed
 over these connections, this can make gnutella use quite a bit of bandwidth.
 Its usability for modem users has been debated.
</p>
<sect1>
History
<p>
The original gnutella client was created by Nullsoft, the creators of Winamp,
 a subsidiary of AOL/Time Warner. It was released for public beta testing, and
 on the same day withdrawn due to pressure from AOL. The build released on that
 day, 0.48, was the last one to officially come from Nullsoft. However leaked
 versions up until 0.56 appeared, and are reputed to come from Nullsoft.
</p>
<p>
Not long after the beta test release, many developers around the world
 reverse engineered the protocol used by this client, and developed other programs
 which were inter-operable. This is the category under which gnut falls, as
 well as many other clients which implement the protocol. A good place to look
 for other clients is the <htmlurl url="http://gnutella.wego.com" name="Gnutella Portal">.
</p>
<sect1>
Gnut
<p>
Gnut is a command-line client which implements the gnutella protocol. It
 supports all features available in the original Nullsoft client, as well as
 many others. Bandwidth limiting, sorting of results, regular expression searching,
 are among the list. It will compile and run on a wide range of POSIX compliant
 (and not so compliant) systems including: SunOS, Linux, FreeBSD, HP-UX, and
 Win32.
</p>
<sect>
Basic Usage
<sect1>
Building Gnut
<p>
If you are not using one of the available precompile versions, you need
 to build Gnut from the source code. Gnut uses a standard Gnu automake/autoconf
 build system. First untar your distribution, cd into the directory, then do
 the standard:
</p>
<p>
<verb>
./configure
make
make install
</verb>
</p><p>
This will build gnut and install it into your default installation path.
</p>
<sect1>
Starting Gnut
<p>
How hard can that be, simply type gnut!
</p>
<p>
<verb>
&lsqb;josh@zaphod gnut&rsqb;&dollar; gnut
num_columns=78 num_rows=34
131.151.189.18
gnut version 0.3.29 at your service

Bound to port: 5635
gnut&gt;
</verb>
</p><p>
You're started, now all you have to do is enter at least one other servant's
 IP address. Once you have one address, gnut will find others and do its best
 to keep you always connected to the gnutella network. So, you'll need an IP
 address, a good place to look is at the <htmlurl url="http://gnutella.wego.com" name="Gnutella Portal">, there are usually several hosts listed
 on the first page. Find an IP to try, then use the <em>open</em> command to pull it
 up, then use the <em>update</em> command to request more IP addresses.
</p>
<p>
<verb>
gnut&gt; open 216.231.59.208:8080
gnut&gt; update
</verb>
</p><p>
If you want to see the status of all the network connections that gnut
 has open at any time, you can use the <em>info</em> command.
</p>
<p>
<verb>
gnut&gt; info
HOST STATS:  Hosts: 19       Files: 2.72K      Size: 9.145G
NET STATS:   Msg Received: 20         Msg Sent: 1
                      Bytes Rcvd: 740             Bytes Sent: 23
QUERY STATS: Queries: 0        Responses Sent: 0
SHARE STATS: Num Shared: 0    Size Shared: 0
CONNECTION STATS:
-----------------
1)198.109.221.88:6346   Packs:         0:0               0:0     Bytes:        0:0
TID: 7171     Type: OUT   State:   CONN   Rate:           0:0           /sec
</verb>
<p>
<descrip>
 <tag>
HOST_STATS</tag>Shows information about the gnutellaNet (or rather, the
 parts of the gnutellaNet that are known to you).
 <tag>
NET_STATS</tag>Shows info about the infomration you send and receive over
 the gnutellaNet.
 <tag>
SHARE_STATS</tag>Self-explaining.
 <tag>
CONNECTION_STATS</tag>Reveals the hosts you are currently connected to,
 whether these connections are incoming or outgoing and at what speed they run
 at.
</descrip>
</p><sect1>
Sharing
<p>
If you're running gnutella, it's probably because you want to help share
 some files with your fellow neighbor. Sharing files is easy in gnut, all you
 have to do is either put them all in one directory, or make the appropriate
 symlinks (if on a Unix platform). Then you use the <em>share</em> and <em>scan</em> commands
 to share your files.
</p>
<p>
<verb>
gnut&gt; share /home/mp3:/home/movies
gnut&gt; scan
Scanned 386 files and 3649352 Kbytes.
gnut&gt;
</verb>
</p><p>
And now all your hot files can be downloaded by anyone around the world.
</p>
<sect1>
Searching
<p>
Searching is just as easy as sharing was. In gnut, you use the <em>find</em> command.
 It takes one argument, which is the search keyword you are looking for. It
 waits for you to press a key as search results come in. The results don't stop
 coming in when you press the key, you just lose feedback of it.
</p>
<p>
<verb>
gnut&gt; find britney spears
Searching the gnutella network for: britney spears
Press any key to continue
63 results received.
</verb>
</p><p>
After you think enough responses have arrived, hit any key to end the search.
 You are then presented with a sorted list of the files which matched your query.
 
</p>
<p>
<verb>
1)Britney Spears- Oops!...I Did It Again.mpg
129.142.84.183:6346  size:42.565M   ref: 29   speed: 28
2)Britney Spears- Sometimes.mpg
139.142.84.183:6346  size:39.054M   ref: 0    speed: 28
etc...
---more---
</verb>
</p><p>
Let's say that you really wanted the "Sometimes" video. What you would first
 do is hit "q" to stop displaying results, then you would use the <em>get</em> command
 to grab the file, then the <em>info t</em> command to display the results of the ongoing
 transfer.
</p>
<p>
<verb>
gnut&gt; get 2
gnut&gt; 
Download of Britney Spears- Sometimes.mpg.gnut started.
</verb>
</p><p>
(NOTE: The file is given the extension ".gnut" until it has been completely
 downloaded. This way you can easily recognize incomplete files.)
</p>
<p>
<verb>
gnut&gt; info t
TRANSFER_STATS:
---------------
1) 139.142.84.183:6346   2.3&percnt;  3.41K/39.054M    3.41K/sec ETA 2h10h34m 
TID: 15369    IN  State: UP   Name: Britney Spears- Sometimes.mpg
TOTALS: Rate     0:3.41K /sec

gnut&gt; 
Download of Britney Spears- Sometimes.mpg.gnut succeeded.
</verb>
</p><p>
And now you have Britney Spear's latest video in your current working directory.
 Crazy huh?
</p>
<sect>
Advanced Usage
<sect1>
Invocation
<p>
Gnut has a variety of command line arguments that can be used in special
 circumstances. They are listed below, with a short description of each.
</p>
<p>
<itemize>
 <item>
<bf>-l &lt;&num;&gt;</bf> Sets the initial logging level to the value of &num;.
 This specifies how much information Gnut displays at runtime, which is useful
 for debugging purposes, or to examine your network traffic in detail. The higher
 the level, the more information you get. Beware, though: A high log level may
 flood your screen. (You can type between the lines.)
 <item>
<bf>-c &lt;file&gt;</bf> Specify a script to run at startup. This will bypass any
 &tilde;/.gnutrc you may have.
 <item>
<bf>-p &lt;&num;&gt;</bf> Start gnut listening on TCP port &num;.
 <item>
<bf>-i &lsqb;IP/interface&rsqb;</bf> IP (or interface) to broadcast as belonging
 to us.
 <item>
<bf>-d</bf> Daemon mode, never ask for input at the console.
 <item>
<bf>-x</bf> Exit after having run any scripts.
 <item>
<bf>-v</bf> Output version information and exit.
 <item>
<bf>-h</bf> Display a usage message and exit.
</itemize>
</p><sect1>
Run-Time Commands
<sect2>
Overview
<p>
Gnut is a command line interface. That means you have to give it commands.
 Commands in gnut are a single word followed by optional arguments. All commands
 can be abbreviated to the point that they are still unique. 
</p>
<sect2>
Notation
<p>
Brackets are used in the regular expression sense. Thus &lsqb;abc&rsqb;
 means use either a, b, or c. Textual arguments are indicated with less than
 and greater than signs, for example &lt;arg&gt;. The &num; sign is used to
 indicate a scalar number. A &percnt;&percnt; is used to indicate a list and/or
 range of numbers. These ranges can be specified in several ways. For example:
</p>
<p>
<verb>
&num;         = Just a single number
&num;-&num;       = Range of number, Ex: 4-6
&num;,&num;,&num;     = Command delimited list, Ex: 2,6,5
&num;-&num;,&num;,&num;-&num; = Any combination thereof
</verb>
</p><sect2>
List of Commands
<p>
<itemize>
 <item>
<bf>info &lsqb;hqnsct&rsqb;</bf> - Display various information.
 <itemize>
  <item>
h - Host
  <item>
q - Query
  <item>
n - Network
  <item>
s - Local Shares
  <item>
c - Connections
  <item>
t - Transfers
 </itemize>
 <item>
<bf>open</bf><bf><em> </em>&lt;host&gt;</bf> - Open outgoing connection to &lt;host&gt;
 <item>
<bf>find &lt;string&gt;</bf> - Search the Gnutella network for &lt;string&gt;. This
 is a keyword based search, and nearly every client specifies this as a boolean
 AND search with all non-alphanumeric characters ignored.
 <item>
<bf>monitor</bf> - Turn on the search monitor.
 <item>
<bf>update</bf> - Send out ping packets to all connected hosts. If configuration
 variable update_clear is set, then the current host list is discarded as well.
 <item>
<bf>response</bf> <bf>&lt;regexp&gt;</bf> - Show the current query responses which match
 the given regular expression. The results are sorted according to the sort_order
 configuration variable.
 <item>
<bf>get &percnt;&percnt;</bf> - Start downloading files referenced by &percnt;&percnt;.
 If more downloads are requested than allowed by max_uploads, then the downloads
 are queued.
 <item>
<bf>push &percnt;&percnt;</bf> - Same as get, however only a push connection is
 attempted.
 <item>
<bf>stop &percnt;&percnt;</bf> - Stop the transfers referenced by &percnt;&percnt;.
 <item>
<bf>clear &percnt;&percnt;</bf> - Removes finished transfers from the transfer list.
 <item>
<bf>kill</bf><bf><em> </em>&percnt;&percnt;</bf> - Terminate the gnutella connections referenced by
 &percnt;&percnt;.
 <item>
<bf>hosts</bf> - Displays the current host catcher, this can result in a lot of
 information!
 <item>
<bf>limit &num; &percnt;&percnt;</bf> - Limit the transfers referenced by &percnt;&percnt;
 to &num; bytes per second.
 <item>
<bf>log</bf><bf><em> </em>&num; </bf>- Set the current log level to &num;.
 <item>
<bf>share</bf><bf><em> </em>&lt;paths&gt;</bf> - Takes a ":" delimited list of paths to share. (";" on
 Win32)
 <item>
<bf>scan</bf> - Rescans the files in the share paths.
 <item>
<bf>play &percnt;&percnt;</bf> - Runs the program set in play_prog with the URL
 of queries &percnt;&percnt; as arguments. 
 <item>
<bf>set &lt;val&gt; &lt;key&gt;</bf> - Sets a configuration value. See Section 4.3.
 <item>
<bf>sleep &lt;&num;&gt;</bf> - Do nothing for &num; seconds.
 <item>
<bf>quit</bf><bf><em> </em></bf><em></em>- Quit gnut.
</itemize>
</p><sect1>
Configuration Variables
<p>
Nearly every aspect of gnut can be configured using it's built in configuration
 system. All configuration variables can be considered to either be numeric,
 or alphanumeric. If you enter non-numeric characters into a numeric variable,
 it will just be treated as a zero.
</p>
<p>
Follows is a list of all the available configuration variables, along with
 a short description of how it affects gnut's operation. In most cases, each
 variable only controls one small aspect of gnut, allowing for a wide variety
 of possible configurations.
</p>
<sect2>
User Interface
<p>
<itemize>
 <item>
<em>auto_clear</em> - Boolean, if set to 1, transfers are removed from the transfer
 list after completion without user intervention.
 <item>
<em>beep_on_first</em> - Boolean, if set to 1, an audible tone is emitted after
 the first search result of a new query is received.
 <item>
<em>download_path</em> - String, directory where downloads should be stored.
 <item>
<em>munge</em> - Boolean, if set to 1, large numbers are displayed with unit postfixes.
 <item>
<em>packet_stats</em> - Boolean, if set to 1, a large amount of interesting statistics
 are shown in the connection information list.
 <item>
<em>paginate</em> - Boolean, if set to 1, gnut will stop for user input after a
 screen-full of information has been displayed. This allows for easy viewing
 of long lists.
 <item>
<em>play_prog</em> - String, the program to be used to stream media files.
 <item>
<em>sort_order</em> - String, series of characters indicating what fields should
 be sorted on when using the response command. A sort string has the following
 format: 
 <verb>
"?&lsqb;+-&rsqb;?&lsqb;+-&rsqb;..."

? is a single character from the following set:
s = size
p = speed
e = extension

+ indicates asecending order, - indicates descending order

For Ex: "e+s-" sorts by extension, followed by size in descending order.
 </verb>
 <item>
<em>verbose</em> - Boolean, if set to 1, the user is immediately notified of when
 downloads start, when they succeed, and when they are enqueued.
 <item>
<em>wait_after_find</em> - Boolean, if set to 1, the find command displays a pretty
 little indicator showing how many results have come in. Otherwise they just
 come in the background.
</itemize>
</p><sect2>
Paths
<p>
<itemize>
 <item>
<em>download_path</em> - String, the directory where downloaded files are written.
 <item>
<em>share_paths</em> - String, directories where scanning for uploadable files occurs.
 Setting this variable has the same effect as the <em>share</em> command.
</itemize>
</p><sect2>
Limits
<p>
Numerical limits, as well as bandwidth limits are supported for transfers
 and connections. The following variables control this operation.
</p>
<p>
<itemize>
 <item>
<em>default_download_cap</em> - Numeric, all new downloads are initially limited
 to this many bytes per second.
 <item>
<em>default_upload_cap</em> - Numeric, all new uploads are initially limited to
 this many bytes.
 <item>
<em>global_bandwidth_cap</em> - Numeric, the sum of all upload and download bandwidths
 is limited to this.
 <item>
<em>max_downloads</em> - Numeric, maximum number of simultaneous downloads to allow.
 Any more than this are queued.
 <item>
<em>max_incoming</em> - Numeric, the gnutella protocol requires that clients connect
 to other clients. This allows you to limit the number of other clients connected
 to yourself.
 <item>
<em>max_uploads</em> - Numeric, the maximum number of outgoing file transfers allowed
 at any one time. New requests are denied after this number is reached.
</itemize>
</p><sect2>
Password Protection
<p>
Gnut can form password protected mini-networks. The password is negotiated
 with each other gnutella servant that is connected to.
</p>
<p>
<itemize>
 <item>
<em>password</em> - String, phrase to use for authentication with remote hosts.
 <item>
<em>password_required</em> - Boolean, if set all incoming gnutella connections will
 be verified against the password.
</itemize>
</p><sect2>
Network Settings
<p>
These pertain to the gnutella protocol, and most users will have no need
 to mess with them.
</p>
<p>
<itemize>
 <item>
<em>hidden</em> - Boolean, if set, the client will not respond to pings, and thus
 will not end up in any other client's host catcher.
 <item>
<em>local_port</em> - Numeric, read-only, the port to which gnut is bound. If you
 wish to change this, you have to use the command-line option.
 <item>
<em>redirect</em> - Boolean, when set, behavior when the maximum number of incoming
 connections is reached changes. Instead of ignoring all new connections, the
 oldest one is dropped and new connections are never refused. This can be used
 to set up a high availability entry point into the gnutella network.
 <item>
<em>speed</em> - Numeric, speed to broadcast us as over the network. This is mostly
 meaningless.
 <item>
<em>ttl</em> - Numeric, the TTL to use for new packets, and to limit routed packets
 to.
</itemize>
</p><sect2>
HTML interface
<p>
If you point your web browser to a gnut servant on the correct port, it
 has the ability to show a list of the shared files. You can also search the
 gnutella network through this interface. That way you could set up a gnut server
 that you can use from any web browser, and not necessarily be at your computer.
</p>
<p>
<itemize>
 <item>
<em>html_enable</em> - Boolean, if set to 1, the html interface is enabled.
 <item>
<em>html_template</em> - String, path to an optional html template file. See section
 4.5.
</itemize>
</p><sect2>
Caching
<p>
As of gnut 0.3.27, caching of frequently requested files is supported.
 Gnut will watch all gnutella connections for query responses, and randomly
 download files into a local cache. This is intended to help distribute the
 load of highly requested files across many computers.
</p>
<p>
<itemize>
 <item>
<em>cache_path</em> - String, set to the directory where you want cached files to
 be stored.
 <item>
<em>cache_refresh</em> - Numeric, number of seconds between updates to the cache.
 <item>
<em>cache_size</em> - Numeric, maximum number of kilobytes to allow the cache to
 grow.
</itemize>
</p><sect1>
Configuration Files
<p>
Gnut is capable of executing files consisting of gnut commands. Upon startup
 it defaults to loading the file &tilde;/.gnutrc (Win32 users can put this file
 in the current working directory). The actual name of the file can be set as
 a command-line option. All the commands are executed before any user input
 is requested.
</p>
<sect1>
Web Access
<p>
You can access a list of all files shared by a Gnut servant by creating
 a connection to them from withing a web browser. to test it for yourself, just
 enter something like <em>http://127.0.0.1:5634</em> (if 5634 is your Gnut port) in your
 browser's address bar. A list of all your shared files should come up. By giving
 your IP address to others, you can let others access your files over the web.
 They can also search the gnutellaNet through your servant by clicking on "Refresh
 Response List." Nifty, eh?
</p>
<p>
Gnut can use a template file for this interface. It is specified in the
 <em>html_template</em> configuration variable. This file is a standard HTML file, except
 that you embed the comment &lt;!-- gnut --&gt; where you want the gnut specific
 stuff to go.
</p>
<sect>
F.A.Q.
<sect1>
Will gnut run on Slackware 4.0?
<p>
No. Gnut requires glibc2.0, you need to upgrade to this before you can
 use it.
</p>
<sect1>
Does ggnut work?
<p>
No, ggnut worked a long time ago, and until some intrepid hacker fixes
 him, you'll have to live with the standard command-line front-end.
</p>
<sect1>
How do I change the port in gnut?
<p>
The port gnut listens on can only be changed on the command line. Use the
 -p option. For example:
</p>
<p>
<verb>
gnut -p 6346
</verb>
</p><sect1>
Does gnut has feature &lt;x&gt;?
<p>
Look in this manual, read README, if you don't see it in either place,
 then the answer is no.
</p>
<sect>
Ideas for Advanced Use
<sect1>
High Availability Connection Point
<p>
Gnut can be used as a publicized connection point into the main gnutella
 network. Just set <em>max_incoming</em> to somewhere around 10 or 20, and <em>redirect</em> to
 1. It might be best not to share any files in this case as the gnutella traffic
 itself is liable to consume large amounts of bandwidth.
</p>
<sect1>
Scriptable Downloads
<p>
Using an interpreted language such as perl, gnut can be directed to automatically
 search and download requested files. Never again will you have to worry about
 when that one host you've been waiting for will get on.
</p>


</article>
