
=head1 NAME

ncdc - Ncurses Direct Connect Client

=head1 SYNOPSIS

ncdc [options]

=head1 DESCRIPTION

Ncdc is a modern and lightweight direct connect client with a friendly ncurses
interface.

=head1 GETTING STARTED

This is a basic introduction for those who are new to ncdc. See the chapters
below for a more detailed description of the available functionality.

What you see when starting up ncdc is an input line where you can input
commands and a log window where the results are displayed, much like a regular
terminal. Commands within ncdc start with a slash (e.g. C</help>) and have tab
completion to help you.

The first thing you will want to do after starting ncdc for the first time is
to setup some basic information and settings:

  /set nick MyNick
  /set description ncdc is awesome!
  /set connection 10
  /share "My Awesome Files" /path/to/files

And if you have a direct connection to the internet or if your router allows
port forwarding, you may also want to enable active mode:

  /set active_port 34194
  /set active true

See the help text for each of the commands and settings for more information.
Of course, all of the above settings are saved to the database and will be used
again on the next run.

To connect to a hub, use /open:

  /open ncdc adc://dc.blicky.net:2780/

Here I<ncdc> is the personal name you give to the hub, and the second argument
the URL. This URL will be saved in the database, so the next time you want to
connect to this hub, you can simply do C</open ncdc>. See the help text for
C</open> and C</connect> for more information. If you want to automatically
connect to a hub when ncdc starts up, use the C<autoconnect> setting.

Ncdc uses a tabbed interface: every hub opens in a new tab, and there are
several other kinds of tabs available as well. The type of tab is indicated in
the tab list on the bottom of the screen with a character prefix. Hubs, for
example, are prefixed with a C<#>. If a tab needs your attention, a colored
exclamation mark is displayed before the tab name, different colors are used
for different types of activity.

Everything else should be fairly self-explanatory: To search for files, use the
C</search> command. To browse through the user list of a hub, use C</userlist> or
hit Alt+u. To browse someone's file list, use C</browse> or hit the 'b' key in
the user list. And to monitor your upload and download connections, use
C</connections> or hit Alt+n.


=head1 OPTIONS

=over

=item B<-c, --session-dir=> I<dir>

Use a different session directory. Defaults to the contents of the environment
variable `$NCDC_DIR' or if this is unset to `$HOME/.ncdc'.

=item B<-h, --help>

Display summary of options.

=item B<-n, --no-autoconnect>

Don't automatically connect to hubs with the C<autoconnect> option set.

=item B<--no-bracketed-paste>

Disable bracketed pasting.

=item B<-v, --version>

Display ncdc version.

=back


=head1 GETTING CONNECTED

As with most file sharing clients, ncdc supports two modes of being connected:
I<active> and I<passive>. In passive mode (the default), you can connect to the
outside world but nobody can connect (directly) to you. When passive, you will
only be able to transfer files with people who are in active mode. In active
mode, however, you will have some port open to the rest of the network to which
other clients can connect. When active, you will be able to transfer files with
everyone and you may get more and faster search results. Configuring active
mode is therefore recommended.

In many setups, all you need to do to switch to active mode is to set a TCP/UDP
port and enable the C<active> setting:

  /set active_port 34194
  /set active true

When you connect to a hub, the status bar will tell you whether you are active
or passive on that particular hub, and what IP address is being used to allow
others to connect to you. For most hubs, your IP address will be detected
automatically, but in the event that this fails, you can also set it yourself:

  /set active_ip 13.33.33.7

If you are behind a NAT or firewall, you have to ensure that the port you
configured is somehow allowed and/or forwarded. The C<active_port> setting is
used for incoming TCP connections and UDP messages. You can configure a
different UDP port with the C<active_udp_port> setting. Contrary to many toher
Direct Connect clients, ncdc only uses a single port for incoming TCP and TLS
connections; There is no separate port for TLS.

The C</listen> command can tell you which ports it expects to be forwarded, and
for which hubs these ports will be used. It only lists hubs on which you are
currently active, so the output will change when you open or close a hub
connection.

If you have multiple network interfaces, you can force ncdc to use only a
single interface by setting the C<local_address> setting to the address of that
interface. This affects both outgoing connections (they will be forced to go
through the configured interface) and incoming connections (the ports will be
bound to the configured interface).

All of the previously mentioned settings can be set globally (with C</set>) and
on a per-hub basis (with C</hset>). This allows you to be active on an internet
hub and a LAN-only hub at the same time. It also allows you to be active in one
hub while passive in another, or to use different ports for each hub.


=head1 INTERACTIVE COMMANDS

The following is the list of commands that can be used within ncdc. The /help
command can also be used get a list of available commands and to access this
documentation.

