# Changelog
All notable changes to this project will be documented in this file.

The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

---

## 0.12.0

### Fixed
- Fixed parsing mac address from leases file, and added unit tests to prevent this bug from happening again.

### Changed
- All logging now uses `tracing` instead of `env_logger`. It still uses the `RUST_LOG` environment variable. The server offloads logging to a dedicated thread which prevents performance degradation during periods of excessive logging. In rare scenarios with extreme logging, preventing packet drop is prioritized over preventing log drop.

### Internal
- Some docker images are now minimal, hardened images.
- Use kea cloudsmith repository to install `perfdhcp` dynamically in docker container and allow cross-platform load testing.

---

## 0.11.0

### Breaking
- The `Lease` struct now uses a `Zoned` type from the `jiff` crate instead of a `SystemTime`. Therefore, the `toe-beans-leases.toml` format has changed.
- Renamed `Config` to `ServerConfig` to disambiguate it as more config structs are added.
- Split config from `ServerConfig` into `InnerServerConfig`, `SocketConfig` and `LeaseConfig`. `SocketConfig` is also used by `ClientConfig`. This changed the `toe-beans.toml` file format. `::new()` methods now take these split configs.
- `LeaseConfig` has a `leases_file_path` option that can be used independently of `ServerConfig.config_path`.
- Acquire a lock to the leases file. If you want to run multiple toe-beans servers at once, use a different `leases_file_path` for each. 
- Instead of writing the entire leases file every 10 seconds, each lease assignment is written separately and immediately. To make this happen, the leases file has significantly changed. For example, it no longer uses toml and has a different file name ("toe-beans.leases"). It has all the performance of the delayed approach without the delay.
- `InnerServerConfig.parameters` now accepts a `u8` key instead of a `String` key. This prevents unnecessary conversions.

### Added
- New `LeaseTime::ONE_DAY` const. It is used by default in `LeaseConfig`.

---

## 0.10.0

### Added
- If a relay agent sets the `giaddr`, it is now used.
- Git hooks for `pre-push`. If you are a developer working on `toe-beans`, please see the `/CONTRIBUTING.md` for setup.
- Added `MessageOptionsList`.

### Changed
- Limit writing to the leases file to every 10 seconds to significantly improve loaded throughput.
- Atomically write to the leases file so that it can't be corrupted during an update.
- Decode logic for flags moved to `Flags`.
- Update `inherface` crate (improves performance).

### Internal
- Organize docker files into a common parent directory and split docker-compose.yml into composable parts.
- Add load testing with ISC `perfdhcp`.

---

## 0.9.0

### Breaking
- `Socket`'s `unicast` method now accepts a `SocketAddrV4` instead of a `ToSocketAddr`.
- `Socket::MAX_MESSAGE_SIZE` moved to `MAX_MESSAGE_SIZE`.

### Changed
- Optimize encoding with more efficient allocation.
- Add `Debug` to remaining pub types and add lint to enforce doing so.
- Improvements to docker setup.

### Added
- Type aliases `MagicBuffer`, `OptionsBuffer`.
- Constants `MAGIC_SIZE`, `NON_MAGIC_SIZE`.

---

## 0.8.0

### Breaking
- `Slicer` methods are now prefixed with `slice` instead of `parse`.
- `MessageSlicer` has been replaced with `UndecodedMessage` which returns fixed size arrays instead of slices now.
- `from_bytes` accepts an `UndecodedMessage` now.
- Replaced `Deliverable` with `Encodable` and `Decodable` which allows more flexibility when sending/receiving in `Socket`.

### Added
- Type alias called `MessageBuffer`.
- Constants for `Socket::MAX_MESSAGE_SIZE`, `Socket::EMPTY_MESSAGE_BUFFER`.
- Methods for `Socket::receive_raw`, `Socket::receive_mock`.
- `Slicer` methods `slice_unchecked`, `slice_remainder`, and `reset` are now public.
- `UndecodedMessage` can slice fields in any order and non-sequentially.
- `slice_flags_temporary` method to `UndecodedMessage` to make decoding flags easier.

### Changed
- Add comments and a unit test to explain/ensure that decoding never panics.

---

## 0.7.0

### Breaking
- The `Leases` `restore` and `restore_or_new` have been combined into `new`. Whether or not a restore happens is now controlled by the `use_leases_file` `Config` flag.

### Fixed
- Leases file truncation.

### Added
- `Config` now has a `use_leases_file` flag.

### Changed
- Updated dependencies to latest.

---

## 0.6.0

### Breaking
- `static_leases` moved from `Leases` to server `Config`.

### Changed
- Restored static leases are no longer permitted to be unassignable network or broadcast addresses.
- Static leases cant be assigned to anyone other than who they are reserved for.
- Improvements to client binary and docker setup.

---

## 0.5.0

### Breaking
- Disable trace logs in release builds. You may still view them in debug builds.
- The "End" option is automatically added/removed during encode/decode. You should no longer manually add it to your list of options.
- `Client::new` now accepts a `ClientConfig`. 

### Added
- constants `CLIENT_PORT`, `TEST_CLIENT_PORT`, `RESOLVED_CLIENT_PORT`, `SERVER_PORT`, `TEST_SERVER_PORT`, and `RESOLVED_SERVER_PORT`.
  - The resolved constants are now used in various places. This means that release builds now use the proper privileged ports by default.
- server logs the version of toe-beans it is running when it starts.

### Changed
- Various improvements to client binary. The `dora` command successfully assign an ip address in the new docker test.

---

## 0.4.0

### Breaking
- Use `ip_network` crate instead of `ipnetwork` crate because of the additional methods that the new one provides.
- Remove ip network range from leases file and `IpPool` struct because all range checks have been moved from request handling to server startup.
- Renamed `IpPool` to `Leases` and `ip_pool` to `leases`.

### Changed
- The leases file is kept open instead of being open/closed for every write. This should be more performant.

### Added
- `LeaseTime::INFINITY` const.

---

## 0.3.1

### Fixed
- Restoring from a leases file can no longer have duplicate ip addresses in "available" and "leased".
- Remove network and broadcast addresses from the pool of assignable and assigned addresses.

---

## 0.3.0

### Breaking
- Remove `v4` feature. This should be minimally breaking because `v4_client` and `v4_server` are still default features.
- `IpPool.extend` no longer accepts an ip address as an argument. It will extend an offered lease now too.
- `IpPool.is_expired` is removed for now. Its now available (privately) on `Lease` instead.
- `IpPool.unoffer` has been combined with `IpPool.release`.
- The format of the leases file changed.

### Fixed
- `IpPool` will not try to reuse acked ips after 300 seconds when all available addresses are exhausted. It will instead use `Config.lease_time` which should be longer. `300` should only be for offers.

### Changed
- This project's license has been changed from GPL v3 to LGPL v2. See LICENSE file for more information.
- Improved Flags serializing performance with the new `temporary_to_bytes` method.
- Improved IpPool performance and (a little bit of) memory usage.

---

## 0.2.1

### Fixed
- Failure on `amd64` platforms, due to issue with a dependency crate, where `c_char` was represented as `i8` instead of `u8`. This should also fix docs.rs.

---

## 0.2.0

Initial release!

---

## 0.1.0

Reserve crate name.
