Created
November 21, 2019 20:09
-
-
Save ubogdan/b2ed77cf1076c2d0e9ea9e7ae43fe227 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ValidAS takes an int and returns true if valid or false if not. | |
func ValidAS(a int) bool { | |
// we'll make some basic oversimplicifcations and include unassigned space as valid for convienience. | |
// not valid yet, but more valid than doc and reserved space. | |
switch { | |
case a == 0: | |
return false | |
case a > 1 && a < 64496: | |
// current valid 2byte range that makes up most of the internet. | |
return true | |
case a >= 64496 && a <= 65535: | |
// documentation and reserved | |
return false | |
case a > 65536 && a <= 131071: | |
// reserved bottom end of 4byte range | |
return false | |
case a >= 131072 && a < 397213: | |
// valid 4byte range | |
return true | |
case a >= 397213: | |
// end of 4byte range and up. | |
return false | |
} | |
return true | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment