Git Product home page Git Product logo

fossa's People

Contributors

alashkin avatar cpq avatar dhamp avatar doconn avatar elfring avatar grodansparadis avatar imax9000 avatar kaplan2539 avatar mattn avatar mkmik avatar rojer avatar xuchunyang avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

fossa's Issues

Avoid spurious updates to the timestamp when rebuilding docs

Currently every doc build will change the last updated footer text, even if nothing actually changed. This is confusing and also introduces needless merge conflicts in most of our branches.

diff --git a/docs/index.html b/docs/index.html
index 721aed2..d75e540 100644
--- a/docs/index.html
+++ b/docs/index.html
@@ -1337,7 +1337,7 @@ Destination is '\0'-terminated.</p>
 </div>
 <div id="footer">
 <div id="footer-text">
-Last updated 2014-11-14 16:28:47 CET
+Last updated 2014-11-14 16:30:12 CET
 </div>
 </div>
 </body>

Port fossa to Arduino Mega

Create a shim layer for Arduino that implements async socket IO.
Create a sketch that periodically reports some data to the remote server using fossa.
Organize that sketch as a tutorial on how to use fossa on arduino, add it to fossa/examples

Fix cpp-coveralls + codeship integration

cpp-coveralls doesn't know the actual branch name because the CI performs a detached head checkout and so every pull request updates the HEAD branch of coveralls.io and we have fluctuating coverage in the reports (and badge).

SSL* pointer is not freed.

We allocate it at net_skeleton.c:accept_conn():494.

But in net_skeleton.c:ns_destroy_conn() we don't call SSL_shutdown/SSL_free.

It could be something like:

if (conn->ssl != NULL) {
SSL_shutdown(conn->ssl);
SSL_free(conn->ssl);
conn->ssl = NULL;
}

-lpthread is missing

$ git pull https://github.com/cesanta/net_skeleton.git
$ cd net_skeleton
$ cd examples
$ make
clang echo.c ../net_skeleton.c -o echo -W -Wall -pedantic -O0 -g -I..
/tmp/net_skeleton-dc8c91.o: In function ns_start_thread': ../net_skeleton.c:(.text+0x329): undefined reference topthread_create'
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make: *** [echo] Error 1

ns_mgr_poll influence other select call each other

The function ns_mgr_poll is cost all the thread cpu,it will influence other select call each other. May add users private io,timer and signal poll to ns_mgr_poll is necessary.some private event register api is needed.

Switch to self-documented API

Decide on function comments format.
Move functions docs from .adoc back to source.
Generate API .adoc from the source automatically.

Unintuitive order of NS_CLOSE and NS_HTTP_REPLY

One way for HTTP-servers to send a reply is to send it without Content-Length header set and signal the end of the message by terminating the connection. In this case, http_handler() calls the user's callback with NS_CLOSE first, then, after determining that ns_parse_http returns a positive value, calls the users' callback with NS_HTTP_REPLY.

It's heavily inconvenient since I cannot free and zero user_data when processing NS_CLOSE, because I won't be able to correctly process NS_HTTP_REPLY later. However, since NS_CLOSE is not guaranteed to be followed by NS_HTTP_REPLY, I cannot defer freeing user_data until processing NS_HTTP_REPLY either, because then I would leak memory!

If this order is by design, I'd be pleased to learn how should one correctly free user_data.

Add async DNS support

Basically that means merging https://github.com/cesanta/sldr into fossa.
SLDR is client only. Basic server functionality is needed as well.
A, AAAA, MX requests are fine for now.
Examples needed: examples/dns_client and examples/dns_server

ns_rpc_create_reply doesn't retain the type of id.

For example if my RPC request was '{"id": "123", ..... }' the reponse would be '{"id": 123, ...}'
and if it was '{"id": 123 ...}' the reponse would be '{"id": 123, ...}'.
If it was '{"id": "hello", ...}' the response would be '{"id": hello, ...}'

According to the spec, id can be of any type.

NS_MAX_HTTP_REQUEST_SIZE messes up processing of HTTP requests/responses

The following code in http_handler is problematic:

req_len = ns_parse_http(io->buf, io->len, &hm);
if (req_len < 0 || io->len >= NS_MAX_HTTP_REQUEST_SIZE) {
  nc->flags |= NSF_CLOSE_IMMEDIATELY;
}

It means that if the recv_buffer contains full headers of an HTTP-message and is bigger than NS_MAX_HTTP_REQUEST_SIZE, then during the next poll an NS_HTTP_REQUEST or NS_HTTP_REPLY event will be sent, with http_message structure that contains a probably incomplete HTTP-message, and with message.len bigger than recv_iobuf.len.

First, it messes up processing of HTTP-responses, because they're usually bigger than 8K and don't arrive in one piece, so the user callback sees truncated message during processing of NS_HTTP_REPLY and/or NS_HTTP_REQUEST, but unless it compares to64(http_get_header("Content-Length")) with hm->body.len, it doesn't know that the message is truncated.

Second, with message.len bigger than recv_iobuf.len some code (say, that logs contents of HTTP-messages into a log-file "as is") may behave unpredictably. Well, they usually just crash. And while we're at it, without "Content-Length" header sent, message.len tend to be just (size_t)(~0) for non-GET messages (including HTTP-responses) which too causes troubles if one isn't careful enough.

Third, it may or may not manifest depending on the network speed: if it's fast enough, the whole HTTP-message will arrive between two polls, and everything will work fine. If not, HTTP-messages may get truncated.