=over

=item B</accept>

Use this command to accept the TLS certificate of a hub. This command is used only in the case the keyprint of the TLS certificate of a hub does not match the keyprint stored in the database.

=item B</browse> [[-f] <user>]

Without arguments, this opens a new tab where you can browse your own file list. Note that changes to your list are not immediately visible in the browser. You need to re-open the tab to get the latest version of your list.

With arguments, the file list of the specified user will be downloaded (if it has not been downloaded already) and the browse tab will open once it's complete. The `-f' flag can be used to force the file list to be (re-)downloaded.

=item B</clear>

Clears the log displayed on the screen. Does not affect the log files in any way. Ctrl+l is a shortcut for this command.

=item B</close>

Close the current tab. When closing a hub tab, you will be disconnected from the hub and all related userlist and PM tabs will also be closed. Alt+c is a shortcut for this command.

=item B</connect> [<address>]

Initiate a connection with a hub. If no address is specified, will connect to the hub you last used on the current tab. The address should be in the form of `protocol://host:port/' or `host:port'. The `:port' part is in both cases optional and defaults to :411. The following protocols are recognized: dchub, nmdc, nmdcs, adc, adcs. When connecting to an nmdcs or adcs hub and the SHA256 keyprint is known, you can attach this to the url as `?kp=SHA256/<base32-encoded-keyprint>'

Note that this command can only be used on hub tabs. If you want to open a new connection to a hub, you need to use /open first. For example:

  /open testhub
  /connect dchub://dc.some-test-hub.com/

See the /open command for more information.

=item B</connections>

Open the connections tab.

=item B</delhub> <name>

Remove a hub from the configuration

=item B</disconnect>

Disconnect from a hub.

=item B</gc>

Cleans up unused data and reorganizes existing data to allow more efficient storage and usage. Currently, this commands removes unused hash data, does a VACUUM on db.sqlite3, removes unused files in inc/ and old files in fl/.

This command may take some time to complete, and will fully block ncdc while it is running. It is recommended to run this command every once in a while. Every month is a good interval. Note that when ncdc says that it has completed this command, it's lying to you. Ncdc will still run a few large queries on the background, which may take up to a minute to complete.

=item B</grant> [-list|<user>]

Grant someone a slot. This allows the user to download from you even if you have no free slots.  The slot will remain granted until the /ungrant command is used, even if ncdc has been restarted in the mean time.

To get a list of users whom you have granted a slot, use `/grant' without arguments or with `-list'. Be warned that using `/grant' without arguments on a PM tab will grant the slot to the user you are talking with. Make sure to use `-list' in that case.

Note that a granted slot is specific to a single hub. If the same user is also on other hubs, he/she will not be granted a slot on those hubs.

=item B</help> [<command>|set <key>|keys [<section>]]

To get a list of available commands, use /help without arguments.
To get information on a particular command, use /help <command>.
To get information on a configuration setting, use /help set <setting>.
To get help on key bindings, use /help keys.


=item B</hset> [<key> [<value>]]

Get or set per-hub configuration variables. Works equivalent to the `/set' command, but can only be used on hub tabs. Use `/hunset' to reset a variable back to its global value.

=item B</hunset> [<key>]

This command can be used to reset a per-hub configuration variable back to its global value.

=item B</kick> <user>

Kick a user from the hub. This command only works on NMDC hubs, and you need to be an OP to be able to use it.

=item B</listen>

List currently opened ports.

=item B</me> <message>

This allows you to talk in third person. Most clients will display your message as something like:

  ** Nick is doing something

Note that this command only works correctly on ADC hubs. The NMDC protocol does not have this feature, and your message will be sent as-is, including the /me.

=item B</msg> <user> [<message>]

Send a private message to a user on the currently opened hub. If no message is given, the tab will be opened but no message will be sent.

=item B</nick> [<nick>]

Alias for `/hset nick' on hub tabs, and `/set nick' otherwise.

=item B</open> [-n] [<name>] [<address>]

Without arguments, list all hubs known by the current configuration. Otherwise, this opens a new tab to use for a hub. The name is a (short) personal  name you use to identify the hub, and will be used for storing hub-specific  configuration.

