Compare commits

...

3 Commits

Author SHA1 Message Date
db9192a69c sip: attempt reconnection anytime network is routable, not just when routability changes
this resolves an issue where the network could be routable but DNS had
failed, and CallsSipOrigin settled into the offline state with
`CALLS_ACCOUNT_STATE_REASON_CONNECTION_DNS_ERROR`. in this situation, we
now attempt a reconnection every 15s, instead of waiting for the network
to go down and back up again.
2024-08-18 13:45:48 +00:00
017b26a0c8 use linphone's sofia_sip
the DNS is less buggy
2024-08-18 13:00:04 +00:00
012d1af9dc nix: build with debug info 2024-08-18 09:04:18 +00:00
3 changed files with 64 additions and 7 deletions

View File

@@ -4,7 +4,43 @@
{ pkgs ? import <nixpkgs> {} }:
let
inherit (pkgs) stdenv;
in stdenv.mkDerivation {
buildDebug = p: p.overrideAttrs (base: {
dontStrip = true;
env = (base.env or {}) // {
mesonBuildType = "debugoptimized";
NIX_CFLAGS_COMPILE = "-ggdb -Og -fno-omit-frame-pointer";
# mesonBuildType = "debug";
# NIX_CFLAGS_COMPILE = "-g -O0 -fno-omit-frame-pointer";
};
});
sofia_sip' = pkgs.sofia_sip.overrideAttrs (base: {
# sofia_sip linphone fork (2024-08-17)
# it seems to have less buggy DNS (sresolv)? the DNS actually reports errors to the consumer, instead of just never returning.
# more specifically, `outgoing_answer_a` always calls its continuation: that's actually in libsofia-sip-ua/nta/nta.c
src = with pkgs; fetchFromGitLab {
domain = "gitlab.linphone.org";
owner = "BC/public/external";
repo = "sofia-sip";
rev = "b924a57e8eeb24e8b9afc5fd0fb9b51d5993fe5d";
hash = "sha256-1VbKV+eAJ80IMlubNl7774B7QvLv4hE8SXANDSD9sRU=";
};
});
# sofia_sip' = pkgs.sofia_sip.overrideAttrs (base: {
# # sofia_sip tip (2024-08-17)
# src = with pkgs; fetchFromGitHub {
# owner = "freeswitch";
# repo = "sofia-sip";
# rev = "0a50b8402fa5b6190a6c91c2e04dfe44a40de02c";
# hash = "sha256-cxLk0IEwpoxeuVllnZ4/6JqzCd0GVeLyulFj0EYgnek=";
# };
# });
# sofia_sip' = pkgs.sofia_sip.overrideAttrs (base: {
# postPatch = (base.postPatch or "") + ''
# substituteInPlace libsofia-sip-ua/sresolv/sofia-resolv/sres.h \
# --replace 'SRES_MAX_RETRY_COUNT = 6' 'SRES_MAX_RETRY_COUNT = 0'
# '';
# });
in buildDebug (stdenv.mkDerivation {
pname = "calls";
version = "unstable";
src = ./.;
@@ -41,6 +77,6 @@ in stdenv.mkDerivation {
libpeas2
libsecret
modemmanager
sofia_sip
(buildDebug sofia_sip')
];
}
})

View File

@@ -1105,6 +1105,12 @@ go_online (CallsAccount *account,
}
}
static void
go_online_opportunistically (CallsSipOrigin *self)
{
if (self->auto_connect)
go_online (CALLS_ACCOUNT (self), TRUE);
}
static const char *
get_address (CallsAccount *account)
@@ -1706,10 +1712,12 @@ calls_sip_origin_init (CallsSipOrigin *self)
if (!sip_test_env || sip_test_env[0] == '\0') {
CallsNetworkWatch *nw = calls_network_watch_get_default ();
if (nw)
if (nw) {
g_signal_connect_swapped (calls_network_watch_get_default (), "network-changed",
G_CALLBACK (recreate_sip), self);
else
g_signal_connect_swapped (calls_network_watch_get_default (), "network-routable",
G_CALLBACK (go_online_opportunistically), self);
} else
g_warning ("Network watch unavailable. Unable to detect network changes.");
}

View File

@@ -61,6 +61,7 @@ static GParamSpec *props[PROP_LAST_PROP];
enum {
NETWORK_CHANGED,
NETWORK_ROUTABLE,
N_SIGNALS
};
static guint signals[N_SIGNALS];
@@ -282,10 +283,12 @@ fetch_ipv6 (CallsNetworkWatch *self)
static gboolean
on_watch_network (CallsNetworkWatch *self)
{
gboolean has_v4 = fetch_ipv4 (self);
gboolean has_v6 = fetch_ipv6 (self);
gboolean changed_v4 = FALSE;
gboolean changed_v6 = FALSE;
changed_v4 = fetch_ipv4 (self) && g_strcmp0 (self->tmp_addr, self->ipv4) != 0;
changed_v4 = has_v4 && g_strcmp0 (self->tmp_addr, self->ipv4) != 0;
if (changed_v4) {
g_free (self->ipv4);
self->ipv4 = g_strdup (self->tmp_addr);
@@ -293,7 +296,7 @@ on_watch_network (CallsNetworkWatch *self)
g_object_notify_by_pspec (G_OBJECT (self), props[PROP_IPV4]);
}
changed_v6 = fetch_ipv6 (self) && g_strcmp0 (self->tmp_addr, self->ipv6) != 0;
changed_v6 = has_v6 && g_strcmp0 (self->tmp_addr, self->ipv6) != 0;
if (changed_v6) {
g_free (self->ipv6);
self->ipv6 = g_strdup (self->tmp_addr);
@@ -304,6 +307,9 @@ on_watch_network (CallsNetworkWatch *self)
if (changed_v4 || changed_v6)
g_signal_emit (self, signals[NETWORK_CHANGED], 0);
if (has_v4 || has_v6)
g_signal_emit (self, signals[NETWORK_ROUTABLE], 0);
return G_SOURCE_CONTINUE;
}
@@ -360,6 +366,13 @@ calls_network_watch_class_init (CallsNetworkWatchClass *klass)
NULL, NULL, NULL,
G_TYPE_NONE,
0);
signals[NETWORK_ROUTABLE] = g_signal_new ("network-routable",
CALLS_TYPE_NETWORK_WATCH,
G_SIGNAL_RUN_LAST,
0,
NULL, NULL, NULL,
G_TYPE_NONE,
0);
props[PROP_IPV4] =
g_param_spec_string ("ipv4",