]> git.tdb.fi Git - libs/net.git/log
libs/net.git
10 months agoAdd a dynamic receiver class for more flexible packet handling master
Mikko Rasa [Thu, 1 Jun 2023 07:31:43 +0000 (10:31 +0300)]
Add a dynamic receiver class for more flexible packet handling

It's useful for middleware libraries which may not know all packet types
at compile time, or if different packets need to be routed to different
receivers.

15 months agoRemove function overloads for manually specifying packet IDs
Mikko Rasa [Sun, 15 Jan 2023 21:50:54 +0000 (23:50 +0200)]
Remove function overloads for manually specifying packet IDs

Since the IDs can be transposed when sending and receiving, this isn't
terribly useful anymore.  For Communicator's multi-protocol support
having abnormally high packet IDs is detrimental.

15 months agoRedesign Communicator to support multiple protocols
Mikko Rasa [Sun, 15 Jan 2023 21:32:10 +0000 (23:32 +0200)]
Redesign Communicator to support multiple protocols

This makes it easier for a library to provide a base protocol and allow
applications to add their own protocols on top.  It's also used for the
Communicator's internal handshake protocol.

15 months agoProvide access to packet IDs in Protcool
Mikko Rasa [Sun, 15 Jan 2023 08:04:25 +0000 (10:04 +0200)]
Provide access to packet IDs in Protcool

15 months agoAdd a base id parameter to Protocol's serialization functions
Mikko Rasa [Sun, 15 Jan 2023 07:36:07 +0000 (09:36 +0200)]
Add a base id parameter to Protocol's serialization functions

This allows multiplexing protocols on a single connection by externally
adjusting their packet ID.

15 months agoAdd some useful factory functions to InetAddr and Inet6Addr
Mikko Rasa [Sat, 14 Jan 2023 22:31:22 +0000 (00:31 +0200)]
Add some useful factory functions to InetAddr and Inet6Addr

15 months agoDecorate things which constitute the public API
Mikko Rasa [Sat, 14 Jan 2023 22:30:50 +0000 (00:30 +0200)]
Decorate things which constitute the public API

16 months agoFix processing of IPv6 addresses in HTTP server
Mikko Rasa [Sun, 11 Dec 2022 16:26:02 +0000 (18:26 +0200)]
Fix processing of IPv6 addresses in HTTP server

16 months agoMark sockets as close-on-exec upon creation on Linux
Mikko Rasa [Sun, 11 Dec 2022 15:59:16 +0000 (17:59 +0200)]
Mark sockets as close-on-exec upon creation on Linux

16 months agoUse the append function from string utilities
Mikko Rasa [Sun, 11 Dec 2022 12:06:36 +0000 (14:06 +0200)]
Use the append function from string utilities

16 months agoAdjust copyability of classes
Mikko Rasa [Sun, 11 Dec 2022 11:54:17 +0000 (13:54 +0200)]
Adjust copyability of classes

In most cases the use of std::unique_ptr already makes classes move-only
where necessary.

16 months agoDon't create the WinSock helper until the first socket is created
Mikko Rasa [Sun, 11 Dec 2022 11:14:57 +0000 (13:14 +0200)]
Don't create the WinSock helper until the first socket is created

16 months agoCheck for EOF return before checking for errors
Mikko Rasa [Sun, 11 Dec 2022 10:17:12 +0000 (12:17 +0200)]
Check for EOF return before checking for errors

The check_sys_error function converts errors from non-blocking operations
which would block into a zero return, making them indistinguishable from
a zero return due to the other end closing the connection.

16 months agoMove the address family enum into sockaddr.h
Mikko Rasa [Sun, 11 Dec 2022 09:43:25 +0000 (11:43 +0200)]
Move the address family enum into sockaddr.h

16 months agoInclude the matching header first in .cpp files
Mikko Rasa [Sun, 11 Dec 2022 09:39:07 +0000 (11:39 +0200)]
Include the matching header first in .cpp files

