Commit Graph

15 Commits (90471d68050ebd05439435330e4d0dbb19c6fd1e)

Author SHA1 Message Date
Tatsuhiro Tsujikawa 0640ea6254 2009-02-04 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>
Added --bt-external-ip option. You can specify the external IP
	address to report to a BitTorrent tracker. Although this
	function is named 'external', it can accept any kind of IP
	addresses.
	* src/DefaultBtAnnounce.cc
	* src/OptionHandlerFactory.cc
	* src/option_processing.cc
	* src/prefs.cc
	* src/prefs.h
	* src/usage_text.h
	* test/DefaultBtAnnounceTest.cc
2009-02-04 14:11:30 +00:00
Tatsuhiro Tsujikawa bd8645262d 2008-12-09 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>
Fixed the bug that bad URI is sent to the tracker when the
	announe URI in torrent file includes query.
	* src/DefaultBtAnnounce.cc
	* test/DefaultBtAnnounceTest.cc
2008-12-09 11:51:07 +00:00
Tatsuhiro Tsujikawa b3aa7cef1d 2008-11-28 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>
RFC3986 complied Percent-Encoding(urlencode).
	Use uppercase hexadecimal digits for encoded text instead of
	lowercase ones.
	* src/Request.cc
	* src/Util.cc
	* src/Util.h
	* test/BtHandshakeMessageTest.cc
	* test/DefaultBtAnnounceTest.cc
	* test/DefaultBtContextTest.cc
	* test/RequestTest.cc
	* test/UtilTest.cc
