diff options
author | Marvin Borner | 2020-11-21 13:57:54 +0100 |
---|---|---|
committer | Marvin Borner | 2020-11-21 13:57:54 +0100 |
commit | e8aa2eb5787b5074b5b2867cb89653387f7e8d67 (patch) | |
tree | a7426f8fcc8d74813ca71275290acae74d7c10e0 /apps | |
parent | 5c0ab661d3af07186c1fb1c8a8b22d3a894b1be1 (diff) |
Added browser IP address support
Diffstat (limited to 'apps')
-rw-r--r-- | apps/browser.c | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/apps/browser.c b/apps/browser.c index d03d963..b434c7c 100644 --- a/apps/browser.c +++ b/apps/browser.c @@ -70,13 +70,18 @@ void on_submit(void *event, struct element *box) } char *query = http_query_get(url, path ? path : "/"); - char *dns[2]; - dns_split(url, dns); + u32 ip = 0; + if (!ip_pton(url, &ip)) { + char *dns[2]; + dns_split(url, dns); + ip = dns_request(dns[0], dns[1]); + } + struct element_text_box *l = output->data; struct element_label *c = code_label->data; struct socket *socket = net_open(S_TCP); - if (socket && net_connect(socket, dns_request(dns[0], dns[1]), 80)) { + if (socket && net_connect(socket, ip, 80)) { net_send(socket, query, strlen(query)); char buf[4096] = { 0 }; net_receive(socket, buf, 4096); @@ -86,6 +91,7 @@ void on_submit(void *event, struct element *box) } else { l->text = strdup("Can't connect to server."); c->text = strdup("000"); + c->color_fg = COLOR_RED; } gui_sync(root, output); gui_sync(root, code_label); |