google.com.onion
www.goooooooooooooooooooooooooooooooooooooooooooooooooooooooooogle.com
connectivitycheck.gstatic.com
OUT_OF_BOUNDS
0: ByteArrayBase_.to_string <sdk>/core/collections.toit:1403:5
1: parts_ <sdk>/net/modules/dns.toit:356:16
2: decode_name <sdk>/net/modules/dns.toit:346:3
3: SimpleDnsServer.lookup.<block>.<block> ../src/pkg_dns_simple_server/src/dns_simple_server.toit:90:19
4: SmallInteger_.repeat <sdk>/core/numbers.toit:1194:3
5: SimpleDnsServer.lookup.<block> ../src/pkg_dns_simple_server/src/dns_simple_server.toit:89:18
6: catch.<block> <sdk>/core/exceptions.toit:124:10
7: catch <sdk>/core/exceptions.toit:122:1
8: catch <sdk>/core/exceptions.toit:73:10
9: SimpleDnsServer.lookup ../src/pkg_dns_simple_server/src/dns_simple_server.toit:34:18
10: run_dns ../src/pkg_dns_simple_server/examples/captive_portal.toit:308:23
11: run_portal.<lambda> ../src/pkg_dns_simple_server/examples/captive_portal.toit:146:13
catch --trace
SimpleDnsServer.lookup
DEBUG: client connected {peer: 192.168.4.2:53410}
DEBUG: incoming request {peer: 192.168.4.2:53410, path: /gen_204}
TEMPORARY_REDIRECTS ::= {
"generate_204": "/", // Used by Android captive portal detection.
"gen_204": "/", // Used by Android captive portal detection.
// Add more redirects in order to create an alias for a file.
}
hotspot-detect.html
hotspot-detect.html
run_dns network/net.Interface:
my_ip := network.address
socket := network.udp_open --port=53
hosts := SimpleDnsServer my_ip // Answer my IP to all queries.
hosts.remove_host "chat-e2ee-mini.facebook.com"
hosts.remove_host "mqtt-mini.facebook.com"
hosts.remove_host "www.goooooooooooooooooooooooooooooooooooooooooooooooooooooooooogle.com"
hosts.remove_host "google.com.onion"
hosts.remove_host "graph.facebook.com"
hosts.remove_host "chat-e2ee-mini.facebook.com"
while true:
datagram /udp.Datagram := socket.receive
response := hosts.lookup datagram.data
if response:
e := catch:
socket.send
udp.Datagram response datagram.address
if e:
//print "udp exception: $e"
Decode name:
#[0x00, 0x11, 0x01, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x06, 0x67, 0x6f, 0x6f]
^^^^
#[0x67, 0x6c, 0x65, 0x03, 0x63, 0x6f, 0x6d, 0x05, 0x6f, 0x6e, 0x69, 0x6f, 0x6e, 0x00, 0x00, 0x01]
#[0x00, 0x01]
Got google.com.onion
Decode name:
#[0x00, 0x11, 0x01, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x06, 0x67, 0x6f, 0x6f]
^^^^
#[0x67, 0x6c, 0x65, 0x03, 0x63, 0x6f, 0x6d, 0x05, 0x6f, 0x6e, 0x69, 0x6f, 0x6e, 0x00, 0x00, 0x01]
#[0x00, 0x01]
Got google.com.onion
if response_address == null:
return response.create_error_ dns.ERROR_NAME
print_
$ ping www.goooooooooooooooooooooooooooooooooooooooooooooooooooooooooogle.com
PING goooooooooooooooooooooooooooooooooooooooooooooooooooooooooogle.com (34.102.136.180) 56(84) bytes of data.
64 bytes from 180.136.102.34.bc.googleusercontent.com (34.102.136.180): icmp_seq=1 ttl=54 time=49.8 ms
Decode name:
----
Received a Toit system message. Executing the command below will
make it human readable:
----
#[0x07, 0x0e, 0x01, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0a, 0x61, 0x6c, 0x74]
***
EXCEPTION error.
OUT_OF_BOUNDS
0: ByteArrayBase_.to_string <sdk>/core/collections.toit:1403:5
1: parts_ <sdk>/net/modules/dns.toit:356:16
2: decode_name <sdk>/net/modules/dns.toit:346:3
3: SimpleDnsServer.lookup.<block>.<block> ../src/pkg_dns_simple_server/src/dns_simple_server.toit:105:19
4: SmallInteger_.repeat <sdk>/core/numbers.toit:1194:3
5: SimpleDnsServer.lookup.<block> ../src/pkg_dns_simple_server/src/dns_simple_server.toit:104:18
6: catch.<block> <sdk>/core/exceptions.toit:124:10
7: catch <sdk>/core/exceptions.toit:122:1
8: catch <sdk>/core/exceptions.toit:73:10
9: SimpleDnsServer.lookup ../src/pkg_dns_simple_server/src/dns_simple_server.toit:51:18
10: run_dns ../src/pkg_dns_simple_server/examples/captive_portal.toit:288:23
11: run_portal.<lambda> ../src/pkg_dns_simple_server/examples/captive_portal.toit:148:13
***
^^^^
#[0x33, 0x2d, 0x6d, 0x74, 0x61, 0x6c, 0x6b, 0x06, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x03, 0x63]
#[0x6f, 0x6d, 0x00, 0x00, 0x01, 0x00, 0x01]
Got alt3-mtalk.google.com
Decode name:
#[0x07, 0x0e, 0x01, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0a, 0x61, 0x6c, 0x74]
^^^^
#[0x33, 0x2d, 0x6d, 0x74, 0x61, 0x6c, 0x6b, 0x06, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x03, 0x63]
#[0x6f, 0x6d, 0x00, 0x00, 0x01, 0x00, 0x01]
Got alt3-mtalk.google.com
Decode name:
#[0x58, 0x16, 0x01, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x09, 0x6d, 0x71, 0x74]
^^^^
#[0x74, 0x2d, 0x6d, 0x69, 0x6e, 0x69, 0x08, 0x66, 0x61, 0x63, 0x65, 0x62, 0x6f, 0x6f, 0x6b, 0x03]
#[0x63, 0x6f, 0x6d, 0x00, 0x00, 0x01, 0x00, 0x01]
Got mqtt-mini.facebook.com
Decode name:
#[0x58, 0x16, 0x01, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x09, 0x6d, 0x71, 0x74]
^^^^
#[0x74, 0x2d, 0x6d, 0x69, 0x6e, 0x69, 0x08, 0x66, 0x61, 0x63, 0x65, 0x62, 0x6f, 0x6f, 0x6b, 0x03]
#[0x63, 0x6f, 0x6d, 0x00, 0x00, 0x01, 0x00, 0x01]
Got mqtt-mini.facebook.com
NO I DONT LIKE
decode_name
/hotspot-detect.html
**
EXCEPTION error.
Connection closed
0: tcp_write_ <sdk>/net/modules/tcp.toit:199:3
1: TcpSocket.write <sdk>/net/modules/tcp.toit:165:16
2: Writer.write <sdk>/writer.toit:39:23
3: ChunkedWriter.write_header_ <pkg:pkg-http>/chunked.toit:92:13
4: ChunkedWriter.write <pkg:pkg-http>/chunked.toit:72:5
5: ResponseWriter_.write <pkg:pkg-http>/server.toit:124:18
6: handle.<block> ../src/pkg_dns_simple_server/examples/captive_portal.toit:264:12
7: Map.get.<block> <sdk>/core/collections.toit:2699:33
8: HashedInsertionOrderedCollection_.find_body_ <sdk>/core/collections.toit:2176:3
9: HashedInsertionOrderedCollection_.find_ <sdk>/core/collections.toit:2155:12
10: Map.get <sdk>/core/collections.toit:2699:15
11: Map.get <sdk>/core/collections.toit:2679:12
12: handle ../src/pkg_dns_simple_server/examples/captive_portal.toit:261:26
13: run_portal.<lambda>.<lambda> ../src/pkg_dns_simple_server/examples/captive_portal.toit:159:13
14: Server.run_connection_.<block> <pkg:pkg-http>/server.toit:93:17
15: catch.<block> <sdk>/core/exceptions.toit:124:10
16: catch <sdk>/core/exceptions.toit:122:1
17: catch <sdk>/core/exceptions.toit:97:10
18: Server.run_connection_ <pkg:pkg-http>/server.toit:92:7
19: Server.listen.<lambda>.<block>.<block> <pkg:pkg-http>/server.toit:67:24
20: catch.<block> <sdk>/core/exceptions.toit:124:10
21: catch <sdk>/core/exceptions.toit:122:1
22: catch <sdk>/core/exceptions.toit:73:10
23: Server.listen.<lambda>.<block> <pkg:pkg-http>/server.toit:66:16
24: Server.listen.<lambda> <pkg:pkg-http>/server.toit:53:24
**
diff --git a/examples/captive_portal.toit b/examples/captive_portal.toit
index 418bab8..d8320b2 100644
--- a/examples/captive_portal.toit
+++ b/examples/captive_portal.toit
@@ -23,6 +23,17 @@ import .website.resources
CAPTIVE_PORTAL_SSID ::= "mywifi"
CAPTIVE_PORTAL_PASSWORD ::= "12345678"
+PORTAL_PROBES ::= [
+ "hotspot.localnet",
+ "connectivitycheck.gstatic.com",
+ "www.gstatic.com",
+ "www.apple.com",
+ "captive.apple.com",
+ "clients3.google.com",
+ "www.msftconnecttest.com",
+ "connectivitycheck.platform.hicloud.com",
+]
+
// On the device we use port 80 for the web server, but that is not
// available to non-privileged users on desktop systems, so we fall
// back on this port when testing on desktop Toit.
@@ -123,7 +134,10 @@ run_dns network/net.Interface:
socket := network.udp_open --port=53
- hosts := SimpleDnsServer my_ip // Answer my IP to all queries.
+ hosts := SimpleDnsServer // DNS server with no default answer.
+
+ PORTAL_PROBES.do:
+ hosts.add_host it my_ip // Answer my IP to the known probe domains.
while true:
datagram /udp.Datagram := socket.receive
PORTAL_PROBES
diff --git a/src/resources/wifi_esp32.cc b/src/resources/wifi_esp32.cc
index 11fd104b..b6e629f3 100644
--- a/src/resources/wifi_esp32.cc
+++ b/src/resources/wifi_esp32.cc
@@ -384,7 +384,14 @@ PRIMITIVE(init) {
// because they do not correctly check for malloc failure.
esp_netif_t* netif = null;
if (ap) {
+ esp_netif_ip_info_t two_hundred_network;
+ two_hundred_network.ip.addr = ESP_IP4TOADDR( 200, 200, 200, 1);
+ two_hundred_network.gw.addr = ESP_IP4TOADDR( 200, 200, 200, 1);
+ two_hundred_network.netmask.addr = ESP_IP4TOADDR( 255, 255, 255, 0);
+ esp_netif_inherent_config_t netif_config = ESP_NETIF_INHERENT_DEFAULT_WIFI_AP();
+ netif_config.ip_info = &two_hundred_network;
esp_netif_config_t netif_ap_config = ESP_NETIF_DEFAULT_WIFI_AP();
+ netif_ap_config.base = &netif_config;
netif = esp_netif_new(&netif_ap_config);
} else {
esp_netif_config_t netif_sta_config = ESP_NETIF_DEFAULT_WIFI_STA();
connectivitycheck.gstatic.com
#! /bin/bash
cd toit/
export IDF_PATH=$PWD/third_party/esp-idf
$IDF_PATH/install.sh
source $IDF_PATH/export.sh
make all
make esp32
// WINDOWS PC works on 10 Pro and 11
else if path == "/connecttest.txt": path = "index.html" // to fix windows pc captive problem
else if path == "/redirect": path = "index.html" // to fix windows pc captive problem
/canonical.html
/success.txt?ipv4
handle_http_request
handle_http_request request/http.Request writer/http.ResponseWriter access_points/List -> Map?:
query := url.QueryString.parse request.path
resource := query.resource
if resource == "/": resource = "index.html"
if resource == "/hotspot-detect.html": resource = "index.html" // Needed for iPhones.
if resource.starts_with "/": resource = resource[1..]
handle request/http.Request writer/http.ResponseWriter -> none:
path := request.path
if path == "/": path = "index.html"
else if path == "/hotspot-detect.html": path = "index.html"
else if path == "/connecttest.txt": path = "index.html"
else if path == "/redirect": path = "index.html"
+
+
QueryString
+
QueryString.parse
+
+
[wifi] DEBUG: connected
[wifi] INFO: network address statically assigned {ip: 200.200.200.1}
[wifi] INFO: dns server address not supplied by network; using fallback dns servers
ets Jul 29 2019 12:21:46
rst:0x1 (POWERON_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT)
configsip: 0, SPIWP:0xee
clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00
QueryString.parse
+