Module: sip-router
Branch: master
Commit: 84563257d6c174c7ef3c7ee9b931e64a0b5a95c2
URL: http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=8456325…
Author: Peter Dunkley <peter.dunkley(a)crocodile-rcs.com>
Committer: Peter Dunkley <peter.dunkley(a)crocodile-rcs.com>
Date: Tue Sep 18 19:29:36 2012 +0100
modules/websocket: Updated example kamailio.cfg
- Now using corex and alias_subdomains.
It is quite likely that a WebSocket server will be running on a host within
the domain it is authoritative for and that the WebSocket client will
address that host directly. This means that the alias_subdomains modparam
is a good way to get a domain and all of its sub-domains to match "myself".
This is very useful for checking the Host: header in the WebSocket
handshake.
- Added handling of OPTIONS pings.
- Fixed a problem with the Host: header check.
When you connect to a WS or WSS socket in Google Chrome on the default ports
(80 and 443 respectively) the Host: header will contain just a hostname
(for example, "proxy.example.com") which works with is_myself().
When you connect to a WS or WSS socket in Google Chrome on a non-default port
(for example, 8080 or 8443 respectively) the Host: header will contain a
hostname and port (for example, "proxy.example.com:8080") whoch does not work
with is_myself().
However, both "sip:proxy.example.com" and "sip:proxy.example.com:8080" will
work, so simply adding "sip:" to the start of the contents of the Host:
header before checking fixes the problem.
- Tidied up response reason texts.
- Tidied up some of the TLS specific checks in event_route[xhttp:request].
- Removed some DBG level log messages.
- Added a (commented out) example for checking the Origin: header in the
WebSocket handshake.
---
modules/websocket/example/kamailio.cfg | 44 +++++++++++++++++++++++--------
1 files changed, 32 insertions(+), 12 deletions(-)
diff --git a/modules/websocket/example/kamailio.cfg b/modules/websocket/example/kamailio.cfg
index 5cc76ab..17ae075 100644
--- a/modules/websocket/example/kamailio.cfg
+++ b/modules/websocket/example/kamailio.cfg
@@ -5,6 +5,7 @@
#!substdef "!DBURL!sqlite:///etc/kamailio/db.sqlite!g"
#!substdef "!MY_IP_ADDR!a.b.c.d!g"
+#!substdef "!MY_DOMAIN!example.com!g"
#!substdef "!MY_WS_PORT!80!g"
#!substdef "!MY_WSS_PORT!443!g"
#!substdef "!MY_WS_ADDR!tcp:MY_IP_ADDR:MY_WS_PORT!g"
@@ -20,8 +21,6 @@
fork=yes
children=4
-alias="example.com"
-
#!ifdef WITH_TLS
enable_tls=1
#!endif
@@ -65,6 +64,7 @@ loadmodule "auth.so"
loadmodule "auth_db.so"
loadmodule "kex.so"
loadmodule "mi_rpc.so"
+loadmodule "corex.so"
#!ifdef WITH_TLS
loadmodule "tls.so"
#!endif
@@ -105,6 +105,9 @@ modparam("auth_db", "calculate_ha1", yes)
modparam("auth_db", "password_column", "password")
modparam("auth_db", "load_credentials", "")
+# ----- corex params -----
+modparam("corex", "alias_subdomains", "MY_DOMAIN")
+
#!ifdef WITH_TLS
# ----- tls params -----
modparam("tls", "tls_method", "SSLv23")
@@ -203,10 +206,15 @@ route[REQINIT] {
exit;
}
- if(!sanity_check("1511", "7")) {
+ if (!sanity_check("1511", "7")) {
xlog("Malformed SIP message from $si:$sp\n");
exit;
}
+
+ if (uri == myself && is_method("OPTIONS") && !(uri=~"sip:.*[@]+.*")) {
+ options_reply();
+ exit;
+ }
}
# Handle requests within SIP dialogs
@@ -239,7 +247,7 @@ route[WITHINDLG] {
exit;
}
}
- sl_send_reply("404","Not here");
+ sl_send_reply("404","Not Found");
}
exit;
}
@@ -287,7 +295,7 @@ route[AUTH] {
# if caller is not local subscriber, then check if it calls
# a local destination, otherwise deny, not an open relay here
if (from_uri!=myself && uri!=myself) {
- sl_send_reply("403","Not relaying");
+ sl_send_reply("403","Forbidden");
exit;
}
}
@@ -307,7 +315,11 @@ event_route[xhttp:request] {
set_reply_close();
set_reply_no_connect();
- if ($Rp != MY_WS_PORT && $Rp != MY_WSS_PORT) {
+ if ($Rp != MY_WS_PORT
+#!ifdef WITH_TLS
+ && $Rp != MY_WSS_PORT
+#!endif
+ ) {
xlog("L_WARN", "HTTP request received on $Rp\n");
xhttp_reply("403", "Forbidden", "", "");
exit;
@@ -318,17 +330,25 @@ event_route[xhttp:request] {
if ($hdr(Upgrade)=~"websocket"
&& $hdr(Connection)=~"Upgrade"
&& $rm=~"GET") {
- xlog("L_DBG", "WebSocket\n");
- xlog("L_DBG", " Host: $hdr(Host)\n");
- xlog("L_DBG", " Origin: $hdr(Origin)\n");
- if ($hdr(Host) == $null || !is_myself($hdr(Host))) {
+ # Validate Host - make sure the client is using the correct
+ # alias for WebSockets
+ if ($hdr(Host) == $null || !is_myself("sip:" + $hdr(Host))) {
xlog("L_WARN", "Bad host $hdr(Host)\n");
xhttp_reply("403", "Forbidden", "", "");
exit;
}
- # Optional... validate Origin
+ # Optional... validate Origin - make sure the client is from an
+ # authorised website. For example,
+ #
+ # if ($hdr(Origin) != "http://communicator.MY_DOMAIN"
+ # && $hdr(Origin) != "https://communicator.MY_DOMAIN") {
+ # xlog("L_WARN", "Unauthorised client $hdr(Origin)\n");
+ # xhttp_reply("403", "Forbidden", "", "");
+ # exit;
+ # }
+
# Optional... perform HTTP authentication
# ws_handle_handshake() exits (no further configuration file
@@ -341,7 +361,7 @@ event_route[xhttp:request] {
}
}
- xhttp_reply("404", "Not found", "", "");
+ xhttp_reply("404", "Not Found", "", "");
}
event_route[websocket:closed] {
Module: sip-router
Branch: master
Commit: 9430290ad91ca775bb18f54e70308917ce1e790a
URL: http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=9430290…
Author: Daniel-Constantin Mierla <miconda(a)gmail.com>
Committer: Daniel-Constantin Mierla <miconda(a)gmail.com>
Date: Tue Sep 18 09:18:52 2012 +0200
pkg/kamailio/rpm: added option to set pkg memory size for init.d script
- split of MEMORY parameter to SHM_MEMORY and PKG_MEMORY
- EXTRA_OPTIONS variable to add other command line parameters
---
pkg/kamailio/rpm/kamailio.default | 9 +++++++--
pkg/kamailio/rpm/kamailio.init | 11 +++++++----
2 files changed, 14 insertions(+), 6 deletions(-)
diff --git a/pkg/kamailio/rpm/kamailio.default b/pkg/kamailio/rpm/kamailio.default
index d962311..90e6ca7 100644
--- a/pkg/kamailio/rpm/kamailio.default
+++ b/pkg/kamailio/rpm/kamailio.default
@@ -11,8 +11,11 @@ USER=kamailio
# Group to run as
GROUP=kamailio
-# Amount of memory to allocate for the running Kamailio server (in Mb)
-MEMORY=64
+# Amount of shared memory to allocate for the running Kamailio server (in Mb)
+SHM_MEMORY=64
+
+# Amount of private memory to allocate for the running Kamailio server (in Mb)
+PKG_MEMORY=4
# Enable the server to leave a core file when it crashes.
# Set this to 'yes' to enable kamailio to leave a core file when it crashes
@@ -23,3 +26,5 @@ MEMORY=64
# init file for an example configuration.
DUMP_CORE=no
+# Add extra command line parameters in the EXTRA_OPTIONS variable
+# EXTRA_OPTIONS="-a no"
diff --git a/pkg/kamailio/rpm/kamailio.init b/pkg/kamailio/rpm/kamailio.init
index 93742db..ff6f701 100644
--- a/pkg/kamailio/rpm/kamailio.init
+++ b/pkg/kamailio/rpm/kamailio.init
@@ -13,6 +13,7 @@
. /etc/rc.d/init.d/functions
KAM=/usr/sbin/kamailio
+KAMCFG=/etc/kamailio/kamailio.cfg
PROG=kamailio
PID_FILE=/var/run/kamailio.pid
LOCK_FILE=/var/lock/subsys/kamailio
@@ -25,7 +26,7 @@ RUN_KAMAILIO=no
# otherwise the boot process will just stop
check_fork ()
{
- if grep -q "^[[:space:]]*fork[[:space:]]*=[[:space:]]*no.*" /etc/kamailio/kamailio.cfg; then
+ if grep -q "^[[:space:]]*fork[[:space:]]*=[[:space:]]*no.*" $KAMCFG; then
echo "Not starting $DESC: fork=no specified in config file; run /etc/init.d/kamailio debug instead"
exit 1
fi
@@ -76,10 +77,12 @@ if [ "$RUN_KAMAILIO" != "yes" ]; then
fi
-MEMORY=$((`echo $MEMORY | sed -e 's/[^0-9]//g'`))
+SHM_MEMORY=$((`echo $SHM_MEMORY | sed -e 's/[^0-9]//g'`))
+PKG_MEMORY=$((`echo $PKG_MEMORY | sed -e 's/[^0-9]//g'`))
[ -z "$USER" ] && USER=kamailio
[ -z "$GROUP" ] && GROUP=kamailio
-[ $MEMORY -le 0 ] && MEMORY=32
+[ $SHM_MEMORY -le 0 ] && SHM_MEMORY=32
+[ $PKG_MEMORY -le 0 ] && PKG_MEMORY=32
if test "$DUMP_CORE" = "yes" ; then
# set proper ulimit
@@ -92,7 +95,7 @@ if test "$DUMP_CORE" = "yes" ; then
# echo "$COREDIR/core.%e.sig%s.%p" > /proc/sys/kernel/core_pattern
fi
-OPTIONS="-P $PID_FILE -m $MEMORY -u $USER -g $GROUP"
+OPTIONS="-P $PID_FILE -m $SHM_MEMORY -M $PKG_MEMORY -u $USER -g $GROUP $EXTRA_OPTIONS"
# See how we were called.
THIS IS AN AUTOMATED MESSAGE, DO NOT REPLY.
A new Flyspray task has been opened. Details are below.
User who did this - Juha Heinanen (jh)
Attached to Project - sip-router
Summary - record_route_advertised_address() does not add second rr
Task Type - Bug Report
Category - Module
Status - New
Assigned To -
Operating System - All
Severity - Low
Priority - Normal
Reported Version - 3.3
Due in Version - Undecided
Due Date - Undecided
Details - rr readme on record_route_advertised_address() function tells:
Note: A second Record-Route will be inserted if the transport used on
the inbound and outbound interfaces changes.
that is not the case. i made call
record_route_advertised_address("192.98.103.10:5060");
when request came over udp and went out over tcp and only one rr header
was inserted:
incoming ngrep:
U 2012/09/17 17:30:17.467079 192.98.103.10:5060 -> 192.98.103.2:5070
INVITE sip:test@test.fi SIP/2.0.
....
outgoing ngrep:
T 2012/09/17 17:30:17.504631 192.98.103.10:5060 -> 192.98.103.10:38078 [AP]
INVITE sip:0x20b7580@192.98.103.10:5050;transport=tcp SIP/2.0.
Record-Route: <sip:192.98.103.10:5060;ftag=wumod;lr>.
....
i had not set enable_double_rr param and default is 1.
More information can be found at the following URL:
http://sip-router.org/tracker/index.php?do=details&task_id=248
You are receiving this message because you have requested it from the Flyspray bugtracking system. If you did not expect this message or don't want to receive mails in future, you can change your notification settings at the URL shown above.
current implementation of nathelper nat pinging is based on obtaining
contact info from usrloc module:
static void
nh_timer(unsigned int ticks, void *timer_idx)
{
...
rval = ul.get_all_ucontacts(buf, cblen, (ping_nated_only?ul.nat_flag:0),
((unsigned int)(unsigned long)timer_idx)*natping_interval+iteration,
natping_processes*natping_interval);
would it be feasible to have another mode where the contact info is
obtained from database location table? this would make it possible to
ping nated contacts also from other hosts than the registrar, such as a
dispatcher.
any comments?
-- juha