From 2214c43b346b9747f19becf45da777e5bcccd568 Mon Sep 17 00:00:00 2001 From: ruslandoga Date: Mon, 24 Jun 2024 18:29:55 +0700 Subject: [PATCH] happy tcp (#4245) * happy tcp * changelog * update mix.lock --------- Co-authored-by: hq1 --- CHANGELOG.md | 2 ++ config/runtime.exs | 19 ++++++++++++++++++- lib/plausible/application.ex | 1 + mix.exs | 3 ++- mix.lock | 1 + 5 files changed, 24 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index ec65062cb490..065196ce6b1e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,10 +9,12 @@ All notable changes to this project will be documented in this file. - Add `does_not_contain` filter support to dashboard ### Removed +- Deprecate `ECTO_IPV6` and `ECTO_CH_IPV6` env vars in CE plausible/analytics#4245 ### Changed - Increase hourly request limit for API keys in CE from 600 to 1000000 (practically removing the limit) plausible/analytics#4200 +- Make TCP connections try IPv6 first with IPv4 fallback in CE plausible/analytics#4245 - `is` and `is not` filters in dashboard no longer support wildcards. Use contains/does not contain filter instead. ### Fixed diff --git a/config/runtime.exs b/config/runtime.exs index 88b70b978482..170f39933d45 100644 --- a/config/runtime.exs +++ b/config/runtime.exs @@ -319,7 +319,18 @@ config :plausible, PlausibleWeb.Endpoint, websocket_url: websocket_url, secure_cookie: secure_cookie -maybe_ipv6 = if System.get_env("ECTO_IPV6"), do: [:inet6], else: [] +maybe_ipv6 = + if get_var_from_path_or_env(config_dir, "ECTO_IPV6") do + if config_env() in [:ce, :ce_dev, :ce_test] do + Logger.warning( + "ECTO_IPV6 is no longer necessary as all TCP connections now try IPv6 automatically with IPv4 fallback" + ) + end + + [:inet6] + else + [] + end db_cacertfile = get_var_from_path_or_env(config_dir, "DATABASE_CACERTFILE", CAStore.file_path()) @@ -368,6 +379,12 @@ maybe_ch_ipv6 = get_var_from_path_or_env(config_dir, "ECTO_CH_IPV6", "false") |> String.to_existing_atom() +if maybe_ch_ipv6 && config_env() in [:ce, :ce_dev, :ce_test] do + Logger.warning( + "ECTO_CH_IPV6 is no longer necessary as all TCP connections now try IPv6 automatically with IPv4 fallback" + ) +end + ch_cacertfile = get_var_from_path_or_env(config_dir, "CLICKHOUSE_CACERTFILE") ch_transport_opts = [ diff --git a/lib/plausible/application.ex b/lib/plausible/application.ex index 5b79d17207c0..12ba22c31f0d 100644 --- a/lib/plausible/application.ex +++ b/lib/plausible/application.ex @@ -8,6 +8,7 @@ defmodule Plausible.Application do def start(_type, _args) do on_ee(do: Plausible.License.ensure_valid_license()) + on_ce(do: :inet_db.set_tcp_module(:happy_tcp)) children = [ Plausible.Cache.Stats, diff --git a/mix.exs b/mix.exs index b40e304b5a79..19b023a42717 100644 --- a/mix.exs +++ b/mix.exs @@ -143,7 +143,8 @@ defmodule Plausible.MixProject do {:sweet_xml, "~> 0.7.4"}, {:zstream, "~> 0.6.4"}, {:con_cache, "~> 1.1.0"}, - {:req, "~> 0.5.0"} + {:req, "~> 0.5.0"}, + {:happy_tcp, github: "ruslandoga/happy_tcp", only: [:ce, :ce_dev, :ce_test]} ] end diff --git a/mix.lock b/mix.lock index 9123696b1820..370b3f52371e 100644 --- a/mix.lock +++ b/mix.lock @@ -63,6 +63,7 @@ "gproc": {:hex, :gproc, "0.9.1", "f1df0364423539cf0b80e8201c8b1839e229e5f9b3ccb944c5834626998f5b8c", [:rebar3], [], "hexpm", "905088e32e72127ed9466f0bac0d8e65704ca5e73ee5a62cb073c3117916d507"}, "grpcbox": {:hex, :grpcbox, "0.17.1", "6e040ab3ef16fe699ffb513b0ef8e2e896da7b18931a1ef817143037c454bcce", [:rebar3], [{:acceptor_pool, "~> 1.0.0", [hex: :acceptor_pool, repo: "hexpm", optional: false]}, {:chatterbox, "~> 0.15.1", [hex: :ts_chatterbox, repo: "hexpm", optional: false]}, {:ctx, "~> 0.6.0", [hex: :ctx, repo: "hexpm", optional: false]}, {:gproc, "~> 0.9.1", [hex: :gproc, repo: "hexpm", optional: false]}], "hexpm", "4a3b5d7111daabc569dc9cbd9b202a3237d81c80bf97212fbc676832cb0ceb17"}, "hackney": {:hex, :hackney, "1.20.1", "8d97aec62ddddd757d128bfd1df6c5861093419f8f7a4223823537bad5d064e2", [:rebar3], [{:certifi, "~> 2.12.0", [hex: :certifi, repo: "hexpm", optional: false]}, {:idna, "~> 6.1.0", [hex: :idna, repo: "hexpm", optional: false]}, {:metrics, "~> 1.0.0", [hex: :metrics, repo: "hexpm", optional: false]}, {:mimerl, "~> 1.1", [hex: :mimerl, repo: "hexpm", optional: false]}, {:parse_trans, "3.4.1", [hex: :parse_trans, repo: "hexpm", optional: false]}, {:ssl_verify_fun, "~> 1.1.0", [hex: :ssl_verify_fun, repo: "hexpm", optional: false]}, {:unicode_util_compat, "~> 0.7.0", [hex: :unicode_util_compat, repo: "hexpm", optional: false]}], "hexpm", "fe9094e5f1a2a2c0a7d10918fee36bfec0ec2a979994cff8cfe8058cd9af38e3"}, + "happy_tcp": {:git, "https://github.com/ruslandoga/happy_tcp.git", "d639436bf8e7b456abc86bac13b722a2b6d60725", []}, "heroicons": {:hex, :heroicons, "0.5.3", "ee8ae8335303df3b18f2cc07f46e1cb6e761ba4cf2c901623fbe9a28c0bc51dd", [:mix], [{:castore, ">= 0.0.0", [hex: :castore, repo: "hexpm", optional: false]}, {:phoenix_live_view, ">= 0.18.2", [hex: :phoenix_live_view, repo: "hexpm", optional: false]}], "hexpm", "a210037e8a09ac17e2a0a0779d729e89c821c944434c3baa7edfc1f5b32f3502"}, "hpack": {:hex, :hpack_erl, "0.3.0", "2461899cc4ab6a0ef8e970c1661c5fc6a52d3c25580bc6dd204f84ce94669926", [:rebar3], [], "hexpm", "d6137d7079169d8c485c6962dfe261af5b9ef60fbc557344511c1e65e3d95fb0"}, "hpax": {:hex, :hpax, "0.2.0", "5a58219adcb75977b2edce5eb22051de9362f08236220c9e859a47111c194ff5", [:mix], [], "hexpm", "bea06558cdae85bed075e6c036993d43cd54d447f76d8190a8db0dc5893fa2f1"},