Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make it "clearer" that the target file might "not be there" #186

Open
wants to merge 102 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
102 commits
Select commit Hold shift + click to select a range
82fb651
Fix read when message size wasn't read in one step
pankdm Apr 10, 2013
728edf8
Throw AnnounceException when current tracker client isn't available.
sroze Jul 18, 2013
9370d86
Fix order of uploaded/downloaded parameters in HTTPAnnounceRequestMes…
mpetazzoni Jul 22, 2013
1ad97ef
Merge pull request #45 from sroze/trackerless-patch
mpetazzoni Jul 22, 2013
2e643f4
add the ability to set upload/download rate-limits (in kB/sec.) on sh…
ptgoetz Jul 19, 2013
b15ea5e
add javadoc documentation for upload/download rate-limit functionality
ptgoetz Jul 22, 2013
73b78f2
reduce rate limit code duplication by refactoring code present in bot…
ptgoetz Jul 22, 2013
3ef9e9b
add example of upload/download rate limiting to the client usage sample.
ptgoetz Jul 22, 2013
13db7ab
add comments documenting the drawbacks/potential improvements for the…
ptgoetz Jul 22, 2013
00bc8f2
minor formatting/style modifications based on feedback from pull requ…
ptgoetz Jul 22, 2013
42775d5
Merge pull request #49 from ptgoetz/rate-limits
mpetazzoni Jul 23, 2013
59a2ec1
Fix a few styling issues from recent contributions
mpetazzoni Jul 23, 2013
c004fa8
Merge pull request #40 from pankdm/fix-incomplete-read
mpetazzoni Jul 23, 2013
64b8865
fixes Issue #47
oxlade39 Jul 22, 2013
a47a275
fixes turn/ttorrent#51
pwoodworth Jul 24, 2013
0dcb033
Merge pull request #50 from oxlade39/bug_fix
mpetazzoni Jul 24, 2013
bf4d679
Merge pull request #53 from pwoodworth/issue-51
mpetazzoni Jul 25, 2013
c1dbcd9
Update pom for compatibility with the maven-release-plugin
pwoodworth Jul 30, 2013
9e8abed
Use maven-shade-plugin to produce executable jar
pwoodworth Jul 30, 2013
5a499ce
Clean up javadoc problems
pwoodworth Jul 30, 2013
c06b110
Merge pull request #54 from pwoodworth/shaded
mpetazzoni Jul 31, 2013
f69190b
Merge pull request #55 from pwoodworth/releaseplugin
mpetazzoni Jul 31, 2013
89a6754
Merge pull request #56 from pwoodworth/javadoc
mpetazzoni Jul 31, 2013
0080296
Fix pom parent relative path
pwoodworth Aug 14, 2013
9e09ee5
Adding more platform agnostic shell scripts
pwoodworth Aug 15, 2013
d50eb99
Removing old shell scripts
pwoodworth Aug 15, 2013
86f4a2f
Merge pull request #57 from pwoodworth/scripts
mpetazzoni Aug 16, 2013
1c8dbfc
Move entry-point main methods to separate package
pwoodworth Aug 26, 2013
d33c361
Merge pull request #59 from pwoodworth/climove
mpetazzoni Aug 26, 2013
dbfd004
Fixes turn/ttorrent#42
pwoodworth Aug 28, 2013
06a3dfc
Merge pull request #60 from pwoodworth/issue-42
mpetazzoni Aug 28, 2013
dd8e7c9
Use commons-io throughout
pwoodworth Sep 11, 2013
f72705f
Merge pull request #63 from pwoodworth/commonsio
mpetazzoni Sep 12, 2013
d243274
Use commons-codec for hex and digest encoding
pwoodworth Aug 28, 2013
6fd448f
Merge pull request #64 from pwoodworth/codec
mpetazzoni Sep 17, 2013
869f664
Fix Piece compareTo ordering
pwoodworth Sep 20, 2013
32c66e1
Correcting improper use of Java 7 API
pwoodworth Sep 26, 2013
d787d9c
Merge pull request #65 from pwoodworth/piececompare
mpetazzoni Sep 30, 2013
cce0c02
Developer contact info updates
mpetazzoni Oct 24, 2013
b540ebd
Change FileCollectionStorage to not write 0 bytes to the next file at…
camerondavison Nov 25, 2013
053b13d
Instead of abusing SocketChannel.read in a tight loop, use a Selector
maxaf Oct 27, 2013
6ff991d
Fixing email address of contributor in README
mpetazzoni Nov 26, 2013
37bff2a
Code style fixes
mpetazzoni Nov 26, 2013
186dbb3
Merge pull request #73 from a86c6f7964/collectionfileselect
mpetazzoni Nov 26, 2013
d403b7a
Create Travis-CI configuration
mpetazzoni Dec 6, 2013
9dac22a
Add Travis-CI status image
mpetazzoni Dec 6, 2013
5c9f3cf
Bump to version 1.4; first release to Maven Central
mpetazzoni Dec 6, 2013
51f0676
[maven-release-plugin] prepare release ttorrent-1.4
mpetazzoni Dec 6, 2013
efe3a26
[maven-release-plugin] prepare for next development iteration
mpetazzoni Dec 6, 2013
9550b79
Add documentation about declaring ttorrent as a POM dependency
mpetazzoni Dec 8, 2013
fd9d585
Update README.md
ralscha Apr 12, 2014
04e9b9a
Merge pull request #93 from ralscha/patch-1
mpetazzoni Apr 12, 2014
755483b
Added support for multiple announce URLs to CLI
Chet-Thales Jul 21, 2014
101007e
Merge pull request #100 from chester8mcgee/master
mpetazzoni Jul 21, 2014
856284e
Added request strategy interface to abstract different strategy imple…
cjmalloy Nov 4, 2014
e9b07e5
Moved default request strategy to explicit constant.
cjmalloy Nov 8, 2014
1d8cec2
Merge pull request #106 from cjmalloy/master
mpetazzoni Nov 9, 2014
848f07f
Fixed file list for multi-file torrents.
cjmalloy Nov 10, 2014
15dee06
Merge pull request #109 from cjmalloy/master
mpetazzoni Nov 10, 2014
c072a12
Add a piece length option to the torrent creator CLI
rambegaokar-nv Nov 24, 2014
f9f2430
Merge pull request #111 from rambegaokar/master
mpetazzoni Dec 31, 2014
23ec122
Refactored out dependency on log4j.
cjmalloy Feb 20, 2015
ea63138
Merge pull request #119 from cjmalloy/master
mpetazzoni Feb 20, 2015
600836b
Updated maven example.
cjmalloy Feb 20, 2015
5eb5ecb
Updated install instructions.
cjmalloy Feb 20, 2015
af13a3b
Merge pull request #121 from cjmalloy/master
mpetazzoni Feb 20, 2015
a9bff22
Enabled tests.
cjmalloy Feb 20, 2015
e763bad
Merge pull request #122 from cjmalloy/master
mpetazzoni Feb 20, 2015
520ec2b
fix order of fields in the 'send announce' packets going to udp trackers
halfmanhalffish Apr 1, 2015
a2b3cad
Merge pull request #123 from halfmanhalffish/fixudptrackerbug
mpetazzoni Apr 13, 2015
e715525
fixed wrong maven artifactId
hagai-lvi Apr 17, 2015
8a51499
Use a larger port range, fixes #132
dessalines May 22, 2015
87c53b7
fix bug by which not all peers that the server reports are reported b…
May 19, 2015
e4a0b10
Merge pull request #129 from halfmanhalffish/fixpeerreporting
mpetazzoni May 25, 2015
9068525
Merge pull request #134 from tchoulihan/master
mpetazzoni Aug 3, 2015
1d448c1
Merge pull request #125 from hagai-lvi/master
mpetazzoni Aug 3, 2015
fe1ab72
Remove outdated comment
mpetazzoni Jan 5, 2016
3ce7fab
Fixed bitfield payload in bitfield message
philipphenkel Jan 16, 2016
7b18f1b
Allow explicit start of peer message exchange
philipphenkel Jan 16, 2016
2bb40c7
Merge pull request #160 from henkel/master
mpetazzoni Jan 18, 2016
7fc5279
Remove dependency on Apache commons-codec
philipphenkel Jan 19, 2016
a702f85
Merge pull request #161 from henkel/develop
mpetazzoni Jan 22, 2016
e228a0d
Allow immedidate shutdown of peerexchange by notifying out-going thread
philipphenkel Jan 29, 2016
bb789f9
Merge pull request #162 from henkel/immediate-shutdown-of-peerexchange
mpetazzoni Feb 3, 2016
ede0391
Change the length of an existing storage file only if required
philipphenkel Mar 2, 2016
760bd1b
Check for selector key validity before trying to use it. Fixes #169
mpetazzoni Mar 9, 2016
a397f13
Include documentation about Client observable. Fixes #165
mpetazzoni Mar 9, 2016
2df5fbe
Merge pull request #170 from henkel/adjust-length-of-existing-file-on…
mpetazzoni Mar 9, 2016
7c8b407
Javadoc markup fixes and release prep
mpetazzoni Mar 9, 2016
7dcb78d
Document usage of dependency version 1.5. Fixes #127
mpetazzoni Mar 9, 2016
4b9cafa
Prepare for 1.5 release
mpetazzoni Mar 9, 2016
081bab4
Move version forward to 1.6-SNAPSHOT
mpetazzoni Mar 9, 2016
e9e9773
Extra Maven build plugins specific to release in a release profile
mpetazzoni Mar 9, 2016
4471694
Fix byteArrayToHexString and add tests
philipphenkel Mar 12, 2016
7acb2d0
Merge pull request #174 from henkel/fix-byte-array-to-hex-string
mpetazzoni Mar 14, 2016
5d4a149
Unchoke the random peer in optimistic unchoking
bwzhou Apr 8, 2016
e1daf41
Merge pull request #177 from bwzhou/patch-1
mpetazzoni Apr 12, 2016
4aca5ac
Fix indent in pom.xml
mpetazzoni Jun 18, 2016
4a8e2a6
Fix Javadoc link in common.Utils
mpetazzoni Jun 18, 2016
fce1fc7
Fixed a BufferUnderflowException in message parsing when PeerExchange…
bwzhou Jul 1, 2016
d2b0739
Merge pull request #180 from bwzhou/master
mpetazzoni Jul 7, 2016
35a4b23
Make it "clearer" that the target file might "not be there"
zanella Sep 29, 2016
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,12 @@

