freeswitch多租户配置

263 阅读1分钟

1.官方文档

developer.signalwire.com/freeswitch/…

2. conf/sip_profiles/internal.xml

 <!--
        These are enabled to make the default config work better out of the box.
        If you need more than ONE domain you **MUST DISABLE** these options.

    -->
    <!--all inbound reg will look in this domain for the users -->
    <param name="force-register-domain" value="$${domain}"/>
    <!--all inbound reg will stored in the db using this domain -->
    <param name="force-register-db-domain" value="$${domain}"/>

编辑后结果

    <!--all inbound reg will look in this domain for the users -->
    <!--<param name="force-register-domain" value="$${domain}"/>-->
    <!--force the domain in subscriptions to this value -->
    <!--<param name="force-subscription-domain" value="$${domain}"/>-->
    <!--all inbound reg will stored in the db using this domain -->
    <!--<param name="force-register-db-domain" value="$${domain}"/>-->

3.创建租户用户相关文件

/usr/local/freeswitch/

$ cp conf/directory/default.xml conf/directory/company-a.org.xml
$ cp conf/directory/default.xml conf/directory/company-b.org.xml
$ cp -a conf/directory/default conf/directory/company-a.org
$ cp -a conf/directory/default conf/directory/company-b.org

执行后

$ ls -l

total 24
drwxr-xr-x 3 diego diego 4096 2009-09-23 04:30 company-a.org
-rw-r--r-- 1 diego diego 2656 2009-09-29 22:21 company-a.org.xml
drwxr-xr-x 3 diego diego 4096 2009-09-23 04:30 company-b.org
-rw-r--r-- 1 diego diego 2656 2009-09-29 22:21 company-b.org.xml
drwxr-xr-x 3 diego diego 4096 2009-09-23 04:30 default
-rw-r--r-- 1 diego diego 2656 2009-09-23 04:30 default.xml
$

3.1编辑配置文件

  • conf/directory/company-a.org.xml
 <include>
  <!--the domain or ip (the right hand side of the @ in the addr-->
  <domain name="company-a.org">
    <params>
      <param name="dial-string" value="{presence_id=${dialed_user}@${dialed_domain}}${sofia_contact(${dialed_user}@${dialed_domain})}"/>
    </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"/>
      <variable name="user_context" value="company-a.org"/>
    </variables>

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

    </groups>

  </domain>
</include>
  • conf/directory/company-b.org.xml
<include>
  <!--the domain or ip (the right hand side of the @ in the addr-->
  <domain name="company-b.org">
    <params>
      <param name="dial-string" value="{presence_id=${dialed_user}@${dialed_domain}}${sofia_contact(${dialed_user}@${dialed_domain})}"/>
    </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"/>
      <variable name="user_context" value="company-b.org"/>
    </variables>

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

    </groups>

  </domain>
</include>

4.编辑用户文件

注释 user_context这一行就ok了

4.1 conf/directory/company-a.org

<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>

4.2 conf/directory/company-b.org/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>

5.修改配置 conf/sip_profiles/internal.xml

<!--<param name="force-register-domain" value="$${domain}"/>-->
<!--<param name="force-register-db-domain" value="$${domain}"/>-->
<!--<param name="force-subscription-domain" value="$${domain}"/>-->

5.创建租户配置文件

5.1 复制文件

复制conf/dialplan/default.xml 文件名为:conf/dialplan/company-a.org.xml 和 conf/dialplan/company-b.org.xml

5.2 编辑文件

conf/dialplan/company-a.org.xml

<include>
  <context name="company-a.org">
    <!-- your extensions here -->
  </context>
</include>

conf/dialplan/company-b.org.xml

<include>
  <context name="company-b.org">
    <!-- your extensions here -->
  </context>
</include>

6.重新连接

使用mac环境,软件 Telephone,Windows 使用microSIP可以达到同样的效果。

现在使用 [1000@company-a.org]才能进行连接,也就是设置domain为刚才配置文件名称。 domain可以设置成任意值,但是network中要配置对应的freeswitch地址。如下图:

image.png

image.png