Home | 简体中文 | 繁体中文 | 杂文 | Github | 知乎专栏 | Facebook | Linkedin | Youtube | 打赏(Donations) | About
知乎专栏

181.13. 多租户(多领域)配置

			
[root@netkiller ~]# cat /etc/freeswitch/directory/default/1000.xml			
<include>
     <domain name="sip.netkiller.cn">
         <user id="1000">
             <params>
                 <param name="password" value="1234"/>
             </params>
         </user>
         <user id="1001">
             <params>
                 <param name="password" value="1234"/>
             </params>
         </user>
     </domain>
 
     <domain name="voip.netkiller.cn">
         <user id="1000">
             <params>
                 <param name="password" value="1234"/>                                                                                                                                        
             </params>
         </user>
         <user id="1001">
             <params>
                 <param name="password" value="1234"/>
             </params>
         </user>
     </domain>
 </include>			
			
		

181.13.1. 测试号码

freeswitch提供了测试号码

		
号码		说明
9664	保持音乐
9196	echo,回音测试
9195	echo,回音测试,延迟5秒
9197	milliwatte extension,铃音生成
9198	TGML 铃音生成示例
5000	示例IVR4000听取语音信箱
33xx	电话会议,48K(其中xx可为00-99,下同)
32xx	电话会议,32K
31xx	电话会议,16K
30xx	电话会议,8K
2000-2002	呼叫组
1000-1019	默认分机号
		
			

181.13.1.1. 测试分机号

1000-1019 测试账号位置

			
[root@netkiller ~]# ls /etc/freeswitch/directory/default/
1000.xml  1002.xml  1004.xml  1006.xml  1008.xml  1010.xml  1012.xml  1014.xml  1016.xml  1018.xml  brian.xml    example.com.xml
1001.xml  1003.xml  1005.xml  1007.xml  1009.xml  1011.xml  1013.xml  1015.xml  1017.xml  1019.xml  default.xml  skinny-example.xml			
			
				

用户配置文件

			
[root@netkiller ~]# cat /etc/freeswitch/directory/default/1000.xml 
<include>
  <user id="1000">
    <params>
      <param name="password" value="$${default_password}"/>
      <param name="vm-password" value="1000"/>
    </params>
    <variables>
      <variable name="toll_allow" value="domestic,international,local"/>
      <variable name="accountcode" value="1000"/>
      <variable name="user_context" value="default"/>
      <variable name="effective_caller_id_name" value="Extension 1000"/>
      <variable name="effective_caller_id_number" value="1000"/>
      <variable name="outbound_caller_id_name" value="$${outbound_caller_name}"/>
      <variable name="outbound_caller_id_number" value="$${outbound_caller_id}"/>
      <variable name="callgroup" value="techsupport"/>
    </variables>
  </user>
</include>
			
				

账号密码在 /etc/freeswitch/vars.xml 配置文件中

			
<X-PRE-PROCESS cmd="set" data="default_password=eFyS2wcZo1zKZ3KG"/>
			
				

用下面方法查看密码

			
[root@netkiller ~]# cat /etc/freeswitch/vars.xml | grep default_password
       YOU SHOULD CHANGE THIS default_password value if you don't want to be subject to any
  <X-PRE-PROCESS cmd="set" data="default_password=eFo1zKZyS2wcZ3KG"/>		
			
				

181.13.2. 组呼叫配置

定义组呼叫拨号规则

			
[root@netkiller ~]# cat /etc/freeswitch/directory/default/1000.xml			
    <extension name="group_dial_sales">
      <condition field="destination_number" expression="^2000$">
        <action application="bridge" data="${group_call(sales@${domain_name})}"/>
      </condition>
    </extension>

    <extension name="group_dial_support">
      <condition field="destination_number" expression="^2001$">
        <action application="bridge" data="group/support@${domain_name}"/>
      </condition>
    </extension>

    <extension name="group_dial_billing">
      <condition field="destination_number" expression="^2002$">
        <action application="bridge" data="group/billing@${domain_name}"/>
      </condition>
    </extension>
			
			

配置组内用户

			
[root@netkiller ~]# cat /etc/freeswitch/directory/default.xml 
<!--
    NOTICE NOTICE NOTICE NOTICE NOTICE NOTICE NOTICE NOTICE NOTICE NOTICE

    FreeSWITCH works off the concept of users and domains just like email.
    You have users that are in domains for example 1000@domain.com.

    When freeswitch gets a register packet it looks for the user in the directory
    based on the from or to domain in the packet depending on how your sofia profile
    is configured.  Out of the box the default domain will be the IP address of the
    machine running FreeSWITCH.  This IP can be found by typing "sofia status" at the
    CLI.  You will register your phones to the IP and not the hostname by default.
    If you wish to register using the domain please open vars.xml in the root conf
    directory and set the default domain to the hostname you desire.  Then you would
    use the domain name in the client instead of the IP address to register
    with FreeSWITCH.

    NOTICE NOTICE NOTICE NOTICE NOTICE NOTICE NOTICE NOTICE NOTICE NOTICE