# Ignore build output
/build/*
/target/*
/release.properties

# Ignore Javadoc output
/doc/*
cli/doc/*
core/doc/*

# Ignore any eventual Eclipse project files, these don't belong in the
# repository.
Expand All @@ -17,4 +20,4 @@
*.swp
*.bak
*~
*~
pom.xml.releaseBackup
1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
language: java
23 changes: 16 additions & 7 deletions INSTALL
Original file line number Diff line number Diff line change
@@ -1,20 +1,21 @@
Howto build and use the BitTorrent library
Howto build and use the ttorrent library
==========================================

Dependencies
------------

This Java implementation of the BitTorrent protocol implements a BitTorrent
tracker (an HTTP service), and a BitTorrent client. The only dependencies of
the BitTorrent library are:
tracker (an HTTP service), and a BitTorrent client. All dependencies are managed
by maven. The only dependencies of ttorrent-core are:

* the log4j library
* the slf4j logging library
* the SimpleHTTPFramework
* the Apache Commons (Codec and IO)

These libraries are provided in the lib/ directory, and are automatically
included in the JAR file created by the build process.
The CLI module also depends on:

* the log4j library
* the jargs library

Building the distribution JAR
-----------------------------
Expand All @@ -23,6 +24,14 @@ Simply execute the following command:

$ mvn package

To build the library's JAR file (in the target/ directory). You can then import
To build the library's JAR file (in the core/target/ directory). You can then import
this JAR file into your Java project and start using the Java BitTorrent
library.

This will also create a shaded JAR (in the cli/target/ directory). You can then use
this JAR file in conjunction with the three scripts in the bin/ folder. Each script
allows execution of one of the following entry points:

* ClientMain - for running a torrent client
* TorrentMain - for creating .torrent files
* TrackerMain - for running a tracking server
49 changes: 47 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
Ttorrent, a Java implementation of the BitTorrent protocol
==========================================================

[![Build Status](https://travis-ci.org/mpetazzoni/ttorrent.png)](https://travis-ci.org/mpetazzoni/ttorrent)

Description
-----------

Expand Down Expand Up @@ -65,6 +67,22 @@ usage message on the console when invoked with the ``-h`` command-line flag.

### As a library

To use ``ttorrent`` is a library in your project, all you need is to
declare the dependency on the latest version of ``ttorrent``. For
example, if you use Maven, add the following in your POM's dependencies
section:

```xml
<dependencies>
...
<dependency>
<groupId>com.turn</groupId>
<artifactId>ttorrent-core</artifactId>
<version>1.5</version>
</dependency>
</dependencies>
```

*Thanks to Anatoli Vladev for the code examples in #16.*

#### Client code
Expand All @@ -82,6 +100,12 @@ Client client = new Client(
new File("/path/to/your.torrent"),
new File("/path/to/output/directory")));

// You can optionally set download/upload rate limits
// in kB/second. Setting a limit to 0.0 disables rate
// limits.
client.setMaxDownloadRate(50.0);
client.setMaxUploadRate(50.0);

// At this point, can you either call download() to download the torrent and
// stop immediately after...
client.download();
Expand All @@ -95,6 +119,9 @@ client.download();
client.waitForCompletion();

// At any time you can call client.stop() to interrupt the download.

// If you plan on using the downloaded file(s) right away uncomment the line below
//client.getTorrent().finish();
```

#### Tracker code
Expand Down Expand Up @@ -124,6 +151,23 @@ tracker.start();
tracker.stop();
```

### Track download progress

You can track the progress of the download and the state of the torrent
by registering an `Observer` on your `Client` instance. The observer is
updated every time a piece of the download completes:

```java
client.addObserver(new Observer() {
@Override
public void update(Observable observable, Object data) {
Client client = (Client) observable;
float progress = client.getTorrent().getCompletion();
// Do something with progress.
}
});
```

License
-------

Expand All @@ -134,21 +178,22 @@ License version 2.0. See COPYING file for more details.
Authors and contributors
------------------------

* Maxime Petazzoni <<[email protected]>> (Platform Engineer at Turn, Inc)
* Maxime Petazzoni <<[email protected]>> (Software Engineer at SignalFuse, Inc)
Original author, main developer and maintainer
* David Giffin <<[email protected]>>
Contributed parallel hashing and multi-file torrent support.
* Thomas Zink <<[email protected]>>
Fixed a piece length computation issue when the total torrent size is an
exact multiple of the piece size.
* Johan Parent <<parent_johan@yahoo.com>>
* Johan Parent <<parent\_johan@yahoo.com>>
Fixed a bug in unfresh peer collection and issues on download completion on
Windows platforms.
* Dmitriy Dumanskiy
Contributed the switch from Ant to Maven.
* Alexey Ptashniy
Fixed an integer overflow in the calculation of a torrent's full size.

And many other helpful contributors on GitHub! Thanks to all of you.

Caveats
-------
Expand Down
18 changes: 0 additions & 18 deletions bin/tracker

This file was deleted.

73 changes: 73 additions & 0 deletions bin/ttorrent
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
#!/bin/sh

# Copyright (C) 2012 Turn, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

EXECJAR="ttorrent-*-shaded.jar"

real_path() {
case $1 in
/*)
SCRIPT="$1"
;;
*)
PWD=`pwd`
SCRIPT="$PWD/$1"
;;
esac
CHANGED=true
while [ "X$CHANGED" != "X" ] ; do
# Change spaces to ":" so the tokens can be parsed.
SAFESCRIPT=`echo $SCRIPT | sed -e 's; ;:;g'`
# Get the real path to this script, resolving any symbolic links
TOKENS=`echo $SAFESCRIPT | sed -e 's;/; ;g'`
REALPATH=
for C in $TOKENS; do
# Change any ":" in the token back to a space.
C=`echo $C | sed -e 's;:; ;g'`
REALPATH="$REALPATH/$C"
# If REALPATH is a sym link, resolve it. Loop for nested links.
while [ -h "$REALPATH" ] ; do
LS="`ls -ld "$REALPATH"`"
LINK="`expr "$LS" : '.*-> \(.*\)$'`"
if expr "$LINK" : '/.*' > /dev/null; then
# LINK is absolute.
REALPATH="$LINK"
else
# LINK is relative.
REALPATH="`dirname "$REALPATH"`""/$LINK"
fi
done
done
if [ "$REALPATH" = "$SCRIPT" ] ; then
CHANGED=""
else
SCRIPT="$REALPATH"
fi
done
echo "$REALPATH"
}

base=$(dirname $(real_path $0))
CPARG=$(find ${base}/../build -name "$EXECJAR" | tail -n 1)
if [ -z "$CPARG" ] ; then
echo "Unable to find $EXECJAR"
exit 1
fi
if [ -z "$MAINCLASS" ] ; then
CPARG="-jar $CPARG"
else
CPARG="-cp $CPARG $MAINCLASS"
fi
exec java $CPARG "$@"
6 changes: 3 additions & 3 deletions bin/client → bin/ttorrent-torrent
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
#!/bin/sh

# Copyright (C) 2012 Turn, Inc.
#
Expand All @@ -14,5 +14,5 @@
# See the License for the specific language governing permissions and
# limitations under the License.

base=$(dirname $(readlink -f $0))
exec java -jar $(find ${base}/../build -name "ttorrent-*.jar" | tail -n 1) $*
EXEFILE="${0%-torrent}"
MAINCLASS="com.turn.ttorrent.cli.TorrentMain" "${EXEFILE}" "$@"
6 changes: 3 additions & 3 deletions bin/torrent → bin/ttorrent-tracker
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
#!/bin/sh

# Copyright (C) 2012 Turn, Inc.
#
Expand All @@ -14,5 +14,5 @@
# See the License for the specific language governing permissions and
# limitations under the License.

base=$(dirname $(readlink -f $0))
exec java -cp $(find ${base}/../build -name "ttorrent-*.jar" | tail -n 1) com.turn.ttorrent.common.Torrent $*
EXEFILE="${0%-tracker}"
MAINCLASS="com.turn.ttorrent.cli.TrackerMain" "${EXEFILE}" "$@"
5 changes: 5 additions & 0 deletions cli/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
/target/

/.classpath
/.project
/.settings
77 changes: 77 additions & 0 deletions cli/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>

<parent>
<groupId>com.turn</groupId>
<artifactId>ttorrent</artifactId>
<version>1.6-SNAPSHOT</version>
</parent>

<name>Java BitTorrent library CLI</name>
<artifactId>ttorrent-cli</artifactId>
<packaging>jar</packaging>

<dependencies>
<dependency>
<groupId>com.turn</groupId>
<artifactId>ttorrent-core</artifactId>
<version>1.6-SNAPSHOT</version>
</dependency>

<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
<version>1.6.4</version>
</dependency>
<dependency>
<groupId>net.sf</groupId>
<artifactId>jargs</artifactId>
<version>1.0</version>
</dependency>
</dependencies>

<build>
<defaultGoal>package</defaultGoal>

<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>2.4</version>
<configuration>
<archive>
<manifest>
<addDefaultImplementationEntries>true</addDefaultImplementationEntries>
</manifest>
</archive>
<includes>
<include>**</include>
</includes>
</configuration>
</plugin>

<plugin>
<artifactId>maven-shade-plugin</artifactId>
<version>2.1</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
<configuration>
<outputFile>${project.build.directory}/${project.artifactId}-${project.version}-shaded.jar</outputFile>
<transformers>
<transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
<manifestEntries>
<Main-Class>com.turn.ttorrent.cli.ClientMain</Main-Class>
</manifestEntries>
</transformer>
</transformers>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
Loading