ton-blockchain / ton

Main TON monorepo
Other
2.99k stars 920 forks source link

TON DNS - Resolve name and nslookup utility #676

Open air3ijai opened 1 year ago

air3ijai commented 1 year ago

How we can resolve TON DNS name in a simple way?

  1. TON DNS & Domains
  2. What is TON DNS?
  3. TEPs/text/0081-dns-standard.md

Questions

  1. Can we do it somehow via TON Explorer and which one?
  2. Can we do it somehow via CLI app?

Thanks!

air3ijai commented 1 year ago

Now, we are trying to follow the guide Accessing TON Sites, it does not work as it was already mentioned in the Access TON Site on TON Storage via TON Proxy #677.

In the guide, you propose to access the site just-for-test.ton using two addresses via TON Proxy

  1. http://just-for-test.ton
  2. http://utoljjye6y4ixazesjofidlkrhyiakiwrmes3m5hthlc6ie2h72gllt.adnl

How we can get ADNL address from the TON DNS one?

justdmitry commented 1 year ago

How we can get ADNL address from the TON DNS one?

ADNL address is stored in "site" record in DNS NFT contract data, see https://github.com/ton-blockchain/TEPs/blob/master/text/0081-dns-standard.md#dns-records

Once you spin-up some server to host your site - you should put adnl address of this server to 'site' record of your domain via dns.ton.org (or programmatically). And proxy will read this record and request specified server for your site files.

air3ijai commented 1 year ago

ADNL address is stored in "site" record in DNS NFT contract data, see https://github.com/ton-blockchain/TEPs/blob/master/text/0081-dns-standard.md#dns-records

Sounds clear, but how we can do it via Explorer?

For example, just-for-test.ton is owned by the EQCD39VS5jcptHL8vMjEXrzGaRcCVYto7HUn4bpAOg8xqB2N address.

  1. How can we find address of the resolver?
  2. How can we call resolver to get the value stored in the site record? Is there any examples how can we do that using curl or maybe there is a native CLI app for that?

Once you spin-up some server to host your site - you should put adnl address of this server to 'site' record of your domain via dns.ton.org (or programmatically).

I'm discovering a way to do it via TON Storage, rather than TON Proxy. It is much easier to run 10 TON Storage nodes which will download and redistribute specific BagID, than to run TON Proxy and take care about distributing same private key to all of them.

And proxy will read this record and request specified server for your site files.

It means that proxy can resolve the address?

justdmitry commented 1 year ago

Sounds clear, but how we can do it via Explorer?

I don't know if any explorer can show you this (this info is public, but no one can list all stored DNS "records" AFAIK). To update - only domain owner can do it via dns.ton.org or by sending special message to dns nft.


For example, just-for-test.ton is owned by the EQCD39VS5jcptHL8vMjEXrzGaRcCVYto7HUn4bpAOg8xqB2N address.

Do not be confused with "NFT owner". For example "foundation.ton" domain (I don't want to spend time repeating for just-for-test one, sorry) has this addresses:

So "owner" opened dns.ton.org and put "assigned" address in "wallet" record. It's like in real life, say, Everscale devs purchase "the-best-crypto.org" domain and make it redirect to "ton.org".

For now explorers (e.g. tonscan.org) will redirect you to "assigned" wallet EQCD...qB2N when you search for "foundation.ton", not to NFT one. I have created https://github.com/catchain/tonscan/issues/63 issue for them to show both.

I don't know if other explorer can show you more info, instead I used this C# code.


I'm discovering a way to do it via TON Storage

To server side from TON Storage, you need to put storage bag-id into "site" record of DNS NFT Item (instead of server ADNL) on dns.ton.org. The proxy is responsible for connecting to storage bag instead of adnl server.

justdmitry commented 1 year ago

How we can resolve TON DNS name in a simple way?

I created Telegram bot https://t.me/TonDomainInfoBot that shows detailed info from DNS-enabled smartcontracts. It currently supports .ton domains, .t.me usernames and +888 anonymous numbers.

air3ijai commented 1 year ago

Thank you for implementation 💜

And let's check how it works

Information for domain just-for-test.ton:

{
"address": "EQCaoY-mwc8LShGcAgeVsq03giBUsak-9h2OuJ9ctH7QZG3y",
"isDeployed": true,
"index": "sD1oUJVNRRUleevcrILAtW3rvgTSDWBwXAXIR2rVsKQ=",
"collectionAddress": "EQC3dNlesgVD8YbAazcauIrXBPfiVhMMr5YYk2in0Mtsz0Bz",
"domain": "just-for-test",
"ownerAddress": "EQCdqXGvONLwOr3zCNX5FjapflorB6ZsOdcdfLrjsDLt3Fy9",
"auctionInfo": null,
"lastFillUpTime": "2022-12-29T20:11:12+00:00",
"entries": {
  "wallet": "EQCD39VS5jcptHL8vMjEXrzGaRcCVYto7HUn4bpAOg8xqB2N",
  "siteToAdnl": null,
  "siteToStorage": "56A168B40A04E646DB7717B9E2CDAC79F904E5D0F7CDB2419FE8F8F7160C6FE7",
  "storage": null,
  "dnsNextResolver": null
}
}

Information for domain just-dmitry.ton:

{
"address": "EQCzXYXCzjEuCk1MqQcy7Qzs1brmshaFzNunV55QxJhF8hfY",
"isDeployed": true,
"index": "aJ/xjzHX02XcfBqE86QQsz3Xsl1ojYvsFbRwOBCa0KU=",
"collectionAddress": "EQC3dNlesgVD8YbAazcauIrXBPfiVhMMr5YYk2in0Mtsz0Bz",
"domain": "just-dmitry",
"ownerAddress": "EQDP_JFi4IucdPmEHJBSjEoSHlbC57G_8HLJAgqe05a-sGZ8",
"auctionInfo": null,
"lastFillUpTime": "2023-06-05T09:37:31+00:00",
"entries": {
  "wallet": "EQDP_JFi4IucdPmEHJBSjEoSHlbC57G_8HLJAgqe05a-sGZ8",
  "siteToAdnl": null,
  "siteToStorage": "9686AAB427C3337928A33E3EFDEA0C3A9AEFBC0922447B61402CDE389F955885",
  "storage": null,
  "dnsNextResolver": null
}
}

As we see in the comment, tonutils-proxy shows same result for just-dmitry.ton

2023/05/22 12:12:03 SEARCHING FOR BAG ID 9686aab427c3337928a33e3efdea0c3a9aefbc0922447b61402cde389f955885