-->

<include>
  <!--the domain or ip (the right hand side of the @ in the addr-->
  <domain name="$${domain}">
    <params>
      <param name="dial-string" value="{^^:sip_invite_domain=${dialed_domain}:presence_id=${dialed_user}@${dialed_domain}}${sofia_contact(*/${dialed_user}@${dialed_domain})},${verto_contact(${dialed_user}@${dialed_domain})}"/>
      <!-- These are required for Verto to function properly -->
      <param name="jsonrpc-allowed-methods" value="verto"/>
      <!-- <param name="jsonrpc-allowed-event-channels" value="demo,conference,presence"/> -->
    </params>

    <variables>
      <variable name="record_stereo" value="true"/>
      <variable name="default_gateway" value="$${default_provider}"/>
      <variable name="default_areacode" value="$${default_areacode}"/>
      <variable name="transfer_fallback_extension" value="operator"/>
    </variables>

    <groups>
      <group name="default">
        <users>
          <X-PRE-PROCESS cmd="include" data="default/*.xml"/>
        </users>
      </group>

      <group name="sales">
        <users>
          <!--
              type="pointer" is a pointer so you can have the
              same user in multiple groups.  It basically means
              to keep searching for the user in the directory.
          -->
          <user id="1000" type="pointer"/>
          <user id="1001" type="pointer"/>
          <user id="1002" type="pointer"/>
          <user id="1003" type="pointer"/>
          <user id="1004" type="pointer"/>
        </users>
      </group>

      <group name="billing">
        <users>
          <user id="1005" type="pointer"/>
          <user id="1006" type="pointer"/>
          <user id="1007" type="pointer"/>
          <user id="1008" type="pointer"/>
          <user id="1009" type="pointer"/>
        </users>
      </group>

      <group name="support">
        <users>
          <user id="1010" type="pointer"/>
          <user id="1011" type="pointer"/>
          <user id="1012" type="pointer"/>
          <user id="1013" type="pointer"/>
          <user id="1014" type="pointer"/>
        </users>
      </group>
    </groups>

  </domain>
</include>

			
			

181.13.3. 代接电话

有一组号码,他们可能在通话,你希望终止他们的通话,接到自己这边来,可以使用,代接电话功能。

确认代接电话拨号规则已经配置 /etc/freeswitch/dialplan/default.xml

			
    <extension name="global-intercept">
      <condition field="destination_number" expression="^886$">
        <action application="answer"/>
        <action application="intercept" data="${hash(select/${domain_name}-last_dial_ext/global)}"/>
        <action application="sleep" data="2000"/>
      </condition>
    </extension>

    <extension name="group-intercept">
      <condition field="destination_number" expression="^\*8$">
        <action application="answer"/>
        <action application="intercept" data="${hash(select/${domain_name}-last_dial_ext/${callgroup})}"/>
        <action application="sleep" data="2000"/>
      </condition>
    </extension>

    <extension name="intercept-ext">
      <condition field="destination_number" expression="^\*\*(\d+)$">
        <action application="answer"/>
        <action application="intercept" data="${hash(select/${domain_name}-last_dial_ext/$1)}"/>
        <action application="sleep" data="2000"/>
      </condition>
    </extension>

    <extension name="redial">
      <condition field="destination_number" expression="^(redial|870)$">
        <action application="transfer" data="${hash(select/${domain_name}-last_dial/${caller_id_number})}"/>
      </condition>
    </extension>
			
			

创建一组用户 callgroup 相同,此处的 callgroup 与 组呼叫 没有任何关系,callgroup 是指代接电话组。

			
[root@production default]# cat /etc/freeswitch/directory/default/177.xml 
<include>
        <user id="177">
                <params>
                        <param name="password" value="0848"/>
                        <param name="vm-password" value="0848"/>
                </params>
                <variables>
                        <variable name="toll_allow" value="domestic,international,local"/>
                        <variable name="accountcode" value="177"/>
                        <variable name="user_context" value="default"/>
                        <variable name="effective_caller_id_name" value="BG7NYT"/>
                        <variable name="effective_caller_id_number" value="177"/>
                        <variable name="outbound_caller_id_name" value="$${outbound_caller_name}"/>
                        <variable name="outbound_caller_id_number" value="$${outbound_caller_id}"/>
                        <variable name="callgroup" value="bg7nyt"/>
                </variables>
        </user>
</include>			
			
			

配置好后,你可以找几个电话测试,拨通一组后,用另一部话机不通 886 就能接管正在通话的号码。