jksys

package
v0.0.0-...-a9e9222 Latest Latest
Warning

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

Go to latest
Published: Jan 6, 2022 License: GPL-3.0 Imports: 13 Imported by: 0

Documentation

Overview

Author: jmdvirus@roamter.com

System operation

Author: jmdvirus@roamter.com

System information

Index

Constants

View Source
const (
	TotalName = "Total"
	FreeName  = "Free"
)

Someday this name will get from file with different location

Variables

View Source
var LocalMac string
View Source
var Localaddr string

Functions

func FilterDomainOfIptables

func FilterDomainOfIptables(domain string) error

func FilterDomainRemove

func FilterDomainRemove(domain string) error

func IfDomainValid

func IfDomainValid(domain string) bool

func KFIPAddress

func KFIPAddress() string

Return ip address

func KFIPAddressName

func KFIPAddressName(inter string) (string, error)

func KFLocalMac

func KFLocalMac() (string, error)

func KFMacAddress

func KFMacAddress() string

Return mac address with upper chars of the first not lo one.

func KFParseTrafficFromString

func KFParseTrafficFromString(trafficstr, port string) (int64, int64)

first return is input traffic, second return is output traffic

func KFPortTraffic

func KFPortTraffic(port string) (int64, int64)

Caculate the traffic.

func KFPortTrafficRouter

func KFPortTrafficRouter(port string) (int64, int64)

func KFReadAllData

func KFReadAllData(filename string) []byte

func KFServerConfig

func KFServerConfig(str string) error

copy back of shadowsocks.json and restart shadowsocks.

func KFSetFireWall

func KFSetFireWall(ports []string) bool

Reset firewall with @ports

func KFSetFireWallRouter

func KFSetFireWallRouter(ports []string, dstip string, srcport, dstport int, interf string) bool

Reset firewall with @ports Set Router mode sysctl net.ipv4.ip_forward=1 iptables -A FORWARD -d 133.130.97.109 -i eth1 -p tcp -m tcp --dport 8989 -j ACCEPT iptables -A FORWARD -d 133.130.97.109 -i eth1 -p udp -m udp --dport 8989 -j ACCEPT iptables -t nat -A PREROUTING -p tcp -m tcp --dport 8989 -j DNAT --to-destination 133.130.97.109:8989 iptables -t nat -A PREROUTING -p udp -m udp --dport 8989 -j DNAT --to-destination 133.130.97.109:8989 iptables -t nat -A POSTROUTING -o eth1 -j MASQUERADE

dstip: forward to srcport: data from the port dstport: forward to port interf: check data for the interface (eth0,eth1)

func KFStopFirewall

func KFStopFirewall()

func SysFilterDomainDiff

func SysFilterDomainDiff(filename string, data []string) bool

func SysFilterDomainFromFiles

func SysFilterDomainFromFiles(filename string) error

func SysFilterDomainWriteToFile

func SysFilterDomainWriteToFile(filename string, data []string) error

func SysProgramRunning

func SysProgramRunning(runshell, progName string) bool

func SysRestartProgram

func SysRestartProgram(progName, args string) bool

func SystemRun

func SystemRun(command string, args string) bool

func SystemRunNew

func SystemRunNew(command string, args ...string) bool

func SystemRunReturn

func SystemRunReturn(command string, args string) string

func SystemRunWithReturn

func SystemRunWithReturn(command string, args ...string) string

Types

type KFSystemInfo

type KFSystemInfo struct {
	Kernel   string
	Core     string
	Platform string
	Hostname string
	CPUs     int

	OSName   string
	IPAddr   string
	Mac      string
	TotalRam uint64
	FreeRam  uint64

	TotalDisk uint64
	FreeDisk  uint64

	CPUUsage float64
}

func NewSystemInfo

func NewSystemInfo() *KFSystemInfo

func (*KFSystemInfo) KFCPUInfo

func (si *KFSystemInfo) KFCPUInfo() float64

Return cpu percentage

func (*KFSystemInfo) KFCPUToString

func (si *KFSystemInfo) KFCPUToString() string

func (*KFSystemInfo) KFDiskInfo

func (si *KFSystemInfo) KFDiskInfo() (uint64, uint64)

Get Disk info Return Total,Free

func (*KFSystemInfo) KFDiskString

func (si *KFSystemInfo) KFDiskString() string

func (*KFSystemInfo) KFDiskStringM

func (si *KFSystemInfo) KFDiskStringM() string

func (*KFSystemInfo) KFMemInfo

func (si *KFSystemInfo) KFMemInfo() (uint64, uint64)

func (*KFSystemInfo) KFSysBase

func (si *KFSystemInfo) KFSysBase() error

func (*KFSystemInfo) MemToString

func (si *KFSystemInfo) MemToString() string

func (*KFSystemInfo) MemToStringM

func (si *KFSystemInfo) MemToStringM() string

type ProcessCPU

type ProcessCPU struct {
	// contains filtered or unexported fields
}

Get CPU info

Jump to

Keyboard shortcuts

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