codefrau / SqueakJS

A Squeak Smalltalk VM in Javascript
https://squeak.js.org
MIT License
365 stars 75 forks source link

Add functional name/address resolver to SocketPlugin #88

Closed ErikOnBike closed 4 years ago

ErikOnBike commented 4 years ago

With this functionality it is possible to either lookup the (IPv4) address of the given hostname or lookup the name of the given address.

For address lookup DNS over HTTP (DoH) is used. For name lookup the cached name (from the address lookup) is used. There are some API's for doing name lookups, but these are not standardised like DoH and/or require a payed subscription. Therefore chosen for simple solution assuming lookups are always done for addresses resolved earlier in the process. If an unknown address is provided, the dotted decimal name is answered (ie '104.24.23.6').

Quad9 (IP 9.9.9.9) is used as server for DoH because it seems to take privacy of users serious. Other servers can be found at https://en.wikipedia.org/wiki/Public_recursive_name_server

Example (tested on Cuis and Squeak):

| address name |
address := NetNameResolver addressForName: 'squeak.js.org'.
name := NetNameResolver nameForAddress: address timeout: 5.
{ address . name } "Array with: #[104 24 23 6] with: 'squeak.js.org'"
ErikOnBike commented 4 years ago

The Travis CI failure seems unrelated to the code change. The X virtual framebuffer (Xvfb) is unavailable.

ErikOnBike commented 4 years ago

This PR is now part of the modularised SqueakJS version. Closing this PR.