If you have specified an address or have previously connected to a hub from a tab with the same name, /open will automatically connect to the hub. Use the `-n' flag to disable this behaviour.

See /connect for more information on connecting to a hub.

=item B</password> <password>

This command can be used to send a password to the hub without saving it to the database. If you wish to login automatically without having to type /password every time, use '/hset password <password>'. Be warned, however, that your password will be saved unencrypted in that case.

=item B</pm> <user> [<message>]

Alias for /msg

=item B</queue>

Open the download queue.

=item B</quit>

Quit ncdc.

=item B</reconnect>

Reconnect to the hub. When your nick or the hub encoding have been changed, the new settings will be used after the reconnect.

This command can also be used on the main tab, in which case all connected hubs will be reconnected.

=item B</refresh> [<path>]

Initiates share refresh. If no argument is given, the complete list will be refreshed. Otherwise only the specified directory will be refreshed. The path argument can be either an absolute filesystem path or a virtual path within your share.

=item B</say> <message>

Sends a chat message to the current hub or user. You normally don't have to use the /say command explicitly, any command not staring with '/' will automatically imply `/say <command>'. For example, typing `hello.' in the command line is equivalent to `/say hello.'. Using the /say command explicitly may be useful to send message starting with '/' to the chat, for example `/say /help is what you are looking for'.

=item B</search> [options] <query>

Performs a file search, opening a new tab with the results.

Available options:

  -hub      Search the current hub only. (default)
  -all      Search all connected hubs, except those with `chat_only' set.
  -le  <s>  Size of the file must be less than <s>.
  -ge  <s>  Size of the file must be larger than <s>.
  -t   <t>  File must be of type <t>. (see below)
  -tth <h>  TTH root of this file must match <h>.

File sizes (<s> above) accept the following suffixes: G (GiB), M (MiB) and K (KiB).

The following file types can be used with the -t option:

  1  any      Any file or directory. (default)
  2  audio    Audio files.
  3  archive  (Compressed) archives.
  4  doc      Text documents.
  5  exe      Windows executables.
  6  img      Image files.
  7  video    Video files.
  8  dir      Directories.

Note that file type matching is done using file extensions, and is not very reliable.

=item B</set> [<key> [<value>]]

Get or set global configuration variables. Use without arguments to get a list of all global settings and their current value. Glob-style pattern matching on the settings is also possible. Use, for example, `/set color*' to list all color-related settings.

See the `/unset' command to change a setting back to its default, and the `/hset' command to manage configuration on a per-hub basis. Changes to the settings are automatically saved to the database, and will not be lost after restarting ncdc.

To get information on a particular setting, use `/help set <key>'.

=item B</share> [<name> <path>]

Use /share without arguments to get a list of shared directories.
When called with a name and a path, the path will be added to your share. Note that shell escaping may be used in the name. For example, to add a directory with the name `Fun Stuff', you could do the following:

  /share "Fun Stuff" /path/to/fun/stuff

Or:

  /share Fun\ Stuff /path/to/fun/stuff

The full path to the directory will not be visible to others, only the name you give it will be public. An initial `/refresh' is done automatically on the added directory.

=item B</ungrant> [<user>]

Revoke a granted slot.

=item B</unset> [<key>]

This command can be used to reset a global configuration variable back to its default value.

=item B</unshare> [<name>]

To remove a single directory from your share, use `/unshare <name>', to remove all directories from your share, use `/unshare /'.

Note that the hash data associated with the removed files will remain in the database. This allows you to re-add the files to your share without needing to re-hash them. The downside is that the database file may grow fairly large with unneeded information. See the `/gc' command to clean that up.

=item B</userlist>

Opens the user list of the currently selected hub. Can also be accessed using Alt+u.

=item B</version>

Display version information.

=item B</whois> <user>

This will open the user list and select the given user.

=back




=head1 SETTINGS

The following is a list of configuration settings. These settings can be
changed and queried using the C</set> command for global settings and C</hset>
for hub-local settings. All configuration data is stored in the db.sqlite3 file
in the session directory.

=over

=item B<active> <boolean>

Enables or disables active mode. You may have to configure your router and/or firewall for this to work, see the `active_ip' and `active_port' settings for more information.

=item B<active_ip> <string>

Your public IP address for use in active mode. If this is not set or set to '0.0.0.0' for IPv4 or '::' for IPv6, then ncdc will try to automatically get your IP address from the hub. If you do set this manually, it is important that other clients can reach you using this IP address. If you connect to a hub on the internet, this should be your internet (WAN) IP. Likewise, if you connect to a hub on your LAN, this should be your LAN IP.

Both an IPv4 and an IPv6 address are set by providing two IP addresses separated with a comma. When unset, '0.0.0.0,::' is assumed. Only the IP version used to connect to the hub is used. That is, if you connect to an IPv6 hub, then the configured IPv6 address is used and the IPv4 address is ignored.

When set to the special value `local', ncdc will automatically get your IP address from the local network interface that is used to connect to the hub. This option should only be used if there is no NAT between you and the hub, because this will give the wrong IP if you are behind a NAT.

=item B<active_port> <integer>

The listen port for incoming connections in active mode. Set to `0' to automatically assign a random port. This setting is by default also used for the UDP port, see the `active_tls_port' settings to change that. If you are behind a router or firewall, make sure that you have configured it to forward and allow these ports.

