Esempio n. 1
0
// Parse prefix and compute corresponding from and to.
func Prefix(vars url.Values) (from, to uint64, err error) {

	if p := vars.Get("prefix"); p == "" {
		return 0, 0, nil
	}

	prefix, err := strconv.ParseUint(vars.Get("prefix"), 10, 64)
	if err != nil {
		return 0, 0, err
	}

	from, err = enum.PrefixToE164(prefix)
	if err != nil {
		return 0, 0, err
	}

	to, _ = enum.PrefixToE164(prefix + 1)

	return
}
Esempio n. 2
0
// Extract the E164 part of an ENUM query. Ex: 1.2.3.4.domain -> 4321.
func extractE164FromName(name string) (number uint64, err error) {
	numberprefix := strings.Join(reg.FindAllString(name, -1), "")
	number, err = enum.ConvertEnumToInt(numberprefix)
	number, err = enum.PrefixToE164(number)
	return
}