Documentation
¶
Index ¶
- Constants
- Variables
- type GalangNMAP
- type GalangNet
- func (*GalangNet) GetCIDRAvailableAddrList(cidr string) ([]string, error)
- func (*GalangNet) GetExternalIP() (string, error)
- func (*GalangNet) GetLocalIPv4() (string, error)
- func (*GalangNet) GetRangeAddrList(_range string) ([]string, error)
- func (*GalangNet) GetSystemUUIDForLinux() (string, error)
- func (*GalangNet) IP2long(ipstr string) (uint32, error)
- func (*GalangNet) IPSFormat(target string) ([]string, error)
- func (*GalangNet) IsRangeOf(addr, cidr string) (bool, error)
- func (n *GalangNet) LPM(ip string, subnets []string) (string, error)
- func (*GalangNet) Long2ip(ip uint32) string
- func (*GalangNet) MaskLengthToNetmask(cidr int) (string, error)
- func (*GalangNet) NetmaskToMaskLength(netmask string) (int, error)
- type GalangSNMP
- type Host
- type HostResult
- type Interface
- type InterfaceStatus
- type SNMPWrapper
- type Scanner
- type ScannerStatus
- type SubnetInfo
- func (sub *SubnetInfo) AddressString() string
- func (sub *SubnetInfo) BradcastString() string
- func (sub *SubnetInfo) GetCidrSignature() string
- func (sub *SubnetInfo) HighAddress() string
- func (sub *SubnetInfo) IsRangeOf(addr string) (bool, error)
- func (sub *SubnetInfo) LowAddress() string
- func (sub *SubnetInfo) NetmaskString() string
- func (sub *SubnetInfo) NetworkString() string
- func (sub *SubnetInfo) Size() uint32
- func (s *SubnetInfo) ToString() string
- type System
Constants ¶
const ( IP_REG = `^(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)(\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)){3}$` CIDR_REG = `` /* 130-byte string literal not displayed */ FULL_CIDR_REG = `` /* 212-byte string literal not displayed */ RANGE_REG = `` /* 212-byte string literal not displayed */ )
const INTERFACE_IP_LIST_OID = `.1.3.6.1.2.1.4.20.1.2`
Variables ¶
var ( Network GalangNet SNMP GalangSNMP NMAP GalangNMAP )
var InterfaceStatus_name = map[int32]string{
1: "UP",
2: "DOWN",
3: "Testing",
4: "Unknown",
5: "Dormant",
6: "NotPresent",
}
var InterfaceStatus_value = map[string]int32{
"UP": 1,
"DOWN": 2,
"Testing": 3,
"Unknown": 4,
"Dormant": 5,
"NotPresent": 6,
}
var ScannerStatus_name = map[int32]string{
1: "Created",
2: "Pending",
3: "Running",
4: "Success",
5: "Error",
}
var ScannerStatus_value = map[string]int32{
"Created": 1,
"Pending": 2,
"Running": 3,
"Success": 4,
"Error": 5,
}
var System_obj = map[string]string{
".1.3.6.1.2.1.1.1.0": "sysDescr",
".1.3.6.1.2.1.1.2.0": "sysObjectID",
".1.3.6.1.2.1.1.3.0": "sysUpTime",
".1.3.6.1.2.1.1.4.0": "sysContact",
".1.3.6.1.2.1.1.5.0": "sysName",
".1.3.6.1.2.1.1.6.0": "sysLocation",
}
var System_oid = map[string]string{
"sysDescr": ".1.3.6.1.2.1.1.1.0",
"sysObjectID": ".1.3.6.1.2.1.1.2.0",
"sysUpTime": ".1.3.6.1.2.1.1.3.0",
"sysContact": ".1.3.6.1.2.1.1.4.0",
"sysName": ".1.3.6.1.2.1.1.5.0",
"sysLocation": ".1.3.6.1.2.1.1.6.0",
}
var System_oids = []string{System_oid[`sysDescr`], System_oid[`sysObjectID`], System_oid[`sysUpTime`], System_oid[`sysContact`], System_oid[`sysName`], System_oid[`sysLocation`]}
Functions ¶
This section is empty.
Types ¶
type GalangNMAP ¶
type GalangNMAP byte
func (*GalangNMAP) NewScanner ¶
func (*GalangNMAP) NewScanner(target, user string) (*Scanner, error)
NewScanner 新建一个扫描器
type GalangNet ¶
type GalangNet byte
func (*GalangNet) GetCIDRAvailableAddrList ¶
GetCIDRAvailableAddrList retrun available ip address list
func (*GalangNet) GetExternalIP ¶
GetExternalIP 获取公网IP地址
func (*GalangNet) GetLocalIPv4 ¶
GetLocalIPv4 获取本机ipv4地址
func (*GalangNet) GetRangeAddrList ¶
GetRangeAddrList 获取一个范围里的ip地址 192.168.1.222-192.168.1.228
func (*GalangNet) GetSystemUUIDForLinux ¶
GetSystemUUIDForLinux get linux dmidecode -s system-uuid
func (*GalangNet) IPSFormat ¶
GetIPSFormat will format target string to a valid string array if target is a ip like 192.168.1.222 will format ['192.168.1.222'] if target is a range of ip like 192.168.1.222[-||~]192.168.1.224 will format ['192.168.1.222','192.168.1.223','192.168.1.224']
func (*GalangNet) MaskLengthToNetmask ¶
MaskLengthToNetmask 24 >>> 255.255.255.0
type GalangSNMP ¶
type GalangSNMP byte
func (*GalangSNMP) NewSnmpWrapper ¶
func (*GalangSNMP) NewSnmpWrapper(target, community string, version gosnmp.SnmpVersion, timeout int64) (*SNMPWrapper, error)
type HostResult ¶
type Interface ¶
type Interface struct {
Name string `json:"name,omitempty"`
MacAddress string `json:"mac_addr,omitempty"`
IPv4 string `json:"ip,omitempty"`
NetMask string `json:"netmask,omitempty"`
Status InterfaceStatus `json:"status,omitempty"`
}
type InterfaceStatus ¶
type InterfaceStatus int32
const ( UP InterfaceStatus = 1 DOWN InterfaceStatus = 2 Testing InterfaceStatus = 3 Unknown InterfaceStatus = 4 Dormant InterfaceStatus = 5 NotPresent InterfaceStatus = 6 )
The current operational state of the interface. The testing(3) state indicates that no operational packets can be passed. If ifAdminStatus is down(2) then ifOperStatus should be down(2). If ifAdminStatus is changed to up(1) then ifOperStatus should change to up(1) if the interface is ready to transmit and receive network traffic; it should change to dormant(5) if the interface is waiting for external actions (such as a serial line waiting for an incoming connection); it should remain in the down(2) state if and only if there is a fault that prevents it from going to the up(1) state; it should remain in the notPresent(6) state if the interface has missing (typically, hardware) components.
func (InterfaceStatus) String ¶
func (x InterfaceStatus) String() string
type SNMPWrapper ¶
func (*SNMPWrapper) Interfaces ¶
func (wrap *SNMPWrapper) Interfaces() ([]Interface, error)
func (*SNMPWrapper) SystemInfo ¶
func (wrap *SNMPWrapper) SystemInfo() (*System, error)
type Scanner ¶
type Scanner struct {
Id string `json:"id"`
Targets []string `json:"targets"`
StartTime time.Time `json:"start_at"`
EndTime time.Time `json:"end_at"`
Status ScannerStatus `json:"status"`
Message string `json:"message"`
User string `json:"user"`
Result nmap.Run `json:"result"`
Warnings []string `json:"warnings"`
}
func (*Scanner) Hosts ¶
func (sc *Scanner) Hosts() HostResult
type ScannerStatus ¶
type ScannerStatus int32
const ( Created ScannerStatus = 1 Pending ScannerStatus = 2 Running ScannerStatus = 3 Success ScannerStatus = 4 Error ScannerStatus = 5 )
func (ScannerStatus) String ¶
func (x ScannerStatus) String() string
type SubnetInfo ¶
type SubnetInfo struct {
// contains filtered or unexported fields
}
SubnetInfo apache subnetutils for go version
func NewSubnetInfo ¶
func NewSubnetInfo(cidr string) (*SubnetInfo, error)
NewSubnetInfo 创建一个subnetInfo对象
func (*SubnetInfo) AddressString ¶
func (sub *SubnetInfo) AddressString() string
AddressString 获取ip地址
func (*SubnetInfo) BradcastString ¶
func (sub *SubnetInfo) BradcastString() string
BradcastString 获取广播地址
func (*SubnetInfo) GetCidrSignature ¶
func (sub *SubnetInfo) GetCidrSignature() string
GetCidrSignature 获取无分类地址
func (*SubnetInfo) HighAddress ¶
func (sub *SubnetInfo) HighAddress() string
HighAddress return the last available address in current subnet
func (*SubnetInfo) IsRangeOf ¶
func (sub *SubnetInfo) IsRangeOf(addr string) (bool, error)
IsRangeOf 判断输入的ip是否在当前网段内
func (*SubnetInfo) LowAddress ¶
func (sub *SubnetInfo) LowAddress() string
LowAddress return the first available address in current subnet
func (*SubnetInfo) NetmaskString ¶
func (sub *SubnetInfo) NetmaskString() string
NetmaskString 获取子网掩码
func (*SubnetInfo) NetworkString ¶
func (sub *SubnetInfo) NetworkString() string
NetworkString 获取网络地址
func (*SubnetInfo) Size ¶
func (sub *SubnetInfo) Size() uint32
Size returns available ip address size