Debian Codegraph @

network/net_windows.go

raw symbols SCIP
1 package network
2
3 import (
4 "fmt"
5 "net"
6 "strings"
7
8 "github.com/google/gopacket/pcap"
9 )
10
11 /*
12 * net.Interface does not have the correct name on Windows and pcap.Interface
13 * does not have the hardware address for some reason ... so this is what I
14 * had to do in Windows ... tnx Microsoft <3
15 *
16 * FIXME: Just to be clear *THIS IS SHIT*. Please someone test, find a more
17 * elegant solution and refactor ... i'm seriously tired of this.
18 */
19
20 func areTheSame(iface net.Interface, piface pcap.Interface) bool {
21 if addrs, err := iface.Addrs(); err == nil {
22 for _, ia := range addrs {
23 for _, ib := range piface.Addresses {
24 if ia.String() == ib.IP.String() || strings.HasPrefix(ia.String(), ib.IP.String()) {
25 return true
26 }
27 }
28 }
29 }
30 return false
31 }
32
33 func getInterfaceName(iface net.Interface) string {
34 devs, err := pcap.FindAllDevs()
35 if err != nil {
36 return iface.Name
37 }
38
39 for _, dev := range devs {
40 if areTheSame(iface, dev) {
41 return dev.Name
42 }
43 }
44
45 return iface.Name
46 }
47
48 func SetInterfaceChannel(iface string, channel int) error {
49 return fmt.Errorf("Windows does not support WiFi channel hopping.")
50 }
51
52 func GetSupportedFrequencies(iface string) ([]int, error) {
53 freqs := make([]int, 0)
54 return freqs, fmt.Errorf("Windows does not support WiFi channel hopping.")
55 }
56
57 func ForceMonitorMode(iface string) error {
58 return nil
59 }