49 Commits

Author SHA1 Message Date
1ae3523fe2 Add a pkg-config file to the project.
I ended up having to edit CMakeLists.txt a bit to get it to work out.
So I modified the versioning in version.h to utilize the new variable I made.
No functionality is changed, just worked on the build system.
2021-06-24 16:09:43 -07:00
Fred Nicolson
5b2b92835e
Add support for chunked HTTP response parsing 2019-11-25 16:29:06 +00:00
Fred Nicolson
134940138a
Update CMakeLists.txt 2019-05-17 13:06:39 +01:00
Fred Nicolson
52ff3c6e27
Don't enable SSL by default 2019-05-03 23:25:53 +01:00
Fred Nicolson
32767786af
Moving enums to enum classes 2019-05-01 17:06:09 +01:00
Fred Nicolson
7343529302 Add support for extracting std::vector<bool> from packets 2019-01-17 11:51:18 +00:00
Fred Nicolson
cb532d41b2 Improvements to error reporting 2019-01-14 13:33:08 +00:00
Fred Nicolson
f26225946c Fix cmake 2018-10-01 15:40:55 +01:00
Fred Nicolson
3f1deb427e
Update CMakeLists.txt 2018-07-12 12:41:34 +01:00
Fred Nicolson
248e0a8a2a Tweak build file to remove output postfixes, and specify optimisation level 2018-07-12 12:32:49 +01:00
Fred Nicolson
5a790e4caa Added version file. Moved things into correct namespace.
Added version file for getting library info.

Some stuff, like Base64/Sha1 wasn't in the fr namespace. Has been moved into it.
2018-07-12 12:10:55 +01:00
Fred Nicolson
27d02ca055 fr::Packet optimisations & marking Sendable::send() as const
Replaced instances of resize&memcpy with append, which gives a noticeable performance boost.

fr::Packet::operator<<(const char *str) no longer converts str into an std::string before adding it, removing an unneeded copy.

fr::Packet::clear no longer calls erase, should result in more of the internal buffer remaining allocated.

Framing for std::vector's has been changed from a uint64_t to a uint32_t (breaking change for packet framing!)
2018-03-27 12:03:55 +01:00
Unknown
fa843b57c8 Added experimental WebSocket support.
Added Sha1 hash, and Base64 encode implementations which are optionally compiled if websock support is enabled, to assist in the WebSock handshake.

Added WebSocket to manage the WebSock protocol during connections.

