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

dnslink resolution broken in 0.3.4 #1267

Closed
Luzifer opened this issue May 21, 2015 · 2 comments
Closed

dnslink resolution broken in 0.3.4 #1267

Luzifer opened this issue May 21, 2015 · 2 comments

Comments

@Luzifer
Copy link
Member

Luzifer commented May 21, 2015

In 0.3.4 dnslink resolution for domains is completely broken.

# dig txt swagger.luzifer.io

; <<>> DiG 9.8.3-P1 <<>> txt swagger.luzifer.io
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 32322
;; flags: qr rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 7, ADDITIONAL: 0

;; QUESTION SECTION:
;swagger.luzifer.io.        IN  TXT

;; ANSWER SECTION:
swagger.luzifer.io. 59  IN  TXT "dnslink=/ipfs/QmczrnBpAgnhCo87rtZ8VbLfGU5v8g7cKr7Ef2fKRvYniA/"
[...]

# curl -i -H 'Host: swagger.luzifer.io' http://localhost:8080/
HTTP/1.1 404 Not Found
Content-Type: text/plain; charset=utf-8
Date: Thu, 21 May 2015 04:46:13 GMT
Content-Length: 19

404 page not found

namesys is not resolving the hosts dnslink according to ipfs daemon --debug so the path seems to be intercepted before ipns_hostname.go

@Luzifer Luzifer changed the title dnslink resolution broken dnslink resolution broken in 0.3.4 May 21, 2015
@Luzifer
Copy link
Member Author

Luzifer commented May 21, 2015

# curl -i -H 'Host: swagger.luzifer.io' http://localhost:8080/ipfs/QmczrnBpAgnhCo87rtZ8VbLfGU5v8g7cKr7Ef2fKRvYniA/
HTTP/1.1 200 OK
Cache-Control: public, max-age=29030400
Etag: QmczrnBpAgnhCo87rtZ8VbLfGU5v8g7cKr7Ef2fKRvYniA
Suborigin: QmczrnBpAgnhCo87rtZ8VbLfGU5v8g7cKr7Ef2fKRvYniA
X-Ipfs-Path: /ipfs/QmczrnBpAgnhCo87rtZ8VbLfGU5v8g7cKr7Ef2fKRvYniA/
Date: Thu, 21 May 2015 05:28:00 GMT
Content-Type: text/html; charset=utf-8
Transfer-Encoding: chunked

<!DOCTYPE html>

Hostnames with dnslink entries are handled like any other gateway address. So maybe the handler in ipns_hostname.go is not called?

@Luzifer
Copy link
Member Author

Luzifer commented May 21, 2015

# ./ipfs daemon 2>&1
Initializing daemon...
API server listening on /ip4/127.0.0.1/tcp/5001
Ohai IPNSHostnameOption
Gateway (readonly) server listening on /ip4/127.0.0.1/tcp/8080
Ohai HandleFunc
ERR: not a key

^C
Received interrupt signal, shutting down...
Publishing!
07:58:00.873 ERROR     ipnsfs: leveldb: closed system.go:83
diff --git a/core/corehttp/ipns_hostname.go b/core/corehttp/ipns_hostname.go
index f651cc6..97867fc 100644
--- a/core/corehttp/ipns_hostname.go
+++ b/core/corehttp/ipns_hostname.go
@@ -1,6 +1,7 @@
 package corehttp

 import (
+       "fmt"
        "net/http"
        "path"
        "strings"
@@ -13,15 +14,20 @@ import (
 // an IPNS name.
 // The rewritten request points at the resolved name on the gateway handler.
 func IPNSHostnameOption() ServeOption {
+       fmt.Printf("Ohai IPNSHostnameOption\n")
        return func(n *core.IpfsNode, mux *http.ServeMux) (*http.ServeMux, error) {
                childMux := http.NewServeMux()
                mux.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
+                       fmt.Printf("Ohai HandleFunc\n")
                        ctx, cancel := context.WithCancel(n.Context())
                        defer cancel()

                        host := strings.SplitN(r.Host, ":", 2)[0]
                        if p, err := n.Namesys.Resolve(ctx, host); err == nil {
                                r.URL.Path = path.Join(p.String(), r.URL.Path)
+                               fmt.Printf("%s\n", r.URL.Path)
+                       } else {
+                               fmt.Printf("ERR: %s", err)
                        }
                        childMux.ServeHTTP(w, r)
                })
# ag "not a key"
path/path.go
82:     return "", errors.New("not a key")

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

No branches or pull requests

1 participant