From e181fd3c9034346596e87fcbd8e9209228d37759 Mon Sep 17 00:00:00 2001 From: Robert Scheck Date: Jun 29 2020 19:06:46 +0000 Subject: Initial import --- diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..98c8c53 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +/re-*.tar.gz diff --git a/README.md b/README.md deleted file mode 100644 index 73bec3d..0000000 --- a/README.md +++ /dev/null @@ -1,3 +0,0 @@ -# libre - -Libre is a portable and generic library for real-time communications with async IO support and a complete SIP stack with support for SDP, RTP/RTCP, STUN/TURN/ICE, BFCP and DNS client. \ No newline at end of file diff --git a/libre-0.6.1-ea0509d.patch b/libre-0.6.1-ea0509d.patch new file mode 100644 index 0000000..3852f6d --- /dev/null +++ b/libre-0.6.1-ea0509d.patch @@ -0,0 +1,211 @@ +https://github.com/creytiv/re/compare/v0.6.1...ea0509d + +diff --git a/debian/changelog b/debian/changelog +index 0177da1..f1ecfaf 100644 +--- a/debian/changelog ++++ b/debian/changelog +@@ -1,3 +1,21 @@ ++libre (0.6.1-3) unstable; urgency=medium ++ ++ * version 0.6.1-3 ++ ++ -- Richard Aas Thu, 23 Apr 2020 13:00:00 +0200 ++ ++libre (0.6.1-2) unstable; urgency=medium ++ ++ * version 0.6.1-2 ++ ++ -- Richard Aas Wed, 4 Mar 2020 14:00:00 +0100 ++ ++libre (0.6.1-1) unstable; urgency=medium ++ ++ * version 0.6.1-1 ++ ++ -- Richard Aas Tue, 25 Feb 2020 09:00:00 +0100 ++ + libre (0.6.1) unstable; urgency=medium + + * version 0.6.1 +diff --git a/debian/rules b/debian/rules +index aba04b6..84ec8a1 100755 +--- a/debian/rules ++++ b/debian/rules +@@ -11,7 +11,7 @@ + + + EXTRA_CFLAGS:="$(shell dpkg-buildflags --get CFLAGS | sed -e 's/-O2//')" +-EXTRA_LFLAGS:="$(shell dpkg-buildflags --get LDFLAGS) -Wl,-soname,libre.so.0" ++EXTRA_LFLAGS:="$(shell dpkg-buildflags --get LDFLAGS) -Wl,-soname,libre.so" + + + configure: configure-stamp +diff --git a/include/re_fmt.h b/include/re_fmt.h +index 55806bf..ec0ebd5 100644 +--- a/include/re_fmt.h ++++ b/include/re_fmt.h +@@ -42,6 +42,7 @@ int pl_strcasecmp(const struct pl *pl, const char *str); + int pl_cmp(const struct pl *pl1, const struct pl *pl2); + int pl_casecmp(const struct pl *pl1, const struct pl *pl2); + const char *pl_strchr(const struct pl *pl, char c); ++const char *pl_strrchr(const struct pl *pl, char c); + + /** Advance pl position/length by +/- N bytes */ + static inline void pl_advance(struct pl *pl, ssize_t n) +diff --git a/include/re_tcp.h b/include/re_tcp.h +index 98dba71..5a836bb 100644 +--- a/include/re_tcp.h ++++ b/include/re_tcp.h +@@ -50,6 +50,7 @@ typedef void (tcp_close_h)(int err, void *arg); + /* TCP Socket */ + int tcp_sock_alloc(struct tcp_sock **tsp, const struct sa *local, + tcp_conn_h *ch, void *arg); ++struct tcp_sock *tcp_sock_dup(struct tcp_sock *tso); + int tcp_sock_bind(struct tcp_sock *ts, const struct sa *local); + int tcp_sock_listen(struct tcp_sock *ts, int backlog); + int tcp_accept(struct tcp_conn **tcp, struct tcp_sock *ts, tcp_estab_h *eh, +diff --git a/mk/re.mk b/mk/re.mk +index 3347945..5f30810 100644 +--- a/mk/re.mk ++++ b/mk/re.mk +@@ -271,6 +271,7 @@ endif + AFLAGS := cru + LIB_SUFFIX := .dylib + HAVE_KQUEUE := 1 ++ SYSROOT := $(shell xcrun --show-sdk-path)/usr + endif + ifeq ($(OS),netbsd) + CFLAGS += -fPIC -DNETBSD +@@ -735,14 +736,8 @@ git_snapshot: + # Debian + .PHONY: deb + deb: +- dpkg-buildpackage -rfakeroot +- +-.PHONY: debclean +-debclean: +- @rm -rf build-stamp configure-stamp debian/files debian/$(PROJECT) \ +- debian/lib$(PROJECT) debian/lib$(PROJECT)-dev debian/tmp \ +- debian/.debhelper debian/*.debhelper debian/*.debhelper.log \ +- debian/*.substvars ++ dpkg-buildpackage -rfakeroot --post-clean ++ + + # RPM + RPM := $(shell [ -d /usr/src/rpm ] 2>/dev/null && echo "rpm") +diff --git a/src/fmt/pl.c b/src/fmt/pl.c +index a35fe77..7c46817 100644 +--- a/src/fmt/pl.c ++++ b/src/fmt/pl.c +@@ -503,3 +503,28 @@ const char *pl_strchr(const struct pl *pl, char c) + + return NULL; + } ++ ++ ++/** ++ * Locate the last occurrence of character in pointer-length string ++ * ++ * @param pl Pointer-length string ++ * @param c Character to locate ++ * ++ * @return Pointer to last char if found, otherwise NULL ++ */ ++const char *pl_strrchr(const struct pl *pl, char c) ++{ ++ const char *p, *end; ++ ++ if (!pl_isset(pl)) ++ return NULL; ++ ++ end = pl->p + pl->l - 1; ++ for (p = end; p >= pl->p; p--) { ++ if (*p == c) ++ return p; ++ } ++ ++ return NULL; ++} +diff --git a/src/rtmp/conn.c b/src/rtmp/conn.c +index 6fe16ad..00e36fa 100644 +--- a/src/rtmp/conn.c ++++ b/src/rtmp/conn.c +@@ -437,7 +437,7 @@ static int send_connect(struct rtmp_conn *conn) + 1, + RTMP_AMF_TYPE_OBJECT, 8, + RTMP_AMF_TYPE_STRING, "app", conn->app, +- RTMP_AMF_TYPE_STRING, "flashVer", "LNX 9,0,124,2", ++ RTMP_AMF_TYPE_STRING, "flashVer", "FMLE/3.0", + RTMP_AMF_TYPE_STRING, "tcUrl", conn->uri, + RTMP_AMF_TYPE_BOOLEAN, "fpad", false, + RTMP_AMF_TYPE_NUMBER, "capabilities", 15.0, +@@ -803,18 +803,30 @@ int rtmp_connect(struct rtmp_conn **connp, struct dnsc *dnsc, const char *uri, + struct pl pl_hostport; + struct pl pl_host; + struct pl pl_port; ++ struct pl pl_path; + struct pl pl_app; + struct pl pl_stream; ++ const char *tok; + uint16_t defport; + int err; + + if (!connp || !uri) + return EINVAL; + +- if (re_regex(uri, strlen(uri), "[a-z]+://[^/]+/[^/]+/[^]+", +- &pl_scheme, &pl_hostport, &pl_app, &pl_stream)) ++ if (re_regex(uri, strlen(uri), "[a-z]+://[^/]+/[^]+", ++ &pl_scheme, &pl_hostport, &pl_path)) + return EINVAL; + ++ tok = pl_strrchr(&pl_path, '/'); ++ if (!tok) ++ return EINVAL; ++ ++ pl_app.p = pl_path.p; ++ pl_app.l = tok - pl_path.p; ++ ++ pl_stream.p = tok + 1; ++ pl_stream.l = pl_path.p + pl_path.l - pl_stream.p; ++ + if (!pl_strcasecmp(&pl_scheme, "rtmp")) { + tls = NULL; + defport = RTMP_PORT; +diff --git a/src/tcp/tcp.c b/src/tcp/tcp.c +index f146b87..1ca98ed 100644 +--- a/src/tcp/tcp.c ++++ b/src/tcp/tcp.c +@@ -650,6 +650,33 @@ int tcp_sock_alloc(struct tcp_sock **tsp, const struct sa *local, + + + /** ++ * Duplicate TCP socket ++ * ++ * @param tso TCP Socket to duplicate ++ * ++ * @return Duplicated TCP Socket if success, otherwise NULL ++ */ ++struct tcp_sock *tcp_sock_dup(struct tcp_sock *tso) ++{ ++ struct tcp_sock *ts; ++ ++ if (!tso) ++ return NULL; ++ ++ ts = mem_zalloc(sizeof(*ts), sock_destructor); ++ if (!ts) ++ return NULL; ++ ++ ts->fd = -1; ++ ts->fdc = tso->fdc; ++ ++ tso->fdc = -1; ++ ++ return ts; ++} ++ ++ ++/** + * Bind to a TCP Socket + * + * @param ts TCP Socket diff --git a/libre-0.6.6-re-register-without-stale.patch b/libre-0.6.6-re-register-without-stale.patch new file mode 100644 index 0000000..253a55f --- /dev/null +++ b/libre-0.6.6-re-register-without-stale.patch @@ -0,0 +1,25 @@ +From e79e627765d076670beb8367385768472fc0fbf4 Mon Sep 17 00:00:00 2001 +From: Juha Heinanen +Date: Mon, 16 Sep 2019 09:06:03 +0300 +Subject: [PATCH] do not fail authorization if it has succeed before + +Proposed to upstream: https://github.com/creytiv/re/issues/223 +--- + src/sip/auth.c | 4 +++- + 1 file changed, 3 insertions(+), 1 deletion(-) + +diff --git a/src/sip/auth.c b/src/sip/auth.c +index 1357cad1..21e9c3c1 100644 +--- a/src/sip/auth.c ++++ b/src/sip/auth.c +@@ -161,7 +161,9 @@ static bool auth_handler(const struct sip_hdr *hdr, const struct sip_msg *msg, + goto out; + } + else { +- if (!pl_isset(&ch.stale) || pl_strcasecmp(&ch.stale, "true")) { ++ /* error if first auth attempt fails */ ++ if ((!pl_isset(&ch.stale) || ++ pl_strcasecmp(&ch.stale, "true")) && (realm->nc == 2)) { + err = EAUTH; + goto out; + } diff --git a/libre.spec b/libre.spec new file mode 100644 index 0000000..b8351b3 --- /dev/null +++ b/libre.spec @@ -0,0 +1,95 @@ +# No upstream .so name versioning: https://github.com/creytiv/re/issues/249 +%global soversion 0 + +Summary: Library for real-time communications and SIP stack +Name: libre +Version: 0.6.1 +Release: 2%{?dist} +License: BSD +URL: http://www.creytiv.com/re.html +Source0: https://github.com/creytiv/re/archive/v%{version}/re-%{version}.tar.gz +# Latest fixes from Git (not yet available in a release) +Patch0: libre-0.6.1-ea0509d.patch +# Do not fail authorization if it has succeed before +Patch1: libre-0.6.6-re-register-without-stale.patch +BuildRequires: make +BuildRequires: gcc +BuildRequires: openssl-devel +BuildRequires: zlib-devel +# Cover multiple third party repositories +Obsoletes: libre0 < 0.6.1-2 +Provides: libre0 = %{version}-%{release} +Provides: libre0%{?_isa} = %{version}-%{release} +Obsoletes: re < 0.6.1-2 +Provides: re = %{version}-%{release} +Provides: re%{?_isa} = %{version}-%{release} + +%description +Libre is a portable and generic library for real-time communications with +async IO support and a complete SIP stack with support for SDP, RTP/RTCP, +STUN/TURN/ICE, BFCP and DNS client. + +%package devel +Summary: Development files for the re library +Requires: %{name}%{?_isa} = %{version}-%{release} +Requires: pkgconfig +Requires: openssl-devel +Requires: zlib-devel +# Cover multiple third party repositories +Obsoletes: libre0-devel < 0.6.1-2 +Provides: libre0-devel = %{version}-%{release} +Provides: libre0-devel%{?_isa} = %{version}-%{release} +Obsoletes: re-devel < 0.6.1-2 +Provides: re-devel = %{version}-%{release} +Provides: re-devel%{?_isa} = %{version}-%{release} + +%description devel +The libre-devel package includes header files and libraries necessary for +developing programs which use the re C library. + +%prep +%setup -q -n re-%{version} +%patch0 -p1 -b .ea0509d +%patch1 -p1 -b .re-register-without-stale + +%build +%make_build \ + SHELL='sh -x' \ + RELEASE=1 \ + USE_OPENSSL=1 \ + USE_ZLIB=1 \ + EXTRA_CFLAGS="$RPM_OPT_FLAGS" \ + EXTRA_LFLAGS="$RPM_LD_FLAGS" \ + LIB_SUFFIX=.so.%{soversion} \ + SH_LFLAGS="-shared -Wl,-soname,libre.so.%{soversion}" + +%install +%make_install \ + LIBDIR=%{_libdir} \ + LIB_SUFFIX=.so.%{soversion} + +# Create missing symlink and remove static library +ln -s %{name}.so.%{soversion} $RPM_BUILD_ROOT%{_libdir}/%{name}.so +rm -f $RPM_BUILD_ROOT%{_libdir}/%{name}.a + +%ldconfig_scriptlets + +%files +%license docs/COPYING +%doc docs/ChangeLog +%{_libdir}/%{name}.so.%{soversion} + +%files devel +%{_libdir}/%{name}.so +%{_includedir}/re/ +%{_libdir}/pkgconfig/%{name}.pc +%{_datadir}/re/ + +%changelog +* Sun Jun 28 2020 Robert Scheck 0.6.1-2 +- Add patch to accept 401 to re-register without stale=true +- Changes to match the Fedora Packaging Guidelines (#1843264 #c1) + +* Thu May 28 2020 Robert Scheck 0.6.1-1 +- Upgrade to 0.6.1 (#1843264) +- Initial spec file for Fedora and Red Hat Enterprise Linux diff --git a/sources b/sources new file mode 100644 index 0000000..2829378 --- /dev/null +++ b/sources @@ -0,0 +1 @@ +SHA512 (re-0.6.1.tar.gz) = 370b54bf3953118efa47efaaa95e43f22bdd45ca81611d2a81b21cf6ceb3bbb5d319010ca45cec3d86602d44ab9d7e8a21d45f4e174ea7392a14bed897487092