2008-11-27 15:29:15 +00:00
Tatsuhiro Tsujikawa 1ef99931e1 2008-04-27 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
Rewritten Exception class. Throw exception object, not its pointer and
	catch by reference, so that remove problematic delete operator for
	catched exception.
	* src/Exception.cc
	* src/Exception.h
	* test/ExceptionTest.cc
	* src/*: All files throwing/catching exception.
	* test/*: All files throwing/catching exception.
2008-04-27 02:22:14 +00:00
Tatsuhiro Tsujikawa 3505201f33 2008-04-20 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
Rewritten SharedHandle. Now copy constructor taking raw pointer 
has
	keyword explicit and SharedHandle's default constructor 
initializes
	its internal obj to null, old implementation initializes it 
using
	obj's default constructor.
	To assign null, write SharedHandle<T> x(...); x.reset();
	TODO: test/SharedHandleTest.cc needs more tests.
	* src/SharedHandle.h
2008-04-20 00:50:22 +00:00
Tatsuhiro Tsujikawa 032c7c2808 2008-03-09 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
type cleanup for allmost all remaining files.
2008-03-09 12:24:01 +00:00
Tatsuhiro Tsujikawa fc0fa4203a 2008-03-07 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
Use unsigned char for data store.
2008-03-07 12:05:50 +00:00
Tatsuhiro Tsujikawa 55552adb93 2008-03-03 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
Included missing iostream.
	* test/AllTest.cc
	* test/BtDependencyTest.cc
	* test/BtExtendedMessageTest.cc
	* test/DHTConnectionImplTest.cc
	* test/DHTMessageFactoryImplTest.cc
	* test/DHTMessageTrackerEntryTest.cc
	* test/DHTNodeTest.cc
	* test/DHTRoutingTableSerializerTest.cc
	* test/DefaultBtAnnounceTest.cc
	* test/DefaultBtContextTest.cc
	* test/DefaultBtMessageFactoryTest.cc
	* test/DefaultExtensionMessageFactoryTest.cc
	* test/HandshakeExtensionMessageTest.cc
	* test/HttpResponseTest.cc
	* test/MetalinkProcessorTest.cc
	* test/MultiFileAllocationIteratorTest.cc
	* test/SocketCoreTest.cc
	* test/UTPexExtensionMessageTest.cc
2008-03-03 11:30:12 +00:00
Tatsuhiro Tsujikawa c0d2223c77 2008-02-16 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
Added Message Stream Encryption(MSE) support.
	Currently, aria2 accepts incoming connections with Obfuscation Header
	and legacy BitTorrent Header and establishes connections with
	Obfuscation Header first and if failed then retry with legacy
	BitTorrent header. If plain text and ARC4 is provided, aria2 always
	choose ARC4. The new option to change the default behavior is planned.
	For tracker extension, "supportcrypto=1" is added statically.
	* src/PeerInitiateConnectionCommand.{h, cc}
	* src/PeerConnection.{h, cc}
	* src/HandleRegistry.h
	* src/SocketCore.h
	* src/PeerReceiveHandshakeCommand.{h, cc}
	* src/BtRegistry.{h, cc}
	* src/PeerListenCommand.cc
	* src/InitiatorMSEHandshakeCommand.{h, cc}
	* src/ReceiverMSEHandshakeCommand.{h, cc}
	* src/MSEHandshake.{h, cc}
	* src/ARC4Encryptor.h
	* src/ARC4Decryptor.h
	* src/LibgcryptARC4Encryptor.h
	* src/LibgcryptARC4Decryptor.h
	* src/LibgcryptARC4Context.h
	* src/LibsslARC4Encryptor.h
	* src/LibsslARC4Decryptor.h
	* src/LibsslARC4Context.h
	* src/DHKeyExchange.h
	* src/LibgcryptDHKeyExchange.h
	* src/LibsslDHKeyExchange.h
	* src/DefaultBtAnnounce.cc: Just added "supportcrypto=1" parameter.
	* test/DefaultBtAnnounceTest.cc
	* test/ARC4Test.cc
	* test/DHKeyExchangeTest.cc
	
	Removed prepareForRetry() because it is not used.
	* src/PeerAbstractCommand.{h, cc}
	* src/PeerInteractionCommand.{h, cc}
	* src/PeerInitiateConnectionCommand.{h, cc}
2008-02-17 15:56:47 +00:00
Tatsuhiro Tsujikawa 1b7c198289 2008-02-08 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
Removed "using namespace std;" from all sources. Appended std:: 
prefix to c++
	standard classes.
	Included string.h where mem* function are used.
2008-02-08 15:53:45 +00:00
Tatsuhiro Tsujikawa da4d9092b2 2008-01-04 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
Fixed segmentation fault when bad torrent metainfo is parsed.
	Added dynamic_cast properly to detect the misconfiguration of 
metainfo
	and then throw exception or skip it.
	* src/DefaultBtContext.{h, cc}
	* test/DefaultBtContextTest.cc
	* src/AnnounceList.cc
	* src/CompactPeerListProcessor.cc
	* src/message.h
	* src/DefaultBtAnnounce.{h, cc}
	* test/DefaultBtAnnounceTest.cc
	* src/BencodeVisitor.cc
2008-01-04 12:31:49 +00:00
Tatsuhiro Tsujikawa b482568d59 2007-12-10 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
Fixed the bug: only first announce URL is tried in AnnounceTier,
	in stopped and completed event.
	* src/AnnounceList.{h, cc}
	* test/AnnounceListTest.cc
	* src/DefaultBtAnnounce.cc
	* test/DefaultBtAnnounceTest.cc

	Sorted URLs.
	* test/Metalink2RequestGroupTest.cc
2007-12-09 15:54:54 +00:00
Tatsuhiro Tsujikawa aef50efed0 2007-11-12 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
Do not rotate tiers in announce-list.
	* src/DefaultBtAnnounce.{h, cc}: Removed trackerNumTry.
	AnnounceList::allTiersFailed() used instead to detect whether 
all
	tiers are tried and failed.
	* test/DefaultBtAnnounceTest.cc
	* src/AnnounceList.{h, cc}: If all tiers are tried and failed 
then
	allTiersFailed() returns true. To reset tier pointer, call 
resetTier();
	* test/AnnounceListTest.cc
	* src/TrackerWatcherCommand.cc (execute): Removed DlAbortEx 
catch
	clause. Catch RecoverableException instead of DlRetryEx instead.
2007-11-12 14:13:00 +00:00
Tatsuhiro Tsujikawa d8ae699182 2007-11-04 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
Fixed: the listen port sent to the tracker is wrong. If aria2 
fails
	to open listen port, then remove the port number from the 
tracker
	request.
	* src/DefaultBtAnnounce.cc 
	* test/DefaultBtAnnounceTest.cc
	* test/MockPieceStorage.h
	
	Inject randomizer to DefaultBtAnnounce and DefaultBtContext to 
make
	them more testable.
	* src/DefaultBtAnnounce.{h, cc}
	* src/DefaultBtContext.{h, cc}
	* src/Util.{h, cc}
	* test/DefaultBtAnnounceTest.cc
	* test/DefaultBtContextTest.cc
	* test/UtilTest.cc
	
	Added 'B' to upload bytes readout.
	* src/ConsoleStatCalc.cc

	Now the listen port for BitTorrent download is opened when it is
	needed.
	* src/DownloadEngineFactory.cc
	* src/BtSetup.{h, cc}
	* src/PeerListenCommand.{h, cc}
	
	Now an exception thrown while parsing tracker response is now 
logged.
	If DlAbortEx is catched, then btAnnounce->resetAnnounce() 
immediately
	called, which means no retry is made in this case, assuming a 
tracker
	has a problem.
	* src/TrackerWatcherCommand.cc
	
	Fixed: downloading a file whose length is unkown fails.
	* src/DownloadCommand.cc

	Simplified prepareForNextSegment()
	* src/DownloadCommand.cc

	Updated
	* po/POTFILES.in
2007-11-04 12:26:12 +00:00
Tatsuhiro Tsujikawa ec642ad294 2006-11-05 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
To divide TorrentMan into 6 classes: BtContext, BtRuntime,
	PeerStorage, PieceStorage, BtAnnounce and BtProgressInfoFile

	* src/TrackerWatcherComand.h: Made subclass of 
BtContextAwareCommand.
	* src/SeedCheckCommand.cc: Use pieceStorage, btRuntime
	* src/PeerAbstractCommand.h: Made subclass of 
BtContextAwareCommand.
	* src/PeerAbstractCommand.cc: Use btRuntime.
	* src/BtContextAwareCommand.h: New class.
	* src/FileEntry.h: Added accessor methods for following 
variables.
	(path): Made private.
	(length): Made private.
	(offset): Made private.
	(extracted): Made private.
	(requested): Made private.
	(FileEntries): New definition.
	(FileEntryHandle): New definition.
	* src/FileEntry.cc: New file.
	* src/HaveEraseCommand.h: Made subclass of 
BtContextAwareCommand.
	* src/HaveEraseCommand.cc: Use btRuntime, pieceStorage.
	* src/PeerChokeCommand.h: Made subclass of 
BtContextAwareCommand.
	* src/PeerChokeCommand.cc: Use btRuntime, peerStorage, 
pieceStorage.
	* src/PieceStorage.h: New file.
	* src/PeerInteractionCommand.h: Use btContext.
	* src/PeerInteractionCommand.cc: Use pieceStorage, peerStorage,
	btRuntime.
	* src/DefaultBtProgressInfoFile.h: New file.
	* src/DefaultBtProgressInfoFile.cc: New file.
	* src/File.cc
	(Util.h): New include.
	(mkdirs): New function.
	* src/MultiDiskAdaptor.h
	(mkdir): New function.
	* src/PeerListProcessor.h
	(Peers): Removed.
	* src/PeerInteraction.h
	(torrentMan): Removed.
	(btContext): New variable.
	(peerStorage): New variable.
	(pieceStorage): New variable.
	(btAnnounce): New variable.
	(getTorrentMan): Removed.
	(getBtContext): New function.
	* src/PeerInteraction.cc: Use btContext, peerStorage, 
pieceStorage,
	btAnnounce.
	* src/HandshakeMessage.h
	(TorrentMan.h): Removed.
	* src/HandshakeMessage.cc: Use btContext.
	* src/DefaultBtAnnounce.cc: New file.
	* src/MultiDiskWriter.cc: Use the accessor methods of FileEntry.
	* src/DefaultPieceStorage.cc: New file.
	* src/DefaultBtContext.h: New file.
	* src/TorrentRequestInfo.cc: Use btContext, pieceStorage.
	Use the accessor methods of FileEntry.
	* src/CookieBox.cc: Updated to use Util::slice().
	* src/PieceMessage.cc: Use btContext, pieceStorage.
	* src/common.h (SharedHandle.h): New include.
	* src/PeerMessage.cc (PeerMessage): Added btContext, 
peerStorage,
	pieceStorage.
	* src/TorrentAutoSaveCommand.h: Made subclass of 
BtContextAwareCommand.
	* src/DiskAdaptor.h
	(topDir): Removed.
	(getFileEntryFromPath): Changed the return type to 
FileEntryHandle.
	(setTopDir): Removed.
	(getTopDir): Removed.
	* src/BtContext.h: New file.
	* src/DefaultPeerStorage.h: New file.
	* src/PieceMessage.h (TorrentMan.h): Removed.
	* src/RequestMessage.h (TorrentMan.h): Removed.
	* src/TorrentDownloadEngine.h
	(uploadLength): New variable.
	(btContext): New variable.
	(btRuntime): New variable.
	(pieceStorage): New variable.
	(peerStorage): New variable.
	(btAnnounce): New variable.
	(btProgressInfoFile): New variable.
	(torrentMan): Removed.
	(setBtContext): New function.
	* src/TorrentDownloadEngine.cc: Use BtContext, BtRuntime, 
pieceStorage,
	peerStorage, btAnnounce, btProgressInfoFile.
	* src/Piece.h
	(toString): New function.
	(Pieces): New type definition.
	* src/Peer.h
	(active): New variable.
	(Peer): Added active.
	(activate): Set active to true.
	(deactivate): Set active to false.
	(isActive): New function.
	(Peers): New type definition.
	* src/DirectDiskAdaptor.cc
	(getFilePath): Use the accessor methods of FileEntry.
	* src/TorrentConsoleDownloadEngine.h
	(afterEachIteration): New function.
	* src/TorrentConsoleDownloadEngine.cc
	(haltRequested): New variable.
	(sendStatistics): Use pieceStorage, btRuntime.
	(afterEachIteration): New function.
	* src/AnnounceList: AnnounceTier->AnnounceTierHandle.
	* src/Directry.h
	(Directory): New function.
	(DirectoryHandle): New type definition.
	* src/BtProgressInfoFile.h: New file.
	* src/RequestMessage.cc: Use pieceStorage.
	* src/BtRuntime.h: New file.
	* src/DefaultBtContext.cc: New file.
	* src/BitfieldMan.h
	(getCompletedLength): New function(private).
	(getCompletedLength): New function.
	(getFilteredCompletedLength): New function.
	* src/BitfieldMan.h
	(getCompletedLength): New function(private).
	(getCompletedLength): New function.
	(getFilteredCompletedLength): New function.
	* src/MultiDiskAdaptor.cc
	(mkdir): New function.
	(openFile): Call mkdir().
	(initAndOpenFile): Call mkdir().
	* src/CancelMessage.h
	(TorrentMan.h): Removed.
	* src/RejectMessage.h
	(TorrentMan.h): Removed.
	* src/DownloadEngineFactory.cc
	(DefaultPieceStorage.h): New include.
	(DefaultPeerStorage.h): New include.
	(DefaultBtAnnounce.h): New include.
	(DefaultBtProgressInfoFile.h): New include.
	(newTorrentConsoleEngine): Rewritten.
	* src/ShareRatioSeedCriteria.h
	(torrentMan): Removed.
	(btContext): New variable.
	(peerStorage): New variable.
	(btRuntime): New variable.
	(evaluate): Use btContext, btRuntime, peerStorage.
	* src/AnnounceTier.h: New file.
	* src/BtAnnounce.h: New file.
	* src/BtRegistry.h: New file.
	* src/PeerInitiateConnectionCommand.h: Added btContext.
	* src/PeerConnection.h (TorrentMan.h): Removed.
	* src/PeerMessageFactory.cc: Use btContext, pieceStorage.
	* src/Util.h
	(slice): Added an argument.
	* src/Util.cc
	(slice): Added an argument to control whether trim is made or 
not.
	* src/PeerStorage.h: New file.
	* src/BtRegistry.cc: New file.
	* src/TrackerUpdateCommand.h: Made subclass of 
BtContextAwareCommand.
	* src/CopyDiskAdaptor.cc: Use the accessor methods of FileEntry.
	* src/MultiDiskWriter.h: FileEntry -> FileEntryHandle
	* src/PeerListenCommand.cc: Use btRuntime, peerStorage, 
btContext.
	* src/TorrentRequestInfo.h
	(e): Removed.
	(showFileEntry): Added an argument.
	(getDownloadEngine): Return 0.
	* src/DefaultBtAnnounce.h: New file.
	* src/TorrentAutoSaveCommand.cc: Use btRuntime, 
btProgressInfoFile.
	* src/TrackerWatcherComand.cc: Use btRuntime, btAnnounce,
	* src/PeerMessageFactory.h
	(btContext): New variable.
	(pieceStorage): New variable.
	* src/TrackerUpdateCommand.cc: Use btRuntime, peerStorage, 
btContext,
	btAnnounce.
	* src/DiskAdaptor.cc
	(DiskAdaptor): Removed topDir.
	(~DiskAdaptor): Removed topDir.
	* src/PeerListenCommand.h: Made subclass of 
BtContextAwareCommand.
	* src/SeedCheckCommand.h: Made subclass of 
BtContextAwareCommand.
	* src/File.h (mkdirs): New function.
	* src/DefaultPeerStorage): New file.
	* src/DownloadEngineFactory.h
	(newTorrentConsoleEngine): Use btContext.
	* src/BtContextAwareCommand.cc: New file.
	* src/PeerInitiateConnectionCommand.cc: Use btRuntime, 
peerStorage.
	* src/PeerMessage.h
	(btContext): New variable.
	(peerStorage): New variable.
	(pieceStorage): New variable.
	(setBtContext): New function.
	* src/Directry.cc
	(Directory): New function.
	(createDir): Do nothing if name.size() == 0.
	* src/AnnounceList.h
	(AnnounceTier): Removed. 
	(AnnounceTiers): Removed.
	* src/DefaultPieceStorage.h: New file.
	* src/Piece.cc (toString): New function.
	
	To fix typo:
	
	* src/main.cc (showVersion): Fixed typo.

	To fix compile warning:
	
	* src/DelegatingPeerListProcessor.cc
	(canHandle): Added "return false".
2006-11-05 15:04:17 +00:00