This avoids accidentally using transitively included headers.

16 months agoUse std::unique_ptr for owning pointers
Mikko Rasa [Sun, 11 Dec 2022 09:08:04 +0000 (11:08 +0200)]
Use std::unique_ptr for owning pointers

16 months agoRefactor the API for defining packets in Protocol
Mikko Rasa [Sat, 10 Dec 2022 23:21:11 +0000 (01:21 +0200)]
Refactor the API for defining packets in Protocol

A variadic template function provides a nicer interface than chained call
operators.  Required C++ standard version is now C++14 due to deduced
automatic return types.

16 months agoAdd missing override specifiers
Mikko Rasa [Sat, 10 Dec 2022 22:15:18 +0000 (00:15 +0200)]
Add missing override specifiers

16 months agoFix an incorrect multiple inclusion guard
Mikko Rasa [Sat, 10 Dec 2022 22:14:54 +0000 (00:14 +0200)]
Fix an incorrect multiple inclusion guard

16 months agoUse nullptr instead of 0 for pointers
Mikko Rasa [Sat, 10 Dec 2022 22:14:38 +0000 (00:14 +0200)]
Use nullptr instead of 0 for pointers

16 months agoFurther simplify the protocol serializers
Mikko Rasa [Sat, 10 Dec 2022 19:54:59 +0000 (21:54 +0200)]
Further simplify the protocol serializers

16 months agoAdd unit tests for some classes
Mikko Rasa [Sat, 10 Dec 2022 18:01:33 +0000 (20:01 +0200)]
Add unit tests for some classes

16 months agoFix a length calculation bug in Protocol::dispatch
Mikko Rasa [Sat, 10 Dec 2022 17:59:30 +0000 (19:59 +0200)]
Fix a length calculation bug in Protocol::dispatch

The packet header was not being included in the returned length.

16 months agoSimplify the inner workings of Protocol
Mikko Rasa [Sat, 10 Dec 2022 17:51:56 +0000 (19:51 +0200)]
Simplify the inner workings of Protocol

The CompoundDef hierarchy was basically just a polymorphic wrapper for
Serializer.  Might as well make Serializer itself polymorphic.

16 months agoUse default member initializers where possible
Mikko Rasa [Sat, 10 Dec 2022 00:15:40 +0000 (02:15 +0200)]
Use default member initializers where possible

16 months agoRework protocol hash calculation
Mikko Rasa [Fri, 9 Dec 2022 23:47:45 +0000 (01:47 +0200)]
Rework protocol hash calculation

Instead of creating a string and hashing it, just build the hash
directly.

16 months agoReserve space for strings before appending characters
Mikko Rasa [Fri, 9 Dec 2022 22:27:01 +0000 (00:27 +0200)]
Reserve space for strings before appending characters

16 months agoUse the auto type to shorten long declarations
Mikko Rasa [Fri, 9 Dec 2022 22:22:01 +0000 (00:22 +0200)]
Use the auto type to shorten long declarations

16 months agoPrefer range-based for loops where possible
Mikko Rasa [Fri, 9 Dec 2022 22:18:32 +0000 (00:18 +0200)]
Prefer range-based for loops where possible

16 months agoUse the override specifier when overriding
Mikko Rasa [Fri, 9 Dec 2022 22:04:07 +0000 (00:04 +0200)]
Use the override specifier when overriding

16 months agoMark special member functions as defaulted where appropriate
Mikko Rasa [Fri, 9 Dec 2022 22:03:22 +0000 (00:03 +0200)]
Mark special member functions as defaulted where appropriate

16 months agoUse a static local variable for assigning packet IDs
Mikko Rasa [Fri, 9 Dec 2022 21:00:40 +0000 (23:00 +0200)]
Use a static local variable for assigning packet IDs

This avoids the need of a definition for the static member variable of
a template class.

