bin+lib ift

A library to read template strings for local network interfaces

10 unstable releases (3 breaking)

✓ Uses Rust 2018 edition

0.3.2 Mar 28, 2019
0.3.1 Jan 22, 2019
0.2.3 Jan 16, 2019
0.1.0 Jan 8, 2019
0.0.2-alpha.1 Jan 8, 2019

#21 in Template engine

Download history 44/week @ 2019-01-17 26/week @ 2019-01-24 5/week @ 2019-01-31 7/week @ 2019-02-07 8/week @ 2019-02-14 3/week @ 2019-02-21 23/week @ 2019-02-28 3/week @ 2019-03-07 11/week @ 2019-03-14 178/week @ 2019-03-21 16/week @ 2019-03-28 14/week @ 2019-04-04 4/week @ 2019-04-11 31/week @ 2019-04-25

119 downloads per month

MIT license

41KB
854 lines

Build Status Ift Version

IFT (interface templates)

Template strings to extract the correct interface and IpAddr to bind to. Heavily inspired by https://github.com/hashicorp/go-sockaddr

What is it?

eval(docs) takes an interface template string. The template is a string that starts with a producer and is followed by filters and sorts each of which is pipe | delimited. eval returns a vector of IpAddr objects that can then be used as bindings

Usage

general

use ift::eval;
print!("{:?}", eval(r#"GetInterface "en0""#).unwrap());

actix

use actix_web::{
   server,
   App,
};
let mut s = server::new(|| { App::new() });
for ip in ift::eval("GetPrivateInterfaces").unwrap().into_iter() {
  s = s.bind((ip, 8080)).unwrap();
}

Example Templates

  • get private interfaces GetAllInterfaces | FilterFlags "up" | FilterForwardable | SortBy "default"
  • get private interfaces short GetPrivateInterfaces
  • get specific interface by name GetInterface "en0"
  • get only interfaces with ipv6 addresses GetAllInterfaces | FilterIPv6

Example Code

There are examples in the examples folder.

  • actix - bind multiple private interfaces

developing

To regenerate the RFC code

make gen

To Update README

make update

To Release

You can use the cargo release command.

cargo release patch

License: MIT

Dependencies

~5.5MB
~105K SLoC