changeset 33:e5d83559f2b5

Recreate patches. Major refactoring because paths have changed and the style of some source files has changed.
author Franz Glasner <fzglas.hg@dom66.de>
date Mon, 17 Mar 2025 11:17:31 +0100
parents ede848cde37b
children 691d748c5811
files files/patch-examples_etc_turnserver.conf files/patch-src_apps_common_hiredis__libevent2.c files/patch-src_apps_common_hiredis__libevent2.h files/patch-src_apps_relay_dbdrivers_dbd__redis.c files/patch-src_apps_relay_hiredis__libevent2.c files/patch-src_apps_relay_hiredis__libevent2.h
diffstat 6 files changed, 193 insertions(+), 191 deletions(-) [+]
line wrap: on
line diff
--- a/files/patch-examples_etc_turnserver.conf	Sun Mar 16 17:05:09 2025 +0100
+++ b/files/patch-examples_etc_turnserver.conf	Mon Mar 17 11:17:31 2025 +0100
@@ -1,6 +1,6 @@
---- examples/etc/turnserver.conf.orig	2021-01-10 19:59:55 UTC
+--- examples/etc/turnserver.conf.orig	2024-12-11 18:13:38 UTC
 +++ examples/etc/turnserver.conf
-@@ -334,17 +334,17 @@
+@@ -359,17 +359,19 @@
  # as the user database.
  # This database can be used for long-term credential mechanism
  # and it can store the secret value for secret-based timed authentication in TURN REST API.
@@ -19,6 +19,8 @@
  #
 -#redis-statsdb="ip=<ip-address> dbname=<database-number> password=<database-user-password> port=<port> connect_timeout=<seconds>"
 +#redis-statsdb="ip=<ip-address> socket=<unix-domain-socket-path> dbname=<database-number> password=<database-user-password> port=<port> connect_timeout=<seconds>"
++
++# For Redis: use of "unix=" is an alias for "socket=".
  
  # The default realm to be used for the users when no explicit
  # origin/realm relationship is found in the database, or if the TURN
