-
Notifications
You must be signed in to change notification settings - Fork 1
这是一个对monotorrent学习和二次开发的项目,现在完成的工作如下:修复了依次请求tracker时,接收到tracker返回消息再发起下一次请求的bug;增加了与中转服务器通信功能,通信使用protobuf;
License
stuboy9/src
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
PRE-REQUISITES ------------------------------------------------------------------------------------------------------------ To run: MS.NET 2.0 or Mono 1.1.16.1+ To build: MonoDevelop, Visual Studio, SharpDevelop or the standard *nix toolchain BUILDING MONOTORRENT: ------------------------------------------------------------------------------------------------------------ MakeFiles: To build using the makefiles, execute the following commands: $ ./autogen.sh $ make $ make install This will only build MonoTorrent.dll. The other sub-projects are not built via this method. Project Files: You can open the MonoTorrent.sln file in MonoDevelop, SharpDevelop or Visual Studio. This is the preferred way to build MonoTorrent and all the sub-projects. BRIEF INTRODUCTION INTO HOW THE CODE SHOULD BE USED ------------------------------------------------------------------------------------------------------------ [MonoTorrent Client] To run the sample client you need to do the following: 1) Make sure that MonoTorrent.dll and SampleClient.exe are in the same folder 2) Create a folder in that directory called "Torrents". 3) Put any number of .torrent files into the Torrents directory. This files will all be loaded by the sample client. 5) Launch SampleClient.exe to begin downloading. All files will be downloaded to a directory called "Downloads". Note: Only statistics will only be shown for the first .torrent loaded into the engine. So there is no real point in loading more than one .torrent into the engine. Developer Notes: There are a few important things developers should note before creating a gui/service using the library. Firstly there is no guarantee what thread the events will be fired on, so if you're doing GUI updates, you will need to make sure that you perform your actual GUI update in a threadsafe manner. [The Tracker] ============ The code of the Tracker is located in MonoTorrent.Tracker. There is one sample Tracker implementation in MonoTorrent.TrackerApp. The Tracker is a piece of Software which listens for HttpRequests. Each Request can either be an Announce or Scrape request. Therefore the Tracker needs code which handles HttpRequests. The Tracker was programmed in such a way that it is independent of the http handling code. The http handling code is called Frontend. There are currently two Frontends implemented. The first uses the class HttpListener. This implementation got most attention. The second one uses the Asp.Net infrastructe and the HttpHandles classes. It therefore could be used in xsp2, mod_mono or even in IIS. But the second implementation was just a proof of concept and is not tested but should be functional. There exists and Frontend directory which contains all the Frontend handling code. There is also a Backend part of the Tracker. The backend is responsible for storing the Informations per Torrent which should be Announced to the peers. There is currently one Backend implementation which uses the .Net internal Datastructes List<> and Dictionary<> called SimpleTorrentManager. A Backend needs to implement the ITorrentManager interface. If you would like to start the Tracker the TrackerEngine is the class you would like to use. The sequence below is enough to start the Tracker: TrackerEngine engine = TrackerEngine.Instance engine.Address = "127.0.0.1"; engine.Port = 10000; engine.Frontend = TrackerFrontend.InternalHttp; engine.Start(); Adding Torrents is easy too. Just get an Tracker instance and call AddTorrent: Torrent t = new Torrent(); t.LoadTorrent(path); TrackerEngine.Instance.Tracker.AddTorrent(t); The two code snippets are enough to start a simple tracker. If you would like to tune the Tracker to use less Bandwidth you can set various things in the Tracker instance. One such thing would be to use the compact response format: Tracker.Instance.AllowNonCompact = true; The other place where you can tune is to implement the IIntervalAlgorithm. An implementor can controll at which rate the peers should request an Announce or Scrape. Currently we have an static implementation which uses static defaults taken from the original BitTorrent implementation. It's even possible to higher the intervals based on the number of peers using the Torrent. Tracker.cs is the code where everything is glued together. It is something like the heart of the Tracker implementation. Howto Test: If you want to test the Tracker just compile it with MonoDevelop. The Tracker searches (and creates if not found) for a directory named ./torrents. In this Directory every Torrent is loaded on startup. To test the Torrent you need some torrents pointing at the Tracker. This can be done with the unit test. Just run gnunit2 and load the Common.dll in src/bin/Debug. Copy the single.torrent and torrentcreator.torrent into src/bin/Debug/torrents and start the Tracker in MonoDevelop. Then you can load the Torrents in Azureus or BitTorrent and check if the Tracker reacts on Announces and Scrapes.
About
这是一个对monotorrent学习和二次开发的项目,现在完成的工作如下:修复了依次请求tracker时,接收到tracker返回消息再发起下一次请求的bug;增加了与中转服务器通信功能,通信使用protobuf;
Topics
Resources
License
Stars
Watchers
Forks
Releases
No releases published
Packages 0
No packages published