Fourth, the fact that recv_iobuf is bigger than NS_MAX_HTTP_REQUEST_SIZE doesn't mean that the request is actually bigger than NS_MAX_HTTP_REQUEST_SIZE: HTTP/1.1 allows pipelining of requests, so the recv_iobuf may contain several HTTP-messages.

Add bluetooth support

Make net_skeleton accept BT/BLE endpoints.
Suggested address format: bluetooth://..., ble://...

warnings about usage of C++ style comments

cc unit_test.c -o unit_test -lpthread -W -Wall -pedantic -O0 -g -I.. -lssl
unit_test.c:1:1: warning: C++ style comments are not allowed in ISO C90 [enabled by default]
unit_test.c:1:1: warning: (this will be reported only once per input file) [enabled by default]
In file included from unit_test.c:13:0:
../net_skeleton.c:1:1: warning: C++ style comments are not allowed in ISO C90 [enabled by default]
../net_skeleton.c:1:1: warning: (this will be reported only once per input file) [enabled by default]
In file included from ../net_skeleton.c:17:0,
from unit_test.c:13:
../net_skeleton.h:1:1: warning: C++ style comments are not allowed in ISO C90 [enabled by default]
../net_skeleton.h:1:1: warning: (this will be reported only once per input file) [enabled by default]
clang nc.c ../net_skeleton.c -DNS_ENABLE_SSL -lssl -o nc -lpthread -W -Wall -pedantic -O0 -g -I..

Won't bind to ipv6 wildcard

I have an issue where net_skeleton won't bind to the ipv6 wildcard with a port string like "[::]:1234". The issues occurs on ARM-based arch linux. It can be fixed by changing the bind call in ns_open_listening_socket from:

bind(
    sock,
    &sa->sa,
    sa->sa.sa_family == AF_INET ? sizeof(sa->sin) : sizeof(sa->sa)
)

to

bind(
    sock,
    &sa->sa,
    sa->sa.sa_family == AF_INET ? sizeof(sa->sin) : sizeof(sa->sin6)
)

On Windows, errors on NSF_CONNECTING sockets never get detected

Here is how select() behaves for non-blocking sockets after connect() was called and the connection attempt has failed, on Windows and on (recent versions of) Linux:

On Windows, such sockets are reported in errorfds only.
On Linux, such sockets are reported in readfds and in writefds.
Both behaviours violate POSIX: sockets with pending errors are required to be reported in errorfds (which Linux doesn't do), and since read/write operations on disconnected socket don't block, such sockets are required to be reported in readfds and writefds as well (which Windows doesn't do).

The actual problem: ns_mgr_poll() passes NULL as errorfds to select(), and so it never detects failed attempts to establish outbound connections (on Windows). Coupled with the absense of any connection timeout functionality (although everything is there for it), it leads to some nasty surprises in programs built on top of Net Skeleton: for example, Mangoose in proxying mode may never reply anything to the request.

I don't have an immediate patch to resolve this, unfortunately. I can only advise to change the order of checking conn->flags and FD_ISSET inside the loop over sockets: test conn->flags to understand what fdsets are of interest, then call FD_ISSET to check whether the socket is ready to work, or not yet, or failed miserably.

ns_parse_address() reads from uninitialized variable when parsing an empty string

All calls to sscanf() will fail to write to the port variable if the str is "". However, the very last line checks whether port is less than 65'535.

Proposed fix:

--- a/modules/skeleton.c
+++ b/modules/skeleton.c
@@ -339,7 +339,7 @@ int ns_resolve(const char *host, char *buf, size_t n) {

 /* Address format: [PROTO://][IP_ADDRESS:]PORT[:CERT][:CA_CERT] */
 static int ns_parse_address(const char *str, union socket_address *sa, int *p) {
-  unsigned int a, b, c, d, port;
+  unsigned int a, b, c, d, port = 0;
   int len = 0;
   char host[200];
 #ifdef NS_ENABLE_IPV6

Retrieve DNS server address error in win32 platform

When testing example/http_client,
type command ./http_client http://www.microsoft.com/ got right response in Linux(Ubuntu 14.04) but nothing printed in Windows platform(Windows 7 x64).

With some efforts, I found function ns_get_ip_address_of_nameserver() try to retrieve item under registry HKLM\\SYSTEM\\ControlSet001\\Services\\Tcpip\\Parameters\\Interfaces\, and copy first item's NameServer field as the address of DNS server.
But when got too many interface items(as I shown below) and the NameServer field is an empty string, or the NameServer string contains more than one IP address(seperated by comma token), we cannot retrieve the right DNS server address we want.

dns_server_name

json library conflict

Fossa wanted to integrate my application.
Now I use a JSON library (libjson0-dev).
I get conflict with:

  • "json_object.h:92:14: error: previous definition here typedef enum json_type"
    and
    -"fossa.h:402:6: error: multiple definition of ‘enum json_type’"

any way to fix?
very good job.
congratulations

Error C4700 under Visual C++

With Visual C++ 2012, when compiled with either /Od(default in Debug mode) or /Ox, I got this:

fossa.c(575): error 4700: local variable 'sa' used without having been initialized.
fossa.c(582): error 4700: local variable 'sa' used without having been initialized.
fossa.c(2939): warning 4013: '_wopen' undefined; assuming extern returning int

ns_rpc_dispatch should accpet non-constant handler + method lists

As it is presently, ns_rpc_dispatch only accepts const char** for a list of method names.
Would it be possible to make it char ** ? This information is passed in for every RPC dispatch. It might be possible that methods get added and removed on the fly.

I'm writing a wrapper C++ class over net_skeleton's JSON-RPC. It has an register_handler method that takes in a method name and a handler and registers it on the fly. Such a thing doesn't seem possible with the current function signature of ns_rpc_dispatch.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.