add ivr config

This commit is contained in:
东皇大叔 2020-07-15 10:42:42 +08:00
parent ac7f187410
commit 26e05537df
10 changed files with 882 additions and 685 deletions

View File

@ -3,6 +3,8 @@ package com.pudonghot.yo.fsagent.controller;
import com.pudonghot.yo.model.domain.Tenant;
import freemarker.template.Configuration;
import java.nio.charset.StandardCharsets;
import org.apache.commons.lang3.StringUtils;
import org.springframework.http.MediaType;
import org.springframework.context.ApplicationContext;
import com.pudonghot.yo.fsagent.service.TenantService;
@ -31,12 +33,7 @@ public class BaseXmlController {
* @return init FreeMarker view
*/
protected FreeMarkerView view() {
final FreeMarkerView view = new FreeMarkerView();
view.setApplicationContext(applicationContext);
view.setConfiguration(configuration);
view.setContentType(MediaType.APPLICATION_XML_VALUE);
view.setEncoding(StandardCharsets.UTF_8.name());
return view;
return view(null);
}
/**
@ -46,8 +43,14 @@ public class BaseXmlController {
* @return init FreeMarker view
*/
protected FreeMarkerView view(final String path) {
final FreeMarkerView view = view();
view.setUrl(path);
final FreeMarkerView view = new FreeMarkerView();
if (StringUtils.isNotBlank(path)) {
view.setUrl(path);
}
view.setApplicationContext(applicationContext);
view.setConfiguration(configuration);
view.setContentType(MediaType.APPLICATION_XML_VALUE);
view.setEncoding(StandardCharsets.UTF_8.name());
return view;
}

View File

@ -22,7 +22,13 @@ import org.springframework.web.servlet.view.freemarker.FreeMarkerView;
*/
@Slf4j
@Controller
@RequestMapping("/xml/config")
@RequestMapping(value = "/xml/config",
params = {
"section=configuration",
"tag_name=configuration",
"key_name=name",
"key_value"
})
public class ConfigController extends BaseXmlController {
@Autowired
private GatewayService gatewayService;
@ -43,6 +49,12 @@ public class ConfigController extends BaseXmlController {
return empty(SECTION_CONFIGURATION);
}
/**
* Sofia Config
*
* @param params params
* @return config xml
*/
@RequestMapping(params = "key_value=sofia.conf")
public FreeMarkerView sofiaConfig(
@RequestParam
@ -51,7 +63,7 @@ public class ConfigController extends BaseXmlController {
log.info("Fetch sofia config XML.");
log.debug("XML sofia config [{}].", params);
final FreeMarkerView view = view("config/sofia.conf.xml");
final FreeMarkerView view = configView("sofia.conf.xml");
final List<Gateway> gateways = gatewayService.list(
new Search(Gateway.ACTIVE, true));
gateways.forEach(g -> g.setName(gatewayService.genGatewayName(g)));
@ -60,11 +72,21 @@ public class ConfigController extends BaseXmlController {
return view;
}
@RequestMapping(params = "key_value=acl.conf")
public FreeMarkerView aclConfig(
@RequestParam
final Map<String, Object> params) {
log.info("Fetch ACL config XML.");
log.debug("XML ACL config [{}].", params);
return configView("acl.conf.xml");
}
/**
* 似乎不起作用FreeSWITCH还是会加载本地
* ODBC CDR
*
* @param params request params
* @return ODBC CDR config xml
* @return config xml
*/
@RequestMapping(params = "key_value=odbc_cdr.conf")
public FreeMarkerView odbcCdrConfig(
@ -74,7 +96,7 @@ public class ConfigController extends BaseXmlController {
log.info("Fetch ODBC CDR config XML.");
log.debug("XML ODBC CDR [{}].", params);
final FreeMarkerView view = view("config/odbc_cdr.conf.xml");
final FreeMarkerView view = configView("odbc_cdr.conf.xml");
attr(view, "odbcDsn", OdbcUtils.odbcDsn((DruidDataSource) dataSource));
return view;
@ -87,6 +109,37 @@ public class ConfigController extends BaseXmlController {
log.info("Fetch event socket config XML.");
log.debug("XML event socket config [{}].", params);
return view("config/event_socket.conf.xml");
return configView("event_socket.conf.xml");
}
@RequestMapping(params = "key_value=curl.conf")
public FreeMarkerView curlConfig(
@RequestParam
final Map<String, Object> params) {
log.info("Fetch cURL config XML.");
log.debug("XML cURL [{}].", params);
return configView("curl.conf.xml");
}
@RequestMapping(params = "key_value=ivr.conf")
public FreeMarkerView ivrConfig(
@RequestParam("Menu-Name")
final String menu,
@RequestParam
final Map<String, Object> params) {
log.info("Fetch IVR [{}] config XML.", menu);
log.debug("XML IVR [{}].", params);
return configView("ivr.conf.xml");
}
/**
* {@inheritDoc}
*/
protected FreeMarkerView configView(final String path) {
return attr(super.view("config/main.conf.xml"), "content", path);
}
}

View File

@ -1,3 +1,4 @@
<!-- <#noparse> -->
<configuration name="acl.conf" description="Network Lists">
<network-lists>
<!--
@ -31,4 +32,5 @@
</list>
</network-lists>
</configuration>
<!-- </#noparse> -->

View File

@ -0,0 +1,5 @@
<configuration name="curl.conf" description="cURL module">
<settings>
<param name="max-bytes" value="64000" />
</settings>
</configuration>

View File

@ -1,10 +1,10 @@
<configuration name="event_socket.conf" description="Socket Client">
<settings>
<param name="nat-map" value="false" />
<param name="listen-ip" value="::" />
<param name="listen-ip" value="0.0.0.0" />
<param name="listen-port" value="8021" />
<param name="password" value="ClueCon" />
<param name="stop-on-bind-error" value="true"/>
<!--<param name="apply-inbound-acl" value="loopback.auto"/>-->
<param name="stop-on-bind-error" value="true" />
<param name="apply-inbound-acl" value="wan.auto" />
</settings>
</configuration>

View File

@ -0,0 +1,133 @@
<!-- <#noparse> -->
<configuration name="ivr.conf" description="IVR menus">
<menus>
<!-- demo IVR setup -->
<!-- demo IVR, Main Menu -->
<menu name="demo_ivr"
greet-long="phrase:demo_ivr_main_menu"
greet-short="phrase:demo_ivr_main_menu_short"
invalid-sound="ivr/ivr-that_was_an_invalid_entry.wav"
exit-sound="voicemail/vm-goodbye.wav"
confirm-macro=""
confirm-key=""
tts-engine="flite"
tts-voice="rms"
confirm-attempts="3"
timeout="10000"
inter-digit-timeout="2000"
max-failures="3"
max-timeouts="3"
digit-len="4">
<!-- The following are the definitions for the digits the user dials -->
<!-- Digit 1 transfer caller to the public FreeSWITCH conference -->
<entry action="menu-exec-app" digits="1" param="bridge sofia/$${domain}/888@conference.freeswitch.org"/>
<entry action="menu-exec-app" digits="2" param="transfer 9196 XML default"/> <!-- FS echo -->
<entry action="menu-exec-app" digits="3" param="transfer 9664 XML default"/> <!-- MOH -->
<entry action="menu-exec-app" digits="4" param="transfer 9191 XML default"/> <!-- ClueCon -->
<entry action="menu-exec-app" digits="5" param="transfer 1234*256 enum"/> <!-- Screaming monkeys -->
<entry action="menu-sub" digits="6" param="demo_ivr_submenu"/> <!-- demo sub menu -->
<!-- Using a regex in the digits tag lets you define a dial pattern for the caller
You may define multiple regexes if you need a different pattern for some reason -->
<entry action="menu-exec-app" digits="/^(10[01][0-9])$/" param="transfer $1 XML features"/>
<entry action="menu-top" digits="9"/> <!-- Repeat this menu -->
</menu>
<!-- Demo IVR, Sub Menu -->
<menu name="demo_ivr_submenu"
greet-long="phrase:demo_ivr_sub_menu"
greet-short="phrase:demo_ivr_sub_menu_short"
invalid-sound="ivr/ivr-that_was_an_invalid_entry.wav"
exit-sound="voicemail/vm-goodbye.wav"
timeout="15000"
max-failures="3"
max-timeouts="3">
<!-- The demo IVR sub menu prompt basically just says, "press star to return to previous menu..." -->
<entry action="menu-top" digits="*"/>
</menu>
<!-- TTS sample; non-functional but it demonstrates say: and TTS -->
<!--
<menu name="demo3"
greet-long="say:Press 1 to join the conference, Press 2 to join the other conference"
greet-short="say:Press 1 to join the conference, Press 2 to join the other conference"
invalid-sound="say:invalid extension"
exit-sound="say:exit sound"
timeout ="15000"
max-failures="3">
<entry action="menu-exit" digits="*"/>
<entry action="menu-play-sound" digits="1" param="say:You pressed 1"/>
<entry action="menu-exec-app" digits="2" param="transfert 1000 XML default"/>
<entry action="menu-exec-app" digits="3" param="transfert 1001 XML default"/>
</menu>
-->
<!-- new demo IVR, Main Menu -->
<menu name="new_demo_ivr"
greet-long="phrase:new_demo_ivr_main_menu"
greet-short="phrase:new_demo_ivr_main_menu_short"
invalid-sound="ivr/ivr-that_was_an_invalid_entry.wav"
exit-sound="voicemail/vm-goodbye.wav"
confirm-macro=""
confirm-key=""
tts-engine="flite"
tts-voice="rms"
confirm-attempts="3"
timeout="10000"
inter-digit-timeout="2000"
max-failures="3"
max-timeouts="3"
digit-len="4">
<entry action="menu-sub" digits="1" param="freeswitch_ivr_submenu"/> <!-- FreeSWITCH sub menu -->
<entry action="menu-sub" digits="2" param="freeswitch_solutions_ivr_submenu"/> <!-- FreeSWITCH Solutions sub menu -->
<entry action="menu-sub" digits="3" param="cluecon_ivr_submenu"/> <!-- ClueCon sub menu -->
<entry action="menu-exec-app" digits="4" param="5000 XML default"/> <!-- original demo IVR -->
<entry action="menu-top" digits="9"/> <!-- Repeat this menu -->
</menu>
<!-- FreeSWITCH IVR Sub Menu -->
<menu name="freeswitch_ivr_submenu"
greet-long="phrase:learn_about_freeswitch_sub_menu"
greet-short="phrase:learn_about_freeswitch_sub_menu"
invalid-sound="ivr/ivr-that_was_an_invalid_entry.wav"
exit-sound="voicemail/vm-goodbye.wav"
timeout="15000"
max-failures="3"
max-timeouts="3">
<entry action="menu-sub" digits="9" param="freeswitch_ivr_submenu"/>
<entry action="menu-top" digits="*"/>
</menu>
<!-- FreeSWITCH Solutions IVR Sub Menu -->
<menu name="freeswitch_solutions_ivr_submenu"
greet-long="phrase:learn_about_freeswitch_solutions_sub_menu"
greet-short="phrase:learn_about_freeswitch_solutions_sub_menu"
invalid-sound="ivr/ivr-that_was_an_invalid_entry.wav"
exit-sound="voicemail/vm-goodbye.wav"
timeout="15000"
max-failures="3"
max-timeouts="3">
<entry action="menu-sub" digits="9" param="freeswitch_solutions_ivr_submenu"/>
<entry action="menu-top" digits="*"/>
</menu>
<!-- ClueCon IVR Sub Menu -->
<menu name="cluecon_ivr_submenu"
greet-long="phrase:learn_about_cluecon_sub_menu"
greet-short="phrase:learn_about_cluecon_sub_menu"
invalid-sound="ivr/ivr-that_was_an_invalid_entry.wav"
exit-sound="voicemail/vm-goodbye.wav"
timeout="15000"
max-failures="3"
max-timeouts="3">
<entry action="menu-sub" digits="9" param="cluecon_ivr_submenu"/>
<entry action="menu-top" digits="*"/>
</menu>
</menus>
</configuration>
<!-- </#noparse> -->

View File

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<document type="freeswitch/xml">
<section name="configuration">
<#include "${content}" />
</section>
</document>

View File

@ -1,45 +1,45 @@
<configuration name="odbc_cdr.conf" description="ODBC CDR Configuration">
<settings>
<param name="odbc-dsn" value="${odbcDsn}" />
<!-- global value can be "a-leg", "b-leg", "both" (default is "both") -->
<param name="log-leg" value="both" />
<!-- value can be "always", "never", "on-db-fail" -->
<param name="write-csv" value="on-db-fail" />
<!-- location to store csv copy of CDR -->
<param name="csv-path" value="/var/log/freeswitch/cdr-odbc" />
<!-- if "csv-path-on-fail" is set, failed INSERTs will be placed here as CSV files otherwise they will be placed in "csv-path" -->
<param name="csv-path-on-fail" value="/var/log/freeswitch/cdr-odbc/failed" />
<!-- dump SQL statement after leg ends -->
<param name="debug-sql" value="false" />
</settings>
<tables>
<!-- both legs will be inserted into this table -->
<table name="br_call_detail_record">
<field name="tenant_id" chan-var-name="x_tenant_id" />
<field name="tenant_code" chan-var-name="x_tenant_code" />
<field name="account" chan-var-name="x_account" />
<field name="conn_id" chan-var-name="x_conn_id" />
<settings>
<param name="odbc-dsn" value="${odbcDsn}" />
<!-- global value can be "a-leg", "b-leg", "both" (default is "both") -->
<param name="log-leg" value="both" />
<!-- value can be "always", "never", "on-db-fail" -->
<param name="write-csv" value="on-db-fail" />
<!-- location to store csv copy of CDR -->
<param name="csv-path" value="/var/log/freeswitch/cdr-odbc" />
<!-- if "csv-path-on-fail" is set, failed INSERTs will be placed here as CSV files otherwise they will be placed in "csv-path" -->
<param name="csv-path-on-fail" value="/var/log/freeswitch/cdr-odbc/failed" />
<!-- dump SQL statement after leg ends -->
<param name="debug-sql" value="false" />
</settings>
<tables>
<!-- both legs will be inserted into this table -->
<table name="br_call_detail_record">
<field name="tenant_id" chan-var-name="x_tenant_id" />
<field name="tenant_code" chan-var-name="x_tenant_code" />
<field name="account" chan-var-name="x_account" />
<field name="conn_id" chan-var-name="x_conn_id" />
<field name="dial_type" chan-var-name="x_dial_type" />
<field name="call_type" chan-var-name="x_call_type" />
<field name="agent_type" chan-var-name="x_agent_type" />
<field name="dial_type" chan-var-name="x_dial_type" />
<field name="call_type" chan-var-name="x_call_type" />
<field name="agent_type" chan-var-name="x_agent_type" />
<field name="uuid" chan-var-name="uuid" />
<field name="call_uuid" chan-var-name="call_uuid" />
<field name="sip_call_id" chan-var-name="sip_call_id" />
<field name="caller_number" chan-var-name="caller_id_number" />
<field name="called_number" chan-var-name="x_called_number" />
<field name="trunk_id" chan-var-name="x_trunk_id" />
<field name="calling_party_number" chan-var-name="x_cpn" />
<field name="start_stamp" chan-var-name="start_stamp" />
<field name="answer_stamp" chan-var-name="answer_stamp" />
<field name="end_stamp" chan-var-name="end_stamp" />
<field name="duration" chan-var-name="duration" />
<field name="mduration" chan-var-name="mduration" />
<field name="billsec" chan-var-name="billsec" />
<field name="billmsec" chan-var-name="billmsec" />
<field name="endpoint_disposition" chan-var-name="endpoint_disposition" />
<field name="hangup_cause" chan-var-name="hangup_cause" />
</table>
</tables>
<field name="uuid" chan-var-name="uuid" />
<field name="call_uuid" chan-var-name="call_uuid" />
<field name="sip_call_id" chan-var-name="sip_call_id" />
<field name="caller_number" chan-var-name="caller_id_number" />
<field name="called_number" chan-var-name="x_called_number" />
<field name="trunk_id" chan-var-name="x_trunk_id" />
<field name="calling_party_number" chan-var-name="x_cpn" />
<field name="start_stamp" chan-var-name="start_stamp" />
<field name="answer_stamp" chan-var-name="answer_stamp" />
<field name="end_stamp" chan-var-name="end_stamp" />
<field name="duration" chan-var-name="duration" />
<field name="mduration" chan-var-name="mduration" />
<field name="billsec" chan-var-name="billsec" />
<field name="billmsec" chan-var-name="billmsec" />
<field name="endpoint_disposition" chan-var-name="endpoint_disposition" />
<field name="hangup_cause" chan-var-name="hangup_cause" />
</table>
</tables>
</configuration>

File diff suppressed because it is too large Load Diff

View File

@ -24,7 +24,7 @@ WORK_DIR=$(pwd)
echo "Work dir [$WORK_DIR]"
if [ -z "$1" ]; then
echo 'Usage: ./start_module.sh module'
echo 'Usage: ./launch_module.sh module(cms,fsagent...)'
exit 1
fi