=item B<active_udp_port> <integer>

The listen port for incoming UDP connections in active mode. Defaults to the `active_port' setting, or to a random number if `active_port' is not set.

=item B<adc_blom> <boolean>

Whether to support the BLOM extension on ADC hubs. This may decrease the bandwidth usage on the hub connection, in exchange for a bit of computational overhead. Some hubs require this setting to be enabled. This setting requires a reconnect with the hub to be active.

=item B<autoconnect> <boolean>

Set to true to automatically connect to the current hub when ncdc starts up.

=item B<autorefresh> <interval>

The time between automatic file refreshes. Recognized suffices are 's' for seconds, 'm' for minutes, 'h' for hours and 'd' for days. Set to 0 to disable automatically refreshing the file list. This setting also determines whether ncdc will perform a refresh on startup. See the `/refresh' command to manually refresh your file list.

=item B<backlog> <integer>

When opening a hub or PM tab, ncdc can load a certain amount of lines from the log file into the log window. Setting this to a positive value enables this feature and configures the number of lines to load. Note that, while this setting can be set on a per-hub basis, PM windows will use the global value (global.backlog).

=item B<chat_only> <boolean>

Set to true to indicate that this hub is only used for chatting. That is, you won't or can't download from it. This setting affects the /search command when it is given the -all option.

=item B<color_*> <color>

The settings starting with the `color_' prefix allow you to change the interface colors. The following is a list of available color settings:

  list_default  - default item in a list
  list_header   - header of a list
  list_select   - selected item in a list
  log_default   - default log color
  log_time      - the time prefix in log messages
  log_nick      - default nick color
  log_highlight - nick color of a highlighted line
  log_ownnick   - color of your own nick
  log_join      - color of join messages
  log_quit      - color of quit messages
  separator     - the list separator/footer bar
  tab_active    - the active tab in the tab list
  tabprio_low   - low priority tab notification color
  tabprio_med   - medium priority tab notification color
  tabprio_high  - high priority tab notification color
  title         - the title bar

The actual color value can be set with a comma-separated list of color names and/or attributes. The first color in the list is the foreground color, the second color is used for the background. When the fore- or background color is not specified, the default colors of your terminal will be used.
The following color names can be used: black, blue, cyan, default, green, magenta, red, white and yellow.
The following attributes can be used: bold, blink, reverse and underline.
The actual color values displayed by your terminal may vary. Adding the `bold' attribute usually makes the foreground color appear brighter as well.

=item B<connection> <string>

Set your upload speed. This is just an indication for other users in the hub so that they know what speed they can expect when downloading from you. The actual format you can use here may vary, but it is recommended to set it to either a plain number for Mbit/s (e.g. `50' for 50 mbit) or a number with a `KiB/s' indicator (e.g. `2300 KiB/s'). On ADC hubs you must use one of the previously mentioned formats, otherwise no upload speed will be broadcasted. This setting is broadcasted as-is on NMDC hubs, to allow for using old-style connection values (e.g. `DSL' or `Cable') on hubs that require this.

This setting is ignored if `upload_rate' has been set. If it is, that value is broadcasted instead.

=item B<description> <string>

A short public description that will be displayed in the user list of a hub.

=item B<disconnect_offline> <boolean>

Automatically disconnect any upload or download transfers when a user leaves the hub, or when you leave the hub. Setting this to `true' ensures that you are only connected with people who are online on the same hubs as you are.

=item B<download_dir> <path>

The directory where finished downloads are moved to. Finished downloads are by default stored in <session directory>/dl/. It is possible to set this to a location that is on a different filesystem than the incoming directory, but doing so is not recommended: ncdc will block when moving the completed files to their final destination.

=item B<download_exclude> <regex>

When recursively adding a directory to the download queue - by pressing `d' on a directory in the file list browser - any item in the selected directory with a name that matches this regular expression will not be added to the download queue.

This regex is not checked when adding individual files from either the file list browser or the search results.

=item B<download_rate> <speed>

Maximum combined transfer rate of all downloads. The total download speed will be limited to this value. The suffixes `G', 'M', and 'K' can be used for GiB/s, MiB/s and KiB/s, respectively. Note that, similar to upload_rate, TCP overhead are not counted towards this limit, so the actual bandwidth usage might be a little higher.

=item B<download_segment> <size>

Minimum segment size to use when requesting file data from another user. Set to 0 to disable segmented downloading.

=item B<download_shared> <boolean>