16 months agoUse deque instead of list for resolver task queue
Mikko Rasa [Fri, 9 Dec 2022 19:51:20 +0000 (21:51 +0200)]
Use deque instead of list for resolver task queue

16 months agoAdd a function to close all HTTP connections
Mikko Rasa [Fri, 9 Dec 2022 18:35:24 +0000 (20:35 +0200)]
Add a function to close all HTTP connections

This can be useful for graceful shutdown at program exit.

16 months agoDon't allow duplicate listen calls
Mikko Rasa [Fri, 9 Dec 2022 18:32:46 +0000 (20:32 +0200)]
Don't allow duplicate listen calls

Also add a function to check if the socket is already listening

16 months agoAdjust exception classes and messages
Mikko Rasa [Fri, 9 Dec 2022 18:31:16 +0000 (20:31 +0200)]
Adjust exception classes and messages

16 months agoRemove unnecessary destructors from exception classes
Mikko Rasa [Fri, 9 Dec 2022 18:18:12 +0000 (20:18 +0200)]
Remove unnecessary destructors from exception classes

16 months agoReject HTTP messages starting with a linefeed
Mikko Rasa [Fri, 9 Dec 2022 17:54:16 +0000 (19:54 +0200)]
Reject HTTP messages starting with a linefeed

It would make str[lf-1] invalid.  Also ignore the carriage return at the
end of the first line when parsing a response.

16 months agoEmit signal_end_of_file after clearing events
Mikko Rasa [Fri, 9 Dec 2022 17:26:55 +0000 (19:26 +0200)]
Emit signal_end_of_file after clearing events

This ensures that the state remains consistent even if a slot throws.

16 months agoUse standard fixed-width integer types
Mikko Rasa [Fri, 9 Dec 2022 16:48:23 +0000 (18:48 +0200)]
Use standard fixed-width integer types

16 months agoUpdate getopt usage with positional arguments
Mikko Rasa [Fri, 9 Dec 2022 16:28:52 +0000 (18:28 +0200)]
Update getopt usage with positional arguments

16 months agoUpdate hash function call
Mikko Rasa [Fri, 9 Dec 2022 16:25:54 +0000 (18:25 +0200)]
Update hash function call

16 months agoUse size_t to represent sizes
Mikko Rasa [Fri, 9 Dec 2022 16:25:09 +0000 (18:25 +0200)]
Use size_t to represent sizes

16 months agoBump the library version and C++ standard
Mikko Rasa [Fri, 9 Dec 2022 16:04:59 +0000 (18:04 +0200)]
Bump the library version and C++ standard

4 years agoAllow creating an Http::Server without immediately listening
Mikko Rasa [Fri, 27 Sep 2019 21:38:06 +0000 (00:38 +0300)]
Allow creating an Http::Server without immediately listening

4 years agoUse an IPv6 socket for Http::Server
Mikko Rasa [Fri, 27 Sep 2019 21:37:41 +0000 (00:37 +0300)]
Use an IPv6 socket for Http::Server

4 years agoFix several errors in FormData parsing
Mikko Rasa [Thu, 26 Sep 2019 23:03:57 +0000 (02:03 +0300)]
Fix several errors in FormData parsing

It was terminating early if a part happened to be of certain length.
Extra whitespace was included at the end of parts and there was also an
out-of-bounds memory access.

4 years agoImprove error handling
Mikko Rasa [Thu, 26 Sep 2019 20:55:01 +0000 (23:55 +0300)]
Improve error handling

Particularly of asynchronous operations

4 years agoAdd parsing for different styles of HTTP headers
Mikko Rasa [Tue, 24 Sep 2019 22:37:00 +0000 (01:37 +0300)]
Add parsing for different styles of HTTP headers

4 years agoSupport serializing bool fields in Protocol
Mikko Rasa [Mon, 23 Sep 2019 11:44:57 +0000 (14:44 +0300)]
Support serializing bool fields in Protocol

