Hey guys, first of all I’m a big fan of what you’re doing here it’s a great product. I’m excited to see all it has to offer.
I’m currently looking at ways to validate numbers to deny calls to invalid/incomplete numbers. For example calls to 6422xxxxxxx should be exactly 11 digits in length. I have been doing this with destinations which works well but it sends a 404 Can’t find destination prefix.
I since found the “validate dst number network” option in the routing plans which works as intended, however the min length & max length fields seem to be ignored when detecting networks and so calls still try to go through (and fail when we send them upstream as the number is invalid).
Here’s an example prefix:
PREFIX | 6422 |
---|---|
COUNTRY | 153 |
NETWORK | 1646 |
NUMBER MIN LENGTH | 11 |
NUMBER MAX LENGTH | 11 |
I’ve checked out the source, I’m only a novice when it comes to PostgreSQL functions but it seems this was just overlooked as I can’t see any reference to the min length or max length at least in this function.
--
-- Name: network_prefixes; Type: TABLE; Schema: sys; Owner: -
--
CREATE TABLE sys.network_prefixes (
id integer NOT NULL,
prefix character varying NOT NULL,
network_id integer NOT NULL,
country_id integer,
number_min_length smallint DEFAULT 0 NOT NULL,
number_max_length smallint DEFAULT 100 NOT NULL,
uuid uuid DEFAULT public.uuid_generate_v1() NOT NULL
);
--
-- Name: detect_network(character varying); Type: FUNCTION; Schema: switch18; Owner: -
--
CREATE FUNCTION switch18.detect_network(i_dst character varying) RETURNS sys.network_prefixes
LANGUAGE plpgsql COST 10
AS $$
declare
v_ret sys.network_prefixes%rowtype;
BEGIN
select into v_ret *
from sys.network_prefixes
where prefix_range(prefix)@>prefix_range(i_dst)
order by length(prefix_range(prefix)) desc
limit 1;
return v_ret;
END;
$$;
Thanks!