Merge pull request #12 from TNkemdilim/develop
Chore(CI): Setup Build for Supported OS
This commit is contained in:
+23
@@ -0,0 +1,23 @@
|
||||
language: rust
|
||||
|
||||
os:
|
||||
- linux
|
||||
- osx
|
||||
- windows
|
||||
|
||||
rust:
|
||||
- nightly
|
||||
- beta
|
||||
- stable
|
||||
|
||||
matrix:
|
||||
allow_failures:
|
||||
- rust: nightly
|
||||
|
||||
script:
|
||||
- cargo build
|
||||
- cargo test
|
||||
|
||||
notifications:
|
||||
email:
|
||||
on_success: never
|
||||
@@ -1,6 +1,7 @@
|
||||
[package]
|
||||
name = "wifi-rs"
|
||||
version = "0.2.2"
|
||||
edition = "2018"
|
||||
authors = ["Tochukwu Nkemdilim <nkemdilimtochukwu@gmail.com>"]
|
||||
description = "Interface with and manage Wireless Network (WiFi)"
|
||||
license = "MIT"
|
||||
|
||||
@@ -25,9 +25,7 @@ Note that only **open**, **WEP** and **WPA-PSK** networks are supported at the m
|
||||
## Example
|
||||
|
||||
```Rust
|
||||
extern crate wifi_rs;
|
||||
use wifi_rs::prelude::*;
|
||||
use wifi_rs::{WiFi, Config};
|
||||
use wifi_rs::{prelude::*, Wifi};
|
||||
|
||||
fn main() -> Result<(), WifiConnectionError> {
|
||||
let config = Some(Config {
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
[package]
|
||||
name = "wifi-connect"
|
||||
version = "0.1.0"
|
||||
edition = "2018"
|
||||
authors = ["Tochukwu Nkemdilim <nkemdilimtochukwu@gmail.com>"]
|
||||
|
||||
[dependencies]
|
||||
wifi-rs = { path = "../../../wifi-rs" }
|
||||
@@ -0,0 +1,15 @@
|
||||
use std::io;
|
||||
use wifi_rs::{prelude::*, WiFi};
|
||||
|
||||
fn main() -> Result<(), io::Error> {
|
||||
let config = Some(Config {
|
||||
interface: Some("wlo1"),
|
||||
});
|
||||
|
||||
let mut wifi = WiFi::new(config);
|
||||
let config = HotspotConfig::new(Some(HotspotBand::Bg), Some(Channel::One));
|
||||
|
||||
wifi.create_hotspot("test-hotspot", "password", Some(&config));
|
||||
|
||||
Ok(())
|
||||
}
|
||||
@@ -1,6 +1,7 @@
|
||||
[package]
|
||||
name = "wifi-cli"
|
||||
version = "0.1.0"
|
||||
edition = "2018"
|
||||
authors = ["Tochukwu Nkemdilim <nkemdilimtochukwu@gmail.com>"]
|
||||
|
||||
[dependencies]
|
||||
|
||||
@@ -1,8 +1,6 @@
|
||||
extern crate clap;
|
||||
extern crate wifi_rs;
|
||||
|
||||
use clap::{App, Arg};
|
||||
use std::io;
|
||||
use wifi_rs::prelude::*;
|
||||
use wifi_rs::WiFi;
|
||||
|
||||
fn main() -> Result<(), io::Error> {
|
||||
@@ -48,8 +46,13 @@ fn main() -> Result<(), io::Error> {
|
||||
// Get Wireless Interface
|
||||
let interface = matches.value_of("interface").unwrap();
|
||||
|
||||
let wifi = WiFi::new(ssid)?;
|
||||
println!("Connection Status: {}", wifi.connect(password));
|
||||
let config = Some(Config {
|
||||
interface: Some(interface),
|
||||
});
|
||||
|
||||
// let wifi = WiFi::new(ssid)?;
|
||||
let mut wifi = WiFi::new(config);
|
||||
println!("Connection Status: {:?}", wifi.connect(ssid, password));
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
@@ -1,8 +1,6 @@
|
||||
extern crate tempfile;
|
||||
|
||||
use self::tempfile::NamedTempFile;
|
||||
use connectivity::stubs::windows_wifi_profile;
|
||||
use crate::connectivity::stubs::windows_wifi_profile;
|
||||
use std::{io, io::Write};
|
||||
use tempfile::NamedTempFile;
|
||||
|
||||
/// A netowork XML handler for windows, responsible creating
|
||||
/// disposable xml profiles files.
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
use connectivity::{Connectivity, WifiConnectionError};
|
||||
use platforms::{Connection, WiFi, WifiError, WifiInterface};
|
||||
use crate::{
|
||||
connectivity::{Connectivity, WifiConnectionError},
|
||||
platforms::{Connection, WiFi, WifiError, WifiInterface},
|
||||
};
|
||||
use std::process::Command;
|
||||
|
||||
/// Wireless network connectivity functionality.
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
use connectivity::handlers::NetworkXmlProfileHandler;
|
||||
use connectivity::{Connectivity, WifiConnectionError};
|
||||
use platforms::{Connection, WiFi, WifiError, WifiInterface};
|
||||
use crate::{
|
||||
connectivity::{handlers::NetworkXmlProfileHandler, Connectivity, WifiConnectionError},
|
||||
platforms::{Connection, WiFi, WifiError, WifiInterface},
|
||||
};
|
||||
use std::process::Command;
|
||||
|
||||
impl WiFi {
|
||||
@@ -42,11 +43,7 @@ impl Connectivity for WiFi {
|
||||
Self::add_profile(ssid, password)?;
|
||||
|
||||
let output = Command::new("netsh")
|
||||
.args(&[
|
||||
"wlan",
|
||||
"connect",
|
||||
&format!("name={}", ssid),
|
||||
])
|
||||
.args(&["wlan", "connect", &format!("name={}", ssid)])
|
||||
.output()
|
||||
.map_err(|err| WifiConnectionError::FailedToConnect(format!("{}", err)))?;
|
||||
|
||||
|
||||
+1
-2
@@ -1,4 +1,4 @@
|
||||
mod providers;
|
||||
pub mod providers;
|
||||
|
||||
use self::providers::prelude::HotspotConfig;
|
||||
use crate::platforms::{WifiError, WifiInterface};
|
||||
@@ -44,7 +44,6 @@ pub trait WifiHotspot: fmt::Debug + WifiInterface {
|
||||
}
|
||||
|
||||
/// Stop serving a wireless network.
|
||||
///
|
||||
/// **NOTE: All users connected will automatically be disconnected.**
|
||||
fn stop_hotspot(&mut self) -> Result<bool, WifiHotspotError> {
|
||||
unimplemented!();
|
||||
|
||||
@@ -16,6 +16,14 @@ pub struct HotspotConfig {
|
||||
channel: Option<Channel>,
|
||||
}
|
||||
|
||||
/// function to create a new config object
|
||||
#[allow(dead_code)]
|
||||
impl HotspotConfig {
|
||||
pub fn new(band: Option<HotspotBand>, channel: Option<Channel>) -> HotspotConfig {
|
||||
HotspotConfig { band, channel }
|
||||
}
|
||||
}
|
||||
|
||||
#[allow(dead_code)]
|
||||
#[derive(Debug)]
|
||||
/// Band type of wireless hotspot.
|
||||
@@ -58,9 +66,9 @@ impl WifiHotspot for WiFi {
|
||||
let mut command = vec![
|
||||
"device".to_string(),
|
||||
"wifi".to_string(),
|
||||
"hotspot".to_string(),
|
||||
"ifname".to_string(),
|
||||
self.interface.to_string(),
|
||||
"hotspot".to_string(),
|
||||
"con-name".to_string(),
|
||||
HOTSPOT_GROUP.to_string(),
|
||||
"ssid".to_string(),
|
||||
|
||||
@@ -1,9 +1,8 @@
|
||||
use hotspot::WifiHotspot;
|
||||
use platforms::WiFi;
|
||||
use crate::{hotspot::WifiHotspot, platforms::WiFi};
|
||||
|
||||
/// Configuration for a wireless hotspot.
|
||||
#[allow(dead_code)]
|
||||
pub struct HotspotConfig {}
|
||||
pub struct HotspotConfig;
|
||||
|
||||
/// Wireless hotspot functionality for a wifi interface.
|
||||
impl WifiHotspot for WiFi {}
|
||||
|
||||
@@ -1,9 +1,11 @@
|
||||
use hotspot::{WifiHotspot, WifiHotspotError};
|
||||
use platforms::{WiFi, WifiError, WifiInterface};
|
||||
use crate::{
|
||||
hotspot::{WifiHotspot, WifiHotspotError},
|
||||
platforms::{WiFi, WifiError, WifiInterface},
|
||||
};
|
||||
use std::process::Command;
|
||||
|
||||
/// Configuration for a wireless hotspot.
|
||||
pub struct HotspotConfig {}
|
||||
pub struct HotspotConfig;
|
||||
|
||||
impl WiFi {
|
||||
/// Attempts to turn on a wireless networ if down.
|
||||
|
||||
@@ -5,6 +5,7 @@ mod platforms;
|
||||
/// Pre-requisite module for `Connectivity`, `Hotspot` functionality.
|
||||
pub mod prelude {
|
||||
pub use crate::connectivity::*;
|
||||
pub use crate::hotspot::providers::prelude::*;
|
||||
pub use crate::hotspot::*;
|
||||
pub use crate::platforms::Config;
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
use platforms::{Config, WifiError, WifiInterface};
|
||||
use crate::platforms::{Config, WifiError, WifiInterface};
|
||||
use std::process::Command;
|
||||
|
||||
#[derive(Debug)]
|
||||
|
||||
@@ -1,6 +1,4 @@
|
||||
use platforms::Config;
|
||||
use platforms::WifiError;
|
||||
use platforms::WifiInterface;
|
||||
use crate::platforms::{Config, WifiError, WifiInterface};
|
||||
use std::process::Command;
|
||||
|
||||
const WINDOWS_INTERFACE: &'static str = "Wireless Network Connection";
|
||||
|
||||
+11
-19
@@ -1,25 +1,17 @@
|
||||
extern crate wifi_rs;
|
||||
use self::wifi_rs::{prelude::*, WiFi};
|
||||
fn fib(n: usize) -> u32 {
|
||||
let mut first = 1;
|
||||
let mut second = 1;
|
||||
|
||||
#[test]
|
||||
fn connect_to_wifi_failed() {
|
||||
let config = Some(Config {
|
||||
interface: Some("wlo1"),
|
||||
});
|
||||
for _ in 2..n {
|
||||
let temp = first;
|
||||
first = second;
|
||||
second += temp
|
||||
}
|
||||
|
||||
let mut wifi = WiFi::new(config);
|
||||
|
||||
assert_eq!(wifi.connect("ssid", "password").unwrap(), false);
|
||||
return second;
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn create_hotspot() {
|
||||
let config = Some(Config {
|
||||
interface: Some("wlo1"),
|
||||
});
|
||||
|
||||
let mut wifi = WiFi::new(config);
|
||||
let hotspot_created = wifi.create_hotspot("hello", "hi", None).unwrap();
|
||||
|
||||
assert_eq!(hotspot_created, true);
|
||||
fn basic() {
|
||||
assert_eq!(fib(10), 55);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user