Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
sanjay900 committed Nov 1, 2016
2 parents 0f8c679 + c0af90e commit b40bda1
Show file tree
Hide file tree
Showing 511 changed files with 51,472 additions and 7,204 deletions.
2 changes: 1 addition & 1 deletion AdAway/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ android {
}
}

compileSdkVersion 23
compileSdkVersion 25
buildToolsVersion "24.0.3"

defaultConfig {
Expand Down
62 changes: 27 additions & 35 deletions AdAway/jni/blank_webserver/mongoose/README.md
Original file line number Diff line number Diff line change
@@ -1,50 +1,41 @@
# <img src="http://www.cesanta.com/hubfs/www.cesanta.com/Images/mongoose_library.png" width="64" height="64"> Mongoose - Embedded Web Server / Embedded Networking Library
# Mongoose - Embedded Web Server / Embedded Networking Library

![](https://img.shields.io/badge/license-GPL_2-green.svg "License")

Mongoose is ideal for embedded environments. It has been designed
for connecting devices and bringing them online. Mongoose
is on the market since 2004, used by vast number of open source and
commercial products - it even runs on space stations!
for connecting devices and bringing them online. On the market since 2004,
used by vast number of open source and
commercial products - it even runs on the International Space station!
Mongoose makes embedded network programming fast, robust, and easy.

Mongoose provides easy to use event-driven interface that allows to implement
network protocols or scalable network applications with little effort.
Mongoose helps developers to manage the complexity of network programming
and let them concentrate on the logic, saving time and money.
- [Download Mongoose Source Code here](https://www.cesanta.com)

If you're looking for a pre-compiled Windows or Mac binary,
- [Download pre-compiled Mongoose web server binary](https://www.cesanta.com/products/binary)

Alternatively,

- [Download Mongoose Source Code here](http://hubs.ly/H01bWvx0)
- [Check our latest releases] (https://github.com/cesanta/mongoose/releases)
- [Read User Guide and API reference](https://docs.cesanta.com/mongoose/dev)
- [Study mongoose example code](https://github.com/cesanta/mongoose/tree/master/examples)

If you are looking for a complete IoT platform with firmware and cloud compotent,
- [Check out Smart.js - a full stack IoT platform](https://github.com/cesanta/smart.js)
Looking for a complete IoT solution with firmware and cloud components?
Check out [Mongoose IoT Firmware and Cloud](https://mongoose-iot.com).

# Support
- [Support Forum - Ask your technical questions here] (http://forum.cesanta.com/index.php?p=/categories/smart-js)
- [Chat - Visit www.cesanta.com for our live chat] (http://www.cesanta.com)
- [Commercial one-to-one support - Available to all commercial license holders] (https://www.cesanta.com/services-support)
- [Study mongoose example code](https://github.com/cesanta/mongoose/tree/master/examples)
- [Read User Guide and API reference](https://docs.cesanta.com/mongoose)
- [Support Forum - ask your technical questions here] (http://forum.cesanta.com/index.php?p=/categories/mongoose)
- [Chat - visit www.cesanta.com for our live chat] (http://www.cesanta.com)
- [Commercial licensing and support available] (https://www.cesanta.com/services-support)
- [Check our latest releases] (https://github.com/cesanta/mongoose/releases)

# Features

* Cross-platform: works on Linux/UNIX, MacOS, QNX, eCos, Windows, Android,
iPhone, FreeRTOS (TI CC3200, ESP8266), etc
* Single-threaded, asynchronous, non-blocking core with simple event-based API
* Native support for [PicoTCP embedded TCP/IP stack](http://www.picotcp.com),
[LWIP embedded TCP/IP stack](https://en.wikipedia.org/wiki/LwIP)
* Supported hardware platforms: TI CC3200, TI MSP432, NRF52, STM32, PIC32, ESP8266, ESP32 and more
* Builtin protocols:
- plain TCP, plain UDP, SSL/TLS (over TCP, one-way or two-way)
- HTTP client, HTTP server
- WebSocket client, WebSocket server
- JSON-RPC client, JSON-RPC server
- MQTT client, MQTT broker
- CoAP client, CoAP server
- DNS client, DNS server, async DNS resolver
* Single-threaded, asynchronous, non-blocking core with simple event-based API
* Native support for [PicoTCP embedded TCP/IP stack](http://www.picotcp.com),
[LWIP embedded TCP/IP stack](https://en.wikipedia.org/wiki/LwIP)
* Tiny static and run-time footprint
* Source code is both ISO C and ISO C++ compliant
* Very easy to integrate: just copy
Expand All @@ -54,13 +45,9 @@ If you are looking for a complete IoT platform with firmware and cloud compotent

# Licensing

Mongoose is released under commercial and [GNU GPL v.2](http://www.gnu.org/licenses/old-licenses/gpl-2.0.html) open source licenses.

Commercial Projects:
Once your project becomes commercialised GPLv2 licensing dictates that you need to either open your source fully or purchase a commercial license. Cesanta offer full, royalty-free commercial licenses without any GPL restrictions. If your needs require a custom license, we’d be happy to work on a solution with you. [Contact us for pricing.] (https://www.cesanta.com/contact)
Mongoose is released under Commercial and [GNU GPL v.2](http://www.gnu.org/licenses/old-licenses/gpl-2.0.html) open source licenses.

Prototyping:
While your project is still in prototyping stage and not for sale, you can use Mongoose’s open source code without license restrictions.
Commercial Projects: [Contact us for commercial license.] (https://www.cesanta.com/contact)

# Dashboard Example

Expand All @@ -70,11 +57,16 @@ the functionality:

![](http://www.cesanta.com/hubfs/www.cesanta.com/diagrams/dash_mongoose_diagram.png)

[Developing a new product? Contact us today to discuss how Mongoose can help
[Developing a new product? Contact us today to discuss how Mongoose can help.
](https://www.cesanta.com/contact)

# Contributions

People who have agreed to the [Cesanta CLA] (https://docs.cesanta.com/contributors_la.shtml) can make contributions. Note that the CLA isn't a copyright assigment but rather a copyright license. You retain the copyright on your contributions.
To submit contributions, sign
[Cesanta CLA](https://docs.cesanta.com/contributors_la.shtml)
and send GitHub pull request. You retain the copyright on your contributions.

# Looking for a pre-compiled Mongoose web server Windows or Mac binary?
- [Download pre-compiled Mongoose web server binary.](https://www.cesanta.com/products/binary)

[![Analytics](https://ga-beacon.appspot.com/UA-42732794-5/project-page)](https://github.com/cesanta/mongoose)
12 changes: 11 additions & 1 deletion AdAway/jni/blank_webserver/mongoose/docs/c-api/coap.h/intro.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,17 @@
---
title: "CoAP"
title: "CoAP API reference"
symbol_kind: "intro"
decl_name: "coap.h"
items:
- { name: mg_coap_add_option.md }
- { name: mg_coap_compose.md }
- { name: mg_coap_free_options.md }
- { name: mg_coap_parse.md }
- { name: mg_coap_send_ack.md }
- { name: mg_coap_send_message.md }
- { name: mg_set_protocol_coap.md }
- { name: struct_mg_coap_message.md }
- { name: struct_mg_coap_option.md }
---

CoAP message format:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@ signature: |
size_t len);
---

Add new option to mg_coap_message structure.
Adds a new option to mg_coap_message structure.
Returns pointer to the newly created option.

Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@ signature: |
void mg_coap_free_options(struct mg_coap_message *cm);
---

Free the memory allocated for options,
if cm paramater doesn't contain any option does nothing.
Frees the memory allocated for options.
If the cm paramater doesn't contain any option it does nothing.

Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@ signature: |
uint32_t mg_coap_parse(struct mbuf *io, struct mg_coap_message *cm);
---

Parse COAP message and fills mg_coap_message and returns cm->flags.
Parses CoAP message and fills mg_coap_message and returns cm->flags.
This is a helper function.

NOTE: usually CoAP work over UDP, so lack of data means format error,
but in theory it is possible to use CoAP over TCP (according to RFC)
NOTE: usually CoAP works over UDP, so lack of data means format error.
But, in theory, it is possible to use CoAP over TCP (according to RFC)

The caller have to check results and treat COAP_NOT_ENOUGH_DATA according to
The caller has to check results and treat COAP_NOT_ENOUGH_DATA according to
underlying protocol:

- in case of UDP COAP_NOT_ENOUGH_DATA means COAP_FORMAT_ERROR,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ signature: |
uint32_t mg_coap_send_ack(struct mg_connection *nc, uint16_t msg_id);
---

Compose CoAP acknowledgement from `mg_coap_message`
and send it into `nc` connection.
Composes CoAP acknowledgement from `mg_coap_message`
and sends it into `nc` connection.
Return value: see `mg_coap_send_message()`

Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ signature: |
struct mg_coap_message *cm);
---

Compose CoAP message from `mg_coap_message`
and send it into `nc` connection.
Return 0 on success. On error, it is a bitmask:
Composes a CoAP message from `mg_coap_message`
and sends it into `nc` connection.
Returns 0 on success. On error, it is a bitmask:

- `#define MG_COAP_ERROR 0x10000`
- `#define MG_COAP_FORMAT_ERROR (MG_COAP_ERROR | 0x20000)`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@ signature: |
int mg_set_protocol_coap(struct mg_connection *nc);
---

Set CoAP protocol handler - trigger CoAP specific events
Sets CoAP protocol handler - triggers CoAP specific events.

14 changes: 13 additions & 1 deletion AdAway/jni/blank_webserver/mongoose/docs/c-api/dns.h/intro.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,19 @@
---
title: "DNS"
title: "DNS API reference"
symbol_kind: "intro"
decl_name: "dns.h"
items:
- { name: mg_dns_copy_questions.md }
- { name: mg_dns_encode_name.md }
- { name: mg_dns_encode_record.md }
- { name: mg_dns_insert_header.md }
- { name: mg_dns_parse_record_data.md }
- { name: mg_dns_uncompress_name.md }
- { name: mg_parse_dns.md }
- { name: mg_send_dns_query.md }
- { name: mg_set_protocol_dns.md }
- { name: struct_mg_dns_message.md }
- { name: struct_mg_dns_resource_record.md }
---


Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
---
title: "mg_dns_copy_questions()"
decl_name: "mg_dns_copy_questions"
symbol_kind: "func"
signature: |
int mg_dns_copy_questions(struct mbuf *io, struct mg_dns_message *msg);
---

Appends already encoded questions from an existing message.

This is useful when generating a DNS reply message which includes
all question records.

Returns the number of appended bytes.

Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
---
title: "mg_dns_encode_name()"
decl_name: "mg_dns_encode_name"
symbol_kind: "func"
signature: |
int mg_dns_encode_name(struct mbuf *io, const char *name, size_t len);
---

Encodes a DNS name.

Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,18 @@ signature: |
size_t rlen);
---

Encode and append a DNS resource record to an IO buffer.
Encodes and appends a DNS resource record to an IO buffer.

The record metadata is taken from the `rr` parameter, while the name and data
are taken from the parameters, encoded in the appropriate format depending on
record type, and stored in the IO buffer. The encoded values might contain
record type and stored in the IO buffer. The encoded values might contain
offsets within the IO buffer. It's thus important that the IO buffer doesn't
get trimmed while a sequence of records are encoded while preparing a DNS
*reply.
reply.

This function doesn't update the `name` and `rdata` pointers in the `rr`
*struct
because they might be invalidated as soon as the IO buffer grows again.
struct because they might be invalidated as soon as the IO buffer grows
again.

Return the number of bytes appened or -1 in case of error.
Returns the number of bytes appened or -1 in case of error.

Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ signature: |
struct mg_dns_message *msg);
---

Insert a DNS header to an IO buffer.
Inserts a DNS header to an IO buffer.

Return number of bytes inserted.
Returns the number of bytes inserted.

Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ signature: |
size_t data_len);
---

Parse the record data from a DNS resource record.
Parses the record data from a DNS resource record.

- A: struct in_addr *ina
- AAAA: struct in6_addr *ina
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,15 @@ signature: |
char *dst, int dst_len);
---

Uncompress a DNS compressed name.
Uncompresses a DNS compressed name.

The containing dns message is required because the compressed encoding
The containing DNS message is required because of the compressed encoding
and reference suffixes present elsewhere in the packet.

If name is less than `dst_len` characters long, the remainder
of `dst` is terminated with `\0' characters. Otherwise, `dst` is not
*terminated.
If the name is less than `dst_len` characters long, the remainder
of `dst` is terminated with `\0` characters. Otherwise, `dst` is not
terminated.

If `dst_len` is 0 `dst` can be NULL.
Return the uncompressed name length.
Returns the uncompressed name length.

Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,5 @@ signature: |
int query_type);
---

Send a DNS query to the remote end.
Sends a DNS query to the remote end.

Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@ signature: |
void mg_set_protocol_dns(struct mg_connection *nc);
---

Attach built-in DNS event handler to the given listening connection.
Attaches a built-in DNS event handler to the given listening connection.

DNS event handler parses incoming UDP packets, treating them as DNS
requests. If incoming packet gets successfully parsed by the DNS event
handler, a user event handler will receive `MG_DNS_REQUEST` event, with
The DNS event handler parses the incoming UDP packets, treating them as DNS
requests. If an incoming packet gets successfully parsed by the DNS event
handler, a user event handler will receive an `MG_DNS_REQUEST` event, with
`ev_data` pointing to the parsed `struct mg_dns_message`.

See
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
---
title: "DNS server API reference"
symbol_kind: "intro"
decl_name: "dns_server.h"
items:
- { name: mg_dns_create_reply.md }
- { name: mg_dns_reply_record.md }
- { name: mg_dns_send_reply.md }
---

Disabled by default; enable with `-DMG_ENABLE_DNS_SERVER`.

Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
---
title: "mg_dns_create_reply()"
decl_name: "mg_dns_create_reply"
symbol_kind: "func"
signature: |
struct mg_dns_reply mg_dns_create_reply(struct mbuf *io,
struct mg_dns_message *msg);
---

Creates a DNS reply.

The reply will be based on an existing query message `msg`.
The query body will be appended to the output buffer.
"reply + recursion allowed" will be added to the message flags and the
message's num_answers will be set to 0.

Answer records can be appended with `mg_dns_send_reply` or by lower
level function defined in the DNS API.

In order to send a reply use `mg_dns_send_reply`.
It's possible to use a connection's send buffer as reply buffer,
and it will work for both UDP and TCP connections.

Example:

```c
reply = mg_dns_create_reply(&nc->send_mbuf, msg);
for (i = 0; i < msg->num_questions; i++) {
rr = &msg->questions[i];
if (rr->rtype == MG_DNS_A_RECORD) {
mg_dns_reply_record(&reply, rr, 3600, &dummy_ip_addr, 4);
}
}
mg_dns_send_reply(nc, &reply);
```
Loading

0 comments on commit b40bda1

Please sign in to comment.