Skip to content
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

Fix: dnslink domain resolving was broken; Add: no caching for those #1272

Merged
merged 2 commits into from
May 24, 2015
Merged

Fix: dnslink domain resolving was broken; Add: no caching for those #1272

merged 2 commits into from
May 24, 2015

Conversation

Luzifer
Copy link
Member

@Luzifer Luzifer commented May 21, 2015

fixes #1234 & #1267

@jbenet PTAL

@jbenet jbenet added the backlog label May 21, 2015
@jbenet
Copy link
Member

jbenet commented May 21, 2015

Thanks this is great. sorry for the resolve errors.

if len(host) > 0 && isd.IsDomain(host) {
name := "/ipns/" + host
if _, err := n.Namesys.Resolve(ctx, name); err == nil {
r.URL.Path = path.Join("/ipns/", host) + r.URL.Path
Copy link
Member

Choose a reason for hiding this comment

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

maybe: name + r.URL.Path ?

@wking
Copy link
Contributor

wking commented May 21, 2015 via email

@Luzifer
Copy link
Member Author

Luzifer commented May 21, 2015

Just using path.Join(p.String, r.URL.Path) leads to bad results… path.Join removes any trailing slash which then leads to redirect foo…

Regarding two DNS resolves: I don't the the problem with this. The DNS entry is cached by the next DNS resolver in the network. For most people their local router, otherwise providers router, … So this are two inexpensive DNS requests compared to one… Yeah sure, one could implement a DNS cache but for now it would work for me this way.

@Luzifer
Copy link
Member Author

Luzifer commented May 21, 2015

About tests: @jbenet and me had an idea for this: https://botbot.me/freenode/ipfs/2015-05-21/?msg=39768745&page=5

@wking
Copy link
Contributor

wking commented May 21, 2015

On Thu, May 21, 2015 at 10:34:41AM -0700, Knut Ahlers wrote:

Just using path.Join(p.String, r.URL.Path) leads to bad results…
path.Join removes any trailing slash which then leads to redirect
foo…

Ah, that makes sense. All these little wrinkles to trip us up :p.

@wking
Copy link
Contributor

wking commented May 21, 2015

On Thu, May 21, 2015 at 10:40:14AM -0700, Knut Ahlers wrote:

About tests: @jbenet and me had an idea for this:
https://botbot.me/freenode/ipfs/2015-05-21/?msg=39768745&page=5

I just see “we need to test this” there, not how to get a mock DNS for
sharness tests. Personally, I'd be fine with some Go tests for this
functionality, since it's a lot easier to plug in a mock DNS resolver
in Go than it is to set one up for sharness tests.

@Luzifer
Copy link
Member Author

Luzifer commented May 21, 2015

We have several tests for the resolver stuff but none of those caught the feature to be fully destroyed. A full-stack-test would test the whole stack and check the "outside" functionality is still intact and not only parts of the codes are okay.

@whyrusleeping
Copy link
Member

we should have a few domains on ipfs.io, like test.ipfs.io or test1.ipfs.io that have TXT records we can use for testing like this

@wking
Copy link
Contributor

wking commented May 21, 2015

On Thu, May 21, 2015 at 11:14:21AM -0700, Jeromy Johnson wrote:

we should have a few domains on ipfs.io, like test.ipfs.io or
test1.ipfs.io that have TXT records we can use for testing like
this

Tests that require a working network connection between the location
running the tests (Travis?) and some external entity (the DNS chain
leading to test.ipfs.io) make me jumpy. For one thing, you could
never change the values in those TXT records without breaking
bisection for commits that assumed the old entries/values. It's easy
enough to mock the DNS entries in Go, so while I like the security of
end-to-end sharness tests, I don't think they're worth the trouble in
this case, and I'd rather have in-Go tests for this functionality.

@jbenet
Copy link
Member

jbenet commented May 22, 2015

we should have a few domains on ipfs.io, like test.ipfs.io or test1.ipfs.io that have TXT records we can use for testing like this

Yep, absolutely. if people drop some records here, i'll add them.

Tests that require a working network connection between the location
running the tests (Travis?) and some external entity (the DNS chain
leading to test.ipfs.io) make me jumpy. For one thing, you could
never change the values in those TXT records without breaking
bisection for commits that assumed the old entries/values. It's easy
enough to mock the DNS entries in Go, so while I like the security of
end-to-end sharness tests, I don't think they're worth the trouble in
this case, and I'd rather have in-Go tests for this functionality.

Agreed with this too. I think we should have a test that is usually mocked, but the mocking can be turned off and run live when in the internet (on CI). (good to test for real).

@jbenet
Copy link
Member

jbenet commented May 22, 2015

@Luzifer should i merge this, or wait for tests?

@Luzifer
Copy link
Member Author

Luzifer commented May 22, 2015

@jbenet for me it would really nice to have this live and working dnslink feature. That way I could continue putting documentation to IPFS… You're the project owner so you have to decide whether to wait or merge…

@jbenet
Copy link
Member

jbenet commented May 22, 2015

@Luzifer i'd also want it in-- so that resolve actually works.

hmmm, @Luzifer would you submit a follow-up PR? not sure how long it would take either way.

@Luzifer
Copy link
Member Author

Luzifer commented May 22, 2015

Actually I'd prefer someone with more knowledge about the whole project and mocking to write the tests…

@whyrusleeping
Copy link
Member

@wking do you think you could handle writing a test or two for this?

@jbenet
Copy link
Member

jbenet commented May 24, 2015

circlci's detecting races for us :) cc @whyrusleeping

==================
WARNING: DATA RACE
Read by goroutine 77:
  github.com/ipfs/go-ipfs/exchange/bitswap.(*Bitswap).ReceiveMessage()
      /home/ubuntu/.go_project/src/github.com/ipfs/go-ipfs/exchange/bitswap/bitswap.go:339 +0x395
  github.com/ipfs/go-ipfs/exchange/bitswap/testnet.(*networkClient).ReceiveMessage()
      <autogenerated>:48 +0xde
  github.com/ipfs/go-ipfs/exchange/bitswap/testnet.(*network).deliver()
      /home/ubuntu/.go_project/src/github.com/ipfs/go-ipfs/exchange/bitswap/testnet/virtual.go:75 +0x16c

Previous write by goroutine 97:
  github.com/ipfs/go-ipfs/exchange/bitswap.(*Bitswap).ReceiveMessage()
      /home/ubuntu/.go_project/src/github.com/ipfs/go-ipfs/exchange/bitswap/bitswap.go:339 +0x3b4
  github.com/ipfs/go-ipfs/exchange/bitswap/testnet.(*networkClient).ReceiveMessage()
      <autogenerated>:48 +0xde
  github.com/ipfs/go-ipfs/exchange/bitswap/testnet.(*network).deliver()
      /home/ubuntu/.go_project/src/github.com/ipfs/go-ipfs/exchange/bitswap/testnet/virtual.go:75 +0x16c

Goroutine 77 (running) created at:
  github.com/ipfs/go-ipfs/exchange/bitswap/testnet.(*network).SendMessage()
      /home/ubuntu/.go_project/src/github.com/ipfs/go-ipfs/exchange/bitswap/testnet/virtual.go:62 +0x265
  github.com/ipfs/go-ipfs/exchange/bitswap/testnet.(*networkClient).SendMessage()
      /home/ubuntu/.go_project/src/github.com/ipfs/go-ipfs/exchange/bitswap/testnet/virtual.go:89 +0xc9
  github.com/ipfs/go-ipfs/exchange/bitswap.(*Bitswap).send()
      /home/ubuntu/.go_project/src/github.com/ipfs/go-ipfs/exchange/bitswap/bitswap.go:446 +0x2db
  github.com/ipfs/go-ipfs/exchange/bitswap.(*Bitswap).taskWorker()
      /home/ubuntu/.go_project/src/github.com/ipfs/go-ipfs/exchange/bitswap/workers.go:74 +0x586
  github.com/ipfs/go-ipfs/exchange/bitswap.func·013()
      /home/ubuntu/.go_project/src/github.com/ipfs/go-ipfs/exchange/bitswap/workers.go:40 +0x6f
  github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/jbenet/goprocess.func·005()
      /home/ubuntu/.go_project/src/github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/jbenet/goprocess/impl-mutex.go:110 +0xa7

Goroutine 97 (running) created at:
  github.com/ipfs/go-ipfs/exchange/bitswap/testnet.(*network).SendMessage()
      /home/ubuntu/.go_project/src/github.com/ipfs/go-ipfs/exchange/bitswap/testnet/virtual.go:62 +0x265
  github.com/ipfs/go-ipfs/exchange/bitswap/testnet.(*networkClient).SendMessage()
      /home/ubuntu/.go_project/src/github.com/ipfs/go-ipfs/exchange/bitswap/testnet/virtual.go:89 +0xc9
  github.com/ipfs/go-ipfs/exchange/bitswap.(*Bitswap).send()
      /home/ubuntu/.go_project/src/github.com/ipfs/go-ipfs/exchange/bitswap/bitswap.go:446 +0x2db
  github.com/ipfs/go-ipfs/exchange/bitswap.(*Bitswap).taskWorker()
      /home/ubuntu/.go_project/src/github.com/ipfs/go-ipfs/exchange/bitswap/workers.go:74 +0x586
  github.com/ipfs/go-ipfs/exchange/bitswap.func·013()
      /home/ubuntu/.go_project/src/github.com/ipfs/go-ipfs/exchange/bitswap/workers.go:40 +0x6f
  github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/jbenet/goprocess.func·005()
      /home/ubuntu/.go_project/src/github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/jbenet/goprocess/impl-mutex.go:110 +0xa7
==================

jbenet added a commit that referenced this pull request May 24, 2015
Fix: dnslink domain resolving was broken; Add: no caching for those
@jbenet jbenet merged commit 4e71ce3 into ipfs:master May 24, 2015
@jbenet jbenet removed the backlog label May 24, 2015
@jbenet jbenet deleted the fix/dnslink branch May 24, 2015 16:47
@jbenet
Copy link
Member

jbenet commented May 24, 2015

(let's do a test as a separate PR -- #1289)

@wking wking mentioned this pull request Jun 12, 2015
hacdias pushed a commit to ipfs/boxo that referenced this pull request Jan 27, 2023
Fix: dnslink domain resolving was broken; Add: no caching for those

This commit was moved from ipfs/kubo@4e71ce3
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

When used to host static websites cache-timeout should not be 48 weeks
4 participants