Skip to content

Commit e0e1f5d

Browse files
committed
update dependencies
1 parent 75825cd commit e0e1f5d

4 files changed

Lines changed: 31 additions & 34 deletions

File tree

.github/workflows/build.yml

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,10 @@ jobs:
1010
linux:
1111
runs-on: ubuntu-latest
1212
steps:
13-
- uses: actions/checkout@v2
14-
- uses: actions-rs/toolchain@v1
13+
- uses: actions/checkout@v4
14+
- uses: actions-rust-lang/setup-rust-toolchain@v1
1515
with:
16-
toolchain: stable
1716
components: rustfmt, clippy
18-
- run: sudo -E `which cargo` test -j`nproc` -- --test-threads 1
19-
- run: sudo -E `which cargo` test -j`nproc` -- --ignored --test-threads 1
17+
- run: sudo -E `which cargo` test -- --test-threads 1
18+
- run: sudo -E `which cargo` test -- --ignored --test-threads 1
2019
- run: sudo -E `which cargo` fmt -- --check
21-
- run: sudo -E `which cargo` clippy -j`nproc`

.github/workflows/publish.yml

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
name: Publish to Crates.io
2+
on:
3+
push:
4+
tags:
5+
- 'v*'
6+
jobs:
7+
publish:
8+
runs-on: ubuntu-latest
9+
steps:
10+
- uses: actions/checkout@v4
11+
- uses: actions-rust-lang/setup-rust-toolchain@v1
12+
- run: cargo login ${{ secrets.CRATES_IO_TOKEN }}
13+
- run: cargo package
14+
- run: cargo publish
15+
release:
16+
runs-on: ubuntu-latest
17+
needs: [publish]
18+
permissions:
19+
contents: write
20+
packages: write
21+
steps:
22+
- uses: actions/checkout@v4
23+
- name: create release
24+
run: gh release create "${{ github.ref_name }}" -t "${{ github.ref_name }}"
25+
env:
26+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

Cargo.toml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,11 @@ license = "MIT"
1010
name = "iptables"
1111
readme = "README.md"
1212
repository = "https://github.com/yaa110/rust-iptables"
13-
version = "0.5.3"
13+
version = "0.6.0"
1414

1515
[lib]
1616
name = "iptables"
1717

1818
[dependencies]
1919
lazy_static = "1"
20-
nix = {version = "0.29", features = ["fs"]}
2120
regex = "1"

src/lib.rs

Lines changed: 0 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,10 @@ pub mod error;
1818

1919
use error::IptablesError;
2020
use lazy_static::lazy_static;
21-
use nix::fcntl::{FlockArg, flock};
2221
use regex::{Match, Regex};
2322
use std::convert::From;
2423
use std::error::Error;
2524
use std::ffi::OsStr;
26-
use std::fs::File;
27-
use std::os::unix::io::AsRawFd;
2825
use std::process::{Command, Output};
2926
use std::vec::Vec;
3027

@@ -407,38 +404,15 @@ impl IPTables {
407404
}
408405

409406
fn run<S: AsRef<OsStr>>(&self, args: &[S]) -> Result<Output, Box<dyn Error>> {
410-
let mut file_lock = None;
411-
412407
let mut output_cmd = Command::new(self.cmd);
413408
let output;
414409

415410
if self.has_wait {
416411
output = output_cmd.args(args).arg("--wait").output()?;
417412
} else {
418-
file_lock = Some(File::create("/var/run/xtables_old.lock")?);
419-
420-
let mut need_retry = true;
421-
while need_retry {
422-
match flock(
423-
file_lock.as_ref().unwrap().as_raw_fd(),
424-
FlockArg::LockExclusiveNonblock,
425-
) {
426-
Ok(_) => need_retry = false,
427-
Err(e) if e == nix::errno::Errno::EAGAIN => {
428-
// FIXME: may cause infinite loop
429-
need_retry = true;
430-
}
431-
Err(e) => {
432-
return Err(Box::new(e));
433-
}
434-
}
435-
}
436413
output = output_cmd.args(args).output()?;
437414
}
438415

439-
if let Some(f) = file_lock {
440-
drop(f)
441-
}
442416
Ok(output)
443417
}
444418
}

0 commit comments

Comments
 (0)