2
0
Эх сурвалжийг харах

Merge branch 'master' of ssh://git.sip-router.org/sip-router

Carsten Bock 13 жил өмнө
parent
commit
c2eab9b90b

+ 2 - 2
modules/corex/README

@@ -108,8 +108,8 @@ Chapter 1. Admin Guide
 
    Example 1.1. Set alias_subdomains parameter
 ...
-modparam("corex", "alias_subdomain", "kamailio.org")
-modparam("corex", "alias_subdomain", "udp:sip-router.org:5060")
+modparam("corex", "alias_subdomains", "kamailio.org")
+modparam("corex", "alias_subdomains", "udp:sip-router.org:5060")
 ...
 
 4. Functions

+ 2 - 2
modules/corex/doc/corex_admin.xml

@@ -81,8 +81,8 @@
 		<title>Set <varname>alias_subdomains</varname> parameter</title>
 		<programlisting format="linespecific">
 ...
-modparam("corex", "alias_subdomain", "kamailio.org")
-modparam("corex", "alias_subdomain", "udp:sip-router.org:5060")
+modparam("corex", "alias_subdomains", "kamailio.org")
+modparam("corex", "alias_subdomains", "udp:sip-router.org:5060")
 ...
 </programlisting>
 	    </example>

+ 32 - 12
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] {

+ 2 - 2
pkg/kamailio/centos/6/kamailio-build.appl

@@ -1,5 +1,5 @@
-name: "kamailio-build-#OS_NAME#-#OS_VERSION#-#BASE_ARCH#"
-summary: "#OS_NAME# #OS_VERSION# for building Kamailio #BASE_ARCH# RPMs"
+name: "kamailio-build-c6-#BASE_ARCH#"
+summary: "CentOS 6 image for building Kamailio #BASE_ARCH# RPMs"
 os:
   name: centos
   version: 6

+ 2 - 2
pkg/kamailio/centos/6/kamailio.appl

@@ -1,5 +1,5 @@
-name: "kamailio-#OS_NAME#-#OS_VERSION#-#BASE_ARCH#"
-summary: "#OS_NAME# #OS_VERSION# for installing Kamailio #BASE_ARCH# RPMs"
+name: "kamailio-c6-#BASE_ARCH#"
+summary: "CentOS 6 image for installing Kamailio #BASE_ARCH# RPMs"
 os:
   name: centos
   version: 6

+ 1 - 1
pkg/kamailio/fedora/16/README

@@ -47,7 +47,7 @@ changes to the commands in this example.
    # cd appliance
    # [sudo] boxgrinder-build \
        [path to]/pkg/kamailio/fedora/17/kamailio-build.appl -d libvirt \
-       --delivery_config connection_uri:qemu:///system,\
+       --delivery-config connection_uri:qemu:///system,\
        image_delivery_uri:/var/lib/libvirt/images,overwrite:true,\
        domain_type:kvm
 2) Start the appliance and log in:

+ 2 - 2
pkg/kamailio/fedora/16/kamailio-build.appl

@@ -1,5 +1,5 @@
-name: "kamailio-build-#OS_NAME#-#OS_VERSION#-#BASE_ARCH#"
-summary: "#OS_NAME# #OS_VERSION# for building Kamailio #BASE_ARCH# RPMs"
+name: "kamailio-build-fc16-#BASE_ARCH#"
+summary: "Fedora 16 image for building Kamailio #BASE_ARCH# RPMs"
 os:
   name: fedora
   version: 16

+ 2 - 2
pkg/kamailio/fedora/16/kamailio.appl

@@ -1,5 +1,5 @@
-name: "kamailio-#OS_NAME#-#OS_VERSION#-#BASE_ARCH#"
-summary: "#OS_NAME# #OS_VERSION# for installing Kamailio #BASE_ARCH# RPMs"
+name: "kamailio-fc16-#BASE_ARCH#"
+summary: "Fedora 16 image for installing Kamailio #BASE_ARCH# RPMs"
 os:
   name: fedora
   version: 16

+ 2 - 2
pkg/kamailio/fedora/17/kamailio-build.appl

@@ -1,5 +1,5 @@
-name: "kamailio-build-#OS_NAME#-#OS_VERSION#-#BASE_ARCH#"
-summary: "#OS_NAME# #OS_VERSION# for building Kamailio #BASE_ARCH# RPMs"
+name: "kamailio-build-fc17-#BASE_ARCH#"
+summary: "Fedora 17 image for building Kamailio #BASE_ARCH# RPMs"
 os:
   name: fedora
   version: 17

+ 2 - 2
pkg/kamailio/fedora/17/kamailio.appl

@@ -1,5 +1,5 @@
-name: "kamailio-#OS_NAME#-#OS_VERSION#-#BASE_ARCH#"
-summary: "#OS_NAME# #OS_VERSION# for installing Kamailio #BASE_ARCH# RPMs"
+name: "kamailio-fc17-#BASE_ARCH#"
+summary: "Fedora 17 image for installing Kamailio #BASE_ARCH# RPMs"
 os:
   name: fedora
   version: 17

+ 7 - 2
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"

+ 7 - 4
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=4
 
 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.