surgeonix / bitswarm Goto Github PK
View Code? Open in Web Editor NEWBittorrent library for clients & streaming purposes
License: GNU Lesser General Public License v3.0
Bittorrent library for clients & streaming purposes
License: GNU Lesser General Public License v3.0
I have one multiple program transport stream (MPTS) with source IP address udp://@228.110.1.1:1234. I wanna develop a program like Mosaic Streaming player that detect available program in udp://@228.110.1.1:1234 till we choose one to play. (demux stream and extract programs baseid on PID or PMT ) this task done in VLC app but i cant switch between program and play one of theme، whiles DVB Viewer app play this stream in programs properly. my platform is .net and i am familiar with Flyleaf (your player) and libVLCSharp and ffplay and DVB viewer
`Core.Initialize();
_libVLC = new LibVLC();
_mediaPlayer = new MediaPlayer(_libVLC);
videoView.MediaPlayer = _mediaPlayer;
_mediaPlayer.Play(new Media(_libVLC, new Uri("... stream ip ...")));`
Do you have any idea for this task?
The client seems to make 3 application instances in memory when starting only 1 single torrent.
This can be confirmed by adding NotifyIcon1 to frmMain and watching for 3 spawn processes after starting a torrent. This is also a issue reflecting peer databases. On my end, a single query to the tracker for peers will add 3 rows into the database (for the same torrent, same instance. Really confuses the announce routines and gives up until next peer table clean interval).
This is a huge no no on nearly any tracker out there, especially older PHP4 trackers due to abuse/peer flooding/DDOS and the early days of the PHP team catching up.
If this is intended behavior, then the requests out to the tracker must be resolved.
Only 1 single unique info_hash should be sent out and acknowledged.
There are 3 rows with exact same data (and tells me its seeding, also no good). It seems to be retrying 3 times every time spawning a new instance? That is fine on the hardware-side of a consumer PC but for the database, this is a killer.
Please confirm.
Exception Exception thrown: 'System.IO.FileNotFoundException' in BencodeNET.dll ("Could not load file or assembly 'System.Buffers, Version=4.0.2.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51' or one of its dependencies. The system cannot find the file specified.") System.IO.FileNotFoundException
can i use your lib to use it for other purposes not for sending files. i want to build a p2p application based on bittorrent for sending/recieving data
Hi I would like to ask. It is possible to do a torrent stream as in monottorent example LVST. Thanks for the reply.
It seems to be a .NET cores issue. To reproduce create few simple Threads and put them in a while (true) Sleep(10);
First: keep up the good work!
.open() does nothing with the following magnet link even in the WinForms demo.
magnet:?xt=urn:btih:ee17eb980ac506e3043474bf3fb42a7777ad991b&dn=Bitchin.Rides.S09E08.Is.There.Anything.Good.on.HDTV.x264-CRiMSON%5Brartv%5D&tr=http%3A%2F%2Ftracker.trackerfix.com%3A80%2Fannounce&tr=udp%3A%2F%2F9.rarbg.me%3A2760&tr=udp%3A%2F%2F9.rarbg.to%3A2780&tr=udp%3A%2F%2Ftracker.fatkhoala.org%3A13750&tr=udp%3A%2F%2Ftracker.thinelephant.org%3A12740
no error or other indication MetadataReceived never fires (or ANY of the events)
Should implement an escape scenario by identifying the responsible peers and banning them
I have fully implemented this into a nice list control with internal BLOB fetch and save/load (and client begins downloads, like limewire sort of).
Works perfect on public torrents, but Private is not possible! uTorrent has absolutely no issues. I cant turn off Private flag in the metadata because that changes the info_hash (database mismatch, seedbox issues etc).
I will investigate but can you please provide a solution or confirmation?
I cant figure it out, I feel it is this line in Tracker.cs
byte[] sendBuff = System.Text.Encoding.UTF8.GetBytes($"GET {uri.AbsolutePath}?info_hash={Utils.StringHexToUrlEncode(options.InfoHash)}&peer_id={Utils.StringHexToUrlEncode(BitConverter.ToString(options.PeerId).Replace("-",""))}&port=11111&left={left}&downloaded={downloaded}&uploaded={uploaded}&event=started&compact=1&numwant={num_want} HTTP/1.1\r\nHost: {host}:{port}\r\nConection: close\r\n\r\n");
I plan to extend this codebase and push this thing forward. I already have it doing a lot, like notifications and much more, really cool library, thank you!
Hi there
I have two questions.
I have integrated this into a small game launcher which will be downloading the game zip file and ideally i would like it to seed while downloading and also get the fastest download speeds possible.
When testing my torrent download using something like qbittorrent then i get full download speeds of 10Mb/s, but when I use my launcher with BitSwarm I get max 3Mb/s download speed.
Any ideas, please let me know.
thanks!
Hi @SuRGeoNix, I'm using the BitSwarm Nuget package and it works very well. I'm just wondering is there an option to limit the download speed? I did some search but didn't found stuffs about that in BitSwarm.
There is by default no user agent string set in the client's HTTP request headers. This can result in private-tracker penalties or other reductions in place of policy, libtorrent, trackers and possible utilization of these fields on the tracker-end. This could be otherwise treated as "Fake-Client" by mainland clients.
Changes:
Tracker.cs
static Tracker()
{
// Allowing Untrusted SSL Certificates with HttpClient
ServicePointManager.ServerCertificateValidationCallback += (sender, cert, chain, sslPolicyErrors) => true;
httpClient.Timeout = new TimeSpan(0, 0, 30); // TODO: Options?
var clientVersion = new ProductInfoHeaderValue("BitSwarm", "2.4.0");
httpClient.DefaultRequestHeaders.UserAgent.Add(clientVersion);
}
Appears the application never initiates a firewall rule request to the Windows firewall allowing inbound connections, this can be helpful in allowing greater forwarding and connectivity.
For this, and the most forward approach I think is first add a new reference, browse COM and point path to
C:\WINDOWS\system32\FirewallAPI.dll
Now add the import
using NetFwTypeLib;
Next, add a new button to designer - button3
On click event
private void button3_Click(object sender, EventArgs e)
{
bool firewallRule = false;
if (MessageBox.Show("Add a Allow All rule for Windows firewall?", "Confirmation", MessageBoxButtons.OKCancel) == DialogResult.OK)
{
// Located in FirewallAPI.dll
INetFwRule firewallRule = (INetFwRule)Activator.CreateInstance(
Type.GetTypeFromProgID("HNetCfg.FWRule"));
firewallRule.Action = (NetFwTypeLib.NET_FW_ACTION_)NET_FW_ACTION_.NET_FW_ACTION_ALLOW;
firewallRule.Description = "Used to allow all internet access.";
firewallRule.Direction = NET_FW_RULE_DIRECTION_.NET_FW_RULE_DIR_IN;
firewallRule.Enabled = true;
firewallRule.InterfaceTypes = "All";
firewallRule.Name = "BitSwarm 2.4.4";
INetFwPolicy2 firewallPolicy = (INetFwPolicy2)Activator.CreateInstance(Type.GetTypeFromProgID("HNetCfg.FwPolicy2"));
firewallPolicy.Rules.Add(firewallRule);
firewallRule = true;
}
if (firewallRule)
MessageBox.Show("Firewall rule added successfully.");
}
To remove rule, whether on program exit or by user control
firewallPolicy.Rules.Remove("BitSwarm 2.4.4");
Unlike most other applications listed by filename (Chrome uses their own name), this taps right into the Windows firewall API so you get the name, the values and directly in.
Its nice to have the firewall pop up window, but it seems this code bypasses that entirely.
This works 100%.
https://docs.microsoft.com/en-us/windows/win32/api/icftypes/
Added some options our other downloader classes uses, transfers work fine. May need tuning. C#9
Tracker.cs
using System.Security.Authentication;
static Tracker()
{
// Allowing Untrusted SSL Certificates with HttpClient
var handler = new HttpClientHandler()
{
SslProtocols = SslProtocols.Tls12,
AllowAutoRedirect = true,
AutomaticDecompression = DecompressionMethods.GZip,
CookieContainer = new CookieContainer()
};
using var httpClient = new HttpClient(handler);
ServicePointManager.ServerCertificateValidationCallback += (sender, cert, chain, sslPolicyErrors) => true;
httpClient.Timeout = new TimeSpan(0, 0, 30); // TODO: Options?
httpClient.DefaultRequestHeaders.UserAgent.Add(new System.Net.Http.Headers.ProductInfoHeaderValue("BitSwarm", BitSwarm.Version));
key = rnd.Next(1, Int32.MaxValue);
}
public async void AnnounceTCP(Int32 num_want = -1, Int64 downloaded = 0, Int64 left = 0, Int64 uploaded = 0)
{
try
{
// Options?
var handler = new HttpClientHandler()
{
SslProtocols = SslProtocols.Tls12,
AllowAutoRedirect = true,
AutomaticDecompression = DecompressionMethods.GZip,
CookieContainer = new CookieContainer()
};
using var httpClient = new HttpClient(handler);
string query = !string.IsNullOrEmpty(uri.Query) ? "&" : "?";
query += $"info_hash={Utils.StringHexToUrlEncode(options.InfoHash)}&peer_id={Utils.StringHexToUrlEncode(BitConverter.ToString(options.PeerId).Replace("-", ""))}&port=11111&left={left}&downloaded={downloaded}&uploaded={uploaded}&event=started&compact=1&numwant={num_want}&key={key:x}";
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.