4 years agoAllow the query part of a URL to be empty
Mikko Rasa [Mon, 23 Sep 2019 11:42:04 +0000 (14:42 +0300)]
Allow the query part of a URL to be empty

This can happen when submitting an empty form with the GET method.

4 years agoPrevent serializing packets without an ID
Mikko Rasa [Sat, 21 Sep 2019 15:23:01 +0000 (18:23 +0300)]
Prevent serializing packets without an ID

An attempt at such may arise from sending a structure intended to be used
as part of other packets, but not a packet on its own.

4 years agoFix the polarity of O_CLOEXEC for Socket
Mikko Rasa [Sat, 21 Sep 2019 15:06:36 +0000 (18:06 +0300)]
Fix the polarity of O_CLOEXEC for Socket

4 years agoProvide more information about exceptions in Http::Server
Mikko Rasa [Sat, 21 Sep 2019 14:53:29 +0000 (17:53 +0300)]
Provide more information about exceptions in Http::Server

4 years agoRemove name from an unused variable
Mikko Rasa [Sat, 21 Sep 2019 14:52:34 +0000 (17:52 +0300)]
Remove name from an unused variable

4 years agoUpdate a deprecated header
Mikko Rasa [Sat, 21 Sep 2019 14:52:14 +0000 (17:52 +0300)]
Update a deprecated header

5 years agoAdd method to query bound status of a socket
Mikko Rasa [Thu, 24 Jan 2019 01:21:23 +0000 (03:21 +0200)]
Add method to query bound status of a socket

6 years agoImplement the required virtual functions in Socket
Mikko Rasa [Tue, 5 Dec 2017 06:40:46 +0000 (08:40 +0200)]
Implement the required virtual functions in Socket

6 years agoFix a flag handling bug in Socket::Private::set_block
Mikko Rasa [Tue, 5 Dec 2017 06:39:14 +0000 (08:39 +0200)]
Fix a flag handling bug in Socket::Private::set_block

7 years agoMove the definition of PacketTypeDef<T>::class_id to a separate header
Mikko Rasa [Tue, 1 Nov 2016 22:00:55 +0000 (00:00 +0200)]
Move the definition of PacketTypeDef<T>::class_id to a separate header

Defining it in protocol.h may cause multiple definitions to appear across
the program and there are cases where they don't get collapsed to one.
DLLs on Windows are one such case.  The _impl header is to be included in
files that add packet definitions to a protocol and nowhere else.

7 years agoIncrease Communicator buffer size to 64k
Mikko Rasa [Wed, 12 Oct 2016 09:59:00 +0000 (12:59 +0300)]
Increase Communicator buffer size to 64k

This is the current maximum size for a packet, and there isn't really
any need to use a smaller buffer.

7 years agoSome largely cosmetic touch-up
Mikko Rasa [Sun, 9 Oct 2016 17:34:33 +0000 (20:34 +0300)]
Some largely cosmetic touch-up

7 years agoSupport compound types in network packets
Mikko Rasa [Sun, 9 Oct 2016 17:30:03 +0000 (20:30 +0300)]
Support compound types in network packets

7 years agoFill in a missing parameter for check_sys_error
Mikko Rasa [Sun, 9 Oct 2016 15:08:38 +0000 (18:08 +0300)]
Fill in a missing parameter for check_sys_error

This was supposed to be in b069cfc but somehow didn't make it into the
commit.

7 years agoAcutally implement Protocol::get_hash
Mikko Rasa [Sun, 9 Oct 2016 15:03:24 +0000 (18:03 +0300)]
Acutally implement Protocol::get_hash

Also trigger an error in Communicator if the hashes don't match

7 years agoRefactor most of Communicator::send to be in the .cpp file
Mikko Rasa [Sun, 9 Oct 2016 13:56:40 +0000 (16:56 +0300)]
Refactor most of Communicator::send to be in the .cpp file

