GithubHelp home page GithubHelp logo

"implied_port" is improperly handled about dht HOT 15 CLOSED

jech avatar jech commented on July 21, 2024
"implied_port" is improperly handled

from dht.

Comments (15)

ghazel avatar ghazel commented on July 21, 2024

Aha, thank you https://github.com/clostra/dcdn/blob/master/client.c#L222

from dht.

jech avatar jech commented on July 21, 2024

Fixed in 7166f21. Thanks.

from dht.

jech avatar jech commented on July 21, 2024

I've also added explicit support for implicit_port in 5853ed1. This is completely untested, @carlreinke, @ghazel, please be so kind as too proof-read me.

from dht.

cfpp2p avatar cfpp2p commented on July 21, 2024

Tested 5853ed1 with transmission. No problems. Thousands of implied_port, every last one Both port and implied_port.


            if(implied_port != 0) {
                if(port != 0) {
                    debugf("Both port and implied_port.\n");
                    /* But continue, that's what the spec says. */
                }
                switch(from->sa_family) {
                case AF_INET:
                    port = htons(((struct sockaddr_in*)from)->sin_port);
                    debugf("Announce_peer: AF_INET implied_port %d.\n", port);
                    break;
                case AF_INET6:
                    port = htons(((struct sockaddr_in6*)from)->sin6_port);
                    debugf("Announce_peer: AF_INET6 implied_port %d.\n", port);
                    break;
                default:
                    port = 0;
                    debugf("Announce_peer: unsupported sa_family! implied port set zero.\n");
                    break;
                }
            }

from dht.

cfpp2p avatar cfpp2p commented on July 21, 2024

OK, it seems to be about 25 per thousand implied_port that don't have Both port and implied_port.

from dht.

jech avatar jech commented on July 21, 2024

from dht.

cfpp2p avatar cfpp2p commented on July 21, 2024

I think it might make sense to log the inverse. Does this make sense?


            if(implied_port != 0) {
                if(port == 0) {
                    debugf("implied_port alone.\n");
                }
                /* Continue either way, that's what the spec says. */

from dht.

jech avatar jech commented on July 21, 2024

from dht.

cfpp2p avatar cfpp2p commented on July 21, 2024

OK, recommend removing the debug statement. It's not about debugging the DHT.

from dht.

cfpp2p avatar cfpp2p commented on July 21, 2024

@ghazel

Aha, thank you https://github.com/clostra/dcdn/blob/master/client.c#L222

0.24 implementation and DHT pollution.

https://github.com/cfpp2p/dht-trs-trs/tree/port-logging logged:

Forty-two percent of 118,152 messages contained optional implied_port.

Of those, 98 percent contain both
non zero port and flagged (non zero) implied_port.
Twenty-four percent of those,
derived (implied) port value differed from port value.
With 0.24
twenty-four percent would have announce peer port incorrect,
NOT based on derived port, but on port.

With 0.24
remaining two percent
messages containing optional implied_port,
those with port=0 (or missing) and implied_port flagged on,
would then announce peer port 1.

Of course this is assuming that port precedes implied_port in the message, which I didn't check.

from dht.

ghazel avatar ghazel commented on July 21, 2024

Bencoding has lexigraphically sorted keys, so implied_port should come first.

from dht.

jech avatar jech commented on July 21, 2024

from dht.

ghazel avatar ghazel commented on July 21, 2024

Sounds like a fun challenge. How many lines would be acceptable?

from dht.

jech avatar jech commented on July 21, 2024

from dht.

ghazel avatar ghazel commented on July 21, 2024

How about net 8 lines? #31

from dht.

Related Issues (16)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.