Whether to download files which are already present in your share. When this is set to `false', adding already shared files results in a UI message instead of adding the file to the download queue.

=item B<download_slots> <integer>

Maximum number of simultaneous downloads.

=item B<email> <string>

Your email address. This will be displayed in the user list of the hub, so only set this if you want it to be public.

=item B<encoding> <string>

The character set/encoding to use for hub and PM messages. This setting is only used on NMDC hubs, ADC always uses UTF-8. Some common values are:

  CP1250      (Central Europe)
  CP1251      (Cyrillic)
  CP1252      (Western Europe)
  ISO-8859-7  (Greek)
  KOI8-R      (Cyrillic)
  UTF-8       (International)

=item B<filelist_maxage> <interval>

The maximum age of a downloaded file list. If a file list was downloaded longer ago than the configured interval, it will be removed from the cache (the fl/ directory) and subsequent requests to open the file list will result in the list being downloaded from the user again. Recognized suffices are 's' for seconds, 'm' for minutes, 'h' for hours and 'd' for days. Set to 0 to disable the cache altogether.

=item B<flush_file_cache> <none|upload|download|hash>[,...]

Tell the OS to flush the file (disk) cache for file contents read while hashing and/or uploading or written to while downloading. On one hand, this will avoid trashing your disk cache with large files and thus improve the overall responsiveness of your system. On the other hand, ncdc may purge any shared files from the cache, even if they are still used by other applications. In general, it is a good idea to enable this if you also use your system for other things besides ncdc, you share large files (>100MB) and people are not constantly downloading the same file from you.

=item B<geoip_cc> <path>|disabled

Path to the GeoIP2 Country database file (GeoLite2-Country.mmdb), or 'disabled' to disable GeoIP lookups. The database can be downloaded  from https://dev.maxmind.com/geoip/geoip2/geolite2/.

=item B<hash_rate> <speed>

Maximum file hashing speed. See the `download_rate' setting for allowed formats for this setting.

=item B<hubname> <string>

The name of the currently opened hub tab. This is a user-assigned name, and is only used within ncdc itself. This is the same name as given to the `/open' command.

=item B<incoming_dir> <path>

The directory where incomplete downloads are stored. This setting can only be changed when the download queue is empty. Also see the download_dir setting.

=item B<local_address> <string>

Specifies the address of the local network interface to use for connecting to the outside and for accepting incoming connections in active mode. Both an IPv4 and an IPv6 address are set by providing two IP addresses separated with a comma. When unset, '0.0.0.0,::' is assumed.

If no IPv4 address is specified, '0.0.0.0' is added automatically. Similarly, if no IPv6 address is specified, '::' is added automatically. The address that is actually used depends on the IP version actually used. That is, if you're on an IPv6 hub, then ncdc will listen on the specified IPv6 address. Note that, even if the hub you're on is on IPv6, ncdc may still try to connect to another client over IPv4, at which point the socket will be bound to the configured IPv4 address.

=item B<log_debug> <boolean>

Log debug messages to stderr.log in the session directory. It is highly recommended to enable this setting if you wish to debug or hack ncdc. Be warned, however, that this may generate a lot of data if you're connected to a large hub.

=item B<log_downloads> <boolean>

Log downloaded files to transfers.log.

=item B<log_hubchat> <boolean>

Log the main hub chat. Note that changing this requires any affected hub tabs to be closed and reopened before the change is effective.

=item B<log_uploads> <boolean>

Log file uploads to transfers.log.

=item B<max_ul_per_user> <integer>

The maximum number of simultaneous upload connections to one user.

=item B<minislots> <integer>

Set the number of available minislots. A `minislot' is a special slot that is used when all regular upload slots are in use and someone is requesting your filelist or a small file. In this case, the other client automatically applies for a minislot, and can still download from you as long as not all minislots are in use. What constitutes a `small' file can be changed with the `minislot_size' setting. Also see the `slots' configuration setting and the `/grant' command.

=item B<minislot_size> <integer>

The maximum size of a file that may be downloaded using a `minislot', in KiB. See the `minislots' setting for more information.

=item B<nick> <string>

Your nick. Nick changes are only visible on newly connected hubs, use the  `/reconnect' command to use your new nick immediately. Note that it is highly discouraged to change your nick on NMDC hubs. This is because clients downloading from you have no way of knowing that you changed your nick, and therefore can't immediately continue to download from you.

=item B<notify_bell> <disable|low|medium|high>

When enabled, ncdc will send a bell to your terminal when a tab indicates a notification. The notification types are:

  high   - Messages directed to you (PM or highlight in hub chat),
  medium - Regular hub chat,
  low    - User joins/quits, new search results, etc.

How a "bell" (or "beep" or "alert", whatever you prefer to call it) manifests itself depends on your terminal. In some setups, this generates an audible system bell. In other setups it can makes your terminal window flash or do other annoying things to get your attention.  And in some setups it is ignored completely.

=item B<password> <string>

Sets your password for the current hub and enables auto-login on connect. If you just want to login to a hub without saving your password, use the `/password' command instead. Passwords are saved unencrypted in the config file.

