npds-tracker-server
文件大小: unknow
源码售价: 5 个金币 积分规则     积分充值
资源说明:Java based server for tracking Newton Personal Data Sharing clients.
# NPDS Tracker Server

A Java based server for tracking and listing [Newton Personal Data Sharing](http://npds.free.fr/) clients.

The [NPDS Tracker Server](http://npds.free.fr/trackers/) was originally developed by [Victor Rehorst](http://www.chuma.org/) and [Paul Guyot](http://kallisys.com/).

Additional contributions and updates have been by generously provided and applied by [Morgan Aldridge](http://makkintosshu.com/), [Grant Hutchinson](http://splorp.com/), [Ron Parker](http://quadzilla.net/), Manuel Probsthain, Peter Geremia, and [Sylvain Pilet](http://message-pad.net/).

Many thanks to [Matt Vaughn](http://chromatin.cshl.edu/vaughn/) for developing NPDS in the first place.

Looking for support? Join the [NPDS mailing list](http://npds.free.fr/list/).


## Requirements

### Java 1.3 or later

The current release of the NPDS Tracker Server has been tested with Java SE (Standard Edition) versions 1.4, 1.5, and 1.6. It will also work with versions earlier than 1.3, but it is not recommended. See the [Basic Set Up](#basic-set-up) section for more information.

The Java SE runtime can be downloaded from [Oracle](http://www.oracle.com/technetwork/java/javase/).

### An internet connection

The NPDS Tracker Server listens for clients on TCP port 3680, as assigned by [IANA](http://www.iana.org/assignments/service-names-port-numbers/service-names-port-numbers.xml). The tracker can also be configured to listen on multiple ports. See the [Settings](#settings) section for more information.

### A text editor

Required to edit the various configuration and template files.

### A terminal program

Required to compile the Java source, install the compiled .jar file, and configuring the related files and components. A terminal program can also be used to remote administer the NPDS Tracker Server using Telnet. See the [Remote Administration](#remote-administration) section for more information.


## Files

`readme.md` — You’re soaking in it

`npdstracker.java` — Java source code for the tracker

`npdstracker.ini` — Settings and configuration for the tracker

`template.html` — HTML page template used by the tracker

`template.css` — Stylesheet used in conjunction with the HTML page template

`npdscmd.txt` — Initial tracker commands. Registered servers are written to this file upon shutdown

`startnpds.sh` — An example shell script for Unix-like operating systems

`manifest.mf` — Information specific to the creation of the `.jar` file


## Getting Started

### Got Java?

First, determine whether Java is installed. Open a command line and type:

```sh
which java
```

This command will return the path where Java is installed on your system.

For example:

```sh
/usr/bin/java
```

If a path is not displayed after running this command, then Java is not currently installed on your system. You will need to download and install the [Java SE](http://www.oracle.com/technetwork/java/javase/) software before proceeding.

To determine the version of Java installed, type the following:

```sh
java -version
```

This command will return information about the current Java installation, including the version number and related software details.

For example:

```sh
java version "1.6.0_30"
```

### Grab the source

Download the [latest version](https://github.com/splorp/npds-tracker-server/archive/master.zip) of the NPDS Tracker Server source. Decompress the archive and move the entire directory to an appropriate location on your system. Technically, you can install and run the tracker software anywhere on your system (providing you have adequate file permissions), with all of the components residing in the same directory. The [Basic Set Up](#basic-set-up) section describes this type of installation.


## Basic Set Up

### Compile the source

Assuming that Java 1.3 or later has been correctly installed, open a command line and compile the server source:

```sh
javac npdstracker.java
```

Depending on your system environment, you may see messages similar to the following. You can safely ignore them.

```sh
Note: npdstracker.java uses unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
```

If compiling was successful, a series of `.class` files will now reside in the source directory.

```sh
npdstracker.class
npdstracker$TConnection.class
npdstracker$THostInfo.class
npdstracker$TQueryException.class
npdstracker$TServer.class
npdstracker$TServerInfo.class
npdstracker$TValidator.class
```

### Configure the server

Edit `npdstracker.ini` and change the settings specific to your installation.

If all of the source files remain in the same directory, you will not need to change the defaults for the `pageTemplate`, `cssTemplate`, or `logfile` path settings.

See the [Settings](#settings) section for setting descriptions and syntax.

### Start the server

Start the server from the command line:

```sh
java npdstracker
```

For Java 1.1 and 1.2 installations, the `-Dsun.net.inetaddr.ttl=0` parameter must be added to the command line. This additional parameter compensates for DNS caching bugs that exist in these versions of the Java runtime.

```sh
java -Dsun.net.inetaddr.ttl=0 npdstracker
```

Test the connection to the tracker by launching your web browser using the following URL:

```sh
http://:3680/
```

Configure an [NPDS Tracker Client](http://npds.free.fr/modules/#trackerclient) to point at the tracker, confirming that it registers properly.


## Advanced Set Up

The basic set up is great for development, testing, and Windows deployment. However, for those running Linux or Mac OS X, it may be preferable to install a tidier and more permanent version of the tracker. This involves creating a `.jar` (Java Archive) file, removing the post-compile `.class` files, and moving the various support files into their respective (and arguably more appropriate) directories.

### Compile the source

Assuming that Java 1.3 or later has been correctly installed, open a command line and compile the server source:

```sh
javac npdstracker.java
```

If compiling was successful, a series of `.class` files will now reside in the source directory.

```sh
npdstracker.class
npdstracker$TConnection.class
npdstracker$THostInfo.class
npdstracker$TQueryException.class
npdstracker$TServer.class
npdstracker$TServerInfo.class
npdstracker$TValidator.class
```

### Create the .jar file

Wrap all those `.class` files into a single `.jar` file from the command line:

```sh
jar cvfm npdstracker.jar manifest.mf *.class
```

After creating the `.jar`, you can safely delete the now redundant `.class` files:

```sh
rm *.class
```

### Put everything in its place

Install the `.jar` file in `/usr/local/bin` from the command line:

```sh
[sudo] mkdir -p /usr/local/bin
[sudo] install npdstracker.jar /usr/local/bin
```

Install the `npdstracker.ini` and `npdscmd.txt` files in `/etc` from the command line:

```sh
[sudo] mkdir -p /etc/npdstracker
[sudo] install npdstracker.ini npdscmd.txt /etc/npdstracker
```

Install the `template.html` and `template.css` files in `/usr/local/share` from the command line:

```sh
[sudo] mkdir -p /usr/local/share/npdstracker
[sudo] install template.html template.css /usr/local/share/npdstracker
```

Create the log file from the command line:

```sh
[sudo] touch /var/log/npdstracker.log
```

### Configure the server

Edit `/etc/npdstracker/npdstracker.ini` from the command line (or using an external text editor). Change the `pageTemplate`, `cssTemplate`, and `logfile` paths as per the installation commands.

```sh
pageTemplate = /usr/local/share/npdstracker/template.html
cssTemplate = /usr/local/share/npdstracker/template.css
logfile = /var/log/npdstracker.log
```

See the [Settings](#settings) section for more information on setting parameters and syntax.


### Start the server

Start the server from the command line:

```sh
java -jar /usr/local/bin/npdstracker.jar -c /etc/npdstracker/npdscmd.txt -o /etc/npdstracker/npdstracker.ini
```

See [Command Line Usage](#command-line-usage) for further details.

Test the connection to the tracker by launching your web browser using the following URL:

```sh
http://:3680/
```

Configure an [NPDS Tracker Client](http://npds.free.fr/modules/#trackerclient) to point at the tracker, confirming that it registers properly.


### Configure a launch daemon

On Darwin or Mac OS X, you can create a launch daemon to automatically launch the tracker on start up. Create a `/Library/LaunchDaemons/fr.free.npds.npdstracker.plist` file and paste in the following XML. This assumes that you have followed the steps for [Advanced Set Up](#advanced-set-up).

```xml



    
        Label
        fr.free.npds.npdstracker
        ProgramArguments
        
            java
            -jar
            /usr/local/bin/npdstracker.jar
            -c
            /etc/npdstracker/npdscmd.txt
            -o
            /etc/npdstracker/npdstracker.ini
        
        KeepAlive
        
            NetworkState
            
        
        RunAtLoad
        
    

```

The launch daemon may be loaded immediately by running the following from the command line, or you can wait until the next boot cycle:

```sh
sudo launchctl load /Library/LaunchDaemons/fr.free.npds.npdstracker.plist
```

On Linux or BSD systems, you can create `init.d` or `rc.d` scripts, respectively, to automatically start the tracker on boot.


## Settings

Configuration settings for the tracker are located in the `npdstracker.ini` file.

### Syntax

The following syntax must be followed when editing the configuration settings:

+ Setting values cannot be enclosed in quotation marks
+ Setting values cannot contain spaces (with the exception of `shareServer` values)
+ Spaces must appear on either side of the equal sign
+ Setting parameter names are case sensitive

### Parameters

Configuration setting parameters are shown listed below, along with with their default values. Note that some parameter names have changed in current releases of the tracker and are not backwards compatible.

#### kPort
```sh
kPort = 3680
```

Specifies the TCP listening port.

The default port is 3680, as assigned by [IANA](http://www.iana.org/assignments/service-names-port-numbers/service-names-port-numbers.xml). However, port 8080 is commonly used for clients that reside behind a firewall. Multiple port numbers may be specified, separated by spaces.


#### trackerName
```sh
trackerName = Default
```

Specifies the name of the site or tracker for use in the HTML template.

Refer to the [Page Template Tag Syntax](#page-template-tag-syntax) section for usage.


#### trackerHost
```sh
trackerHost = http://npds.free.fr/
```

Specifies the URL of the site or server host for use in the HTML template.

Refer to the [Page Template Tag Syntax](#page-template-tag-syntax) section for usage.

#### adminPass
```sh
adminPass = qwerty
```

Specifies the password for the remote administration interface.

This parameter was named `adminpasswd` in NPDS Tracker Server 0.1.36 and earlier. Make sure that this parameter name is correct in the `npdstracker.ini` file.


#### validateTime
```sh
validateTime = 30
```

Specifies how often to validate clients in seconds.


#### validateTries
```sh
validateTries = 3
```

Specifies how many validation attempts will be made before clients are removed from the list.


#### shareEnabled
```sh
shareEnabled = true
```

Specifies whether other trackers may obtain SHARE’d records from this tracker.

Set to ‘true’ to allow sharing, set to anything else to disallow sharing.


#### shareServer
```sh
shareServer = misato.chuma.org 3680
shareServer = www.unna.org 3680
shareServer = newtzilla.quadzilla.net 3680
shareServer = newton.tek-ed.com 3680
```

Specifies servers to obtain SHARE’d records from.

Each `shareServer` entry consists of a tracker hostname or address and a port number. To stop obtaining SHARE’d records from a tracker, comment out or delete the tracker’s `shareServer` entry.


#### privateHostToAccept
```sh
privateHostToAccept =
```

Specifies a private hostname or address to register as a client.

Must be a public DNS entry.


#### pageTemplate
```sh
pageTemplate = template.html
```

Specifies the path and name of the HTML template.

Refer to the [Page Template Tag Syntax](#page-template-tag-syntax) section for usage.


#### cssTemplate
```sh
cssTemplate = template.css
```

Specifies the path and name of the template stylesheet.

Used in conjunction with `pageTemplate`.


#### logFile
```sh
logFile = npdstracker.log
```

Specifies the path and name of the log file.

Log entries generated by the tracker are rather verbose and the log file can grow quite large over time. You can turn off logging altogether (redirecting to stdout) by commenting out the `logFile` setting once you are sure that the server is configured properly.

This parameter was named `logfile` in NPDS Tracker Server 0.1.36 and earlier. Make sure that this parameter name is correct in the `npdstracker.ini` file.


#### logVerbose
```sh
logVerbose = true
```

Specifies whether messages should be written to the log file.

If set to ‘false’, the tracker will only create a log entry if it encounters a serious problem.

This parameter was named `shouldIlog` in NPDS Tracker Server 0.1.36 and earlier. Make sure that this parameter name is correct in the `npdstracker.ini` file.


## Command Line Usage

```sh
java npdstracker [-h] [-c ] [-o ]
```

`-h` — Display help

`-c `  — Specifies the path of the `npdscmd.txt` file containing any commands to run at startup (defaults to none)

`-o ` — Specifies the path of the `npdstracker.ini` file containing configuration and option settings (defaults to settings at compile time)


## Remote Administration

To access the remote administration interface, you’ll need the following:

+ A terminal program or standalone Telnet client
+ The hostname and port of the tracker you wish to administer
+ The password of the tracker you wish to administer

Any changes made using the administration interface are applied immediately to the tracker, but are not saved to the `npdstracker.ini` file. Changes are lost once the tracker is restarted.

### Connection

This example assumes that the tracker is configured to use the default port number.

In your terminal program, open the Telnet connection to the tracker.

```sh
telnet tracker.example.com 3680
```

Hit ‘Enter’

After you connect to the tracker, you have five seconds to enter the following:

```sh
ADMIN 
```

Hit ‘Enter’

You will be presented with the following text:

```sh
Welcome to the NPDS Tracker Server administration interface!
```

Next, type:

```sh
HELP
```

Hit ‘Enter’

This will display a list of available commands.

### Commands

`ABOUT` — Display the current tracker settings

`HALT` — Stop the tracker (with confirmation)

`HELP` — Displays this list of commands

`LOGS` — Dumps the tracker log

`SHARE` — Change the tracker share settings

`SLIST` — View or modify the list of trackers to obtain shared records from

`VTEST` — Trigger a tracker validation

`STATS` — Display the tracker statistics (describe)

`VERIFY` — Change the tracker verification settings

`QUIT` — Exit the administration interface and close the connection


## Page Template Tag Syntax

The [HTML page template](#pagetemplate) can be customized using the following pseudo-SGML tags to insert information into the page. Note that some tag names have changed in current releases of the tracker and are not backwards compatible.

`` — The number of page views since the tracker was restarted

`` — Singular or plural noun based on the page views (“time” vs “times”)

`` — What comes after the GET (usually “/”)

`` — The date and time of the last validation or “Validation is in progress.”

`` — The meta element containing the http-equiv="refresh" value

`` — The list of registered NPDS clients formatted as a table

`` — The number of registered NPDS clients

`` — Singular or plural noun based on number of clients (“server” vs “servers”)

`` — Singular or plural verb based on number of clients (“is” vs “are”)

`` — A linked list of SHARE’d trackers formatted as an unordered list

`` — Inserts the stylesheet as specified in npdstracker.ini (default: template.css)

`` — The URL of the host site or tracker as specified in npdstracker.ini

`` — The name of the host site or tracker as specified in npdstracker.ini

`` — The URL of this tracker, obtained by reading the HTTP header

`` — The time (in minutes) between validations

`` — Singular or plural noun based on the time period (“minute” vs “minutes”)

`` — The current version of the tracker software


## Licensing

Copyright © 2001–2017 Grant Hutchinson, Victor Rehorst, Paul Guyot, et al

This project is licensed under the short and sweet [MIT License](http://opensource.org/licenses/MIT). This license allows you to do anything pretty much anything you want with the contents of the repository, as long as you provide proper attribution and don’t hold anyone liable.

See the [license.txt](https://raw.githubusercontent.com/splorp/npds-tracker-server/master/license.txt) file included in this repository for further details.


## Version History

### 0.1.38 — 31 January 2017

+ [GH] New `` and `` template tags because grammar
+ [GH] New `` and `` template tags because grammar
+ [GH] Standardized template tag naming for `` and ``
+ [GH] Changed date formatting to use full day and month names
+ [GH] Added initial media queries and responsive layout styles
+ [GH] Simplified template and validation string markup
+ [GH] Added MIT license

### 0.1.37 — 18 December 2012

+ [RP] New `` template tag inserts a list of shared trackers
+ [GH] Added command line usage information
+ [GH] Added remote administration documentation
+ [GH] Added getting started documentation
+ [GH] Added configuration settings documentation
+ [GH] Removed redundant configuration comments from the `npdstracker.ini` file
+ [GH] Reinstated classes on unordered lists so they can be styled independently
+ [GH] Wrapped link lists in `

本源码包内暂不包含可直接显示的源代码文件,请下载源码包。