Added WebFrame to allow for sending/receiving data through the WebSock protocol easily.
2018-03-01 23:03:05 +00:00
Unknown
0840c07e24 Improving build system
Instead of #ifdefing files out, they are no longer included by CMake instead.
2018-02-24 21:14:43 +00:00
Fred Nicolson
bb71a5fdf8 Disabled SSL by default
(CI doesn't support it at the moment)
2018-01-10 17:12:21 +00:00
Fred Nicolson
30354f15bc Added support for connect timeouts.
Both fr::TcpSocket and fr::SSLSocket can have timeouts specified when connecting. This works by putting the socket into non-blocking mode, making a connect, and then selecting on the socket for the requested timeout. If the select times out then we've failed to connect, if it didn't time out then we've connected.
2018-01-10 17:08:16 +00:00
Unknown
2215d068af Added the ability to specify listen queue depth through CMake
Rather than defaulting to 10
2017-12-24 12:05:16 +00:00
Fred Nicolson
b574800a0a Fixed compile warnings and a memory leak
Fixed -fPIC warnings and unused function warnings on GCC. 

Fixed fr::TcpSocket not calling freeaddrinfo() on failure to connect, causing a small leak.
2017-12-01 10:59:00 +00:00
Fred Nicolson
abb3655739 Bug fixes and socket improvements
Added the ability to disable certificate verification for SSL sockets which is useful for testing.

Added the ability to specify maximum HTTP request header/body sizes in the CMake build config to prevent a malicious client from causing OOM errors.

Fixed a bug in HttpResponse and HttpRequest parse causing it to abort if the request is invalid in some cases.
2017-09-25 12:29:52 +01:00
Fred Nicolson
f2cebd0847 Work on tests. Bug fixes and tweaks.
Started work on tests for fr::HttpRequest.

Fixed the final POST data variable containing header data it shouldn't (\r\n\r\n).

Fixed fr::Http::header_exists, and family, not converting things to lowercase first.
2017-07-19 17:30:43 +01:00
Fred Nicolson
e748fde121 API changes, and lots of fixes.
fr::HttpSocket has been removed.

fr::Sendable has been added. Classes can inherit this if they want to be sendable through sockets. Both fr::Http (which is inherited by fr::HttpRequest and fr::HttpResponse), and fr::Packet inherit this, to allow them to be sent through fr::Socket::send()/fr::Socket::receive().

Fixed broken fr::SocketSelector and fr::SocketReactor, as they no longer accepted fr::Listener's due to fr::Listener no longer inheriting fr::Socket.
2017-07-18 17:34:49 +01:00
Fred Nicolson
71874837a0 Added 'WebSocket'.
This is just an abstract class which is inherited by fr::HttpSocket<T>, to allow different web socket types to be stored in a generic container.
2017-06-02 16:38:06 +01:00
Unknown
eb136c71f9 Fixed builds with shared libraries enabled failing 2017-06-01 10:46:38 +01:00
Unknown
0778f30d10 Prevented MSVC's inbuild network conversion functions being used
These functions did not play well with the rest of the code, causing float conversion to produce an incorrect value.
2017-05-31 17:02:40 +01:00
Fred Nicolson
bbcf185202 Improved build system
Examples and tests now build on Windows
2017-05-31 16:23:35 +01:00
Fred Nicolson
df2425a94d Added fr::Packet tests and Travis CI file. 2017-05-30 17:07:41 +01:00
Unknown
a6a652e72b Fixed CMake build issues
Tests and examples however, still do not work on Windows and so are disabled by default for now.
2017-05-30 10:51:42 +01:00
Unknown
6c0762bbf2 Integrated googletest into the project
The plan is to add unit tests, to completely test library functionality, alongside continuous integration on GitHub.
2017-05-29 22:55:17 +01:00
Unknown
c4fea83a2c Added support for examples to the build system. Cleaned up examples.
Examples can now be automatically built with the project, if enabled. And I've cleaned up MiaoDX's examples to be more compliant with frnetlib's coding style.
2017-05-29 18:57:39 +01:00
Fred Nicolson
ca95bb326e Fixed CMake error
Accidentally set CXX flags twice
2017-05-23 17:04:06 +01:00
Fred Nicolson
40f8ccb067 Added URL parsing class
Allows the parsing of full URLs into easy chunks. Added as a helper class for users of the library dealing with URLs, and to potentially replace some of the HTTP parsing code in the future.
2017-05-23 16:52:55 +01:00
Fred Nicolson
e15afb3d87 Cleaned up Listener code
Now inherits a 'Listener' class, instead of Socket.
2017-03-31 12:15:13 +01:00
Cloaked9000
5c021761a8 Merged branch master into master 2017-02-02 11:51:43 +00:00
Cloaked9000
5c94b3f6df Added 'fr::Packetable' to allow custom objects to be packed into packets
Can be used by inheriting the 'pack' and 'unpack' members of fr::Packetable. The 'pack' function should add your class members to the packet, and the 'unpack' function should take them back out.
2017-02-02 11:51:31 +00:00
Cloaked9000
fcef4e7164 Update CMakeLists.txt 2017-01-30 11:43:41 +00:00
Cloaked9000
70779fbe9c Added SocketReactor & fixes
Sockets will immediately return fr::Socket::Status::Disconnected if an attempt to send/receive data is made whilst the connection is closed.

Added SocketReactor, which is effectively a little wrapper around fr::SocketSelector, but can automatically call a callback for a socket when data is received on it.
2016-12-20 11:33:31 +00:00
Cloaked9000
2de9540819 Added windows support. Updated build system.
CMake build system builds as a library, not an executable now.

Windows is now supported and should work fine.
2016-12-19 12:10:39 +00:00
Fred Nicolson
9479029c87 Improved CMake build system. Updated readme.
The CMake build system now uses a relative path for modules, and supports a 'USE_SSL' option to optionally link in mbedtls and enable SSL support.

The readme now provides SSL examples.
2016-12-16 22:34:36 +00:00
Cloaked9000
8c94c337e9 SSL Contexts are now shared between sockets 2016-12-16 14:55:41 +00:00
Cloaked9000
509b37095f Added support for passing SSL cert info to listener 2016-12-15 17:59:39 +00:00
Cloaked9000
14fccb84c9 More work on SSL support.
You can now accept SSL connections using SSLListeners, and then send/receive data through the associated SSLSocket.

HttpSocket's now support both HTTP and HTTPS, using templates:

fr::HttpSocket<fr::SSLSocket> https_socket; 
fr::HttpSocket<fr::TcpSocket> http_socket;
2016-12-15 12:29:23 +00:00
Cloaked9000
51291e2cc3 More experimental SSL code
Added SSLSocket, which can actually send/receive encrypted data.

Started adding SSLListener. It doesn't fully work yet.
2016-12-13 18:03:56 +00:00
Cloaked9000
7e9f007acd TLS Test Code 2016-12-12 18:03:27 +00:00
Fred Nicolson
98897dec02 Cleaned up HTTP socket/request code. 2016-12-11 12:14:47 +00:00
Fred Nicolson
fdee42e300 Added ability to both send AND receive HTTP requests and responses. 2016-12-10 16:50:02 +00:00
Fred Nicolson
7aced77a00 Added support for sending and receiving HTTP requests.
Added 'HttpSocket', which inherits TcpSocket and adds a receive and send functions for WebRequest objects.

WebRequest objects can be used to parse, construct and extract HTTP requests. They can be sent through HttpSocket's.
2016-12-10 15:11:01 +00:00
Fred Nicolson
b581418f2e Added support for blocking on multiple sockets simultaneously 2016-12-09 23:52:16 +00:00
Cloaked9000
d36a98b9b2 Send/Receive works on TcpSocket now 2016-12-09 16:55:53 +00:00
Fred Nicolson
4f9502df23 Pushed code across 2016-12-06 23:07:54 +00:00