Crate packeteer

source ·
Expand description

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!
}

Modules§

  • A module for handling DNS operations. It contains structures for DNS flags, packets, queries and answers as well as functions for unpacking and constructing them and enumerators for DNS record classes and types.
  • A module for handling FTP operations. It contains structures for FTP requests and responses as well as functions for generating, unpacking and constructing them.
  • A module for handling Gemini operations. It contains structures for Gemini requests and responses as well as functions for generating, unpacking and constructing them.
  • The module handling HTTP/1.0 and HTTP/1.1 operations. It contains structures for HTTP/1.x requests and responses as well as functions for generating, unpacking and constructing them. It can also upgrade and downgrade HTTP/1.x requests.

Structs§

  • A global structure for key value headers. Can be automatically generated with the function packeteer::generate_kvheader.
  • A global structure for integrating URLs within the structural system of packeteer. Can be automatically generated with the function packeteer::wrap_url.

Functions§

  • A public function for generating a KVHeader structure from two string references representing the key and value.
  • A public function for unwrapping a Url structure into a String.
  • A public function that returns just a Url’s segments as one string.
  • A public function for wrapping a string reference as a Url structure.