Skip to content

Commit bb85e99

Browse files
committed
Fix tests and update dependencies
1 parent 0390508 commit bb85e99

File tree

6 files changed

+38
-32
lines changed

6 files changed

+38
-32
lines changed

.github/workflows/build.yml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
name: Build
2+
3+
on:
4+
push:
5+
branches: [master]
6+
pull_request:
7+
branches: [master]
8+
9+
jobs:
10+
linux:
11+
runs-on: ubuntu-latest
12+
steps:
13+
- uses: actions/checkout@v2
14+
- uses: actions-rs/toolchain@v1
15+
with:
16+
toolchain: stable
17+
components: rustfmt, clippy
18+
- run: sudo -E `which cargo` test -j`nproc` -- --ignored --test-threads 1
19+
- run: sudo -E `which cargo` fmt -- --check
20+
- run: sudo -E `which cargo` clippy -j`nproc`

.travis.yml

Lines changed: 0 additions & 18 deletions
This file was deleted.

Cargo.toml

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,21 @@
11
[package]
2-
name = "iptables"
3-
version = "0.4.3"
42
authors = ["Navid Fathollahzade <yaa110@gmail.com>", "Pit Kleyersburg <pitkley@googlemail.com>"]
5-
edition = "2018"
3+
categories = ["api-bindings"]
64
description = "Rust bindings for iptables"
7-
homepage = "https://github.com/yaa110/rust-iptables"
85
documentation = "https://github.com/yaa110/rust-iptables"
9-
repository = "https://github.com/yaa110/rust-iptables"
10-
readme = "README.md"
6+
edition = "2021"
7+
homepage = "https://github.com/yaa110/rust-iptables"
118
keywords = ["iptables", "netfilter", "bindings"]
12-
categories = ["api-bindings"]
139
license = "MIT"
10+
name = "iptables"
11+
readme = "README.md"
12+
repository = "https://github.com/yaa110/rust-iptables"
13+
version = "0.5.0"
1414

1515
[lib]
1616
name = "iptables"
1717

1818
[dependencies]
1919
lazy_static = "1.4"
20+
nix = "0.23"
2021
regex = "1.4"
21-
nix = "0.20"

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ This crate provides bindings for [iptables](https://www.netfilter.org/projects/i
77

88
```toml
99
[dependencies]
10-
iptables = "0.4"
10+
iptables = "*"
1111
```
1212

1313
## Getting started

src/lib.rs

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -202,9 +202,11 @@ impl IPTables {
202202
#[cfg(target_os = "linux")]
203203
pub fn chain_exists(&self, table: &str, chain: &str) -> Result<bool, Box<dyn Error>> {
204204
match self.is_numeric {
205-
false => self.run(&["-t", table, "-L", chain])
205+
false => self
206+
.run(&["-t", table, "-L", chain])
206207
.map(|output| output.status.success()),
207-
true => self.run(&["-t", table, "-L", chain, "-n"])
208+
true => self
209+
.run(&["-t", table, "-L", chain, "-n"])
208210
.map(|output| output.status.success()),
209211
}
210212
}
@@ -221,7 +223,7 @@ impl IPTables {
221223
}),
222224
true => self.run(&["-t", table, "-S", "-n"]).map(|output| {
223225
String::from_utf8_lossy(&output.stdout).contains(&format!("-A {} {}", chain, rule))
224-
})
226+
}),
225227
}
226228
}
227229

@@ -330,7 +332,7 @@ impl IPTables {
330332
match self.is_numeric {
331333
false => self.get_list(&["-t", table, "-S", chain]),
332334
true => self.get_list(&["-t", table, "-S", chain, "-n"]),
333-
}
335+
}
334336
}
335337

336338
/// Lists rules in the table.
@@ -422,7 +424,7 @@ impl IPTables {
422424
FlockArg::LockExclusiveNonblock,
423425
) {
424426
Ok(_) => need_retry = false,
425-
Err(nix::Error::Sys(en)) if en == nix::errno::Errno::EAGAIN => {
427+
Err(e) if e == nix::errno::Errno::EAGAIN => {
426428
// FIXME: may cause infinite loop
427429
need_retry = true;
428430
}

tests/iptables_test.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ fn test_old() {
1515
cmd: "iptables",
1616
has_wait: false,
1717
has_check: false,
18+
is_numeric: false,
1819
},
1920
"NATOLD",
2021
"NATOLD2",
@@ -25,6 +26,7 @@ fn test_old() {
2526
cmd: "iptables",
2627
has_wait: false,
2728
has_check: false,
29+
is_numeric: false,
2830
},
2931
"FILTEROLD",
3032
);

0 commit comments

Comments
 (0)