ipfs / kubo

An IPFS implementation in Go
https://docs.ipfs.tech/how-to/command-line-quick-start/
Other
16.16k stars 3.01k forks source link

go-ipfs opens non requested TCP listener #3644

Closed daviddias closed 5 years ago

daviddias commented 7 years ago

Version information:

go-ipfs version: 0.4.5-dev-ea36c38 Repo version: 4 System version: amd64/darwin Golang version: go1.7.1

Type: Bug

Priority: P3

Description:

When only listing a WebSockets addr for go-ipfs, it still creates a listener on TCP

Config file

  "Addresses": {
    "Swarm": [
      "/ip4/127.0.0.1/tcp/9999/ws"
    ],
    "API": "/ip4/127.0.0.1/tcp/5001",
    "Gateway": "/ip4/127.0.0.1/tcp/8080"
  },

Output of ipfs id

{
        "ID": "QmU1sz7zVrrR4TkHdFxaJc124CAjuyXZJAnEWUJp6KpnLk",
        "PublicKey": "CAASpgIwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQDDQuKD8oWPOK7KZK7Cpm6oEc3/3rAxIZUiHBF7/7m+umVO24bzM58Ljx78eixnkyXlq96GTZWAZ1z8K87S8IHUC27ho7fJhWaDrQVL2Mhx9G/xHqdvWhX+/3I4V/3Qx1bSIyZ9D4w2UGkHXORnbm1/Fja6jeC1Bfd8vIDYIa/OWR52/Fm8YAYmSCjKEPUXRJW9/QHBMAnHU3rrcsRtkxE8jB5D0zrdVP3BCY+6lLnO2YxcnrwE9BXrq78o5ZKzPSOmqlG2m2/cCdWVDyS97pRrkp540LqirxP+jU1lLtGTkmopV3CbvWyB74mX/SgDX/s5xkSXVPq/AHdXzOMXoN93AgMBAAE=",
        "Addresses": [
                "/ip4/127.0.0.1/tcp/9999/ws/ipfs/QmU1sz7zVrrR4TkHdFxaJc124CAjuyXZJAnEWUJp6KpnLk",
                "/ip4/85.246.63.197/tcp/58157/ipfs/QmU1sz7zVrrR4TkHdFxaJc124CAjuyXZJAnEWUJp6KpnLk"
        ],
        "AgentVersion": "go-ipfs/0.4.5-dev/ea36c38",
        "ProtocolVersion": "ipfs/0.1.0"
}

Note that I also removed all of the bootstrapers from the config.

whyrusleeping commented 7 years ago

well thats weird.

ghost commented 7 years ago

My guess is that's the fallback listener. I see it too.

ghost commented 7 years ago

or fallback dialer or what it's called

photonxp commented 7 years ago

Does the TCP port change in "/ip4/85.246.63.197/tcp/58157/ipfs/QmU1sz7zVrrR4TkHdFxaJc124CAjuyXZJAnEWUJp6KpnLk"?

whyrusleeping commented 7 years ago

This issue probably comes from go-libp2p/p2p/host/basic/basic_host.go where we add addresses that we've been observed to have to the ipfs id output. This touches on another issue where if someone tells us they see us coming from a port above 32000 or so, its definitely not something we're dialable on.

Found the info, we shouldnt ever claim to be listening on ephemeral ports: https://en.wikipedia.org/wiki/Ephemeral_port unless we're actually 100% certain we're doing so (i.e. we have an active listener on one)

This should probably be changed here: https://github.com/libp2p/go-libp2p/blob/master/p2p/protocol/identify/obsaddr.go

Stebalien commented 5 years ago

Fixed. One source of this, at least, was NAT hole punching.