--- a/files/patch-src_apps_common_hiredis__libevent2.c	Sun Mar 16 17:05:09 2025 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,79 +0,0 @@
---- src/apps/common/hiredis_libevent2.c.orig	2022-09-13 07:33:12 UTC
-+++ src/apps/common/hiredis_libevent2.c
-@@ -55,6 +55,7 @@ struct redisLibeventEvents
- 	char *ip;
- 	int port;
- 	char *pwd;
-+	char *usocket;
- 	int db;
- };
- 
-@@ -223,12 +224,13 @@ void send_message_to_redis(redis_context_handle rch, c
- 
- ///////////////////////// Attach /////////////////////////////////
- 
--redis_context_handle redisLibeventAttach(struct event_base *base, char *ip0, int port0, char *pwd, int db)
-+redis_context_handle redisLibeventAttach(struct event_base *base, char *ip0, int port0, char *pwd, char *usocket, int db)
- {
- 
-   struct redisLibeventEvents *e = NULL;
-   redisAsyncContext *ac = NULL;
- 
-+  char sockpath[256] = "\0";
-   char ip[256];
-   if(ip0 && ip0[0])
- 	  STRCPY(ip,ip0);
-@@ -239,7 +241,14 @@ redis_context_handle redisLibeventAttach(struct event_
-   if(port0>0)
- 	  port=port0;
- 
--  ac = redisAsyncConnect(ip, port);
-+  if(usocket)
-+	  STRCPY(sockpath, usocket);
-+
-+  if(usocket) {
-+	ac = redisAsyncConnectUnix(sockpath);
-+  } else {
-+	ac = redisAsyncConnect(ip, port);
-+  }
-   if (!ac) {
-   	fprintf(stderr,"Error: redisAsyncConnect returned NULL\n");
-   	return NULL;
-@@ -260,6 +269,11 @@ redis_context_handle redisLibeventAttach(struct event_
-   e->port = port;
-   if(pwd)
- 	  e->pwd = strdup(pwd);
-+  if(usocket) {
-+	  e->usocket = strdup(usocket);
-+  } else {
-+	  e->usocket = NULL;
-+  }  
-   e->db = db;
- 
-   /* Register functions to start/stop listening for events */
-@@ -281,6 +295,12 @@ redis_context_handle redisLibeventAttach(struct event_
-   		     e);
- 
-   if (e->rev == NULL || e->wev == NULL) {
-+          if(e->rev)
-+          	    event_free(e->rev);
-+          if(e->wev)
-+          	    event_free(e->wev);
-+          free(e->ip);
-+          free(e->pwd);
- 	  free(e);
- 	  return NULL;
-   }
-@@ -331,7 +351,11 @@ static void redis_reconnect(struct redisLibeventEvents
- 	  e->context = NULL;
-   }
- 
--  ac = redisAsyncConnect(e->ip, e->port);
-+  if(e->usocket) {
-+	ac = redisAsyncConnectUnix(e->usocket);
-+  } else {
-+	ac = redisAsyncConnect(e->ip, e->port);
-+  }
-   if(!ac) {
- 	  return;
-   }
--- a/files/patch-src_apps_common_hiredis__libevent2.h	Sun Mar 16 17:05:09 2025 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,11 +0,0 @@
---- src/apps/common/hiredis_libevent2.h.orig	2019-03-02 21:06:19 UTC
-+++ src/apps/common/hiredis_libevent2.h
-@@ -50,7 +50,7 @@ typedef void* redis_context_handle;
- 
- void redis_async_init(void);
- 
--redis_context_handle redisLibeventAttach(struct event_base *base, char *ip, int port, char *pwd, int db);
-+redis_context_handle redisLibeventAttach(struct event_base *base, char *ip, int port, char *pwd, char *usocket, int db);
- 
- void send_message_to_redis(redis_context_handle rch, const char *command, const char *key, const char *format,...);
- 
--- a/files/patch-src_apps_relay_dbdrivers_dbd__redis.c	Sun Mar 16 17:05:09 2025 +0100
+++ b/files/patch-src_apps_relay_dbdrivers_dbd__redis.c	Mon Mar 17 11:17:31 2025 +0100
@@ -1,108 +1,112 @@
---- src/apps/relay/dbdrivers/dbd_redis.c.orig	2021-01-10 19:59:55 UTC
+--- src/apps/relay/dbdrivers/dbd_redis.c.orig	2024-12-11 18:13:38 UTC
 +++ src/apps/relay/dbdrivers/dbd_redis.c
-@@ -50,6 +50,7 @@ struct _Ryconninfo {
- 	char *host;
- 	char *dbname;
- 	char *password;
-+	char *usocket;
- 	unsigned int connect_timeout;
- 	unsigned int port;
- };
-@@ -61,6 +62,7 @@ static void RyconninfoFree(Ryconninfo *co) {
- 		if(co->host) free(co->host);
- 		if(co->dbname) free(co->dbname);
- 		if(co->password) free(co->password);
-+       		if(co->usocket) free(co->usocket);
- 		bzero(co,sizeof(Ryconninfo));
- 	}
- }
-@@ -103,6 +105,8 @@ static Ryconninfo *RyconninfoParse(const char *userdb,
- 				co->host = strdup(seq + 1);
- 			else if (!strcmp(s, "hostaddr"))
- 				co->host = strdup(seq + 1);
-+			else if (!strcmp(s, "socket"))
-+				co->usocket = strdup(seq + 1);
- 			else if (!strcmp(s, "dbname"))
- 				co->dbname = strdup(seq + 1);
- 			else if (!strcmp(s, "db"))
-@@ -185,6 +189,7 @@ redis_context_handle get_redis_async_connection(struct
- 				redisContext *rc = NULL;
+@@ -49,6 +49,7 @@ struct _Ryconninfo {
+ struct _Ryconninfo {
+   char *host;
+   char *dbname;
++  char *usocket;
+   char *user;
+   char *password;
+   unsigned int connect_timeout;
+@@ -65,6 +66,9 @@ static void RyconninfoFree(Ryconninfo *co) {
+     if (co->dbname) {
+       free(co->dbname);
+     }
++    if (co->usocket) {
++      free(co->usocket);
++    }
+     if (co->user) {
+       free(co->user);
+     }
+@@ -114,6 +118,10 @@ static Ryconninfo *RyconninfoParse(const char *userdb,
+         co->host = strdup(seq + 1);
+       } else if (!strcmp(s, "hostaddr")) {
+         co->host = strdup(seq + 1);
++      } else if (!strcmp(s, "socket")) {
++        co->usocket = strdup(seq + 1);
++      } else if (!strcmp(s, "unix")) {
++        co->usocket = strdup(seq + 1);
+       } else if (!strcmp(s, "dbname")) {
+         co->dbname = strdup(seq + 1);
+       } else if (!strcmp(s, "db")) {
+@@ -201,6 +209,7 @@ redis_context_handle get_redis_async_connection(struct
+         redisContext *rc = NULL;
  
- 				char ip[256] = "\0";
-+				char sockpath[256] = "\0";
- 				int port = DEFAULT_REDIS_PORT;
- 				if (co->host)
- 					STRCPY(ip,co->host);
-@@ -194,13 +199,24 @@ redis_context_handle get_redis_async_connection(struct
- 				if (co->port)
- 					port = (int) (co->port);
+         char ip[256] = "\0";
++        char sockpath[256] = "\0";
+         int port = DEFAULT_REDIS_PORT;
+         if (co->host) {
+           STRCPY(ip, co->host);
+@@ -213,13 +222,25 @@ redis_context_handle get_redis_async_connection(struct
+           port = (int)(co->port);
+         }
  
-+				if (co->usocket)
-+					STRCPY(sockpath,co->usocket);
++        if (co->usocket) {
++          STRCPY(sockpath, co->usocket);
++        }
 +
- 				if (co->connect_timeout) {
- 					struct timeval tv;
- 					tv.tv_usec = 0;
- 					tv.tv_sec = (time_t) (co->connect_timeout);
--					rc = redisConnectWithTimeout(ip, port, tv);
-+					if (co->usocket) {
-+						rc = redisConnectUnixWithTimeout(sockpath, tv);
-+					} else {
-+						rc = redisConnectWithTimeout(ip, port, tv);
-+					}
- 				} else {
--					rc = redisConnect(ip, port);
-+					if (co->usocket) {
-+						rc = redisConnectUnix(sockpath);
-+					} else {
-+						rc = redisConnect(ip, port);
-+					}
- 				}
+         if (co->connect_timeout) {
+           struct timeval tv;
+           tv.tv_usec = 0;
+           tv.tv_sec = (time_t)(co->connect_timeout);
+-          rc = redisConnectWithTimeout(ip, port, tv);
++          if (co->usocket) {
++            rc = redisConnectUnixWithTimeout(sockpath, tv);
++          } else {
++            rc = redisConnectWithTimeout(ip, port, tv);
++          }
+         } else {
+-          rc = redisConnect(ip, port);
++          if (co->usocket) {
++            rc = redisConnectUnix(sockpath);
++          } else {
++            rc = redisConnect(ip, port);
++          }
+         }
  
- 				if (!rc) {
-@@ -248,7 +264,7 @@ redis_context_handle get_redis_async_connection(struct
- 				}
- 			}
+         if (!rc) {
+@@ -272,7 +293,7 @@ redis_context_handle get_redis_async_connection(struct
+         }
+       }
  
--			ret = redisLibeventAttach(base, co->host, co->port, co->password, atoi(co->dbname));
-+			ret = redisLibeventAttach(base, co->host, co->port, co->password, co->usocket, atoi(co->dbname));
+-      ret = redisLibeventAttach(base, co->host, co->port, co->user, co->password, atoi(co->dbname));
++      ret = redisLibeventAttach(base, co->host, co->port, co->usocket, co->user, co->password, atoi(co->dbname));
  
- 			if (!ret) {
- 				TURN_LOG_FUNC(TURN_LOG_LEVEL_ERROR, "Cannot initialize Redis DB connection\n");
-@@ -294,12 +310,16 @@ static redisContext *get_redis_connection(void) {
- 			RyconninfoFree(co);
- 		} else {
- 			char ip[256] = "\0";
-+			char sockpath[256] = "\0";
- 			int port = DEFAULT_REDIS_PORT;
- 			if (co->host)
- 				STRCPY(ip,co->host);
- 			if (!ip[0])
- 				STRCPY(ip,"127.0.0.1");
- 
-+			if (co->usocket)
-+				STRCPY(sockpath,co->usocket);
-+
- 			if (co->port)
- 				port = (int) (co->port);
+       if (!ret) {
+         TURN_LOG_FUNC(TURN_LOG_LEVEL_ERROR, "Cannot initialize Redis DB connection\n");
+@@ -324,6 +345,7 @@ static redisContext *get_redis_connection(void) {
+       RyconninfoFree(co);
+     } else {
+       char ip[256] = "\0";
++      char sockpath[256] = "\0";
+       int port = DEFAULT_REDIS_PORT;
+       if (co->host) {
+         STRCPY(ip, co->host);
+@@ -336,13 +358,25 @@ static redisContext *get_redis_connection(void) {
+         port = (int)(co->port);
+       }
  
-@@ -307,9 +327,17 @@ static redisContext *get_redis_connection(void) {
- 				struct timeval tv;
- 				tv.tv_usec = 0;
- 				tv.tv_sec = (time_t) (co->connect_timeout);
--				redisconnection = redisConnectWithTimeout(ip, port, tv);
-+				if (co->usocket) {
-+					redisconnection = redisConnectUnixWithTimeout(sockpath, tv);
-+				} else {
-+					redisconnection = redisConnectWithTimeout(ip, port, tv);
-+				}
- 			} else {
--				redisconnection = redisConnect(ip, port);
-+				if (co->usocket) {
-+					redisconnection = redisConnectUnix(sockpath);
-+				} else {
-+					redisconnection = redisConnect(ip, port);
-+				}
- 			}
++      if (co->usocket) {
++        STRCPY(sockpath, co->usocket);
++      }
++
+       if (co->connect_timeout) {
+         struct timeval tv;
+         tv.tv_usec = 0;
+         tv.tv_sec = (time_t)(co->connect_timeout);
+-        redisconnection = redisConnectWithTimeout(ip, port, tv);
++        if (co->usocket) {
++          redisconnection = redisConnectUnixWithTimeout(sockpath, tv);
++        } else {
++          redisconnection = redisConnectWithTimeout(ip, port, tv);
++        }
+       } else {
+-        redisconnection = redisConnect(ip, port);
++        if (co->usocket) {
++          redisconnection = redisConnectUnix(sockpath);
++        } else {
++          redisconnection = redisConnect(ip, port);
++        }
+       }
  
- 			if (redisconnection) {
+       if (redisconnection) {
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/files/patch-src_apps_relay_hiredis__libevent2.c	Mon Mar 17 11:17:31 2025 +0100
@@ -0,0 +1,75 @@
+--- src/apps/relay/hiredis_libevent2.c.orig	2024-12-11 18:13:38 UTC
++++ src/apps/relay/hiredis_libevent2.c
+@@ -52,6 +52,7 @@ struct redisLibeventEvents {
+   int port;
+   char *user;
+   char *pwd;
++  char *usocket;
+   int db;
+ };
+ 
+@@ -213,8 +214,10 @@ void send_message_to_redis(redis_context_handle rch, c
+ 
+ ///////////////////////// Attach /////////////////////////////////
+ 
+-redis_context_handle redisLibeventAttach(struct event_base *base, char *ip0, int port0, char *user, char *pwd, int db) {
++redis_context_handle redisLibeventAttach(struct event_base *base, char *ip0, int port0, char *usocket, char *user, char *pwd, int db) {
+ 
++  redisAsyncContext *ac = NULL;
++  char sockpath[256] = "\0";
+   char ip[256];
+   if (ip0 && ip0[0]) {
+     STRCPY(ip, ip0);
+@@ -227,7 +230,11 @@ redis_context_handle redisLibeventAttach(struct event_
+     port = port0;
+   }
+ 
+-  redisAsyncContext *ac = redisAsyncConnect(ip, port);
++  if(usocket && usocket[0]) {
++    ac = redisAsyncConnectUnix(sockpath);
++  } else {
++    ac = redisAsyncConnect(ip, port);
++  }
+   if (!ac) {
+     fprintf(stderr, "Error: redisAsyncConnect returned NULL\n");
+     return NULL;
+@@ -253,6 +260,9 @@ redis_context_handle redisLibeventAttach(struct event_
+   if (pwd) {
+     e->pwd = strdup(pwd);
+   }
++  if (usocket) {
++    e->usocket = strdup(usocket);
++  }
+   e->db = db;
+ 
+   /* Register functions to start/stop listening for events */
+@@ -270,6 +280,16 @@ redis_context_handle redisLibeventAttach(struct event_
+   e->wev = event_new(e->base, e->context->c.fd, EV_WRITE, redisLibeventWriteEvent, e);
+ 
+   if (e->rev == NULL || e->wev == NULL) {
++    if (e->rev) {
++      event_free(e->rev);
++    }
++    if (e->wev) {
++      event_free(e->wev);
++    }
++    free(e->ip);
++    free(e->usocket);
++    free(e->user);
++    free(e->pwd);
+     free(e);
+     return NULL;
+   }
+@@ -329,7 +349,11 @@ static void redis_reconnect(struct redisLibeventEvents
+     e->context = NULL;
+   }
+ 
+-  ac = redisAsyncConnect(e->ip, e->port);
++  if(e->usocket) {
++    ac = redisAsyncConnectUnix(e->usocket);
++  } else {
++    ac = redisAsyncConnect(e->ip, e->port);
++  }
+   if (!ac) {
+     return;
+   }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/files/patch-src_apps_relay_hiredis__libevent2.h	Mon Mar 17 11:17:31 2025 +0100
@@ -0,0 +1,11 @@
+--- src/apps/relay/hiredis_libevent2.h.orig	2024-12-11 18:13:38 UTC
++++ src/apps/relay/hiredis_libevent2.h
+@@ -48,7 +48,7 @@ typedef void *redis_context_handle;
+ 
+ #if !defined(TURN_NO_HIREDIS)
+ 
+-redis_context_handle redisLibeventAttach(struct event_base *base, char *ip, int port, char *user, char *pwd, int db);
++redis_context_handle redisLibeventAttach(struct event_base *base, char *ip, int port, char *usocket, char *user, char *pwd, int db);
+ 
+ void send_message_to_redis(redis_context_handle rch, const char *command, const char *key, const char *format, ...);
+