Skip to content

Commit

Permalink
add ip_bound_if for macos & github build
Browse files Browse the repository at this point in the history
  • Loading branch information
leshow committed Mar 28, 2023
1 parent 2255a03 commit d8aa781
Show file tree
Hide file tree
Showing 6 changed files with 211 additions and 9 deletions.
129 changes: 129 additions & 0 deletions .github/workflows/actions.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,129 @@
# Based on https://github.com/actions-rs/meta/blob/master/recipes/msrv.md

on: [push, pull_request]

name: Actions

jobs:
check:
name: Check
runs-on: ubuntu-latest
strategy:
matrix:
rust:
- stable
- beta
- nightly
steps:
- name: Checkout sources
uses: actions/checkout@v2

- name: Install toolchain
uses: actions-rs/toolchain@v1
with:
toolchain: ${{ matrix.rust }}
override: true

- name: Run cargo check
uses: actions-rs/cargo@v1
with:
command: check
args: --all-features

check-mac:
name: Check MacOS
runs-on: macos-latest
strategy:
matrix:
rust:
- stable
steps:
- name: Checkout sources
uses: actions/checkout@v2

- name: Install toolchain
uses: actions-rs/toolchain@v1
with:
toolchain: ${{ matrix.rust }}
override: true

- name: Run cargo check
uses: actions-rs/cargo@v1
with:
command: check
args: --all-features

test:
name: Test Suite
runs-on: ubuntu-latest
strategy:
matrix:
rust:
- stable
steps:
- name: Checkout sources
uses: actions/checkout@v2

- name: Install toolchain
uses: actions-rs/toolchain@v1
with:
toolchain: ${{ matrix.rust }}
override: true

- name: Run cargo test
uses: actions-rs/cargo@v1
with:
command: test
args: --all-features

fmt:
name: Rustfmt
runs-on: ubuntu-latest
strategy:
matrix:
rust:
- stable
steps:
- name: Checkout sources
uses: actions/checkout@v2

- name: Install toolchain
uses: actions-rs/toolchain@v1
with:
toolchain: ${{ matrix.rust }}
override: true

- name: Install rustfmt
run: rustup component add rustfmt

- name: Run cargo fmt
uses: actions-rs/cargo@v1
with:
command: fmt
args: --all -- --check

clippy:
name: Clippy
runs-on: ubuntu-latest
strategy:
matrix:
rust:
- stable
steps:
- name: Checkout sources
uses: actions/checkout@v2

- name: Install toolchain
uses: actions-rs/toolchain@v1
with:
toolchain: ${{ matrix.rust }}
override: true

- name: Install clippy
run: rustup component add clippy

- name: Run cargo clippy
uses: actions-rs/cargo@v1
with:
command: clippy
args: -- -D warnings
1 change: 1 addition & 0 deletions .rust-toolchain
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
1.68.1
79 changes: 73 additions & 6 deletions 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 = "dhcpm"
version = "0.2.2"
version = "0.2.3"
edition = "2021"
authors = ["Evan Cameron <cameron.evan@gmail.com"]
description = """
Expand All @@ -24,8 +24,9 @@ tracing-subscriber = { version = "0.3.14", features = ["env-filter","json"] }
rand = "0.8"
hex = "0.4"
rhai = { version = "1.5.0", optional = true }
socket2 = { version = "0.4.4", features = ["all"] }
socket2 = { version = "0.5", features = ["all"] }
pnet_datalink = "0.31.0"
libc = "0.2.140"
# rhai-rand = { version = "0.1", optional = true }

[features]
Expand Down
5 changes: 5 additions & 0 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -118,9 +118,14 @@ fn main() -> Result<()> {

match interface {
Some(int) => {
#[cfg(any(target_os = "android", target_os = "fuchsia", target_os = "linux"))]
socket
.bind_device(Some(int.name.as_bytes()))
.context("SO_BINDTODEVICE failed")?;
#[cfg(target_vendor = "apple")]
socket
.bind_device_by_index(Some(libc::if_nametoindex(int.name.as_bytes())))
.context("IP_BOUND_IF")?;
if bind_addr.is_ipv6() && bind_addr.ip() == V6_MULTICAST {
socket
.join_multicast_v6(&V6_MULTICAST, int.index)
Expand Down
1 change: 0 additions & 1 deletion src/runner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,6 @@ impl TimeoutRunner {
MsgType::Dora(_) => panic!("should be removed in main"),
// dhcpv6
MsgType::InformationReq(args) => Msg::V6(args.build()),
_ => panic!("unimplemented"),
};
trace!("send");
self.send_tx.send((msg, target, broadcast))?;
Expand Down

0 comments on commit d8aa781

Please sign in to comment.