=item B<reconnect_timeout> <interval>

The time to wait before automatically reconnecting to a hub. Set to 0 to disable automatic reconnect.

=item B<sendfile> <boolean>

Whether or not to use the sendfile() system call to upload files, if supported. Using sendfile() allows less resource usage while uploading, but may not work well on all systems.

=item B<share_emptydirs> <boolean>

Share empty directories. When disabled (the default), empty directories in your share will not be visible to others. This also affects empty directories containing only empty directories, etc. A file list refresh is required for this setting to be effective.

=item B<share_exclude> <regex>

Any file or directory with a name that matches this regular expression will not be shared. A file list refresh is required for this setting to be effective.

=item B<share_hidden> <boolean>

Whether to share hidden files and directories. A `hidden' file or directory is one of which the file name starts with a dot. (e.g. `.bashrc'). A file list refresh is required for this setting to be effective.

=item B<share_symlinks> <boolean>

Whether to follow symlinks in shared directories. When disabled (default), ncdc will never share any files outside of the directory you specified. When enabled, any symlinks in your shared directories will be followed, even when they point to a directory outside your share.

=item B<show_free_slots> <boolean>

When set to true, [n sl] will be prepended to your description, where n is the number of currently available upload slots.

=item B<show_joinquit> <boolean>

Whether to display join/quit messages in the hub chat.

=item B<slots> <integer>

The number of upload slots. This determines for the most part how many people can download from you simultaneously. It is possible that this limit is exceeded in certain circumstances, see the `minislots' setting and the `/grant' command.

=item B<sudp_policy> <disabled|allow|prefer>

Set the policy for sending or receiving encrypted UDP search results. When set to `disabled', all UDP search results will be sent and received in plain text. Set this to `allow' to let ncdc reply with encrypted search results if the other client requested it. `prefer' will also cause ncdc itself to request encryption.

Note that, regardless of this setting, encrypted UDP search results are only used on ADCS hubs. They will never be sent on NMDC or non-TLS ADC hubs. Also note that, even if you set this to `prefer', encryption is still only used when the client on the other side of the connection also supports it.

=item B<tls_policy> <disabled|allow|prefer>

Set the policy for secure client-to-client connections. Setting this to `disabled' disables TLS support for client connections, but still allows you to connect to TLS-enabled hubs. `allow' will allow the use of TLS if the other client requests this, but ncdc itself will not request TLS when connecting to others. Setting this to `prefer' tells ncdc to also request TLS when connecting to others.

The use of TLS for client connections usually results in less optimal performance when uploading and downloading, but is quite effective at avoiding protocol-specific traffic shaping that some ISPs may do. Also note that, even if you set this to `prefer', TLS will only be used if the connecting party also supports it.

=item B<tls_priority> <string>

Set the GnuTLS priority string used for all TLS-enabled connections. See the "Priority strings" section in the GnuTLS manual for details on what this does and how it works. Currently it is not possible to set a different priority string for different types of connections (e.g. hub or incoming/outgoing client connections).

=item B<ui_time_format> <string>

The format of the time displayed in the lower-left of the screen. Set `-' to not display a time at all. The string is passed to the Glib g_date_time_format() function, which accepts roughly the same formats as strftime(). Check out the strftime(3) man page or the Glib documentation for more information. Note that this setting does not influence the date/time format used in other places, such as the chat window or log files.

=item B<upload_rate> <speed>

Maximum combined transfer rate of all uploads. See the `download_rate' setting for more information on rate limiting. Note that this setting also overrides any `connection' setting.

=back




=head1 KEY BINDINGS

