UniversalTunTapDriver is a lightweight library which allows you to control TUN/TAP devices on your windows or linux machine easily.
released in Feb 10, 2023
- Add bad handle detection
- Fix bug: asynchronous I/O can not been used on linux
- Simplify device initialization
- More detailed readme doc
released in Aug 21, 2021
- Add TunIOManager to organize the I/O operation of a TUN device
- Fix some bugs
- Support asynchronous I/O on linux platform
released in Jan 19, 2021
- Update form TunTapDriver-windows* project
- Add support for linux platform
- Fix some bugs
released in Sep 30, 2020
- Upload document and test project
- Fix some bugs
released in Aug 22, 2020
- Upload code
- Open source under MPL2.0 License
*This project is TunTapDriver-windows before Jan 19, 2021. TunTapDriver-windows only support to control TUN/TAP device under windows platform. All the features in the previous are included in UniversalTunTapDriver project.
- Fix some bugs when running on linux platform
- Finish the UNFINISHED code
- Develop and test the control abality of TAP devices on windows and linux platform.
- Open source under MPL2.0 License
- Support to control TUN devices on linux platform
- Support to control TUN devices on windows platform
git clone https://github.com/HBSnail/UniversalTunTapDriver.git
This process should be done by yourself.
This process should be done by yourself.
// The following code only works on windows
// On linux please use "ip" and "ifconfig" in the terminal for createing and enumerating all network interfaces
// ip tuntap add dev tun0 mode tun
// On windows you MUST install 'TAP-Windows Adapter V9' before execute the code
List<TunTapDeviceInfo> DeviceList = GetTapGuidList("tap0901");
//TunTapDeviceInfo is a kind of structure defined as follow
/*
public struct TunTapDeviceInfo
{
public string Name;
public string Guid;
public TunTapDeviceInfo(string n, string g)
{
Name = n;
Guid = g;
}
}
*/
// On linux please set the dInfo to tun name. like "tun0" "tap0" ect.
// On windows please set the dInfo to tun guid. like "{xxxxx-xxxxx-xxxx}".
String dInfo;
TunTapDevice Device = New TunTapDevice(dInfo);
// After this you will successfully create and initial a TUN/TAP device except the name or guid does not exist or the divice was occupied by other process.
// The following code only works on windows
// On linux please use "ifconfig" or "ip" in the terminal.
// ifconfig tun0 x.x.x.x netmask x.x.x.x up
//
Device.ConfigTun(IPAddress.Parse("LOC_IP"), IPAddress.Parse("REM_IP"), IPAddress.Parse("NET_MASK"));
Device.SetConnectionState(ConnectionStatus.Connected);
Device.CreateDeviceIOStream(1500);
FileStream DeviceIOStream = Device.TunTapDeviceIOStream;
This process should be done by yourself.
Thanks!
Auther: HBSnail
Feb 10, 2023