Coder Social home page Coder Social logo

gomanuf's People

Contributors

scp10011 avatar timest avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

gomanuf's Issues

OUI conversion is unstable, such as: 8C:1C:DA:45:E7:B6

现象:某些带有指定前缀长度(非24)匹配的MAC地址会有匹配不稳定的情况;

解决方法如下:
Search函数在搜索时需要先对d的key做排序,然后按序检索

func Search(mac string) (result string) {
	defer func() {
		if r := recover(); r != nil {
			result = ""
		}
	}()
	s := strings.Split(strings.ToUpper(mac), ":")
	bint := b2uint64(s)
	
	var keyFirstFloor []int
	for b := range d {
		keyFirstFloor = append(keyFirstFloor, b)
	}
	sort.Sort(sort.Reverse(sort.IntSlice(keyFirstFloor)))

	for _, b := range keyFirstFloor {
		k := 48 - b
		bint = (bint >> uint8(k)) << uint8(k)
		if _, ok := d[b].(map[uint64]string)[bint]; ok {
			return d[b].(map[uint64]string)[bint]
		}
	}
	return ""
}

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.