On any tab without the text input line, you can press `?' to get the key
bindings for that tab. The list of key bindings is available through the
C</help keys> command, and is reproduced below.

=over

=item B<Global key bindings>

  Alt+j        Open previous tab.
  Alt+k        Open next tab.
  Alt+h        Move current tab left.
  Alt+l        Move current tab right.
  Alt+a        Move tab with recent activity.
  Alt+<num>    Open tab with number <num>.
  Alt+c        Close current tab.
  Alt+n        Open the connections tab.
  Alt+q        Open the download queue tab.
  Alt+o        Open own file list.
  Alt+r        Refresh file list.
  
  Keys for tabs with a log window:
  Ctrl+l       Clear current log window.
  PgUp         Scroll the log backward.
  PgDown       Scroll the log forward.
  
  Keys for tabs with a text input line:
  Left/Right   Move cursor one character left or right.
  End/Home     Move cursor to the end / start of the line.
  Up/Down      Scroll through the command history.
  Tab          Auto-complete current command, nick or argument.
  Alt+b        Move cursor one word backward.
  Alt+f        Move cursor one word forward.
  Backspace    Delete character before cursor.
  Delete       Delete character under cursor.
  Ctrl+w       Delete to previous space.
  Alt+d        Delete to next space.
  Ctrl+k       Delete everything after cursor.
  Ctrl+u       Delete entire line.

=item B<File browser>

  Up/Down      Select one item up/down.
  k/j          Select one item up/down.
  PgUp/PgDown  Select one page of items up/down.
  End/Home     Select last/first item in the list.
  /            Start incremental regex search (press Return to stop editing).
  ,/.          Search next / previous.
  Right/l      Open selected directory.
  Left/h       Open parent directory.
  t            Toggle sorting directories before files.
  s            Order by file size.
  n            Order by file name.
  d            Add selected file/directory to the download queue.
  m            Match selected item with the download queue.
  M            Match entire file list with the download queue.
  a            Search for alternative download sources.

=item B<Connection list>

  Up/Down      Select one item up/down.
  k/j          Select one item up/down.
  PgUp/PgDown  Select one page of items up/down.
  End/Home     Select last/first item in the list.
  d            Disconnect selected connection.
  i/Return     Toggle information box.
  f            Find user in user list.
  m            Send a PM to the selected user.
  q            Find file in download queue.
  b/B          Browse the selected user's list, B to force a redownload.

=item B<Download queue>

  Up/Down      Select one item up/down.
  k/j          Select one item up/down.
  PgUp/PgDown  Select one page of items up/down.
  End/Home     Select last/first item in the list.
  K/J          Select one user up/down.
  f            Find user in user list.
  c            Find connection in the connection list.
  a            Search for alternative download sources.
  d            Remove selected file from the queue.
  +/-          Increase/decrease priority.
  i/Return     Toggle user list.
  r            Remove selected user for this file.
  R            Remove selected user from all files in the download queue.
  x            Clear error state for the selected user for this file.
  X            Clear error state for the selected user for all files.
  
  Note: when an item in the queue has `ERR' indicated in the
  priority column, you have two choices: You can remove the
  item from the queue using `d', or attempt to continue the
  download by increasing its priority using `+'.

=item B<Search results tab>

  Up/Down      Select one item up/down.
  k/j          Select one item up/down.
  PgUp/PgDown  Select one page of items up/down.
  End/Home     Select last/first item in the list.
  f            Find user in user list.
  b/B          Browse the selected user's list, B to force a redownload.
  d            Add selected file to the download queue.
  h            Toggle hub column visibility.
  u            Order by username.
  s            Order by file size.
  l            Order by free slots.
  n            Order by file name.
  m            Match selected item with the download queue.
  M            Match all search results with the download queue.
  q            Match selected users' list with the download queue.
  Q            Match all matched users' lists with the download queue.
  a            Search for alternative download sources.

=item B<User list tab>

  Up/Down      Select one item up/down.
  k/j          Select one item up/down.
  PgUp/PgDown  Select one page of items up/down.
  End/Home     Select last/first item in the list.
  /            Start incremental regex search (press Return to stop editing).
  ,/.          Search next / previous.
  o            Toggle sorting OPs before others.
  s/S          Order by share size.
  u/U          Order by username.
  t/T          Toggle visibility / order by tag column.
  e/E          Toggle visibility / order by email column.
  c/C          Toggle visibility / order by connection column.
  p/P          Toggle visibility / order by IP column.
  i/Return     Toggle information box.
  m            Send a PM to the selected user.
  g            Grant a slot to the selected user.
  b/B          Browse the selected users' list, B to force a redownload.
  q            Match selected users' list with the download queue.

=back




=head1 WEIRD UI FLAGS

Some listings have a flags display, and their meaning may not be immediately obvious.

=head2 File status

You may see one-letter flags to the left of file names in search results and
file list tabs. Their meaning is as follows:

=over

=item H

The file had been added to the file list, but has not been hashed yet and thus
is not visible to others. This flag can appear only when browsing your own list.

=item S

The file is already in your share. If C<download_shared> is set to C<false>,
trying to download it will result only in an informational message. This flag
never appears when browsing your own file list.

=item Q

The file is currently in your download queue. Trying to download it will result
only in an informational message.

=back

=head2 Connection flags

On the connection list window, there are two flags:

=over

=item S

Connection state, can be either B<C>onnecting, B<H>andshake, B<I>dle,
B<D>ownloading, B<U>ploading or B<-> for disconnected.

