Browse Source

- add udpxy

master
vanhofen 3 years ago
parent
commit
69ad115aa7
  1. 20
      package/udpxy/files/udpxy.init
  2. 63
      package/udpxy/patches/0001-udpxy.patch
  3. 28
      package/udpxy/patches/0002-fix-build-with-gcc8.patch
  4. 13
      package/udpxy/patches/0003-fix-build-with-gcc9.patch
  5. 33
      package/udpxy/udpxy.mk

20
package/udpxy/files/udpxy.init

@ -0,0 +1,20 @@
#!/bin/sh
. /etc/init.d/globals
case $1 in
start)
if [ -e /var/etc/.udpxy ]; then
udpxy -p 4022
fi
;;
stop)
if [ -e /var/etc/.udpxy ]; then
trap "" INT
kill -INT $(pidof udpxy)
fi
;;
*)
echo "[$BASENAME] Usage: $0 {start|stop}"
;;
esac

63
package/udpxy/patches/0001-udpxy.patch

@ -0,0 +1,63 @@
--- a/chipmunk/netop.c
+++ b/chipmunk/netop.c
@@ -53,16 +53,24 @@
extern const char IPv4_ALL[];
- assert( (port > 0) && sockfd && ipaddr );
+ int socktype = 0;
+ socklen_t socktypelen = sizeof(socktype);
+ int inetd = !getsockopt(0, SOL_SOCKET, SO_TYPE, &socktype, &socktypelen) && socktype == SOCK_STREAM;
+
+ assert( (!inetd || port > 0) && sockfd && ipaddr );
(void)IPv4_ALL;
TRACE( (void)tmfprintf( g_flog, "Setting up listener for [%s:%d]\n",
ipaddr[0] ? ipaddr : IPv4_ALL, port) );
rc = ERR_INTERNAL;
do {
+ if (inetd)
+ lsock = 0;
+ else
lsock = socket( AF_INET, SOCK_STREAM, 0 );
if( -1 == lsock ) break;
+ if (!inetd) {
(void) memset( &servaddr, 0, sizeof(servaddr) );
servaddr.sin_family = AF_INET;
servaddr.sin_port = htons( (short)port );
@@ -87,6 +95,7 @@
__func__);
break;
}
+ }
#define NONBLOCK 1
rc = set_nblock (lsock, NONBLOCK);
@@ -102,8 +111,10 @@
break;
}
+ if (!inetd) {
rc = bind( lsock, (struct sockaddr*)&servaddr, sizeof(servaddr) );
if( 0 != rc ) break;
+ }
rc = listen (lsock, (bklog > 0 ? bklog : 1));
if( 0 != rc ) break;
--- a/chipmunk/udpxy.c
+++ b/chipmunk/udpxy.c
@@ -1391,7 +1391,12 @@
openlog( g_udpxy_app, LOG_CONS | LOG_PID, LOG_LOCAL0 );
do {
- if( (argc < 2) || (port <= 0) || (rc != 0) ) {
+ int socktype = 0;
+ socklen_t socktypelen = sizeof(socktype);
+ int inetd = !getsockopt(0, SOL_SOCKET, SO_TYPE, &socktype, &socktypelen) && socktype == SOCK_STREAM;
+ if (inetd)
+ no_daemon = 1;
+ if( !inetd && ((argc < 2) || (port <= 0) || (rc != 0)) ) {
usage( argv[0], stderr );
rc = ERR_PARAM; break;
}

28
package/udpxy/patches/0002-fix-build-with-gcc8.patch

@ -0,0 +1,28 @@
diff --git a/udpxrec.c b/udpxrec.c
index c58ceb5..eb186f3 100644
--- a/chipmunk/udpxrec.c
+++ b/chipmunk/udpxrec.c
@@ -604,9 +604,9 @@ int udpxrec_main( int argc, char* const argv[] )
}
else {
if( g_recopt.bg_time < now ) {
- (void)strncpy( now_buf, Zasctime(localtime( &now )),
+ (void)memcpy( now_buf, Zasctime(localtime( &now )),
sizeof(now_buf) );
- (void)strncpy( sel_buf,
+ (void)memcpy( sel_buf,
Zasctime(localtime( &g_recopt.bg_time )),
sizeof(sel_buf) );
@@ -634,9 +634,9 @@ int udpxrec_main( int argc, char* const argv[] )
}
else {
if( g_recopt.end_time < now ) {
- (void)strncpy( now_buf, Zasctime(localtime( &now )),
+ (void)memcpy( now_buf, Zasctime(localtime( &now )),
sizeof(now_buf) );
- (void)strncpy( sel_buf,
+ (void)memcpy( sel_buf,
Zasctime(localtime( &g_recopt.end_time )),
sizeof(sel_buf) );

13
package/udpxy/patches/0003-fix-build-with-gcc9.patch

@ -0,0 +1,13 @@
diff --git a/chipmunk/rparse.c b/chipmunk/rparse.c
index 8cbdda5..560e50d 100644
--- a/chipmunk/rparse.c
+++ b/chipmunk/rparse.c
@@ -175,7 +175,7 @@ parse_udprelay( const char* opt, size_t optlen,
assert( opt && s_addr && s_addrlen && addr && addrlen && port );
- (void) strncpy( s, opt, MAX_OPTLEN );
+ (void) snprintf(s, MAX_OPTLEN, "%s", opt);
s[ MAX_OPTLEN - 1 ] = '\0';
do {

33
package/udpxy/udpxy.mk

@ -0,0 +1,33 @@
################################################################################
#
# udpxy
#
################################################################################
UDPXY_VERSION = git
UDPXY_DIR = udpxy.$(UDPXY_VERSION)
UDPXY_SOURCE = udpxy.$(UDPXY_VERSION)
UDPXY_SITE = https://github.com/pcherenkov
UDPXY_CHECKOUT = tags/1.0-25.1
UDPXY_MAKE_OPTS = \
NO_UDPXREC=yes
UDPXY_MAKE_INSTALL_OPTS = \
PREFIX=$(prefix) \
MANPAGE_DIR=$(TARGET_DIR)$(REMOVE_mandir)
define UDPXY_INSTALL_INIT_SCRIPT
$(INSTALL_EXEC) -D $(PKG_FILES_DIR)/udpxy.init $(TARGET_sysconfdir)/init.d/udpxy
$(UPDATE-RC.D) udpxy defaults 75 25
endef
UDPXY_TARGET_FINALIZE_HOOKS += UDPXY_INSTALL_INIT_SCRIPT
udpxy: | $(TARGET_DIR)
$(call PREPARE)
$(CHDIR)/$($(PKG)_DIR)/chipmunk; \
$(TARGET_CONFIGURE_ENV) \
$(MAKE) $($(PKG)_MAKE_OPTS); \
$(MAKE) $($(PKG)_MAKE_OPTS) install DESTDIR=$(TARGET_DIR) $($(PKG)_MAKE_INSTALL_OPTS)
$(call TARGET_FOLLOWUP)
Loading…
Cancel
Save