FreeSWITCH 1.2
上QQ阅读APP看书,第一时间看更新

Adding a user

Adding one or more users is a simple two-step process, which is as follows:

  1. Create a new XML file for the user, usually by copying an existing file.
  2. Modify the Local_Extension Dialplan entry.

In this example, we will create a new user for a person named Gwen and a username of 1100. Perform the following steps:

  1. Open a terminal window, and change the directory to conf/directory/default.
  2. Make a copy of 1000.xml and name it 1100.xml. A Linux/Unix session looks as follows:
    #>cd /usr/local/freeswitch/conf/directory/default
    #>cp 1000.xml 1100.xml
  3. Open 1100.xml in an editor and make the following changes:
    • Replace all occurrences of 1000 with 1100
    • Change the value of effective_caller_id_name to Gwen
  4. The new file should look as follows:
    <include>
      <user id="1100">
        <params>
          <param name="password" value="$${default_password}"/>
          <param name="vm-password" value="1100"/>
        </params>
        <variables>
          <variable name="toll_allow" 
            value="domestic,international,local"/>
          <variable name="accountcode" value="1100"/>
          <variable name="user_context" value="default"/>
          <variable name="effective_caller_id_name" value="Gwen"/>
          <variable name="effective_caller_id_number"
            value="1100"/>
          <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. Save the file. Next, we need to edit the Dialplan entry for Local_Extension. Open conf/dialplan/default.xml in an editor and locate the following lines:
    <extension name="Local_Extension">
      <condition field="destination_number"
        expression="^(10[01][0-9])$">

This Dialplan extension, as its name implies, routes calls to local extensions. In our case, a local extension is a phone registered to a user in our directory. Recall that FreeSWITCH comes with 20 directory users predefined, numbered 1000 through 1019. This extension corresponds to those 20 users. By default, any call made to 1000, 1001, …, 1019 will be handled by the Local_Extension Dialplan entry. We need to add 1100 to the regular expression. Edit the expression value so that it looks as follows:

^(10[01][0-9]|1100)$

Save the file. (Regular expressions are discussed in greater detail in Chapter 5, Understanding the XML Dialplan, in the Regular expressions section.)

The last thing we need to do is reload the XML configuration. Launch fs_cli and issue the reloadxml command as follows:

freeswitch@internal> reloadxml
+OK [Success]
2012-09-14 14:27:32.942464 [INFO] mod_enum.c:871 ENUM Reloaded
2012-09-14 14:27:32.942464 [INFO] switch_time.c:1163 Timezone reloaded 530 definitions
Tip

Linux/Unix users can save time by opening two terminal windows. Run fs_cli in one window and your editor in the other. For advanced handling of multiple windows check out the GNU Screen utility. More information can be found at http://www.gnu.org/software/screen.

Our new extension has been defined, and we should now be able to register a SIP phone to user 1100. Using the methods described in Chapter 3, Test Driving the Example Configuration, register a SIP phone to user 1100. An X-Lite configuration looks like the following screenshot:

The registered phone can now make outbound calls, and can receive inbound calls from those who dial 1100.

Tip

To see which SIP phones are registered, issue this command at the FreeSWITCH command line: sofia status profile internal reg.

Now that we have successfully added a user, let's test a common feature: voicemail.