Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use external stun-proto crate. #39

Merged
merged 2 commits into from
Jun 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 0 additions & 6 deletions .github/workflows/rust-fuzz.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,6 @@ jobs:
command: 'install'
args: 'cargo-fuzz'

- name: Run cargo-fuzz
uses: actions-rs/cargo@v1
with:
command: 'fuzz'
args: 'run stun_msg_from_bytes -- -max_total_time=20'

- name: Run cargo-fuzz
uses: actions-rs/cargo@v1
with:
Expand Down
5 changes: 3 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,11 @@ edition = "2021"
rust-version = "1.68.2"

[workspace.dependencies]
stun-proto = "0.0.1"
arbitrary = { version = "1", features = ["derive"] }
byteorder = "1"
get_if_addrs = "0.5"
rand = "0.8"
tracing = { version = "0.1", features = ["log"] }
tracing-subscriber = { version = "0.3", features = ["std", "env-filter"] }
tracing = "0.1"
tracing-subscriber = "0.3"

8 changes: 1 addition & 7 deletions fuzz/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,18 +13,12 @@ cargo-fuzz = true
arbitrary.workspace = true
libfuzzer-sys = "0.4"
tracing.workspace = true
tracing-subscriber.workspace = true
tracing-subscriber = { workspace = true, features = ["env-filter"] }

[dependencies.librice-proto]
path = "../librice-proto"
features = ["arbitrary"]

[[bin]]
name = "stun_msg_from_bytes"
path = "fuzz_targets/stun_msg_from_bytes.rs"
test = false
doc = false

[[bin]]
name = "parse_candidate"
path = "fuzz_targets/parse_candidate.rs"
Expand Down
36 changes: 0 additions & 36 deletions fuzz/fuzz_targets/stun_msg_from_bytes.rs

This file was deleted.

10 changes: 3 additions & 7 deletions librice-proto/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,26 +13,22 @@ rust-version.workspace = true
workspace = ".."

[features]
capi = ["libc", "socket2", "tracing-subscriber", "get_if_addrs"]
capi = ["libc", "socket2", "tracing-subscriber/env-filter", "get_if_addrs"]

[dependencies]
arbitrary = { workspace = true, optional = true }
byteorder.workspace = true
crc = "3"
get_if_addrs = { workspace = true, optional = true }
hmac = "0.12"
md-5 = "0.10"
nom = "7"
rand.workspace = true
sha-1 = "0.10"
sha2 = "0.10"
tracing.workspace = true
libc = { version = "0.2", optional = true }
socket2 = { version = "0.5", optional = true }
stun-proto.workspace = true
tracing-subscriber = { workspace = true, optional = true }

[dev-dependencies]
tracing-subscriber.workspace = true
tracing-subscriber = { workspace = true, features = ["env-filter"] }

[package.metadata.capi]
min_version = "0.9.21"
Expand Down
15 changes: 4 additions & 11 deletions librice-proto/src/agent.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ use crate::component::ComponentConnectionState;
use crate::candidate::{ParseCandidateError, TransportType};
use crate::conncheck::{CheckListSetPollRet, ConnCheckEvent, ConnCheckListSet, SelectedPair};
use crate::stream::{Stream, StreamMut, StreamState};
use crate::stun::agent::{StunError, Transmit};
use crate::stun::attribute::StunParseError;
use stun_proto::agent::{StunError, Transmit};
use stun_proto::types::message::StunParseError;
//use crate::turn::agent::TurnCredentials;

/// Errors that can be returned as a result of agent operations.
Expand All @@ -49,10 +49,9 @@ pub enum AgentError {
Aborted,
TimedOut,
StunParse,
StunWrite,
/// Parsing the candidate failed.
CandidateParse(ParseCandidateError),
/// An I/O error occurred.
IoError(std::io::Error),
/// Data was received that does not match the protocol specifications.
ProtocolViolation,
}
Expand All @@ -65,12 +64,6 @@ impl Display for AgentError {
}
}

impl From<std::io::Error> for AgentError {
fn from(e: std::io::Error) -> Self {
Self::IoError(e)
}
}

impl From<ParseCandidateError> for AgentError {
fn from(e: ParseCandidateError) -> Self {
Self::CandidateParse(e)
Expand All @@ -88,7 +81,7 @@ impl From<StunError> for AgentError {
StunError::IntegrityCheckFailed => AgentError::IntegrityCheckFailed,
StunError::ProtocolViolation => AgentError::ProtocolViolation,
StunError::ParseError(_) => AgentError::StunParse,
StunError::IoError(e) => AgentError::IoError(e),
StunError::WriteError(_) => AgentError::StunWrite,
StunError::Aborted => AgentError::Aborted,
StunError::AlreadyInProgress => AgentError::AlreadyInProgress,
}
Expand Down
4 changes: 2 additions & 2 deletions librice-proto/src/candidate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@

//! ICE Candidates

pub use crate::stun::TransportType;
pub use parse::ParseCandidateError;
pub use stun_proto::types::TransportType;

use std::error::Error;
use std::net::SocketAddr;
Expand Down Expand Up @@ -442,7 +442,7 @@ mod parse {

use super::{Candidate, CandidateType, ParseCandidateTypeError};
use super::{ParseTcpTypeError, TcpType};
use crate::stun::{ParseTransportTypeError, TransportType};
use stun_proto::types::{ParseTransportTypeError, TransportType};

/// Errors produced when parsing a candidate
#[derive(Debug)]
Expand Down
4 changes: 2 additions & 2 deletions librice-proto/src/capi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ use crate::candidate::{Candidate, CandidateType};
pub use crate::component::ComponentConnectionState;
use crate::gathering::GatherPoll;
use crate::stream::Credentials;
use crate::stun::agent::{Data, DataOwned, DataSlice, StunAgent, StunError, Transmit};
use crate::stun::TransportType;
use stun_proto::agent::{Data, DataOwned, DataSlice, StunAgent, StunError, Transmit};
use stun_proto::types::TransportType;

static TRACING: Once = Once::new();

Expand Down
Loading
Loading