7 years agoMassive overhaul of the Protocol class
Mikko Rasa [Sun, 9 Oct 2016 13:53:23 +0000 (16:53 +0300)]
Massive overhaul of the Protocol class

Makes the serialization machinery more flexible and reduces the number of
virtual function calls when de/serializing packets.

7 years agoAdd error check to accept
Mikko Rasa [Sun, 25 Sep 2016 22:35:31 +0000 (01:35 +0300)]
Add error check to accept

7 years agoMove most platform-specific code into overlay directories
Mikko Rasa [Sun, 25 Sep 2016 22:28:16 +0000 (01:28 +0300)]
Move most platform-specific code into overlay directories

Unix socket addresses can now be constructed on Windows, but can't be
actually used with sockets.

7 years agoMinor cleanup
Mikko Rasa [Wed, 14 Sep 2016 11:27:15 +0000 (14:27 +0300)]
Minor cleanup

7 years agoUse the correct #ifdef for Windows
Mikko Rasa [Wed, 14 Sep 2016 11:26:50 +0000 (14:26 +0300)]
Use the correct #ifdef for Windows

7 years agoSupport asynchronous name resolution in Http::Client
Mikko Rasa [Wed, 14 Sep 2016 10:51:56 +0000 (13:51 +0300)]
Support asynchronous name resolution in Http::Client

7 years agoImplement an asynchronous name resolver class
Mikko Rasa [Wed, 14 Sep 2016 10:50:29 +0000 (13:50 +0300)]
Implement an asynchronous name resolver class

7 years agoFix header name normalization logic
Mikko Rasa [Mon, 16 May 2016 15:15:29 +0000 (18:15 +0300)]
Fix header name normalization logic

If the name begins with a hyphen, the following letter shall be
uppercased.

7 years agoUse string::size_type to store string offsets
Mikko Rasa [Mon, 16 May 2016 15:15:10 +0000 (18:15 +0300)]
Use string::size_type to store string offsets

7 years agoAdd a class for parsing submitted form data
Mikko Rasa [Mon, 16 May 2016 15:13:38 +0000 (18:13 +0300)]
Add a class for parsing submitted form data

parse_query in utils.h already did it for query strings, but not for
POST requests.

7 years agoAdd a utility struct for parsing complex header values
Mikko Rasa [Mon, 16 May 2016 09:06:19 +0000 (12:06 +0300)]
Add a utility struct for parsing complex header values

It's not used to store headers in Message since not all headers follow
the same syntax.  User-Agent in particular may have semicolons which are
not parameters separators.

8 years agoAdd the most common redirection statuses
Mikko Rasa [Wed, 20 Apr 2016 21:00:21 +0000 (00:00 +0300)]
Add the most common redirection statuses

8 years agoProvide a method for the application to cancel connection keep-alive
Mikko Rasa [Tue, 19 Apr 2016 07:39:55 +0000 (10:39 +0300)]
Provide a method for the application to cancel connection keep-alive

8 years agoAdhere to the spec with connection keep-alive
Mikko Rasa [Tue, 19 Apr 2016 07:38:57 +0000 (10:38 +0300)]
Adhere to the spec with connection keep-alive

Recognize it case-insensitively and add the header on the response.

8 years agoUse connection keepalive on async responses too
Mikko Rasa [Tue, 19 Apr 2016 07:34:42 +0000 (10:34 +0300)]
Use connection keepalive on async responses too

8 years agoHide Http::Server destructor in the library
Mikko Rasa [Tue, 19 Apr 2016 07:31:27 +0000 (10:31 +0300)]
Hide Http::Server destructor in the library

Otherwise sigc::signal destructor will be emitted in the including file,
requiring explicit linking with libsigc++.

8 years agoUse a typecast to avoid a signedness mismatch warning
Mikko Rasa [Thu, 19 Nov 2015 08:17:18 +0000 (10:17 +0200)]
Use a typecast to avoid a signedness mismatch warning

