<pre style='margin:0'>
Dan Villiom Podlaski Christiansen (danchr) pushed a commit to branch master
in repository macports-ports.
</pre>
<p><a href="https://github.com/macports/macports-ports/commit/2ece73c5c3fcffebe5a1389632c778d812c96df8">https://github.com/macports/macports-ports/commit/2ece73c5c3fcffebe5a1389632c778d812c96df8</a></p>
<pre style="white-space: pre; background: #F8F8F8"><span style='display:block; white-space:pre;color:#808000;'>commit 2ece73c5c3fcffebe5a1389632c778d812c96df8
</span>Author: Dan Villiom Podlaski Christiansen <danchr@macports.org>
AuthorDate: Sat Feb 18 21:49:39 2017 +0100
<span style='display:block; white-space:pre;color:#404040;'> aiccu: implement reconnection when interface address changes
</span><span style='display:block; white-space:pre;color:#404040;'>
</span><span style='display:block; white-space:pre;color:#404040;'> The upstream author originally filed ticket 22872, complaining that
</span><span style='display:block; white-space:pre;color:#404040;'> AICCU should never, ever run under a job manager and just stay alive
</span><span style='display:block; white-space:pre;color:#404040;'> forever. Ryan Schmidt eventually addressed this by disabling said
</span><span style='display:block; white-space:pre;color:#404040;'> startup item.
</span><span style='display:block; white-space:pre;color:#404040;'>
</span><span style='display:block; white-space:pre;color:#404040;'> In the same bug, however, a user reported that AICCU did, in fact,
</span><span style='display:block; white-space:pre;color:#404040;'> fail under some circumstances; when changing networks. A bit of
</span><span style='display:block; white-space:pre;color:#404040;'> investigation found that the cause of this that on macOS, sockets
</span><span style='display:block; white-space:pre;color:#404040;'> bound to a wildcard UDP port actually get an IP address assigned
</span><span style='display:block; white-space:pre;color:#404040;'> internally. If the computer later switches networks and loses that
</span><span style='display:block; white-space:pre;color:#404040;'> address, all subsequent reads fail with EADDRNOTAVAIL. I've added a
</span><span style='display:block; white-space:pre;color:#404040;'> patch that addresses this by detecting this error and reestablishing
</span><span style='display:block; white-space:pre;color:#404040;'> the connection.
</span><span style='display:block; white-space:pre;color:#404040;'>
</span><span style='display:block; white-space:pre;color:#404040;'> Under normal circumstances, package maintainers shouldn't fix bugs in
</span><span style='display:block; white-space:pre;color:#404040;'> upstream code, without at the very least having upstream accept the
</span><span style='display:block; white-space:pre;color:#404040;'> fix. However, upstream has effectively abandoned the port; I posted a
</span><span style='display:block; white-space:pre;color:#404040;'> patch to their forum a year ago, and received no reply. Not even from
</span><span style='display:block; white-space:pre;color:#404040;'> the maintainer of the port, so I've taken the liberty of adopting it.
</span><span style='display:block; white-space:pre;color:#404040;'>
</span><span style='display:block; white-space:pre;color:#404040;'> (Anyway, the port itself is somewhat esoteric: it's for an IPv6
</span><span style='display:block; white-space:pre;color:#404040;'> tunneling service that no longer accepts new sign-ups.)
</span><span style='display:block; white-space:pre;color:#404040;'>
</span><span style='display:block; white-space:pre;color:#404040;'> Closes: https://trac.macports.org/ticket/22872
</span>---
net/aiccu/Portfile | 7 +++--
net/aiccu/files/ayiya-reconnect.diff | 59 ++++++++++++++++++++++++++++++++++++
2 files changed, 63 insertions(+), 3 deletions(-)
<span style='display:block; white-space:pre;color:#808080;'>diff --git a/net/aiccu/Portfile b/net/aiccu/Portfile
</span><span style='display:block; white-space:pre;color:#808080;'>index f6ecd2f..d09b197 100644
</span><span style='display:block; white-space:pre;background:#e0e0ff;'>--- a/net/aiccu/Portfile
</span><span style='display:block; white-space:pre;background:#e0e0ff;'>+++ b/net/aiccu/Portfile
</span><span style='display:block; white-space:pre;background:#e0e0e0;'>@@ -1,13 +1,14 @@
</span> # -*- coding: utf-8; mode: tcl; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- vim:fenc=utf-8:ft=tcl:et:sw=4:ts=4:sts=4
<span style='display:block; white-space:pre;background:#e0ffe0;'>+# $Id: Portfile 135911 2015-05-06 21:05:20Z ryandesign@macports.org $
</span>
PortSystem 1.0
name aiccu
version 20070115
<span style='display:block; white-space:pre;background:#ffe0e0;'>-revision 4
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+revision 5
</span> categories net
platforms darwin
<span style='display:block; white-space:pre;background:#ffe0e0;'>-maintainers nomaintainer
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+maintainers {danchr @danchr} openmaintainer
</span>
description Automatic IPv6 Connectivity Configuration Utility
long_description AICCU makes it very easy for SixXS users to get IPv6 connectivity \
<span style='display:block; white-space:pre;background:#e0e0e0;'>@@ -33,7 +34,7 @@ set pid_file ${prefix}/var/run/${name}.pidfile
</span> set conf_file ${prefix}/etc/aiccu.conf
worksrcdir aiccu
<span style='display:block; white-space:pre;background:#ffe0e0;'>-patchfiles Makefile.patch aiccu_conf.patch
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+patchfiles Makefile.patch aiccu_conf.patch ayiya-reconnect.diff
</span>
pre-configure {
reinplace "s|#pidfile /var/run/aiccu.pid|pidfile ${pid_file}|" \
<span style='display:block; white-space:pre;color:#808080;'>diff --git a/net/aiccu/files/ayiya-reconnect.diff b/net/aiccu/files/ayiya-reconnect.diff
</span>new file mode 100644
<span style='display:block; white-space:pre;color:#808080;'>index 0000000..095d4ce
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>--- /dev/null
</span><span style='display:block; white-space:pre;background:#e0e0ff;'>+++ b/net/aiccu/files/ayiya-reconnect.diff
</span><span style='display:block; white-space:pre;background:#e0e0e0;'>@@ -0,0 +1,59 @@
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+diff common/ayiya.c common/ayiya.c
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+--- common/ayiya.c
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++++ common/ayiya.c
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+@@ -77,6 +77,27 @@ void ayiya_log(int level, const char *wh
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ dolog(level, buf);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++static bool ayiya_reconnect(void);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++static bool ayiya_reconnect(void)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++{
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ char *addr = inet_ntoa(ayiya_ipv4_pop);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ TLSSOCKET new_socket = connect_client(addr, AYIYA_PORT, AF_INET, SOCK_DGRAM);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ if (!new_socket)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ ayiya_log(LOG_WARNING, reader_name, NULL, 0, "Error while reconnecting to AYIYA server %s: %s (%d)\n", addr, strerror(errno), errno);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ return false;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ ayiya_log(LOG_DEBUG, reader_name, NULL, 0, "Reconnected to server %s...\n", addr);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ sock_free(ayiya_socket);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ ayiya_socket = new_socket;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ return true;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++}
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ /* Tun -> Socket */
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ void ayiya_reader(char *buf, unsigned int length);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ void ayiya_reader(char *buf, unsigned int length)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+@@ -137,6 +158,13 @@ void ayiya_reader(char *buf, unsigned in
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ if (lenout < 0)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ ayiya_log(LOG_ERR, reader_name, NULL, 0, "Error (%d) while sending %u bytes to network: %s (%d)\n", lenout, length, strerror(errno), errno);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++#ifdef EADDRNOTAVAIL
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ if (errno == EADDRNOTAVAIL)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ ayiya_reconnect();
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++#endif
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ else if (length != (unsigned int)lenout)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+@@ -335,6 +363,13 @@ void ayiya_beat(void)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ if (lenout < 0)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ ayiya_log(LOG_ERR, beat_name, NULL, 0, "Error (%d) while sending %u bytes sent to network: %s (%d)\n", lenout, n, strerror(errno), errno);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++#ifdef EADDRNOTAVAIL
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ if (errno == EADDRNOTAVAIL)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ ayiya_reconnect();
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>++#endif
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ else if (n != lenout)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ {
</span></pre><pre style='margin:0'>
</pre>