Hello,
wondering if it wouldn't be better to get the hostname once at startup,
rather than doing it each time a new cookie is needed.
On the other hand, note that you can set server_id for each kamailio
instance to make it uniquely identifiable, which is also important for
sruid generator (although that uses random and startup timestamp as well).
Also, sometime the local hostname overlaps, seen lots of servers using
just 'www' or 'debian'. So ensuring the uniqueness was shifted to the
sysadmins of the network nodes.
Cheers,
Daniel
On 02/06/16 12:54, Lucian Balaceanu wrote:
Module: kamailio
Branch: master
Commit: 69e57b9260c6c09380fdb9cfd074ea67a459230a
URL:
https://github.com/kamailio/kamailio/commit/69e57b9260c6c09380fdb9cfd074ea6…
Author: Lucian Balaceanu <lucian.balaceanu(a)1and1.ro>
Committer: Lucian Balaceanu <lucian.balaceanu(a)1and1.ro>
Date: 2016-06-02T13:50:02+03:00
rtpengine: change cookie to hostname_pid_seqno
- pid_seqno in gencookie() is not a unique identifictor in a multi kamailio setup
---
Modified: modules/rtpengine/rtpengine.c
---
Diff:
https://github.com/kamailio/kamailio/commit/69e57b9260c6c09380fdb9cfd074ea6…
Patch:
https://github.com/kamailio/kamailio/commit/69e57b9260c6c09380fdb9cfd074ea6…
---
diff --git a/modules/rtpengine/rtpengine.c b/modules/rtpengine/rtpengine.c
index 5481f49..a37ab6f 100644
--- a/modules/rtpengine/rtpengine.c
+++ b/modules/rtpengine/rtpengine.c
@@ -97,6 +97,8 @@ MODULE_VERSION
#define NAT_UAC_TEST_S_1918 0x08
#define NAT_UAC_TEST_RPORT 0x10
+#define COOKIE_SIZE 128
+#define HOSTNAME_SIZE 100
#define DEFAULT_RTPP_SET_ID 0
#define MAX_RTPP_TRIED_NODES 50
@@ -2016,12 +2018,15 @@ static void mod_destroy(void)
}
-
static char * gencookie(void)
{
- static char cook[34];
+ static char cook[COOKIE_SIZE];
+ char hostname[HOSTNAME_SIZE];
+
+ if (gethostname(hostname, HOSTNAME_SIZE - 1) < 0)
+ strcpy(hostname, "host");
+ snprintf(cook, COOKIE_SIZE, "%s_%d_%u ", hostname, (int)mypid, myseqn);
- sprintf(cook, "%d_%u ", (int)mypid, myseqn);
myseqn++;
return cook;
}
_______________________________________________
sr-dev mailing list
sr-dev(a)lists.sip-router.org
http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-dev
--
Daniel-Constantin Mierla
http://www.asipto.com -
http://www.kamailio.org
http://twitter.com/#!/miconda -
http://www.linkedin.com/in/miconda