Join GitHub today
GitHub is home to over 40 million developers working together to host and review code, manage projects, and build software together.
Sign upWebtorrent setting a custom User-Agent in requests #1530
Comments
This comment has been minimized.
This comment has been minimized.
|
Hey @C0nw0nk, Currently the user agent is hard coded for all webseeds, tracker, and metadata requests, though it would be easy to implement a changeable user agent. Would you be looking for changing all instances of the user agent including requests made to trackers or only the user agents included with WebSeed / Metadata requests? All the best. |
This comment has been minimized.
This comment has been minimized.
|
I only had interest in changing the webseed request header that my servers would
receive or inserting a new custom header like this. So modifying the User-Agent or inserting a new custom header would do the job well. Because then i can use that JavaScript header as a authentication method for my server so anyone who tries to directly access the URL because they are missing the request header or expected user-agent i can deny those requests blocking direct URL access to all but webtorrent to prevent hotlinking and bandwidth leeching.
torrent.addRequestHeader("X-New-Header", "Header value")
Either way would be highly useful especially if you say it is easy to do <3 :D
Thanks @SilentBot1
|
This comment has been minimized.
This comment has been minimized.
|
@SilentBot1 Ontop of what i previously wrote does webtorrent when requesting the |
This comment has been minimized.
This comment has been minimized.
|
Borrowing this thread a lite, But i'm wondering how you can get the user-agent of another peer... |
This comment has been minimized.
This comment has been minimized.
|
@C0nw0nk, the implementation I wrote which can be seen here, I'll not send a PR yet as it seems not all your requirements are there, it sets one blanket user-agent for all requests, meaning it is presented to the tracker, .torrent server (metadata server) and webseed. If you are wanting to be able to specify all three separately, that could also be done, though for your use case I would recommend using a combination of a user-agent and request origin or even a custom middleware with tokens. Hey @jimmywarting, The user-agent is only presented in http(s) requests to trackers, webseeds and the metadata server so currently it's not possible to get another peers user-agent, you could possibly create a bittorrent-protocol extension to exchange user-agents with remote peers if it's needed depending on what you are doing. |
This comment has been minimized.
This comment has been minimized.
|
Don't really need it but it would have been interesting to know and see what other torrent clients others are using. Other torrent clients are able to display it so. |
This comment has been minimized.
This comment has been minimized.
|
@jimmywarting sorry, I thought you were asking about the user-agent. The peerId of a peer should contain the version and software being used in the from of a prefix, though with WebTorrent going above version |
This comment has been minimized.
This comment has been minimized.
|
@SilentBot1 Oh, so the peerid prefix is how they figure that out. Thanks mate |
This comment has been minimized.
This comment has been minimized.
|
Would be great if we could add basic Auth, cookies or custom headers as many trackers requires authentication. |
This comment has been minimized.
This comment has been minimized.
|
Hey @untitledlt, I agree this would be a useful feature to be able to assign individual headers for http trackers. This would require changes in at least two modules |
This comment has been minimized.
This comment has been minimized.
|
Related to: #1507 Webtorrent should allow users to transform any part of the http request. Any library that makes http requests should allow the requests to be open for extension, as every user's needs are different. Beware that in Chrome, the user-agent that Webtorrent sets is overwritten with: |
This comment has been minimized.
This comment has been minimized.
|
#1530 (comment) It would be better as a feature like that for custom headers to be added but then again the way @SilentBot1 has added it to the torrent options. client = new WebTorrent([opts]) If opts is specified, then the default options (shown below) will be overridden. { A customheader addition that allows us to specify either one or multiple custom headers to send in requests would go down so well. |
This comment has been minimized.
This comment has been minimized.
|
Any update on when this will be in the mainline version for us to use :) ? |
This comment has been minimized.
This comment has been minimized.
|
It also just occured to me isit possible to overwrite any request header that would be useful for authentication reasons between my HTML pages javascript and my server. Like editing the I would customise these.
|
This comment has been minimized.
This comment has been minimized.
|
Interesting find here. As was mentioned here #1530 (comment) Google Chrome does NOT respect webtorrent changing the User-Agent it will still force its own User-Agent on all requests to torrents and webseeds etc. As for a custom header |
I see webtorrent sends a custom user agent in all its request to my server checking nginx logs.
WebTorrent/0.102.4 (https://webtorrent.io)Isit possible to include a feature to set my own custom user agent in javascript. The benefits of that could be awesome for my server expecting a specific useragent instead in requests and also for
sha1url's etc.