Skip to content
This repository was archived by the owner on Mar 9, 2022. It is now read-only.

randomports: give user ability to init ipfs using random port for swarm. #17

Merged
merged 1 commit into from
Dec 11, 2018

Conversation

tarekbadrsh
Copy link
Contributor

Issue : ipfs/kubo#5176

It's still under development, just to make sure that the code is going to
do as we expected.

Copy link
Member

@Stebalien Stebalien left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Preliminary review: LGTM.

@tarekbadrsh
Copy link
Contributor Author

Hi @Stebalien,

  • I change the description.
  • I don't know how do we test this repo, I can't find any test pkg.
  • I have another idea about random port, we can generate random number and check if it's available, ex.
	src := rand.NewSource(time.Now().UnixNano())
	rnd := rand.New(src)
	portRange := 10000
	port := rnd.Intn(portRange)
	for !isAvailablePort(port) {
		port = rnd.Intn(portRange)
	}

please feel free to ask about more update.

@djdv
Copy link

djdv commented Nov 2, 2018

@tarekbadrshalaan

I don't know how do we test this repo, I can't find any test pkg.

There are tests in go-ipfs at the moment that check the output of the config command.
https://github.com/ipfs/go-ipfs/blob/master/test/sharness/t0021-config.sh
It may be best to add your cases there.

I have another idea about random port, we can generate random number and check if it's available, ex.

Is there benefit to this over the randomness inherited from net.Listen("tcp", "[::]:0")?

@@ -159,6 +163,31 @@ fetching may be degraded.
return nil
},
},
"randomports": {
Description: `Use a random port number for swarm.`,
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hello @djdv
as you can see here I updated the discretion as you said.

again sorry be late and please feel free to ask about more update.

@tarekbadrsh
Copy link
Contributor Author

Is there benefit to this over the randomness inherited from net.Listen("tcp", "[::]:0")?

  • no it was just an idea i thought it might help.

Copy link

@djdv djdv left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems fine to me. 👍
The considerations that came up during review where:

  • Should net.Listen("tcp", "[::]:0") try net.Listen("tcp", "127.0.0.1:") instead of, or in addition to, the ipv6 port?
    But I doubt it's necessary, so I think not.
  • Lack of type assertion check in port = ln.Addr().(*net.TCPAddr).Port
    But it's pretty clear that we'd always have a *net.TCPAddr from Listen here.

@djdv
Copy link

djdv commented Nov 27, 2018

@tarekbadrshalaan
Sorry for my absence, something unexpected came up.
The delay is on me this time ;^)

Patch seems good to me, handing off to @Stebalien

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants