Skip to content

Commit 9e06680

Browse files
committed
feat: Apply iptable rules on startup
1 parent 59b5cad commit 9e06680

4 files changed

Lines changed: 22 additions & 2 deletions

File tree

.github/workflows/release.yml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,9 @@ jobs:
8787
needs: [build]
8888
runs-on: ubuntu-latest
8989
steps:
90+
- name: Checkout Code
91+
uses: actions/checkout@v6
92+
9093
- name: Download All Artifacts
9194
uses: actions/download-artifact@v5
9295
with:
@@ -98,4 +101,6 @@ jobs:
98101
with:
99102
draft: true
100103
prerelease: ${{ contains(github.ref, 'rc') || contains(github.ref, 'beta') || contains(github.ref, 'alpha') }}
101-
files: release-assets/*
104+
files: |
105+
release-assets/*
106+
ubitix.service

src/gateway/mod.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,7 @@ impl Gateway {
137137

138138
let file = self.configuration.file.clone();
139139

140+
info!("Starting file watcher...");
140141
select! {
141142
_ = signal::ctrl_c() => {
142143

@@ -149,6 +150,7 @@ impl Gateway {
149150
}
150151
}
151152

153+
info!("Starting cleanup...");
152154
IPTableRules::delete_all_rules(&self.iptables, &self.state.mapping).await;
153155
Ok(())
154156
}

src/main.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@ async fn main() -> Result<()> {
3434
if cli.gateway {
3535
let gateway = Gateway::load().await?;
3636
info!("Startup finished!");
37-
info!("Starting file watcher...");
3837
gateway.run().await
3938
} else if cli.action {
4039
let action = Action::load().await?;

ubitix.service

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
[Unit]
2+
Description=A tool that automatically detects IPv6 prefix changes and updates iptables NAT rules, and triggers a GitHub Actions workflow.
3+
After=network-online.target
4+
Wants=network-online.target
5+
6+
[Service]
7+
User=root
8+
ExecStart=/usr/local/bin/ubitix --gateway
9+
KillSignal=SIGINT
10+
Restart=always
11+
RestartSec=5
12+
13+
[Install]
14+
WantedBy=multi-user.target

0 commit comments

Comments
 (0)