windowsnetworkinfo

package module
v0.0.0-...-88c2f84 Latest Latest
Warning

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

Go to latest
Published: Apr 16, 2022 License: MIT Imports: 9 Imported by: 0

README

windowsnetworkinfo

Retrives Windows system networking cards informations, wifi profiles and passwords.

Tested on Windows 11, should be compatible at least from Windows 7.

#######

See network_test.go for more example.

How to use in your project:


import (
    ninfo "github.com/a-hydrae/windowsnetworkinfo"
)
....
ni := ninfo.NewNetworkInfo()
if adaptersInfo, err := ni.GetAdaptersInfo(NicType(NIC_WIRELESS802_11)); err == nil {
    for _, adptr := range adaptersInfo.Adapters {
        fmt.Printf("WiFi Adapter: %s\n", adptr.AdapterName)
        fmt.Printf("IP: %v\n", adptr.IpAddressList)
        fmt.Printf("Profiles: %v\n", adptr.WiFiProfiles)
    }
}

OR

import (
    ninfo "github.com/a-hydrae/windowsnetworkinfo"
)
...
ni := ninfo.NewNetworkInfo()
if adaptersInfo, err := ni.GetAdaptersInfo(NicType(NIC_WIRELESS802_11)); err == nil {
    fmt.Println(adaptersInfo.ToJSON())
}

Don't forget CGO_ENABLED=1

Documentation

Rendered for windows/amd64

Index

Constants

View Source
const (
	ERROR_BUFFER_OVERFLOW syscall.Errno = 111
	ERROR_SUCCESS         syscall.Errno = 0
)
View Source
const (
	MAX_ADAPTER_ADDRESS_LENGTH     = 8
	MAX_ADAPTER_DESCRIPTION_LENGTH = 128
	MAX_ADAPTER_NAME_LENGTH        = 256
	MAX_DOMAIN_NAME_LEN            = 128
	MAX_HOSTNAME_LEN               = 128
)
View Source
const (
	NIC_WIRELESS802_11 = 71
	NIC_ATMNETOWRK     = 28
	NIC_LOOPBACK       = 24
	NIC_PPP            = 23
	NIC_TOKENRING      = 9
	NIC_ETHERNET       = 6
)
View Source
const (
	ERROR_INVALID_PARAMETER = 0x57
	MYSQL_TIME_FORMAT       = "2006-01-02 15:04:05"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type AdapterInfo

type AdapterInfo struct {
	AdapterName         string
	Description         string
	MacAddress          string
	Type                string
	CurrentIPAddress    []string
	IpAddressList       []string
	GatewayAddressList  []string
	DhcpServerList      []string
	PrimaryWinsServer   []string
	SecondaryWinsServer []string
	WiFiProfiles        []wiFiProfile
	LeaseObtained       string
	LeaseExpires        string
	Index               int32
	ComboIndex          int32
	HaveWins            bool
	DhcpEnabled         bool
}

type AdaptersInfo

type AdaptersInfo struct {
	Adapters map[string]AdapterInfo
}

func (AdaptersInfo) ToJSON

func (AI AdaptersInfo) ToJSON() (ret []byte, err error)

type NICFilterType

type NICFilterType NicType

type NICSearchFilterGUID

type NICSearchFilterGUID string

type NICSearchFilterID

type NICSearchFilterID int

type NetworkInfo

type NetworkInfo struct{}

func NewNetworkInfo

func NewNetworkInfo() *NetworkInfo

func (*NetworkInfo) GetAdaptersInfo

func (NI *NetworkInfo) GetAdaptersInfo(filters ...interface{}) (ret AdaptersInfo, err error)

GetAdaptersInfo returns network interfaces. Can be filtered (logic are in AND) using GUID, ID and NIC typo

type NicType

type NicType uint32

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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