Documentation ¶
Index ¶
- Constants
- Variables
- func Cpu() (used float64, numOfCore int)
- func Disk() (used float64, total int)
- func FindDeviceNameByIp(ip string) string
- func GetCurrentExecutePath() (string, error)
- func GetCurrentUserHomeDir() string
- func IKEUserCount() int
- func IsIpForwardOn() bool
- func Memory() (used float64, total int)
- func MustIsRoot() bool
- func MustIsRootOnCmd()
- func MustSetCurrentMaxFileNum(limit uint64)
- func MustSetIptableRule(rule IptableRule)
- func NetworkConnection() (connectionCount int)
- func NetworkRXTX(deviceName string) (rx int, tx int)
- func RecoverPath()
- func SetCurrentMaxFileNum(limit uint64) (err error)
- func SetIpForwardOn()
- func SetP2PIpAndUp(req SetP2PIpRequest) error
- func SyncTime()
- func UsagePreInstall()
- type DeviceType
- type IptableRule
- type RouteRule
- type SetP2PIpRequest
- type TunTapInterface
Constants ¶
View Source
const MaxMaxFileNum = 1048576
经过多次尝试,发现这个值只能设置到 1048576
Variables ¶
View Source
var ErrAllDeviceBusy = errors.New("tun/tap: all dev is busy.")
View Source
var ErrPlatformNotSupport = errors.New("Platform Not Support")
Functions ¶
func GetCurrentExecutePath ¶
func GetCurrentUserHomeDir ¶
func GetCurrentUserHomeDir() string
func IKEUserCount ¶
func IKEUserCount() int
func IsIpForwardOn ¶
func IsIpForwardOn() bool
func MustIsRootOnCmd ¶
func MustIsRootOnCmd()
func MustSetCurrentMaxFileNum ¶
func MustSetCurrentMaxFileNum(limit uint64)
func MustSetIptableRule ¶
func MustSetIptableRule(rule IptableRule)
func NetworkConnection ¶
func NetworkConnection() (connectionCount int)
func SetCurrentMaxFileNum ¶
func SetP2PIpAndUp ¶
func SetP2PIpAndUp(req SetP2PIpRequest) error
set tun p2p ip and up this device mtu default to 1500
func UsagePreInstall ¶
func UsagePreInstall()
Types ¶
type DeviceType ¶
type DeviceType string
var DeviceTypeTap DeviceType = "tap"
var DeviceTypeTun DeviceType = "tun"
func (DeviceType) String ¶
func (s DeviceType) String() string
type IptableRule ¶
type IptableRule struct { Table string // example: "nat" Rule string // example: "-A PREROUTING -s 172.20.0.0/16 -p udp -m udp --dport 53 -j REDIRECT --to-ports 53" }
func MustGetIptableRuleList ¶
func MustGetIptableRuleList() []IptableRule
type SetP2PIpRequest ¶
type TunTapInterface ¶
type TunTapInterface interface { io.ReadWriteCloser GetDeviceType() DeviceType Name() string }
Interface is a TUN/TAP interface.
func NewTap ¶
func NewTap(ifName string) (ifce TunTapInterface, err error)
Create a new TAP interface whose name is ifName. If ifName is empty, a default name (tap0, tap1, ... ) will be assigned. ifName should not exceed 16 bytes.
func NewTun ¶
func NewTun(ifName string) (ifce TunTapInterface, err error)
Create a new TUN interface whose name is ifName. If ifName is empty, a default name (tap0, tap1, ... ) will be assigned. ifName should not exceed 16 bytes.
func NewTunNoName ¶
func NewTunNoName() (ifce TunTapInterface, err error)
Click to show internal directories.
Click to hide internal directories.