Skip to content

Commit

Permalink
Merge branch 'release/0.1.4'
Browse files Browse the repository at this point in the history
  • Loading branch information
credmp committed Oct 12, 2021
2 parents 309400a + ddc8b37 commit d8b0457
Show file tree
Hide file tree
Showing 11 changed files with 497 additions and 247 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/rust-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ jobs:
id: create_release
with:
draft: false
prerelease: true
prerelease: false
release_name: ${{ steps.version.outputs.version }}
tag_name: ${{ github.ref }}
env:
Expand Down
18 changes: 18 additions & 0 deletions .github/workflows/rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,21 @@ jobs:
run: cargo test --verbose
- name: Run clippy
run: cargo clippy

coverage:
name: coverage
runs-on: ubuntu-latest
container:
image: xd009642/tarpaulin:develop-nightly
options: --security-opt seccomp=unconfined
steps:
- name: Checkout repository
uses: actions/checkout@v2
- name: Generate code coverage
run: |
cargo +nightly tarpaulin --verbose --all-features --workspace --timeout 120 --out Xml
- name: Upload to codecov.io
uses: codecov/codecov-action@v2
with:
token: ${{ secrets.CODECOV_TOKEN }}
fail_ci_if_error: true
23 changes: 22 additions & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 3 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "hed"
version = "0.1.3"
version = "0.1.4"
edition = "2018"
license = "GPLv3"
authors = ["Arjen Wiersma <arjen@wiersma.org>"]
Expand All @@ -22,6 +22,7 @@ faccess = "0.2.3"
regex = "1.5.4"
sudo = "0.6.0"
termion = "1.5.6"
thiserror = "1.0.29"

[package.metadata.deb]
maintainer = "Arjen Wiersma <arjen@wiersma.org>"
Expand All @@ -36,4 +37,4 @@ priority = "optional"
assets = [
["target/release/hed", "usr/bin/", "755"],
["README.md", "usr/share/doc/hed/README.md", "644"],
]
]
10 changes: 10 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
2021-10-12 Arjen Wiersma <arjen@wiersma.org>

* src/hostfile.rs: handle end of line comments in host entries

2021-10-11 Arjen Wiersma <arjen@wiersma.org>

* src/main.rs: Humane error messages

* src/hostfile.rs: Moved all hostfile methods from main into the struct

2021-10-04 Arjen Wiersma <arjen@wiersma.org>

* src/main.rs: initial tool version - it only adds hosts now and
Expand Down
10 changes: 9 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
[![Issues][issues-shield]][issues-url]
[![GPLv3 License][license-shield]][license-url]
[![LinkedIn][linkedin-shield]][linkedin-url]

[![codecov_shield]][codecov_profile]


<!-- PROJECT LOGO -->
Expand Down Expand Up @@ -270,3 +270,11 @@ Project Link: [https://github.com/credmp/hed](https://github.com/credmp/hed)
[linkedin-shield]: https://img.shields.io/badge/-LinkedIn-black.svg?style=for-the-badge&logo=linkedin&colorB=555
[linkedin-url]: https://linkedin.com/in/credmp
[product-screenshot]: images/cast.gif
[codecov_shield]: https://img.shields.io/codecov/c/github/credmp/hed/develop?style=for-the-badge&token=61TTWQXFI3
[codecov_profile]: https://codecov.io/gh/credmp/hed

<!--
https://codecov.io/gh/credmp/hed/branch/develop/graph/badge.svg?token=61TTWQXFI3
-->
12 changes: 7 additions & 5 deletions samples/kali-default.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
127.0.0.1 localhost
127.0.1.1 kali
127.0.0.1 localhost
127.0.1.1 kali # some snarky comment
10.10.1.1 forge.htb admin.forge.htb
10.10.1.2 fudge.htb admin.fudge.htb # The magnificent fudge machine

# The following lines are desirable for IPv6 capable hosts
::1 localhost ip6-localhost ip6-loopback
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
::1 localhost ip6-localhost ip6-loopback
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
36 changes: 36 additions & 0 deletions src/errors.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
use thiserror::Error;

#[derive(Error, Debug)]
pub enum ApplicationError {
/// Represents a failure to read the hosts file
#[error("hostfile is not readable. Reason: {0}")]
HostFileUnreadable(String),

#[error("Failed to write the hostfile back to the file. Reason: {0}")]
HostFileUnwritable(String),

#[error("Failed to write backup file, refusing to overwrite original ({0})")]
BackupFileWriteFailed(String),

#[error("Failed to convert the IP address, this is normally due to a typo of perhaps you gave a hostname instead?")]
IpAddressConversion(),

#[error("No hostname was given to be added to the hosts file. You should not see this message, if you do, please log an bug report at https://github.com/credmp/hed")]
NoHostnameGiven(),

#[error("An ip address with this name already exists:\n{0}")]
IpAlreadyInUse(String),

#[error("An entry exists with the hostname, but with a different IP:\n{0}")]
HostnameAlreadyInUse(String),

#[error("Could not add host, no parent domain to resolve it. This means that no parent domain exists for the given hostname, try adding it with an IP address, it will be the first entry for this host.\n\nFor instance, if an entry exists called demo.example.com I can not add example.com, as the subdomain is not a parent domain, the other way around will work.")]
NoParentDomain(),

#[error("You should not see this message, if you do, please log an bug report at https://github.com/credmp/hed, it is very appreciated!")]
FileABugReport(),

/// Represents all other cases of `std::io::Error`.
#[error(transparent)]
IOError(#[from] std::io::Error),
}
Loading

0 comments on commit d8b0457

Please # to comment.