gotun

package module
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Jun 19, 2023 License: MIT Imports: 7 Imported by: 0

README

GOTUN

TUN devices are a type of virtual network device that allow programs to easily simulate network behavior. TUN simulates a three-layer device, and allows for the processing of data from the network layer. GOTUN provides a cross-platform TUN device interface for processing IP datagrams on different platforms.

License

Copyright (c) 2023 BitLinkX All Rights Reserved.

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

Documentation

Index

Constants

View Source
const (
	TUNNoPersist = 0 // 清除持久标志
)

Variables

This section is empty.

Functions

This section is empty.

Types

type C_Sockaddr

type C_Sockaddr struct {
	Family uint16 /* address family, AF_xxx   */
	Pad    uint16
	Data   [12]byte /* 14 bytes of protocol address */
}

type GoTunDevice added in v0.0.2

type GoTunDevice interface {
	Open() error
	Close() error
	AddRoute(ip []byte, mask uint8) error
	DelRoute(ip []byte, mask uint8) error
	Read() ([]byte, error)
	Wirte(pack []byte) (int, error)
}

func NewDevice added in v0.0.2

func NewDevice(name string, address [4]byte, mtu int) (GoTunDevice, error)

type Rtentry

type Rtentry struct {
	Pad1    uint64
	Dst     C_Sockaddr /* target address       */
	Gateway C_Sockaddr /* gateway addr (RTF_GATEWAY)   */
	Genmask C_Sockaddr /* target network mask (IP) */
	Flags   uint16
	Pad2    int16
	Pad0    [4]byte
	Pad3    uint64
	Tos     uint8
	Class   uint8
	Pad4    [3]int16
	Metric  int16  /* +1 for binary compatibility! */
	Dev     *byte  /* forcing the device at add    */
	Mtu     uint32 /* per route MTU/Window     */
	Window  uint32 /* Window clamping      */
	Irtt    uint16 /* Initial RTT          */
}

Jump to

Keyboard shortcuts

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