-
Notifications
You must be signed in to change notification settings - Fork 49
Axum HTTP tracker: announce
request in public mode
#185
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Axum HTTP tracker: announce
request in public mode
#185
Conversation
0c7b9c3
to
778a109
Compare
778a109
to
03024e2
Compare
@WarmBeer @da2ce7 when there is an error with an HTTP tracker request, we return a
By the way, In that case, the error is because there is a missing param. I will improve in the new version. BEP-0003 says: Tracker responses are bencoded dictionaries. If a tracker response has a key failure reason, then that maps to a human readable string which explains why the query failed, and no other keys are required. Otherwise, it must have two keys: interval, which maps to the number of seconds the downloader should wait between regular rerequests, and peers. peers maps to a list of dictionaries corresponding to peers, each of which contains the keys peer id, ip, and port, which map to the peer's self-selected ID, IP address or dns name as a string, and port number, respectively. Note that downloaders may rerequest on nonscheduled times if an event happens or they need more peers. I suppose they consider the bencoded dictionary to be "human-readable", but it says nothing about the status code. Should we continue returning a 200 status code even for this kind of error (bad request due to missing params)? I'm assuming ALL responses are bencoded dictionaries, even error responses. For the time being, I will continue returning the same error codes as the Warp version if you think we do not have to change it, but improving the error message. |
056a2a7
to
ceab789
Compare
hi @da2ce7 @WarmBeer on this commit I've fixed error responses because there were not bencoded in the initial implementation. This is a sample error before bencoding it:
I think it does not make sense to expose the location ( On the other hand, being an OS project, It could be helpful to get more info if the error message is not enough. What do you think? |
HTTP tracker error responser must be bencoded. Fixed in the new Axum implementation.
ceab789
to
f327dcf
Compare
I think that it makes sense to have it, as someone can lookup the source-code and find where the error came from... However we should consider including the git-hash, so they can lookup the right version. |
@da2ce7 OK, but do you mean in the error message? I think it would be better if you could get the exact version from your binary running a Anyway, that would be an extra feature not related to this request (we have to include the git-hash first). For this PR, I will continue exposing the error location in the public API responses. |
Yes, of-course it is out of scope of this , however the consumer of the API doesn't necessarily have access to the server to run a |
Ups, right! OK. Then, we can propose a new feature to include the git-hash in located errors. And it will be available automatically in the API responses. |
Although we could add a new non-official HTTP tracker endpoint to get the server version: |
It will be used to extract the right most IP in the X-Forwarded-For header when the tracer is running on reverse proxy.
…he tracker is running on reverse proxy or not Obtaining the remote peer client IP could be a complex task. See: https://adam-p.ca/blog/2022/03/x-forwarded-for/#multiple-headers We were using a custom function to extract the rigth most IP in the X-Forwarded-For HTTP header. This commit starts using an external crate for that.
hi @da2ce7 @WarmBeer, I've started using this crate to get the remote client IP from HTTP headers when the tracker is running on the reverse proxy. The reason is you can even have multiple message-header fields with the same field-name, so I decided to rely on that crate because it seems to be much more complicated than parsing a string. Besides, It could make it easier in the future to change the way we get the remote client IP. You can see the changes in this commit. |
424e3e5
to
e85d115
Compare
Implemented the normal (non-compact)
|
…xum tracker Implemeneted the normal (non-compact) announce response in the new Axum implementation for the HTTP tracker. Only for the tracker public mode and with only the mandatory announce request params.
e85d115
to
3eb7475
Compare
It uses a wrapper for another extractor becuase that extractor cannot be optional. We need to get the rigth most IP in the X-Forwarded-For header only when the tracker is runnin gon reverse proxy. More info: imbolc/axum-client-ip#9 (comment)
c43f79b
to
99dbbe4
Compare
hi @da2ce7 @WarmBeer this is ready to review. Remember this is just one subtask in this parent issue. |
It implements the
announce
request handler in the Axum HTTP tracker forpublic
mode.announce
requestX-Forwarded-For
header on reverse proxy mode. See commented tests.Out of this PR scope:
UPDATE: 16/02/2023