After I've got an email from Alan mcgorven and a Link, Alan is the maker of monotorrent which a.k.a Bitsharp on mono, it becomes clearer for me the path to make a private tracker
How we can make a tracker private is by Embedding a key , a query string on the announce url :
"Basically when you create the torrent, just append a secret key to the
end of the announce url. I'll use the username in my example:
Regular Announce Url:
http://server:port/announce
Joe's announce url:
http://server:port/announce?
pass=joe
Bob's announce url:
http://server:port/announce?pass=bob
Then,
whenever a request is received by the tracker, you first check that the
'pass' key has been supplied in the query string then you check that
the value of it is valid, i.e. you do have a user called joe or bob. If
that check passes, then you can call the Handle () method and process
the request. If the check fails, don't call the Handle () method, but
return an error message instead.
The easiest way to accomplish this is to store an unmodifed
.torrent file on your server and provide a download link. When a user
clicks the link, load the .torrent file into memory in it's raw form (a
BEncodedDictionary), alter the announceurls by appending the key, then
just call bencodedDictionary.Encode () to convert to a byte[] and send
that to the user."
Here is the Working code on Asp.net that i make To Generate the torrentfile, please do combinate this with encrypted the key, the key can be anything you think of , save to db and the tracker should check it.
string filepath = context.Request.Form["txtfilepath"];
System.IO.StreamReader reader = new StreamReader(@filepath, true);
MonoTorrent.BEncoding.RawReader BitTorrentReader = new RawReader(reader.BaseStream);
BEncodedDictionary RawContent = BEncodedDictionary.DecodeTorrent(BitTorrentReader);
BEncodedValue annouceurl;
RawContent.TryGetValue("announce", out annouceurl);
string x = annouceurl.ToString();
x += "?key=somekey";
BEncodedString mynewstring = x;
RawContent["announce"] = mynewstring;
context.Response.ContentType = "application/x-bittorrent";
context.Response.BinaryWrite(RawContent.Encode());
context.Response.End();
2/7/2009
Fix the Mono Torrent Why not Triggering Scrape Feature.
It's because on the HTTP listener only add prefix of http://{0}:{1}/announce/", address, port
Changed on Listeners-> HttpListener.cs
private List<string> prefixes=new List<string>();
public HttpListener(IPAddress address, int port)
: this(string.Format("http://{0}:{1}/announce/", address, port))
{
AddPrefix(string.Format("http://{0}:{1}/scrape/", address, port));
}
private void AddPrefix(string httpPrefix)
{
this.prefixes.Add(httpPrefix);
}
9/7/2009
to get the Tracker statistic .we make what to watch by implementing ITrackable
we access it from the TorrenManager.
So if it's from sample project should be:
foreach (SimpleTorrentManager m in tracker)
{
Console.Write("Name: {0} ", m.Trackable.Name);
Console.WriteLine("Complete: {1} Incomplete: {2} Downloaded: {0}", m.Downloaded, m.Complete, m.Incomplete);
TorrentAccess.UpdateSeederLeecherByFileName(m.Trackable.Name,m.Complete,m.Incomplete);
}
For the pass KEY , we can add another query string it doesn't have to be key=something, we can named it with another one ex: passkey=something
because bit torent client already append a generated key to key. so if you insert something it will be key=something,DDFD where DDFD ex: is the generatedkey from utorrent/bitcommet
13th July 2009
I've updated the tracker which is httplistener to use prefixes http://*:port/announce, some times if a computer has a lot of ip or network card. A Start '*' means
Listen to every of those ip , On this port. There you go it's running on the server now