#protocols #packets #http #networking #packet #assistance #http-request

packeteer

An attempt at a Rust library that can be used to assist in programmatically analysing, serving and handling received protocol packets

16 releases

0.5.2 Jan 15, 2024
0.5.1 Jul 17, 2023
0.4.3 Apr 13, 2022
0.3.2 Mar 20, 2022
0.1.4 Mar 12, 2022

#10 in #packets

MPL-2.0 license

41KB
775 lines

Packeteer

Packeteer is a library that can handle structurally organising protocol packets like HTTP 1.x requests and responses as well as generating, structuring, unpacking and potentially more features depending on the protocol.

Supported protocols

  • HTTP/1.x
  • Gemini
  • FTP
  • DNS

What Packeteer is not

  • a TCP/UDP stream handling library
  • a server
  • a protocol client
  • the only way to do this, probably

A note on licensing

This library changed from the LGPLv3 to MPLv2 as a result of LGPL's requirements for freedom of source on static linking which rustc does.

I've chosen to use the MPL as it is a weaker but still copyleft license that allows you to statically link.

The MPL applies retroactively to all previous versions of this library and will be used for all future versions.


lib.rs:

A packet manipulation, generation, unpackination, and constructionation station.

In all seriousness, packeteer is a crate made to assist with programmatically analysing, serving and handling received protocol packets. This is great for servers, clients, proxies as well as packet sniffers, capturers and analysers. Packeteer doesn't implement any ability to send or receive requests/responses nor does it handle streams or threads for you and is instead supposed to be used in applications to structure packets and potentially do automated operations on them as defined by packeteer modules.

To include packeteer in your project, you'll need to enable the modules you need. For example, if you required the usage of the http1 module, you would add the following to your Cargo.toml file:

packeteer = { version = "0.4", features = ["http1"] }

It's safe to use ambigious version numbers that exclude the bugfix number as breaking changes or new features will result in an increment of the minor version number, or possibly major version number in the future.

Packeteer aims to use as little dependencies as possible. The less dependenices that packeteer uses, the less storage your project uses. Being conservative with dependencies also makes compilation infinitely faster.

An example of request generation using the http1 module:

use packeteer::http1::*;

fn main() {
	// generate_request(method, host, location, body)
	// GET requests don't really require bodies.
	let request = generate_request("GET", "example.service", "/api/example_endpoint", "");
	let req_raw = unpack_request(request);

	// Now to send req_raw through a stream to your client!
}

No runtime deps

Features