tun

package
v1.2.5 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 28, 2022 License: MIT, GPL-3.0 Imports: 20 Imported by: 0

Documentation

Overview

Packages tun provides utilities for tun.

tun包提供 创建tun设备的方法,以及监听tun,将数据解析为tcp/udp数据的方法。

tun 工作在第三层 IP层上。

我们基本上抄了 xjasonlyu/tun2socks, 因此把GPL证书放在了本包的文件夹中

本来最好是直接import的,但是目前(22.12.18)tun2socks的最新代码还没有打tag,而老代码又不可用,所以只能先复制过来。

windows中, 需要从 https://www.wintun.net/ 下载 wintun.dll 放到vs可执行文件旁边

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Listen

func Listen(dev device.Device, tcpFunc func(netLayer.TCPRequestInfo), udpFunc func(netLayer.UDPRequestInfo)) (closer io.Closer, err error)

非阻塞

func Open

func Open(name string) (device.Device, error)

若name为空则会返回错误

Types

type StackCloser

type StackCloser struct {
	*stack.Stack
}

func (*StackCloser) Close

func (sc *StackCloser) Close() error

type UdpMsgConn

type UdpMsgConn struct {
	net.PacketConn
	RealTarget netLayer.Addr
	// contains filtered or unexported fields
}

Wraps net.PacketConn and implements MsgConn

func (*UdpMsgConn) Close

func (mc *UdpMsgConn) Close() error

func (*UdpMsgConn) CloseConnWithRaddr

func (mc *UdpMsgConn) CloseConnWithRaddr(raddr netLayer.Addr) error

func (*UdpMsgConn) Fullcone

func (mc *UdpMsgConn) Fullcone() bool

func (*UdpMsgConn) ReadMsg

func (mc *UdpMsgConn) ReadMsg() ([]byte, netLayer.Addr, error)

func (*UdpMsgConn) WriteMsg

func (mc *UdpMsgConn) WriteMsg(p []byte, peera netLayer.Addr) error

Directories

Path Synopsis
iobased
Package iobased provides the implementation of io.ReadWriter based data-link layer endpoints.
Package iobased provides the implementation of io.ReadWriter based data-link layer endpoints.
tun
Package tun provides TUN which implemented device.Device interface.
Package tun provides TUN which implemented device.Device interface.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL