📄 run_test_nta
字号:
#! /bin/bash## Run nta_test with our own name server## --------------------------------------------------------------------## This file is part of the Sofia-SIP package## Copyright (C) 2005 Nokia Corporation.## Contact: Pekka Pessi <pekka.pessi@nokia.com>## This library is free software; you can redistribute it and/or# modify it under the terms of the GNU Lesser General Public License# as published by the Free Software Foundation; either version 2.1 of# the License, or (at your option) any later version.## This library is distributed in the hope that it will be useful, but# WITHOUT ANY WARRANTY; without even the implied warranty of# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU# Lesser General Public License for more details.## You should have received a copy of the GNU Lesser General Public# License along with this library; if not, write to the Free Software# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA# 02110-1301 USA## --------------------------------------------------------------------## Author: Pekka Pessi <Pekka.Pessi@nokia.com>.##set -xs=${0%/*}resolvfile=.test$$.resolv.confnamedfile=.test$$.named.confpidfile=.test$$.named.pidzonefile=.test$$.example.zonetest x$s = x$0 && s=`pwd`PATH=/usr/sbin:/usr/local/sbin:/sbin:$PATHexport PATHme6="::1"if ../su/localinfo -6 -n -g -s >& /dev/null ; then ipv6=true aaaa=aaaa v6flag=-6 me6=$(../su/localinfo -6 -n -s -g | awk '{print $1; exit(0); }')else if ! ../su/localinfo '--help' >& /dev/null ; then echo "warning: $0: missing 'localinfo', cannot test IPv6" else echo "warning: $0: no valid IPv6 addresses available" fi ipv6=false aaaa=afiif type named >& /dev/null && ./portbind --help >& /dev/nullthenport=$(./portbind $v6flag) sink=$portport=$(./portbind $v6flag $((port + 1))) down=$portport=$(./portbind $v6flag $((port + 1))) bind=$portport=$(./portbind $v6flag $((port + 1))) contact=$port# Disable IPv6 resolver for now if false && eval $ipv6 ; then listen="listen-on-v6 port $bind { any; };" ns=$me6else listen="listen-on port $bind { 127.0.0.1; };" ns="127.0.0.1"ficat > $resolvfile <<EOFnameserver $nsdomain example.comport $bindEOFcat > $namedfile <<EOFoptions { pid-file "$pidfile"; $listen};zone "example.org" in { type master; file "$zonefile";};EOFcat > $zonefile << EOF;; Zone file for example.org; SIP targets: example.org; srv.example.org; down.example.org; na.example.org; ipv6-20-80.example.org; ipv.example.org;\$TTL 60@ IN SOA ns root ( 2002042901 ; SERIAL 7200 ; REFRESH 600 ; RETRY 36000000 ; EXPIRE 60 ; MINIMUM ) NS ns ;; order pref flags service regexp replacement NAPTR 20 15 "s" "SIP+D2U" "" _sip._udp NAPTR 40 25 "s" "SIPS+D2T" "" _sips._tcp NAPTR 40 50 "s" "SIP+D2T" "" _sip._tcpns AAAA $me6 A 127.0.0.1_sip._udp SRV 1 100 $contact me_sips._tcp SRV 3 100 $contact me_sip._tcp SRV 2 100 $contact me_sip._udp.srv SRV 1 100 $contact a_sips._tcp.srv SRV 3 100 $contact a_sip._tcp.srv SRV 2 100 $contact $aaaa_sip._udp.srv2 SRV 1 200 $contact c SRV 1 100 $contact b SRV 1 50 $contact ame AAAA $me6 A 127.0.0.1a A 127.0.0.1b A 0.0.0.2c A 0.0.0.3aaaa AAAA $me6; Directly from NAPTR to A/AAAA (Test 1.6c)na NAPTR 20 15 "a" "SIP+D2T" "" a2; No sensible NAPTR match (and we get 503)na503 NAPTR 20 15 "S" "SIP+D2F" "" a2; No SIP NAPTR match nona NAPTR 20 15 "S" "ZIP+D2U" "" a2_sip._udp.nona SRV 1 10 $contact ip4; No SIP SRV match nosrv NAPTR 20 1 "s" "SIP+D2U" "" _sip._udp.nosrv NAPTR 20 2 "s" "SIP+D2U" "" _sip._udp.srv; This fails (and we get 503)a2 A 127.0.0.2; IP6 should get 80%, IP4 20%ipv6-20-80 NAPTR 20 15 "s" "SIP+D2U" "" _sip._udp.ipv6-20-80_sip._udp.ipv6-20-80 SRV 1 80 $contact ip6 SRV 1 20 $contact ip4_sip._udp.ipv SRV 1 100 $contact ip6_sip._udp.ipv SRV 1 100 $contact ip4ip6 AAAA $me6ip4 A 127.0.0.1; SRV failover to me...down NAPTR 20 15 "s" "SIP+D2U" "" _sip._udp.down_sip._udp.down SRV 1 100 $down me_sip._udp.down SRV 2 100 $contact me; A failoverdown2 A 0.0.0.2 A 0.0.0.3 A 127.0.0.1EOF# -g is also very nice option for namednamed -f -c $namedfile &pid=$!while ! test -r $pidfile && kill -0 $!do sleep 1doneif test -r $pidfile ; then# export SOFIA_DEBUG=9 sink=$sink down=$down \ ipv6=$ipv6 \ SIPCONTACT="sip:*:$contact;comp=sigcomp" \ $VALGRIND ./test_nta "$@" - $resolvfile exit=$? kill $(cat $pidfile) rm $pidfile $zonefile $resolvfile $namedfile 2>/dev/null exit $exitfiexit $?else # not having BIND and portbindipv6=$ipv6 $VALGRIND ./test_nta "$@"exit $?fi
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -