Fix lint errors

This commit is contained in:
世界 2026-06-22 15:49:11 +08:00
parent a9f4123ba2
commit 46aa536b37
No known key found for this signature in database
GPG key ID: CD109927C34A63C4
41 changed files with 498 additions and 406 deletions

View file

@ -1,3 +1,5 @@
//go:build windows
/* SPDX-License-Identifier: MIT
*
* Copyright (C) 2019-2022 WireGuard LLC. All Rights Reserved.

View file

@ -1,3 +1,5 @@
//go:build windows
/* SPDX-License-Identifier: MIT
*
* Copyright (C) 2019-2022 WireGuard LLC. All Rights Reserved.

View file

@ -1,3 +1,5 @@
//go:build windows
/* SPDX-License-Identifier: MIT
*
* Copyright (C) 2019-2022 WireGuard LLC. All Rights Reserved.

View file

@ -1,3 +1,5 @@
//go:build windows
/* SPDX-License-Identifier: MIT
*
* Copyright (C) 2019-2022 WireGuard LLC. All Rights Reserved.
@ -60,9 +62,10 @@ const (
func (luid LUID) fallbackSetDNSForFamily(family AddressFamily, dnses []netip.Addr) error {
var templateFlush string
if family == windows.AF_INET {
switch family {
case windows.AF_INET:
templateFlush = netshCmdTemplateFlush4
} else if family == windows.AF_INET6 {
case windows.AF_INET6:
templateFlush = netshCmdTemplateFlush6
}
@ -72,7 +75,7 @@ func (luid LUID) fallbackSetDNSForFamily(family AddressFamily, dnses []netip.Add
return err
}
cmds = append(cmds, fmt.Sprintf(templateFlush, ipif.InterfaceIndex))
for i := 0; i < len(dnses); i++ {
for i := range dnses {
if dnses[i].Is4() && family == windows.AF_INET {
cmds = append(cmds, fmt.Sprintf(netshCmdTemplateAdd4, ipif.InterfaceIndex, dnses[i].String()))
} else if dnses[i].Is6() && family == windows.AF_INET6 {
@ -85,23 +88,23 @@ func (luid LUID) fallbackSetDNSForFamily(family AddressFamily, dnses []netip.Add
func (luid LUID) fallbackSetDNSDomain(domain string) error {
guid, err := luid.GUID()
if err != nil {
return fmt.Errorf("Error converting luid to guid: %w", err)
return fmt.Errorf("error converting luid to guid: %w", err)
}
key, err := registry.OpenKey(registry.LOCAL_MACHINE, fmt.Sprintf("SYSTEM\\CurrentControlSet\\Services\\Tcpip\\Parameters\\Adapters\\%v", guid), registry.QUERY_VALUE)
if err != nil {
return fmt.Errorf("Error opening adapter-specific TCP/IP network registry key: %w", err)
return fmt.Errorf("error opening adapter-specific TCP/IP network registry key: %w", err)
}
paths, _, err := key.GetStringsValue("IpConfig")
key.Close()
if err != nil {
return fmt.Errorf("Error reading IpConfig registry key: %w", err)
return fmt.Errorf("error reading IpConfig registry key: %w", err)
}
if len(paths) == 0 {
return errors.New("No TCP/IP interfaces found on adapter")
return errors.New("no TCP/IP interfaces found on adapter")
}
key, err = registry.OpenKey(registry.LOCAL_MACHINE, fmt.Sprintf("SYSTEM\\CurrentControlSet\\Services\\%s", paths[0]), registry.SET_VALUE)
if err != nil {
return fmt.Errorf("Unable to open TCP/IP network registry key: %w", err)
return fmt.Errorf("unable to open TCP/IP network registry key: %w", err)
}
err = key.SetStringValue("Domain", domain)
key.Close()

View file

@ -1,3 +1,5 @@
//go:build windows
/* SPDX-License-Identifier: MIT
*
* Copyright (C) 2019-2022 WireGuard LLC. All Rights Reserved.

View file

@ -1,3 +1,5 @@
//go:build windows
/* SPDX-License-Identifier: MIT
*
* Copyright (C) 2019-2022 WireGuard LLC. All Rights Reserved.
@ -62,206 +64,206 @@ type IfType uint32
const (
IfTypeOther IfType = 1 // None of the below
IfTypeRegular1822 = 2
IfTypeHdh1822 = 3
IfTypeDdnX25 = 4
IfTypeRfc877X25 = 5
IfTypeEthernetCSMACD = 6
IfTypeISO88023CSMACD = 7
IfTypeISO88024Tokenbus = 8
IfTypeISO88025Tokenring = 9
IfTypeISO88026Man = 10
IfTypeStarlan = 11
IfTypeProteon10Mbit = 12
IfTypeProteon80Mbit = 13
IfTypeHyperchannel = 14
IfTypeFddi = 15
IfTypeLapB = 16
IfTypeSdlc = 17
IfTypeDs1 = 18 // DS1-MIB
IfTypeE1 = 19 // Obsolete; see DS1-MIB
IfTypeBasicISDN = 20
IfTypePrimaryISDN = 21
IfTypePropPoint2PointSerial = 22 // proprietary serial
IfTypePPP = 23
IfTypeSoftwareLoopback = 24
IfTypeEon = 25 // CLNP over IP
IfTypeEthernet3Mbit = 26
IfTypeNsip = 27 // XNS over IP
IfTypeSlip = 28 // Generic Slip
IfTypeUltra = 29 // ULTRA Technologies
IfTypeDs3 = 30 // DS3-MIB
IfTypeSip = 31 // SMDS, coffee
IfTypeFramerelay = 32 // DTE only
IfTypeRs232 = 33
IfTypePara = 34 // Parallel port
IfTypeArcnet = 35
IfTypeArcnetPlus = 36
IfTypeAtm = 37 // ATM cells
IfTypeMioX25 = 38
IfTypeSonet = 39 // SONET or SDH
IfTypeX25Ple = 40
IfTypeIso88022LLC = 41
IfTypeLocaltalk = 42
IfTypeSmdsDxi = 43
IfTypeFramerelayService = 44 // FRNETSERV-MIB
IfTypeV35 = 45
IfTypeHssi = 46
IfTypeHippi = 47
IfTypeModem = 48 // Generic Modem
IfTypeAal5 = 49 // AAL5 over ATM
IfTypeSonetPath = 50
IfTypeSonetVt = 51
IfTypeSmdsIcip = 52 // SMDS InterCarrier Interface
IfTypePropVirtual = 53 // Proprietary virtual/internal
IfTypePropMultiplexor = 54 // Proprietary multiplexing
IfTypeIEEE80212 = 55 // 100BaseVG
IfTypeFibrechannel = 56
IfTypeHippiinterface = 57
IfTypeFramerelayInterconnect = 58 // Obsolete, use 32 or 44
IfTypeAflane8023 = 59 // ATM Emulated LAN for 802.3
IfTypeAflane8025 = 60 // ATM Emulated LAN for 802.5
IfTypeCctemul = 61 // ATM Emulated circuit
IfTypeFastether = 62 // Fast Ethernet (100BaseT)
IfTypeISDN = 63 // ISDN and X.25
IfTypeV11 = 64 // CCITT V.11/X.21
IfTypeV36 = 65 // CCITT V.36
IfTypeG703_64k = 66 // CCITT G703 at 64Kbps
IfTypeG703_2mb = 67 // Obsolete; see DS1-MIB
IfTypeQllc = 68 // SNA QLLC
IfTypeFastetherFX = 69 // Fast Ethernet (100BaseFX)
IfTypeChannel = 70
IfTypeIEEE80211 = 71 // Radio spread spectrum
IfTypeIBM370parchan = 72 // IBM System 360/370 OEMI Channel
IfTypeEscon = 73 // IBM Enterprise Systems Connection
IfTypeDlsw = 74 // Data Link Switching
IfTypeISDNS = 75 // ISDN S/T interface
IfTypeISDNU = 76 // ISDN U interface
IfTypeLapD = 77 // Link Access Protocol D
IfTypeIpswitch = 78 // IP Switching Objects
IfTypeRsrb = 79 // Remote Source Route Bridging
IfTypeAtmLogical = 80 // ATM Logical Port
IfTypeDs0 = 81 // Digital Signal Level 0
IfTypeDs0Bundle = 82 // Group of ds0s on the same ds1
IfTypeBsc = 83 // Bisynchronous Protocol
IfTypeAsync = 84 // Asynchronous Protocol
IfTypeCnr = 85 // Combat Net Radio
IfTypeIso88025rDtr = 86 // ISO 802.5r DTR
IfTypeEplrs = 87 // Ext Pos Loc Report Sys
IfTypeArap = 88 // Appletalk Remote Access Protocol
IfTypePropCnls = 89 // Proprietary Connectionless Proto
IfTypeHostpad = 90 // CCITT-ITU X.29 PAD Protocol
IfTypeTermpad = 91 // CCITT-ITU X.3 PAD Facility
IfTypeFramerelayMpi = 92 // Multiproto Interconnect over FR
IfTypeX213 = 93 // CCITT-ITU X213
IfTypeAdsl = 94 // Asymmetric Digital Subscrbr Loop
IfTypeRadsl = 95 // Rate-Adapt Digital Subscrbr Loop
IfTypeSdsl = 96 // Symmetric Digital Subscriber Loop
IfTypeVdsl = 97 // Very H-Speed Digital Subscrb Loop
IfTypeIso88025Crfprint = 98 // ISO 802.5 CRFP
IfTypeMyrinet = 99 // Myricom Myrinet
IfTypeVoiceEm = 100 // Voice recEive and transMit
IfTypeVoiceFxo = 101 // Voice Foreign Exchange Office
IfTypeVoiceFxs = 102 // Voice Foreign Exchange Station
IfTypeVoiceEncap = 103 // Voice encapsulation
IfTypeVoiceOverip = 104 // Voice over IP encapsulation
IfTypeAtmDxi = 105 // ATM DXI
IfTypeAtmFuni = 106 // ATM FUNI
IfTypeAtmIma = 107 // ATM IMA
IfTypePPPmultilinkbundle = 108 // PPP Multilink Bundle
IfTypeIpoverCdlc = 109 // IBM ipOverCdlc
IfTypeIpoverClaw = 110 // IBM Common Link Access to Workstn
IfTypeStacktostack = 111 // IBM stackToStack
IfTypeVirtualipaddress = 112 // IBM VIPA
IfTypeMpc = 113 // IBM multi-proto channel support
IfTypeIpoverAtm = 114 // IBM ipOverAtm
IfTypeIso88025Fiber = 115 // ISO 802.5j Fiber Token Ring
IfTypeTdlc = 116 // IBM twinaxial data link control
IfTypeGigabitethernet = 117
IfTypeHdlc = 118
IfTypeLapF = 119
IfTypeV37 = 120
IfTypeX25Mlp = 121 // Multi-Link Protocol
IfTypeX25Huntgroup = 122 // X.25 Hunt Group
IfTypeTransphdlc = 123
IfTypeInterleave = 124 // Interleave channel
IfTypeFast = 125 // Fast channel
IfTypeIP = 126 // IP (for APPN HPR in IP networks)
IfTypeDocscableMaclayer = 127 // CATV Mac Layer
IfTypeDocscableDownstream = 128 // CATV Downstream interface
IfTypeDocscableUpstream = 129 // CATV Upstream interface
IfTypeA12mppswitch = 130 // Avalon Parallel Processor
IfTypeTunnel = 131 // Encapsulation interface
IfTypeCoffee = 132 // Coffee pot
IfTypeCes = 133 // Circuit Emulation Service
IfTypeAtmSubinterface = 134 // ATM Sub Interface
IfTypeL2Vlan = 135 // Layer 2 Virtual LAN using 802.1Q
IfTypeL3Ipvlan = 136 // Layer 3 Virtual LAN using IP
IfTypeL3Ipxvlan = 137 // Layer 3 Virtual LAN using IPX
IfTypeDigitalpowerline = 138 // IP over Power Lines
IfTypeMediamailoverip = 139 // Multimedia Mail over IP
IfTypeDtm = 140 // Dynamic syncronous Transfer Mode
IfTypeDcn = 141 // Data Communications Network
IfTypeIpforward = 142 // IP Forwarding Interface
IfTypeMsdsl = 143 // Multi-rate Symmetric DSL
IfTypeIEEE1394 = 144 // IEEE1394 High Perf Serial Bus
IfTypeIfGsn = 145
IfTypeDvbrccMaclayer = 146
IfTypeDvbrccDownstream = 147
IfTypeDvbrccUpstream = 148
IfTypeAtmVirtual = 149
IfTypeMplsTunnel = 150
IfTypeSrp = 151
IfTypeVoiceoveratm = 152
IfTypeVoiceoverframerelay = 153
IfTypeIdsl = 154
IfTypeCompositelink = 155
IfTypeSs7Siglink = 156
IfTypePropWirelessP2P = 157
IfTypeFrForward = 158
IfTypeRfc1483 = 159
IfTypeUsb = 160
IfTypeIEEE8023adLag = 161
IfTypeBgpPolicyAccounting = 162
IfTypeFrf16MfrBundle = 163
IfTypeH323Gatekeeper = 164
IfTypeH323Proxy = 165
IfTypeMpls = 166
IfTypeMfSiglink = 167
IfTypeHdsl2 = 168
IfTypeShdsl = 169
IfTypeDs1Fdl = 170
IfTypePos = 171
IfTypeDvbAsiIn = 172
IfTypeDvbAsiOut = 173
IfTypePlc = 174
IfTypeNfas = 175
IfTypeTr008 = 176
IfTypeGr303Rdt = 177
IfTypeGr303Idt = 178
IfTypeIsup = 179
IfTypePropDocsWirelessMaclayer = 180
IfTypePropDocsWirelessDownstream = 181
IfTypePropDocsWirelessUpstream = 182
IfTypeHiperlan2 = 183
IfTypePropBwaP2MP = 184
IfTypeSonetOverheadChannel = 185
IfTypeDigitalWrapperOverheadChannel = 186
IfTypeAal2 = 187
IfTypeRadioMac = 188
IfTypeAtmRadio = 189
IfTypeImt = 190
IfTypeMvl = 191
IfTypeReachDsl = 192
IfTypeFrDlciEndpt = 193
IfTypeAtmVciEndpt = 194
IfTypeOpticalChannel = 195
IfTypeOpticalTransport = 196
IfTypeIEEE80216Wman = 237
IfTypeWwanpp = 243 // WWAN devices based on GSM technology
IfTypeWwanpp2 = 244 // WWAN devices based on CDMA technology
IfTypeIEEE802154 = 259 // IEEE 802.15.4 WPAN interface
IfTypeXboxWireless = 281
IfTypeRegular1822 IfType = 2
IfTypeHdh1822 IfType = 3
IfTypeDdnX25 IfType = 4
IfTypeRfc877X25 IfType = 5
IfTypeEthernetCSMACD IfType = 6
IfTypeISO88023CSMACD IfType = 7
IfTypeISO88024Tokenbus IfType = 8
IfTypeISO88025Tokenring IfType = 9
IfTypeISO88026Man IfType = 10
IfTypeStarlan IfType = 11
IfTypeProteon10Mbit IfType = 12
IfTypeProteon80Mbit IfType = 13
IfTypeHyperchannel IfType = 14
IfTypeFddi IfType = 15
IfTypeLapB IfType = 16
IfTypeSdlc IfType = 17
IfTypeDs1 IfType = 18 // DS1-MIB
IfTypeE1 IfType = 19 // Obsolete; see DS1-MIB
IfTypeBasicISDN IfType = 20
IfTypePrimaryISDN IfType = 21
IfTypePropPoint2PointSerial IfType = 22 // proprietary serial
IfTypePPP IfType = 23
IfTypeSoftwareLoopback IfType = 24
IfTypeEon IfType = 25 // CLNP over IP
IfTypeEthernet3Mbit IfType = 26
IfTypeNsip IfType = 27 // XNS over IP
IfTypeSlip IfType = 28 // Generic Slip
IfTypeUltra IfType = 29 // ULTRA Technologies
IfTypeDs3 IfType = 30 // DS3-MIB
IfTypeSip IfType = 31 // SMDS, coffee
IfTypeFramerelay IfType = 32 // DTE only
IfTypeRs232 IfType = 33
IfTypePara IfType = 34 // Parallel port
IfTypeArcnet IfType = 35
IfTypeArcnetPlus IfType = 36
IfTypeAtm IfType = 37 // ATM cells
IfTypeMioX25 IfType = 38
IfTypeSonet IfType = 39 // SONET or SDH
IfTypeX25Ple IfType = 40
IfTypeIso88022LLC IfType = 41
IfTypeLocaltalk IfType = 42
IfTypeSmdsDxi IfType = 43
IfTypeFramerelayService IfType = 44 // FRNETSERV-MIB
IfTypeV35 IfType = 45
IfTypeHssi IfType = 46
IfTypeHippi IfType = 47
IfTypeModem IfType = 48 // Generic Modem
IfTypeAal5 IfType = 49 // AAL5 over ATM
IfTypeSonetPath IfType = 50
IfTypeSonetVt IfType = 51
IfTypeSmdsIcip IfType = 52 // SMDS InterCarrier Interface
IfTypePropVirtual IfType = 53 // Proprietary virtual/internal
IfTypePropMultiplexor IfType = 54 // Proprietary multiplexing
IfTypeIEEE80212 IfType = 55 // 100BaseVG
IfTypeFibrechannel IfType = 56
IfTypeHippiinterface IfType = 57
IfTypeFramerelayInterconnect IfType = 58 // Obsolete, use 32 or 44
IfTypeAflane8023 IfType = 59 // ATM Emulated LAN for 802.3
IfTypeAflane8025 IfType = 60 // ATM Emulated LAN for 802.5
IfTypeCctemul IfType = 61 // ATM Emulated circuit
IfTypeFastether IfType = 62 // Fast Ethernet (100BaseT)
IfTypeISDN IfType = 63 // ISDN and X.25
IfTypeV11 IfType = 64 // CCITT V.11/X.21
IfTypeV36 IfType = 65 // CCITT V.36
IfTypeG703_64k IfType = 66 // CCITT G703 at 64Kbps
IfTypeG703_2mb IfType = 67 // Obsolete; see DS1-MIB
IfTypeQllc IfType = 68 // SNA QLLC
IfTypeFastetherFX IfType = 69 // Fast Ethernet (100BaseFX)
IfTypeChannel IfType = 70
IfTypeIEEE80211 IfType = 71 // Radio spread spectrum
IfTypeIBM370parchan IfType = 72 // IBM System 360/370 OEMI Channel
IfTypeEscon IfType = 73 // IBM Enterprise Systems Connection
IfTypeDlsw IfType = 74 // Data Link Switching
IfTypeISDNS IfType = 75 // ISDN S/T interface
IfTypeISDNU IfType = 76 // ISDN U interface
IfTypeLapD IfType = 77 // Link Access Protocol D
IfTypeIpswitch IfType = 78 // IP Switching Objects
IfTypeRsrb IfType = 79 // Remote Source Route Bridging
IfTypeAtmLogical IfType = 80 // ATM Logical Port
IfTypeDs0 IfType = 81 // Digital Signal Level 0
IfTypeDs0Bundle IfType = 82 // Group of ds0s on the same ds1
IfTypeBsc IfType = 83 // Bisynchronous Protocol
IfTypeAsync IfType = 84 // Asynchronous Protocol
IfTypeCnr IfType = 85 // Combat Net Radio
IfTypeIso88025rDtr IfType = 86 // ISO 802.5r DTR
IfTypeEplrs IfType = 87 // Ext Pos Loc Report Sys
IfTypeArap IfType = 88 // Appletalk Remote Access Protocol
IfTypePropCnls IfType = 89 // Proprietary Connectionless Proto
IfTypeHostpad IfType = 90 // CCITT-ITU X.29 PAD Protocol
IfTypeTermpad IfType = 91 // CCITT-ITU X.3 PAD Facility
IfTypeFramerelayMpi IfType = 92 // Multiproto Interconnect over FR
IfTypeX213 IfType = 93 // CCITT-ITU X213
IfTypeAdsl IfType = 94 // Asymmetric Digital Subscrbr Loop
IfTypeRadsl IfType = 95 // Rate-Adapt Digital Subscrbr Loop
IfTypeSdsl IfType = 96 // Symmetric Digital Subscriber Loop
IfTypeVdsl IfType = 97 // Very H-Speed Digital Subscrb Loop
IfTypeIso88025Crfprint IfType = 98 // ISO 802.5 CRFP
IfTypeMyrinet IfType = 99 // Myricom Myrinet
IfTypeVoiceEm IfType = 100 // Voice recEive and transMit
IfTypeVoiceFxo IfType = 101 // Voice Foreign Exchange Office
IfTypeVoiceFxs IfType = 102 // Voice Foreign Exchange Station
IfTypeVoiceEncap IfType = 103 // Voice encapsulation
IfTypeVoiceOverip IfType = 104 // Voice over IP encapsulation
IfTypeAtmDxi IfType = 105 // ATM DXI
IfTypeAtmFuni IfType = 106 // ATM FUNI
IfTypeAtmIma IfType = 107 // ATM IMA
IfTypePPPmultilinkbundle IfType = 108 // PPP Multilink Bundle
IfTypeIpoverCdlc IfType = 109 // IBM ipOverCdlc
IfTypeIpoverClaw IfType = 110 // IBM Common Link Access to Workstn
IfTypeStacktostack IfType = 111 // IBM stackToStack
IfTypeVirtualipaddress IfType = 112 // IBM VIPA
IfTypeMpc IfType = 113 // IBM multi-proto channel support
IfTypeIpoverAtm IfType = 114 // IBM ipOverAtm
IfTypeIso88025Fiber IfType = 115 // ISO 802.5j Fiber Token Ring
IfTypeTdlc IfType = 116 // IBM twinaxial data link control
IfTypeGigabitethernet IfType = 117
IfTypeHdlc IfType = 118
IfTypeLapF IfType = 119
IfTypeV37 IfType = 120
IfTypeX25Mlp IfType = 121 // Multi-Link Protocol
IfTypeX25Huntgroup IfType = 122 // X.25 Hunt Group
IfTypeTransphdlc IfType = 123
IfTypeInterleave IfType = 124 // Interleave channel
IfTypeFast IfType = 125 // Fast channel
IfTypeIP IfType = 126 // IP (for APPN HPR in IP networks)
IfTypeDocscableMaclayer IfType = 127 // CATV Mac Layer
IfTypeDocscableDownstream IfType = 128 // CATV Downstream interface
IfTypeDocscableUpstream IfType = 129 // CATV Upstream interface
IfTypeA12mppswitch IfType = 130 // Avalon Parallel Processor
IfTypeTunnel IfType = 131 // Encapsulation interface
IfTypeCoffee IfType = 132 // Coffee pot
IfTypeCes IfType = 133 // Circuit Emulation Service
IfTypeAtmSubinterface IfType = 134 // ATM Sub Interface
IfTypeL2Vlan IfType = 135 // Layer 2 Virtual LAN using 802.1Q
IfTypeL3Ipvlan IfType = 136 // Layer 3 Virtual LAN using IP
IfTypeL3Ipxvlan IfType = 137 // Layer 3 Virtual LAN using IPX
IfTypeDigitalpowerline IfType = 138 // IP over Power Lines
IfTypeMediamailoverip IfType = 139 // Multimedia Mail over IP
IfTypeDtm IfType = 140 // Dynamic syncronous Transfer Mode
IfTypeDcn IfType = 141 // Data Communications Network
IfTypeIpforward IfType = 142 // IP Forwarding Interface
IfTypeMsdsl IfType = 143 // Multi-rate Symmetric DSL
IfTypeIEEE1394 IfType = 144 // IEEE1394 High Perf Serial Bus
IfTypeIfGsn IfType = 145
IfTypeDvbrccMaclayer IfType = 146
IfTypeDvbrccDownstream IfType = 147
IfTypeDvbrccUpstream IfType = 148
IfTypeAtmVirtual IfType = 149
IfTypeMplsTunnel IfType = 150
IfTypeSrp IfType = 151
IfTypeVoiceoveratm IfType = 152
IfTypeVoiceoverframerelay IfType = 153
IfTypeIdsl IfType = 154
IfTypeCompositelink IfType = 155
IfTypeSs7Siglink IfType = 156
IfTypePropWirelessP2P IfType = 157
IfTypeFrForward IfType = 158
IfTypeRfc1483 IfType = 159
IfTypeUsb IfType = 160
IfTypeIEEE8023adLag IfType = 161
IfTypeBgpPolicyAccounting IfType = 162
IfTypeFrf16MfrBundle IfType = 163
IfTypeH323Gatekeeper IfType = 164
IfTypeH323Proxy IfType = 165
IfTypeMpls IfType = 166
IfTypeMfSiglink IfType = 167
IfTypeHdsl2 IfType = 168
IfTypeShdsl IfType = 169
IfTypeDs1Fdl IfType = 170
IfTypePos IfType = 171
IfTypeDvbAsiIn IfType = 172
IfTypeDvbAsiOut IfType = 173
IfTypePlc IfType = 174
IfTypeNfas IfType = 175
IfTypeTr008 IfType = 176
IfTypeGr303Rdt IfType = 177
IfTypeGr303Idt IfType = 178
IfTypeIsup IfType = 179
IfTypePropDocsWirelessMaclayer IfType = 180
IfTypePropDocsWirelessDownstream IfType = 181
IfTypePropDocsWirelessUpstream IfType = 182
IfTypeHiperlan2 IfType = 183
IfTypePropBwaP2MP IfType = 184
IfTypeSonetOverheadChannel IfType = 185
IfTypeDigitalWrapperOverheadChannel IfType = 186
IfTypeAal2 IfType = 187
IfTypeRadioMac IfType = 188
IfTypeAtmRadio IfType = 189
IfTypeImt IfType = 190
IfTypeMvl IfType = 191
IfTypeReachDsl IfType = 192
IfTypeFrDlciEndpt IfType = 193
IfTypeAtmVciEndpt IfType = 194
IfTypeOpticalChannel IfType = 195
IfTypeOpticalTransport IfType = 196
IfTypeIEEE80216Wman IfType = 237
IfTypeWwanpp IfType = 243 // WWAN devices based on GSM technology
IfTypeWwanpp2 IfType = 244 // WWAN devices based on CDMA technology
IfTypeIEEE802154 IfType = 259 // IEEE 802.15.4 WPAN interface
IfTypeXboxWireless IfType = 281
)
// MibIfEntryLevel enumeration specifies level of interface information to retrieve in GetIfTable2Ex function call.
@ -270,7 +272,7 @@ type MibIfEntryLevel uint32
const (
MibIfEntryNormal MibIfEntryLevel = 0
MibIfEntryNormalWithoutStatistics = 2
MibIfEntryNormalWithoutStatistics MibIfEntryLevel = 2
)
// NdisMedium enumeration type identifies the medium types that NDIS drivers support.
@ -522,12 +524,12 @@ type TunnelType uint32
const (
TunnelTypeNone TunnelType = 0
TunnelTypeOther = 1
TunnelTypeDirect = 2
TunnelType6to4 = 11
TunnelTypeIsatap = 13
TunnelTypeTeredo = 14
TunnelTypeIPHTTPS = 15
TunnelTypeOther TunnelType = 1
TunnelTypeDirect TunnelType = 2
TunnelType6to4 TunnelType = 11
TunnelTypeIsatap TunnelType = 13
TunnelTypeTeredo TunnelType = 14
TunnelTypeIPHTTPS TunnelType = 15
)
// InterfaceAndOperStatusFlags enumeration type defines interface and operation flags
@ -574,13 +576,13 @@ type ScopeLevel uint32
const (
ScopeLevelInterface ScopeLevel = 1
ScopeLevelLink = 2
ScopeLevelSubnet = 3
ScopeLevelAdmin = 4
ScopeLevelSite = 5
ScopeLevelOrganization = 8
ScopeLevelGlobal = 14
ScopeLevelCount = 16
ScopeLevelLink ScopeLevel = 2
ScopeLevelSubnet ScopeLevel = 3
ScopeLevelAdmin ScopeLevel = 4
ScopeLevelSite ScopeLevel = 5
ScopeLevelOrganization ScopeLevel = 8
ScopeLevelGlobal ScopeLevel = 14
ScopeLevelCount ScopeLevel = 16
)
// RouteData structure describes a route to add
@ -757,7 +759,7 @@ func (addr *RawSockaddrInet) SetAddrPort(addrPort netip.AddrPort) error {
addr4.Family = windows.AF_INET
addr4.Addr = addrPort.Addr().As4()
addr4.Port = htons(addrPort.Port())
for i := 0; i < 8; i++ {
for i := range 8 {
addr4.Zero[i] = 0
}
return nil

View file

@ -1,4 +1,4 @@
//go:build 386 || arm
//go:build windows && (386 || arm)
/* SPDX-License-Identifier: MIT
*

View file

@ -1,4 +1,4 @@
//go:build amd64 || arm64
//go:build windows && (amd64 || arm64)
/* SPDX-License-Identifier: MIT
*

View file

@ -1,3 +1,5 @@
//go:build windows
/* SPDX-License-Identifier: MIT
*
* Copyright (C) 2019-2022 WireGuard LLC. All Rights Reserved.

View file

@ -1,4 +1,4 @@
//go:build 386 || arm
//go:build windows && (386 || arm)
/* SPDX-License-Identifier: MIT
*

View file

@ -1,4 +1,4 @@
//go:build amd64 || arm64
//go:build windows && (amd64 || arm64)
/* SPDX-License-Identifier: MIT
*

View file

@ -1,3 +1,5 @@
//go:build windows
/* SPDX-License-Identifier: MIT
*
* Copyright (C) 2019-2022 WireGuard LLC. All Rights Reserved.

View file

@ -1,3 +1,5 @@
//go:build windows
/* SPDX-License-Identifier: MIT
*
* Copyright (C) 2019-2022 WireGuard LLC. All Rights Reserved.

View file

@ -1,3 +1,5 @@
//go:build windows
/* SPDX-License-Identifier: MIT
*
* Copyright (C) 2019-2022 WireGuard LLC. All Rights Reserved.
@ -104,6 +106,9 @@ func TestAdaptersAddresses(t *testing.T) {
}
ifcs, err = GetAdaptersAddresses(windows.AF_UNSPEC, GAAFlagDefault)
if err != nil {
t.Errorf("GetAdaptersAddresses() returned error: %v", err)
}
for _, i := range ifcs {
ifc, err := i.LUID.Interface()
@ -370,7 +375,7 @@ func TestAddDeleteIPAddress(t *testing.T) {
return
}
addr, err := ifc.LUID.IPAddress(nonexistantIPv4ToAdd.Addr())
_, err = ifc.LUID.IPAddress(nonexistantIPv4ToAdd.Addr())
if err == nil {
t.Errorf("Unicast address %s already exists. Please set nonexistantIPv4ToAdd appropriately.", nonexistantIPv4ToAdd.Addr().String())
return
@ -414,7 +419,7 @@ func TestAddDeleteIPAddress(t *testing.T) {
if count != 1 {
t.Errorf("After adding there are %d new interface(s).", count)
}
addr, err = ifc.LUID.IPAddress(nonexistantIPv4ToAdd.Addr())
addr, err := ifc.LUID.IPAddress(nonexistantIPv4ToAdd.Addr())
if err != nil {
t.Errorf("LUID.IPAddress() returned an error: %w", err)
} else if addr == nil {
@ -431,7 +436,7 @@ func TestAddDeleteIPAddress(t *testing.T) {
time.Sleep(500 * time.Millisecond)
addr, err = ifc.LUID.IPAddress(nonexistantIPv4ToAdd.Addr())
_, err = ifc.LUID.IPAddress(nonexistantIPv4ToAdd.Addr())
if err == nil {
t.Errorf("Unicast address %s still exists, although it's deleted successfully.", nonexistantIPv4ToAdd.Addr().String())
} else if err != windows.ERROR_NOT_FOUND {