9 years agoSet event types on Windows if connect finished immediately
Mikko Rasa [Fri, 10 Apr 2015 18:08:22 +0000 (21:08 +0300)]
Set event types on Windows if connect finished immediately

9 years agoInclude winsock2.h first
Mikko Rasa [Tue, 7 Apr 2015 10:58:25 +0000 (13:58 +0300)]
Include winsock2.h first

It wants to get included before windows.h

9 years agoReject requests with a relative path
Mikko Rasa [Mon, 6 Apr 2015 22:24:18 +0000 (01:24 +0300)]
Reject requests with a relative path

As per the HTTP specification

9 years agoCorrect a typo in a multiple inclusion guard
Mikko Rasa [Mon, 6 Apr 2015 22:23:12 +0000 (01:23 +0300)]
Correct a typo in a multiple inclusion guard

9 years agoProvide a signal to handle errors from Communicator
Mikko Rasa [Mon, 6 Apr 2015 22:19:21 +0000 (01:19 +0300)]
Provide a signal to handle errors from Communicator

Since Communicator is typically used with an EventDispatcher, it can be
inconvenient to just throw exceptions out.  Handling them would require
wrapping the EventDispatcher's tick call in a try block, and the exact
source of the exception would be lost.

9 years agoImplement connection keep-alive in HttpServer
Mikko Rasa [Thu, 22 Jan 2015 14:23:19 +0000 (16:23 +0200)]
Implement connection keep-alive in HttpServer

9 years agoMake Request API consistent with itself and others
Mikko Rasa [Thu, 22 Jan 2015 14:20:00 +0000 (16:20 +0200)]
Make Request API consistent with itself and others

Request::from_url was incorrectly creating requests with unencoded URLs.

9 years agoAdd 405 (method not allowed) status
Mikko Rasa [Thu, 22 Jan 2015 14:16:14 +0000 (16:16 +0200)]
Add 405 (method not allowed) status

Since the HttpServer class allows either GET or POST and returns 501 (not
implemented) for others, programs using it may wish to further limit
processing to GET requests only.

9 years agoAdd shutdown support for client sockets
Mikko Rasa [Thu, 22 Jan 2015 12:10:44 +0000 (14:10 +0200)]
Add shutdown support for client sockets

11 years agoFix 64-bit compilation
Mikko Rasa [Mon, 1 Apr 2013 18:32:19 +0000 (21:32 +0300)]
Fix 64-bit compilation

11 years agoAdd the target type to a lexical_cast invocation
Mikko Rasa [Sat, 1 Dec 2012 10:00:59 +0000 (12:00 +0200)]
Add the target type to a lexical_cast invocation

11 years agoUpdate Build and .gitignore files
Mikko Rasa [Mon, 15 Oct 2012 10:25:32 +0000 (13:25 +0300)]
Update Build and .gitignore files

11 years agoAdd support for AF_UNIX
Mikko Rasa [Mon, 15 Oct 2012 09:07:22 +0000 (12:07 +0300)]
Add support for AF_UNIX

11 years agoHide the set_option and get_option functions in socket_private.h
Mikko Rasa [Mon, 8 Oct 2012 20:38:31 +0000 (23:38 +0300)]
Hide the set_option and get_option functions in socket_private.h

These depend on a system-specific type, so they can't be in a public
header.

11 years agoFix some compilation problems
Mikko Rasa [Mon, 8 Oct 2012 20:37:44 +0000 (23:37 +0300)]
Fix some compilation problems

12 years agoDon't crash on errors without verbose mode
Mikko Rasa [Mon, 31 Oct 2011 14:33:56 +0000 (16:33 +0200)]
Don't crash on errors without verbose mode

12 years agoFix some header names
Mikko Rasa [Wed, 5 Oct 2011 08:30:41 +0000 (11:30 +0300)]
Fix some header names