=item t

This means that the connection is encrypted with TLS.

=back

=head2 User flags

The user list has some flags too:

=over

=item o

Set if the user is an operator in the hub.

=item p

When the user is passive. If this flag is not set, the user is active.

=item t

Set if connections with this user will be encrypted with TLS.

=back


=head1 ENVIRONMENT

$NCDC_DIR is used to determine the session dir, it is only honoured if I<-c> is
not set on the command line.


=head1 FILES

$NCDC_DIR corresponds to the session dir set via I<-c>, environment variable
$NCDC_DIR or $HOME/.ncdc.

=over

=item $NCDC_DIR/cert/

Directory where the client certificates are stored. Must contain a private key
file (client.key) and public certificate (client.crt). These will be generated
automatically when ncdc starts up the first time.

=item $NCDC_DIR/db.sqlite3

The database. This stores all configuration variables, hash data of shared
files, download queue information and other state information. Manually editing
this file with the `sqlite3' commandline tool is possible but discouraged. Any
changes made to the database while ncdc is running will not be read, and may
even get overwritten by ncdc.

=item $NCDC_DIR/dl/

Directory where completed downloads are moved to by default. Can be changed
with the C<download_dir> configuration option.

=item $NCDC_DIR/files.xml.bz2

Filelist containing a listing of all shared files.

=item $NCDC_DIR/fl/

Directory where downloaded file lists from other users are stored. The names of
the files are hex-encoded user IDs that are used internally by ncdc. Old file
lists are deleted automatically after a configurable interval. See the
C<filelist_maxage> configuration option.


=item $NCDC_DIR/history

Command history.

=item $NCDC_DIR/inc/

Default location for incomplete downloads. Can be changed with the
C<incoming_dir> setting. The file names in this directory are the
base32-encoded TTH root of the completed file.

=item $NCDC_DIR/logs/

Directory where all the log files are stored. File names starting with `#' are
hub logs and `~' are user (PM) logs. Special log files are transfers.log and
main.log.

ncdc does not have built-in functionality to rotate or compress log files
automatically. When rotating log files manually (e.g. via a cron job), make
sure to send the SIGUSR1 signal afterwards to force ncdc to flush the old logs
and create or open the new log files.

=item $NCDC_DIR/stderr.log

Error/debug log. This file is cleared every time ncdc starts up.

=item $NCDC_DIR/version

Version of the data directory. This file locked while an ncdc instance is
running, making sure that no two ncdc instances work with the same session
directory at the same time.

=back

=head2 Format of transfers.log

Uploads and downloads are logged in the transfers.log file. Transfers are
separated by a newline (C<0x0a>). Each log line has the following fields,
separated by a space:

=over

=item 1.

Date/time when the transfer ended, formatted as C<[YYYY-MM-DD HH:MM:SS ZONE]>,

=item 2.

Hub name, including the C<#> prefix,

=item 3.

Base32-encoded CID of the other user for ADC transfers, or a '-' for NMDC,

=item 4.

User name (escaped),

=item 5.

IPv4 or IPv6 address,

=item 6.

Direction, C<u> for upload or C<d> for download,

=item 7.

Whether the transfer completed successfully (C<c>) or has been
interrupted/disconnected before all requested file data has been transferred
(C<i>),

=item 8.

Base32-encoded TTH of the transferred file, or '-' for C<files.xml.bz2>,

=item 9.

Total transfer time, in seconds,

=item 10.

File size, in bytes,

=item 11.

File offset, in bytes,

=item 12.

Transfer size, in bytes,

=item 13.

File path (escaped). Absolute virtual path for uploads, destination path for
downloads.

=back

All fields are encoded in UTF-8. Fields that may contain a space or newline are
escaped as follows: A space is escaped as C<\s>, a newline as C<\n> and a
backslash as C<\\>. The timestamp is not escaped.

Many clients download files is separate (smallish) chunks. Ncdc makes no
attempt to combine multiple chunk requests in a single log entry, so you may
see the same uploaded file several times with a different file offset.


=head1 LICENSE

Copyright (C) 2011-2019 Yoran Heling <projects@yorhel.nl>

ncdc is distributed under the MIT license, please read the COPYING file for
more information.

=head1 BUGS

Please report bugs or feature requests to the bug tracker or the mailing list.
Both can be found on the ncdc homepage at L<https://dev.yorhel.nl/ncdc>. There
is also an ADC hub available at C<adc://dc.blicky.net:2780/> for general
support and discussions.

=head1 AUTHOR

ncdc is written by Yoran Heling <projects@yorhel.nl>

Web: L<https://dev.yorhel.nl/ncdc>
