【问题标题】:how to know from which node the file / block was retrieved when querying https://ipfs.io/ipfs/查询 https://ipfs.io/ipfs/ 时如何知道从哪个节点检索文件/块
【发布时间】:2019-05-19 13:23:08
【问题描述】:

当使用哈希从公共网关查询文件时,网关会查询对等节点并将内容作为 http 响应返回。

例如,

问题是:

  • 有什么方法,比如响应头或其他方法,可以知道网关从哪个对等/远程机器检索了内容? (在上面的例子中,我的机器的 peer-id

【问题讨论】:

    标签: ipfs


    【解决方案1】:

    我认为答案是(截至v0.4.20)。 IPFS 在检索块时经历的过程是:

    1. 同时执行以下操作:
      1. 通知所有当前对等方您想要阻止(例如QmXjFR1...
      2. 让网络找到你想要的区块的提供者(例如QmXjFR1...
    2. 如果对等方拥有该块,它会将其发送过来,而您将忽略找到的任何提供者。
    3. 如果没有对等点拥有该块并且找到了提供者,则将提供者添加为对等点并通知您想要该块(例如QmXjFR1...),此时对等点开始发送块。

    理论上,如果你运行 IPFS 节点,你可能会做一些事情来确定一个块来自哪个对等节点。但网关不通过其接口 AFAIK 提供该信息。

    无论如何,我在响应标头中看不到任何内容。以下是点击网关 API 的示例:

    λ curl -v https://gateway.ipfs.io/api/v0/cat/QmT78zSuBmuS4z925WZfrqQ1qHaJ56DQaTfyMUF7F8ff5o
    *   Trying 2602:fea2:2::1...
    * TCP_NODELAY set
    * Connected to gateway.ipfs.io (2602:fea2:2::1) port 443 (#0)
    * ALPN, offering h2
    * ALPN, offering http/1.1
    * Cipher selection: ALL:!EXPORT:!EXPORT40:!EXPORT56:!aNULL:!LOW:!RC4:@STRENGTH
    * successfully set certificate verify locations:
    *   CAfile: /etc/ssl/cert.pem
      CApath: none
    * TLSv1.2 (OUT), TLS handshake, Client hello (1):
    * TLSv1.2 (IN), TLS handshake, Server hello (2):
    * TLSv1.2 (IN), TLS handshake, Certificate (11):
    * TLSv1.2 (IN), TLS handshake, Server key exchange (12):
    * TLSv1.2 (IN), TLS handshake, Server finished (14):
    * TLSv1.2 (OUT), TLS handshake, Client key exchange (16):
    * TLSv1.2 (OUT), TLS change cipher, Client hello (1):
    * TLSv1.2 (OUT), TLS handshake, Finished (20):
    * TLSv1.2 (IN), TLS change cipher, Client hello (1):
    * TLSv1.2 (IN), TLS handshake, Finished (20):
    * SSL connection using TLSv1.2 / ECDHE-RSA-AES256-GCM-SHA384
    * ALPN, server accepted to use h2
    * Server certificate:
    *  subject: CN=ipfs.io
    *  start date: May  7 21:37:01 2019 GMT
    *  expire date: Aug  5 21:37:01 2019 GMT
    *  subjectAltName: host "gateway.ipfs.io" matched cert's "*.ipfs.io"
    *  issuer: C=US; O=Let's Encrypt; CN=Let's Encrypt Authority X3
    *  SSL certificate verify ok.
    * Using HTTP2, server supports multi-use
    * Connection state changed (HTTP/2 confirmed)
    * Copying HTTP/2 data in stream buffer to connection buffer after upgrade: len=0
    * Using Stream ID: 1 (easy handle 0x7ff002806600)
    > GET /api/v0/cat/QmT78zSuBmuS4z925WZfrqQ1qHaJ56DQaTfyMUF7F8ff5o HTTP/2
    > Host: gateway.ipfs.io
    > User-Agent: curl/7.54.0
    > Accept: */*
    >
    * Connection state changed (MAX_CONCURRENT_STREAMS updated)!
    < HTTP/2 200
    < server: nginx
    < date: Wed, 22 May 2019 04:32:43 GMT
    < content-type: text/plain
    < vary: Accept-Encoding
    < trailer: X-Stream-Error
    < vary: Origin
    < x-content-length: 12
    < x-stream-output: 1
    < access-control-allow-origin: *
    < access-control-allow-methods: GET, POST, OPTIONS
    < access-control-allow-headers: X-Requested-With, Range, Content-Range, X-Chunked-Output, X-Stream-Output
    < access-control-expose-headers: Content-Range, X-Chunked-Output, X-Stream-Output
    < x-ipfs-pop: gateway-bank2-sjc1
    < strict-transport-security: max-age=31536000; includeSubDomains; preload
    <
    hello world
    * Connection #0 to host gateway.ipfs.io left intact
    

    【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-03-31
    • 1970-01-01
    • 1970-01-01
    • 2021-07-05
    • 1970-01-01
    • 2017-10-06
    相关资源
    最近更新 更多