From 123e45628767b4c52feb9f7910b96650490924e5 Mon Sep 17 00:00:00 2001 From: "Zaiming (Stone) Shi" Date: Tue, 19 Apr 2022 13:04:57 +0200 Subject: [PATCH] feat: change default trial license * Changed number of connections limit from 10 to 1000 * Added a 'deployment' field, so we know which is which when a customer has multiple licenses * Default expiration is 5 years --- lib-ee/emqx_license/etc/emqx_license.conf | 3 ++- lib-ee/emqx_license/include/emqx_license.hrl | 6 +++--- .../emqx_license/src/emqx_license_parser_legacy.erl | 1 + .../src/emqx_license_parser_v20220101.erl | 9 ++++++--- lib-ee/emqx_license/test/emqx_license_SUITE.erl | 3 +++ .../emqx_license/test/emqx_license_checker_SUITE.erl | 7 +++++++ .../emqx_license/test/emqx_license_parser_SUITE.erl | 12 +++++++++++- .../test/emqx_license_parser_legacy_SUITE.erl | 1 + lib-ee/emqx_license/test/emqx_license_test_lib.erl | 4 ++-- 9 files changed, 36 insertions(+), 10 deletions(-) diff --git a/lib-ee/emqx_license/etc/emqx_license.conf b/lib-ee/emqx_license/etc/emqx_license.conf index 6c5ad217b..476444ea0 100644 --- a/lib-ee/emqx_license/etc/emqx_license.conf +++ b/lib-ee/emqx_license/etc/emqx_license.conf @@ -1,5 +1,6 @@ license { - key = "MjIwMTExCjAKMTAKRXZhbHVhdGlvbgpjb250YWN0QGVtcXguaW8KMjAyMjAxMDEKMzY1MDAKMTAK.MEUCIFc9EUjqB3SjpRqWjqmAzI4Tg4LwhCRet9scEoxMRt8fAiEAk6vfYUiPOTzBC+3EjNF3WmLTiA3B0TN5ZNwuTKbTXJQ=" + # The default license has 1000 connections limit, it is issued on 20220419 and valid for 5 years (1825 days) + key = "MjIwMTExCjAKMTAKRXZhbHVhdGlvbgpjb250YWN0QGVtcXguaW8KZGVmYXVsdAoyMDIyMDQxOQoxODI1CjEwMDAK.MEQCICbgRVijCQov2hrvZXR1mk9Oa+tyV1F5oJ6iOZeSHjnQAiB9dUiVeaZekDOjztk+NCWjhk4PG8tWfw2uFZWruSzD6g==" connection_low_watermark = 75%, connection_high_watermark = 80% } diff --git a/lib-ee/emqx_license/include/emqx_license.hrl b/lib-ee/emqx_license/include/emqx_license.hrl index 19a0cc954..df40942ac 100644 --- a/lib-ee/emqx_license/include/emqx_license.hrl +++ b/lib-ee/emqx_license/include/emqx_license.hrl @@ -9,11 +9,11 @@ -define(EVALUATION_LOG, "\n" - "===============================================================================\n" - "This is an evaluation license that is restricted to 10 concurrent connections.\n" + "================================================================================\n" + "This is an evaluation license that is restricted to 1000 concurrent connections.\n" "If you already have a paid license, please apply it now.\n" "Or you could visit https://emqx.com/apply-licenses/emqx to get a trial license.\n" - "===============================================================================\n" + "================================================================================\n" ). -define(EXPIRY_LOG, diff --git a/lib-ee/emqx_license/src/emqx_license_parser_legacy.erl b/lib-ee/emqx_license/src/emqx_license_parser_legacy.erl index 894d5d8aa..a5fa4ab64 100644 --- a/lib-ee/emqx_license/src/emqx_license_parser_legacy.erl +++ b/lib-ee/emqx_license/src/emqx_license_parser_legacy.erl @@ -89,6 +89,7 @@ dump(#{ [ {customer, Customer}, {email, Email}, + {deployment, "default"}, {max_connections, MaxConnections}, {start_at, format_date(StartAtDate)}, {expiry_at, format_date(ExpiryAtDate)}, diff --git a/lib-ee/emqx_license/src/emqx_license_parser_v20220101.erl b/lib-ee/emqx_license/src/emqx_license_parser_v20220101.erl index bafb02d5d..d721e3de0 100644 --- a/lib-ee/emqx_license/src/emqx_license_parser_v20220101.erl +++ b/lib-ee/emqx_license/src/emqx_license_parser_v20220101.erl @@ -48,6 +48,7 @@ dump( customer_type := CType, customer := Customer, email := Email, + deployment := Deployment, date_start := DateStart, max_connections := MaxConns } = License @@ -59,6 +60,7 @@ dump( [ {customer, Customer}, {email, Email}, + {deployment, Deployment}, {max_connections, MaxConns}, {start_at, format_date(DateStart)}, {expiry_at, format_date(DateExpiry)}, @@ -103,20 +105,21 @@ parse_payload(Payload) -> string:split(string:trim(Payload), <<"\n">>, all) ), case Lines of - [?LICENSE_VERSION, Type, CType, Customer, Email, DateStart, Days, MaxConns] -> + [?LICENSE_VERSION, Type, CType, Customer, Email, Deployment, DateStart, Days, MaxConns] -> collect_fields([ {type, parse_type(Type)}, {customer_type, parse_customer_type(CType)}, {customer, {ok, Customer}}, {email, {ok, Email}}, + {deployment, {ok, Deployment}}, {date_start, parse_date_start(DateStart)}, {days, parse_days(Days)}, {max_connections, parse_max_connections(MaxConns)} ]); - [_Version, _Type, _CType, _Customer, _Email, _DateStart, _Days, _MaxConns] -> + [_Version, _Type, _CType, _Customer, _Email, _Deployment, _DateStart, _Days, _MaxConns] -> {error, invalid_version}; _ -> - {error, invalid_field_number} + {error, unexpected_number_of_fields} end. parse_type(TypeStr) -> diff --git a/lib-ee/emqx_license/test/emqx_license_SUITE.erl b/lib-ee/emqx_license/test/emqx_license_SUITE.erl index 4744a1cef..bc73f9071 100644 --- a/lib-ee/emqx_license/test/emqx_license_SUITE.erl +++ b/lib-ee/emqx_license/test/emqx_license_SUITE.erl @@ -102,6 +102,7 @@ t_check_exceeded(_Config) -> "10", "Foo", "contact@foo.com", + "bar", "20220111", "100000", "10" @@ -130,6 +131,7 @@ t_check_ok(_Config) -> "10", "Foo", "contact@foo.com", + "bar", "20220111", "100000", "10" @@ -160,6 +162,7 @@ t_check_expired(_Config) -> "0", "Foo", "contact@foo.com", + "bar", %% Expired long ago "20211101", "10", diff --git a/lib-ee/emqx_license/test/emqx_license_checker_SUITE.erl b/lib-ee/emqx_license/test/emqx_license_checker_SUITE.erl index dcf2a0197..8842db7f9 100644 --- a/lib-ee/emqx_license/test/emqx_license_checker_SUITE.erl +++ b/lib-ee/emqx_license/test/emqx_license_checker_SUITE.erl @@ -55,6 +55,7 @@ t_dump(_Config) -> "10", "Foo", "contact@foo.com", + "bar", "20220111", "100000", "10" @@ -67,6 +68,7 @@ t_dump(_Config) -> [ {customer, <<"Foo">>}, {email, <<"contact@foo.com">>}, + {deployment, <<"bar">>}, {max_connections, 10}, {start_at, <<"2022-01-11">>}, {expiry_at, <<"2295-10-27">>}, @@ -85,6 +87,7 @@ t_update(_Config) -> "10", "Foo", "contact@foo.com", + "bar", "20220111", "100000", "123" @@ -129,6 +132,7 @@ t_expired_trial(_Config) -> "10", "Foo", "contact@foo.com", + "bar", format_date(Date10DaysAgo), "1", "123" @@ -154,6 +158,7 @@ t_overexpired_small_client(_Config) -> "0", "Foo", "contact@foo.com", + "bar", format_date(Date100DaysAgo), "1", "123" @@ -179,6 +184,7 @@ t_overexpired_medium_client(_Config) -> "1", "Foo", "contact@foo.com", + "bar", format_date(Date100DaysAgo), "1", "123" @@ -204,6 +210,7 @@ t_recently_expired_small_client(_Config) -> "0", "Foo", "contact@foo.com", + "bar", format_date(Date10DaysAgo), "1", "123" diff --git a/lib-ee/emqx_license/test/emqx_license_parser_SUITE.erl b/lib-ee/emqx_license/test/emqx_license_parser_SUITE.erl index a1633d17f..3b4e78a49 100644 --- a/lib-ee/emqx_license/test/emqx_license_parser_SUITE.erl +++ b/lib-ee/emqx_license/test/emqx_license_parser_SUITE.erl @@ -51,6 +51,7 @@ t_parse(_Config) -> "10", "Foo", "contact@foo.com", + "bar-deployment", "20220111", "100000", "10" @@ -73,8 +74,10 @@ t_parse(_Config) -> "0", "10", "Foo", + % one extra field "Bar", "contact@foo.com", + "default-deployment", "20220111", "100000", "10" @@ -85,7 +88,7 @@ t_parse(_Config) -> ?assertMatch({error, _}, Res2), {error, Err2} = Res2, ?assertEqual( - invalid_field_number, + unexpected_number_of_fields, proplists:get_value(emqx_license_parser_v20220101, Err2) ), @@ -97,6 +100,7 @@ t_parse(_Config) -> "ten", "Foo", "contact@foo.com", + "default-deployment", "20220231", "-10", "10" @@ -124,6 +128,7 @@ t_parse(_Config) -> "ten", "Foo", "contact@foo.com", + "default-deployment", "2022-02-1st", "-10", "10" @@ -133,6 +138,7 @@ t_parse(_Config) -> ), ?assertMatch({error, _}, Res4), {error, Err4} = Res4, + ?assertEqual( [ {type, invalid_license_type}, @@ -152,6 +158,7 @@ t_parse(_Config) -> "10", "Foo", "contact@foo.com", + "default-deployment", "20220111", "100000", "10" @@ -167,6 +174,7 @@ t_parse(_Config) -> "10", "Foo", "contact@foo.com", + "default-deployment", "20220111", "100000", "10" @@ -210,6 +218,7 @@ t_dump(_Config) -> [ {customer, <<"Foo">>}, {email, <<"contact@foo.com">>}, + {deployment, <<"default-deployment">>}, {max_connections, 10}, {start_at, <<"2022-01-11">>}, {expiry_at, <<"2295-10-27">>}, @@ -255,6 +264,7 @@ sample_license() -> "10", "Foo", "contact@foo.com", + "default-deployment", "20220111", "100,000", "10" diff --git a/lib-ee/emqx_license/test/emqx_license_parser_legacy_SUITE.erl b/lib-ee/emqx_license/test/emqx_license_parser_legacy_SUITE.erl index 02b842d94..b1c45ade7 100644 --- a/lib-ee/emqx_license/test/emqx_license_parser_legacy_SUITE.erl +++ b/lib-ee/emqx_license/test/emqx_license_parser_legacy_SUITE.erl @@ -58,6 +58,7 @@ t_dump(_Config) -> [ {customer, <<"EMQ X Evaluation">>}, {email, "contact@emqx.io"}, + {deployment, "default"}, {max_connections, 10}, {start_at, <<"2020-06-20">>}, {expiry_at, <<"2049-01-01">>}, diff --git a/lib-ee/emqx_license/test/emqx_license_test_lib.erl b/lib-ee/emqx_license/test/emqx_license_test_lib.erl index bf0ea6e66..d3f2b5bd7 100644 --- a/lib-ee/emqx_license/test/emqx_license_test_lib.erl +++ b/lib-ee/emqx_license/test/emqx_license_test_lib.erl @@ -58,7 +58,7 @@ make_license(Values) -> default_license() -> %% keep it the same as in etc/emqx_license.conf License = - "MjIwMTExCjAKMTAKRXZhbHVhdGlvbgpjb250YWN0QGVtcXguaW8KMjAyMjAxMDEKMzY1MDAKMTAK." - "MEUCIFc9EUjqB3SjpRqWjqmAzI4Tg4LwhCRet9scEoxMRt8fAiEAk6vfYUiPOTzBC+3EjNF3WmLTiA3B0TN5ZNwuTKbTXJQ=", + "MjIwMTExCjAKMTAKRXZhbHVhdGlvbgpjb250YWN0QGVtcXguaW8KZGVmYXVsdAoyMDIyMDQxOQoxODI1CjEwMDAK." + "MEQCICbgRVijCQov2hrvZXR1mk9Oa+tyV1F5oJ6iOZeSHjnQAiB9dUiVeaZekDOjztk+NCWjhk4PG8tWfw2uFZWruSzD6g==", ok = file:write_file(?DEFAULT_LICENSE_FILE, License), ?DEFAULT_LICENSE_FILE.