Skip to content

Commit

Permalink
Fix tests and update dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
yaa110 committed Feb 1, 2022
1 parent 0390508 commit bb85e99
Show file tree
Hide file tree
Showing 6 changed files with 38 additions and 32 deletions.
20 changes: 20 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
name: Build

on:
push:
branches: [master]
pull_request:
branches: [master]

jobs:
linux:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions-rs/toolchain@v1
with:
toolchain: stable
components: rustfmt, clippy
- run: sudo -E `which cargo` test -j`nproc` -- --ignored --test-threads 1
- run: sudo -E `which cargo` fmt -- --check
- run: sudo -E `which cargo` clippy -j`nproc`
18 changes: 0 additions & 18 deletions .travis.yml

This file was deleted.

16 changes: 8 additions & 8 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
[package]
name = "iptables"
version = "0.4.3"
authors = ["Navid Fathollahzade <[email protected]>", "Pit Kleyersburg <[email protected]>"]
edition = "2018"
categories = ["api-bindings"]
description = "Rust bindings for iptables"
homepage = "https://github.com/yaa110/rust-iptables"
documentation = "https://github.com/yaa110/rust-iptables"
repository = "https://github.com/yaa110/rust-iptables"
readme = "README.md"
edition = "2021"
homepage = "https://github.com/yaa110/rust-iptables"
keywords = ["iptables", "netfilter", "bindings"]
categories = ["api-bindings"]
license = "MIT"
name = "iptables"
readme = "README.md"
repository = "https://github.com/yaa110/rust-iptables"
version = "0.5.0"

[lib]
name = "iptables"

[dependencies]
lazy_static = "1.4"
nix = "0.23"
regex = "1.4"
nix = "0.20"
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ This crate provides bindings for [iptables](https://www.netfilter.org/projects/i

```toml
[dependencies]
iptables = "0.4"
iptables = "*"
```

## Getting started
Expand Down
12 changes: 7 additions & 5 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -202,9 +202,11 @@ impl IPTables {
#[cfg(target_os = "linux")]
pub fn chain_exists(&self, table: &str, chain: &str) -> Result<bool, Box<dyn Error>> {
match self.is_numeric {
false => self.run(&["-t", table, "-L", chain])
false => self
.run(&["-t", table, "-L", chain])
.map(|output| output.status.success()),
true => self.run(&["-t", table, "-L", chain, "-n"])
true => self
.run(&["-t", table, "-L", chain, "-n"])
.map(|output| output.status.success()),
}
}
Expand All @@ -221,7 +223,7 @@ impl IPTables {
}),
true => self.run(&["-t", table, "-S", "-n"]).map(|output| {
String::from_utf8_lossy(&output.stdout).contains(&format!("-A {} {}", chain, rule))
})
}),
}
}

Expand Down Expand Up @@ -330,7 +332,7 @@ impl IPTables {
match self.is_numeric {
false => self.get_list(&["-t", table, "-S", chain]),
true => self.get_list(&["-t", table, "-S", chain, "-n"]),
}
}
}

/// Lists rules in the table.
Expand Down Expand Up @@ -422,7 +424,7 @@ impl IPTables {
FlockArg::LockExclusiveNonblock,
) {
Ok(_) => need_retry = false,
Err(nix::Error::Sys(en)) if en == nix::errno::Errno::EAGAIN => {
Err(e) if e == nix::errno::Errno::EAGAIN => {
// FIXME: may cause infinite loop
need_retry = true;
}
Expand Down
2 changes: 2 additions & 0 deletions tests/iptables_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ fn test_old() {
cmd: "iptables",
has_wait: false,
has_check: false,
is_numeric: false,
},
"NATOLD",
"NATOLD2",
Expand All @@ -25,6 +26,7 @@ fn test_old() {
cmd: "iptables",
has_wait: false,
has_check: false,
is_numeric: false,
},
"FILTEROLD",
);
Expand Down

0 comments on commit bb85e99

Please sign in to comment.