|
@@ -32,8 +32,7 @@ MYSQL_ROW g_row; // 字符串数组,mysql 记录行
|
|
#define EXTEN_GLOBAL_FILE "/etc/asterisk/extensions_global_custom.conf"
|
|
#define EXTEN_GLOBAL_FILE "/etc/asterisk/extensions_global_custom.conf"
|
|
#define EXTEN_CALLTRIGGER_FILE "/etc/asterisk/extensions_call_trigger_custom.conf"
|
|
#define EXTEN_CALLTRIGGER_FILE "/etc/asterisk/extensions_call_trigger_custom.conf"
|
|
#define EXTEN_FEATURECODES_FILE "/etc/asterisk/extensions_featurecodes_custom.conf"
|
|
#define EXTEN_FEATURECODES_FILE "/etc/asterisk/extensions_featurecodes_custom.conf"
|
|
-#define SIP_NAT_FILE "/etc/asterisk/sip_nat.conf"
|
|
|
|
-#define SIP_SETTINGS_FILE "/etc/asterisk/sip_settings.conf"
|
|
|
|
|
|
+#define SIP_SETTINGS_FILE "/etc/asterisk/pjsip_transports.conf"
|
|
#define RTP_SETTINGS_FILE "/etc/asterisk/rtp_settings.conf"
|
|
#define RTP_SETTINGS_FILE "/etc/asterisk/rtp_settings.conf"
|
|
#define KEYVALLEN 100
|
|
#define KEYVALLEN 100
|
|
#define VERSION "V1.0.1"
|
|
#define VERSION "V1.0.1"
|
|
@@ -52,135 +51,6 @@ char ivrstr[MAX_SIZE];
|
|
char inboundstr[MIDLE_SIZE];
|
|
char inboundstr[MIDLE_SIZE];
|
|
char prompt[MINI_SIZE];
|
|
char prompt[MINI_SIZE];
|
|
|
|
|
|
-//读取配置文件函数----功能:删除左边空格
|
|
|
|
-char *l_trim(char *szOutput, const char *szInput)
|
|
|
|
-{
|
|
|
|
- assert(szInput != NULL);
|
|
|
|
- assert(szOutput != NULL);
|
|
|
|
- assert(szOutput != szInput);
|
|
|
|
- for (NULL; *szInput != '\0' && isspace(*szInput); ++szInput)
|
|
|
|
- {
|
|
|
|
- ;
|
|
|
|
- }
|
|
|
|
- return strcpy(szOutput, szInput);
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
-/* 删除右边的空格 */
|
|
|
|
-char *r_trim(char *szOutput, const char *szInput)
|
|
|
|
-{
|
|
|
|
- char *p = NULL;
|
|
|
|
- assert(szInput != NULL);
|
|
|
|
- assert(szOutput != NULL);
|
|
|
|
- assert(szOutput != szInput);
|
|
|
|
- strcpy(szOutput, szInput);
|
|
|
|
- for(p = szOutput + strlen(szOutput) - 1; p >= szOutput && isspace(*p); --p)
|
|
|
|
- {
|
|
|
|
- ;
|
|
|
|
- }
|
|
|
|
- *(++p) = '\0';
|
|
|
|
- return szOutput;
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
-/* 删除两边的空格 */
|
|
|
|
-char *a_trim(char *szOutput, const char *szInput)
|
|
|
|
-{
|
|
|
|
- char *p = NULL;
|
|
|
|
- assert(szInput != NULL);
|
|
|
|
- assert(szOutput != NULL);
|
|
|
|
- l_trim(szOutput, szInput);
|
|
|
|
- for (p = szOutput + strlen(szOutput) - 1; p >= szOutput && isspace(*p); --p)
|
|
|
|
- {
|
|
|
|
- ;
|
|
|
|
- }
|
|
|
|
- *(++p) = '\0';
|
|
|
|
- return szOutput;
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
-//main函数接口 参数1:配置文件路径 参数2:配置文件的那一部分,如general 参数3:键名 参数4:键值
|
|
|
|
-int GetProfileString(char *profile, char *AppName, char *KeyName, char *KeyVal )
|
|
|
|
-{
|
|
|
|
- char appname[32], keyname[32];
|
|
|
|
- char *buf, *c;
|
|
|
|
- char buf_i[KEYVALLEN], buf_o[KEYVALLEN];
|
|
|
|
- FILE *fp;
|
|
|
|
- int found = 0; /* 1 AppName 2 KeyName */
|
|
|
|
- if( (fp = fopen( profile, "r" )) == NULL )
|
|
|
|
- {
|
|
|
|
- printf( "openfile [%s] error [%s]\n", profile, strerror(errno) );
|
|
|
|
- return(-1);
|
|
|
|
- }
|
|
|
|
- fseek( fp, 0, SEEK_SET );
|
|
|
|
- memset( appname, 0, sizeof(appname) );
|
|
|
|
- sprintf( appname, "[%s]", AppName );
|
|
|
|
-
|
|
|
|
- while( !feof(fp) && fgets( buf_i, KEYVALLEN, fp ) != NULL )
|
|
|
|
- {
|
|
|
|
- l_trim(buf_o, buf_i);
|
|
|
|
- if( strlen(buf_o) <= 0 )
|
|
|
|
- continue;
|
|
|
|
- buf = NULL;
|
|
|
|
- buf = buf_o;
|
|
|
|
-
|
|
|
|
- if( found == 0 )
|
|
|
|
- {
|
|
|
|
- if( buf[0] != '[' )
|
|
|
|
- {
|
|
|
|
- continue;
|
|
|
|
- }
|
|
|
|
- else if ( strncmp(buf, appname, strlen(appname)) == 0 )
|
|
|
|
- {
|
|
|
|
- found = 1;
|
|
|
|
- continue;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- }
|
|
|
|
- else if( found == 1 )
|
|
|
|
- {
|
|
|
|
- if( buf[0] == '#' )
|
|
|
|
- {
|
|
|
|
- continue;
|
|
|
|
- }
|
|
|
|
- else if ( buf[0] == '[' )
|
|
|
|
- {
|
|
|
|
- break;
|
|
|
|
- }
|
|
|
|
- else
|
|
|
|
- {
|
|
|
|
- if( (c = (char *)strchr(buf, '=')) == NULL )
|
|
|
|
- continue;
|
|
|
|
- memset( keyname, 0, sizeof(keyname) );
|
|
|
|
-
|
|
|
|
- sscanf( buf, "%[^=|^ |^\t]", keyname );
|
|
|
|
- if( strcmp(keyname, KeyName) == 0 )
|
|
|
|
- {
|
|
|
|
- sscanf( ++c, "%[^\n]", KeyVal );
|
|
|
|
- char *KeyVal_o = (char *)malloc(strlen(KeyVal) + 1);
|
|
|
|
- if(KeyVal_o != NULL)
|
|
|
|
- {
|
|
|
|
- memset(KeyVal_o, 0, sizeof(KeyVal_o));
|
|
|
|
- a_trim(KeyVal_o, KeyVal);
|
|
|
|
- if(KeyVal_o && strlen(KeyVal_o) > 0)
|
|
|
|
- strcpy(KeyVal, KeyVal_o);
|
|
|
|
- free(KeyVal_o);
|
|
|
|
- KeyVal_o = NULL;
|
|
|
|
- }
|
|
|
|
- found = 2;
|
|
|
|
- break;
|
|
|
|
- }
|
|
|
|
- else
|
|
|
|
- {
|
|
|
|
- continue;
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- fclose( fp );
|
|
|
|
- if( found == 2 )
|
|
|
|
- return(0);
|
|
|
|
- else
|
|
|
|
- return(-1);
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
char * mytime(){
|
|
char * mytime(){
|
|
time_t my_time;
|
|
time_t my_time;
|
|
time(&my_time);
|
|
time(&my_time);
|
|
@@ -226,6 +96,7 @@ return 0; // 返回成功
|
|
int main(int argc, char **argv) {
|
|
int main(int argc, char **argv) {
|
|
cJSON *pJson,*pSub;
|
|
cJSON *pJson,*pSub;
|
|
int iCount=0;
|
|
int iCount=0;
|
|
|
|
+char sip_udp_nat[2048], sip_tcp_nat[2048], sip_tls_nat[2048], localnet[1792];
|
|
|
|
|
|
typedef struct keys_action {
|
|
typedef struct keys_action {
|
|
char key[MINI_SIZE];
|
|
char key[MINI_SIZE];
|
|
@@ -341,69 +212,6 @@ same => n,WaitExten(1)\n");
|
|
fprintf(conf_ivr_fp,"\n\n");
|
|
fprintf(conf_ivr_fp,"\n\n");
|
|
}
|
|
}
|
|
/*
|
|
/*
|
|
-while ((g_row=mysql_fetch_row(g_res))){ // 打印结果集
|
|
|
|
- if (g_row[0] == NULL || g_row[1] == NULL || g_row[2] == NULL){
|
|
|
|
- printf("some feild is empty!\n");
|
|
|
|
- continue;
|
|
|
|
- }
|
|
|
|
- sprintf(ivrstr,"\
|
|
|
|
-[voicemenu-custom-%s]\n\
|
|
|
|
-include => %s\n\
|
|
|
|
-exten => %s,1,NoOp(%s)",\
|
|
|
|
-g_row[1],\
|
|
|
|
-g_row[6],\
|
|
|
|
-g_row[1],\
|
|
|
|
-g_row[0]\
|
|
|
|
- );
|
|
|
|
- if(g_row[5] != NULL){
|
|
|
|
- sprintf(ivrstr,"%s\nsame => n,Set(CHANNEL(language)=%s)",ivrstr,g_row[5]);
|
|
|
|
- }
|
|
|
|
- memset(prompt, 0, sizeof(prompt));
|
|
|
|
- strncpy(prompt,g_row[2],strlen(g_row[2])-4);
|
|
|
|
- sprintf(ivrstr,"%s\n\
|
|
|
|
-same => n,Set(COUNT=%s)\n\
|
|
|
|
-same => n(loop),Background(%s)",ivrstr,\
|
|
|
|
-g_row[3],\
|
|
|
|
-prompt
|
|
|
|
- );
|
|
|
|
- if(strcmp(g_row[4], "0") != 0 && g_row[4] != NULL){
|
|
|
|
- sprintf(ivrstr,"%s\nsame => n,WaitExten(%s)",ivrstr,g_row[4]);
|
|
|
|
- }
|
|
|
|
- sprintf(ivrstr,"%s\n\
|
|
|
|
-same => n,Set(COUNT=$[${COUNT}-1])\n\
|
|
|
|
-same => n,GotoIf($[${COUNT} < 0]?:loop)\n\
|
|
|
|
-same => n,WaitExten(1)",ivrstr
|
|
|
|
- );
|
|
|
|
- KeysObject keysObject[MINI_SIZE];
|
|
|
|
- memset(keysObject, 0, sizeof(keysObject));
|
|
|
|
- if(g_row[7] != NULL){
|
|
|
|
- pJson = cJSON_Parse(g_row[7]);
|
|
|
|
- iCount = cJSON_GetArraySize(pJson);
|
|
|
|
- for(int i = 0;i < iCount;i++){
|
|
|
|
- pSub = cJSON_GetArrayItem(pJson,i);
|
|
|
|
- if(pSub != NULL){
|
|
|
|
- strcpy(keysObject[i].key,cJSON_GetObjectItem(pSub, "key")->valuestring);
|
|
|
|
- strcpy(keysObject[i].type,cJSON_GetObjectItem(pSub, "type")->valuestring);
|
|
|
|
- strcpy(keysObject[i].exten,cJSON_GetObjectItem(pSub, "exten")->valuestring);
|
|
|
|
- if(strcmp(keysObject[i].type, "hangup") == 0){
|
|
|
|
- sprintf(ivrstr,"%s\nexten => %s,1,Hangup()",ivrstr,keysObject[i].key);
|
|
|
|
- }
|
|
|
|
- else if(strcmp(keysObject[i].type, "extension") == 0){
|
|
|
|
- sprintf(ivrstr,"%s\nexten => %s,1,Goto(default,%s,1)",ivrstr,keysObject[i].key,keysObject[i].exten);
|
|
|
|
- }
|
|
|
|
- else if(strcmp(keysObject[i].type, "ivr") == 0){
|
|
|
|
- sprintf(ivrstr,"%s\nexten => %s,1,Goto(voicemenu-custom-%s,%s,1)",ivrstr,keysObject[i].key,keysObject[i].exten,keysObject[i].exten);
|
|
|
|
- }
|
|
|
|
- else if(strcmp(keysObject[i].type, "group") == 0){
|
|
|
|
- sprintf(ivrstr,"%s\nexten => %s,1,Goto(paging-group-%s,%s,1)",ivrstr,keysObject[i].key,keysObject[i].exten,keysObject[i].exten);
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- strcat(ivrstr,"\n\n");
|
|
|
|
- fputs(ivrstr,conf_ivr_fp);
|
|
|
|
-}
|
|
|
|
-/*
|
|
|
|
[voicemenu-custom-%s]
|
|
[voicemenu-custom-%s]
|
|
include = default
|
|
include = default
|
|
exten = _IVR-X.,1,NoOp(%s)
|
|
exten = _IVR-X.,1,NoOp(%s)
|
|
@@ -450,7 +258,7 @@ fputs("[CallingRule_OutCall]\n",conf_dialrule_fp);
|
|
}
|
|
}
|
|
|
|
|
|
memset(dialrule,0,sizeof(dialrule));
|
|
memset(dialrule,0,sizeof(dialrule));
|
|
- sprintf(dialrule, "exten => _%s,1,Macro(trunkdial-failover,${EXTEN},${%s}",g_row[1], g_row[0]);
|
|
|
|
|
|
+ sprintf(dialrule, "exten => _%s,1,Gosub(trunkdial-failover,s,1(${EXTEN},${%s}",g_row[1], g_row[0]);
|
|
if(g_row[3] != NULL){
|
|
if(g_row[3] != NULL){
|
|
strcat(dialrule,g_row[3]);
|
|
strcat(dialrule,g_row[3]);
|
|
}
|
|
}
|
|
@@ -462,7 +270,7 @@ fputs("[CallingRule_OutCall]\n",conf_dialrule_fp);
|
|
if(g_row[4] != NULL){
|
|
if(g_row[4] != NULL){
|
|
strcat(dialrule,g_row[4]);
|
|
strcat(dialrule,g_row[4]);
|
|
}
|
|
}
|
|
- strcat(dialrule,")\n");
|
|
|
|
|
|
+ strcat(dialrule,"))\n");
|
|
fputs(dialrule,conf_dialrule_fp);
|
|
fputs(dialrule,conf_dialrule_fp);
|
|
}
|
|
}
|
|
|
|
|
|
@@ -498,12 +306,6 @@ if (conf_featurecodes_fp == NULL){
|
|
exit(1);
|
|
exit(1);
|
|
}
|
|
}
|
|
|
|
|
|
-FILE *conf_sip_nat_fp = fopen(SIP_NAT_FILE, "w+");
|
|
|
|
-if (conf_sip_nat_fp == NULL){
|
|
|
|
- perror("Open sip nat conf file Error: ");
|
|
|
|
- exit(1);
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
FILE *conf_sipsetting_fp = fopen(SIP_SETTINGS_FILE, "w+");
|
|
FILE *conf_sipsetting_fp = fopen(SIP_SETTINGS_FILE, "w+");
|
|
if (conf_sipsetting_fp == NULL){
|
|
if (conf_sipsetting_fp == NULL){
|
|
perror("Open sip settings conf file Error: ");
|
|
perror("Open sip settings conf file Error: ");
|
|
@@ -561,21 +363,11 @@ mytime()\
|
|
;!\n\n\
|
|
;!\n\n\
|
|
[featurecodes]\n",\
|
|
[featurecodes]\n",\
|
|
mytime()\
|
|
mytime()\
|
|
-);
|
|
|
|
-
|
|
|
|
- fprintf(conf_sip_nat_fp, ";!\n\
|
|
|
|
-;! Automatically generated configuration file\n\
|
|
|
|
-;! Filename: sip_nat.conf (/etc/asterisk/sip_nat.conf)\n\
|
|
|
|
-;! Generator: Generator SIP NAT\n\
|
|
|
|
-;! Creation Date: %s\n\
|
|
|
|
-;!\n\n\
|
|
|
|
-\n",\
|
|
|
|
-mytime()\
|
|
|
|
);
|
|
);
|
|
|
|
|
|
fprintf(conf_sipsetting_fp, ";!\n\
|
|
fprintf(conf_sipsetting_fp, ";!\n\
|
|
;! Automatically generated configuration file\n\
|
|
;! Automatically generated configuration file\n\
|
|
-;! Filename: sip_settings.conf (/etc/asterisk/sip_settings.conf)\n\
|
|
|
|
|
|
+;! Filename: pjsip_transports.conf (/etc/asterisk/pjsip_transports.conf)\n\
|
|
;! Generator: Generator SIP SETTINGS\n\
|
|
;! Generator: Generator SIP SETTINGS\n\
|
|
;! Creation Date: %s\n\
|
|
;! Creation Date: %s\n\
|
|
;!\n\n\
|
|
;!\n\n\
|
|
@@ -690,43 +482,59 @@ RINGTIME = 30\n\
|
|
else if(strcmp(g_row[1],"pbx.nat.config") == 0){
|
|
else if(strcmp(g_row[1],"pbx.nat.config") == 0){
|
|
pJson = cJSON_Parse(g_row[2]);
|
|
pJson = cJSON_Parse(g_row[2]);
|
|
if(pJson && cJSON_GetObjectItem(pJson, "enable")->valueint == 1){
|
|
if(pJson && cJSON_GetObjectItem(pJson, "enable")->valueint == 1){
|
|
- fprintf(conf_sip_nat_fp, "\
|
|
|
|
-externaddr = %s\n\
|
|
|
|
-externhost = %s\n\
|
|
|
|
-externrefresh = %d\n\
|
|
|
|
|
|
+ memset(sip_udp_nat, 0, sizeof(sip_udp_nat));
|
|
|
|
+ memset(sip_tcp_nat, 0, sizeof(sip_tcp_nat));
|
|
|
|
+ memset(sip_tls_nat, 0, sizeof(sip_tls_nat));
|
|
|
|
+ memset(localnet, 0, sizeof(localnet));
|
|
|
|
+ cJSON *localnetArray = cJSON_GetObjectItem( pJson, "localnet");
|
|
|
|
+ if(localnetArray != NULL){
|
|
|
|
+ int array_size = cJSON_GetArraySize (localnetArray);
|
|
|
|
+ for(int n = 0; n < array_size; n++){
|
|
|
|
+ pSub = cJSON_GetArrayItem(localnetArray, n);
|
|
|
|
+ if(NULL == pSub ){ continue ; }
|
|
|
|
+ sprintf(localnet, "\
|
|
|
|
+local_net = %s\n\
|
|
|
|
+",\
|
|
|
|
+pSub->valuestring\
|
|
|
|
+);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ sprintf(sip_udp_nat, "\
|
|
|
|
+external_media_address = %s\n\
|
|
|
|
+external_signaling_address = %s\n\
|
|
|
|
+%s\n\
|
|
",\
|
|
",\
|
|
cJSON_GetObjectItem(pJson, "externaddr")->valuestring,\
|
|
cJSON_GetObjectItem(pJson, "externaddr")->valuestring,\
|
|
cJSON_GetObjectItem(pJson, "externhost")->valuestring,\
|
|
cJSON_GetObjectItem(pJson, "externhost")->valuestring,\
|
|
-cJSON_GetObjectItem(pJson, "externrefresh")->valueint\
|
|
|
|
|
|
+localnet\
|
|
);
|
|
);
|
|
if(cJSON_GetObjectItem(pJson, "externtcpport") && cJSON_GetObjectItem(pJson, "externtcpport")->valueint != 0)
|
|
if(cJSON_GetObjectItem(pJson, "externtcpport") && cJSON_GetObjectItem(pJson, "externtcpport")->valueint != 0)
|
|
{
|
|
{
|
|
- fprintf(conf_sip_nat_fp, "\
|
|
|
|
-externtcpport = %d\n\
|
|
|
|
|
|
+ sprintf(sip_tcp_nat, "\
|
|
|
|
+external_media_address = %s\n\
|
|
|
|
+external_signaling_address = %s\n\
|
|
|
|
+external_signaling_port = %d\n\
|
|
|
|
+%s\n\
|
|
",\
|
|
",\
|
|
-cJSON_GetObjectItem(pJson, "externtcpport")->valueint\
|
|
|
|
|
|
+cJSON_GetObjectItem(pJson, "externaddr")->valuestring,\
|
|
|
|
+cJSON_GetObjectItem(pJson, "externhost")->valuestring,\
|
|
|
|
+cJSON_GetObjectItem(pJson, "externtcpport")->valueint,\
|
|
|
|
+localnet\
|
|
);
|
|
);
|
|
}
|
|
}
|
|
if(cJSON_GetObjectItem(pJson, "externtlsport") && cJSON_GetObjectItem(pJson, "externtlsport")->valueint != 0)
|
|
if(cJSON_GetObjectItem(pJson, "externtlsport") && cJSON_GetObjectItem(pJson, "externtlsport")->valueint != 0)
|
|
{
|
|
{
|
|
- fprintf(conf_sip_nat_fp, "\
|
|
|
|
-externtlsport = %d\n\
|
|
|
|
|
|
+ sprintf(sip_tls_nat, "\
|
|
|
|
+external_media_address = %s\n\
|
|
|
|
+external_signaling_address = %s\n\
|
|
|
|
+external_signaling_port = %d\n\
|
|
|
|
+%s\n\
|
|
",\
|
|
",\
|
|
-cJSON_GetObjectItem(pJson, "externtlsport")->valueint\
|
|
|
|
-);
|
|
|
|
- }
|
|
|
|
- cJSON *localnetArray = cJSON_GetObjectItem( pJson, "localnet");
|
|
|
|
- if(localnetArray != NULL){
|
|
|
|
- int array_size = cJSON_GetArraySize (localnetArray);
|
|
|
|
- for(int n = 0; n < array_size; n++){
|
|
|
|
- pSub = cJSON_GetArrayItem(localnetArray, n);
|
|
|
|
- if(NULL == pSub ){ continue ; }
|
|
|
|
- fprintf(conf_sip_nat_fp, "\
|
|
|
|
-localnet = %s\n\
|
|
|
|
-",\
|
|
|
|
-pSub->valuestring\
|
|
|
|
|
|
+cJSON_GetObjectItem(pJson, "externaddr")->valuestring,\
|
|
|
|
+cJSON_GetObjectItem(pJson, "externhost")->valuestring,\
|
|
|
|
+cJSON_GetObjectItem(pJson, "externtlsport")->valueint,\
|
|
|
|
+localnet\
|
|
);
|
|
);
|
|
- }
|
|
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -786,8 +594,8 @@ PAGING_AUTO = yes\n\
|
|
else if(strcmp(g_row[1],"paging.calltrigger.config") == 0){
|
|
else if(strcmp(g_row[1],"paging.calltrigger.config") == 0){
|
|
pJson = cJSON_Parse(g_row[2]);
|
|
pJson = cJSON_Parse(g_row[2]);
|
|
fprintf(conf_calltrigger_fp, "\
|
|
fprintf(conf_calltrigger_fp, "\
|
|
-exten => _%s.,1,Macro(calltrigger,${EXTEN})\n\
|
|
|
|
-exten => _%s.,1,Macro(calltrigger,${EXTEN})\n\
|
|
|
|
|
|
+exten => _%s.,1,Gosub(calltrigger,s,1(${EXTEN}))\n\
|
|
|
|
+exten => _%s.,1,Gusub(calltrigger,s,1(${EXTEN}))\n\
|
|
",\
|
|
",\
|
|
cJSON_GetObjectItem(pJson, "start")->valuestring,\
|
|
cJSON_GetObjectItem(pJson, "start")->valuestring,\
|
|
cJSON_GetObjectItem(pJson, "stop")->valuestring\
|
|
cJSON_GetObjectItem(pJson, "stop")->valuestring\
|
|
@@ -797,26 +605,66 @@ cJSON_GetObjectItem(pJson, "stop")->valuestring\
|
|
pJson = cJSON_Parse(g_row[2]);
|
|
pJson = cJSON_Parse(g_row[2]);
|
|
if(cJSON_GetObjectItem(pJson, "udp"))
|
|
if(cJSON_GetObjectItem(pJson, "udp"))
|
|
{
|
|
{
|
|
- fprintf(conf_sipsetting_fp, "udpbindaddr = 0.0.0.0:%d\n",cJSON_GetObjectItem(pJson, "udp")->valueint);
|
|
|
|
|
|
+ fprintf(conf_sipsetting_fp, "\
|
|
|
|
+[transport-udp]\n\
|
|
|
|
+type=transport\n\
|
|
|
|
+protocol=udp\n\
|
|
|
|
+bind=0.0.0.0:%d\n\
|
|
|
|
+tos=CS3\n\
|
|
|
|
+cos=3\n\
|
|
|
|
+allow_reload=no\n\
|
|
|
|
+",cJSON_GetObjectItem(pJson, "udp")->valueint\
|
|
|
|
+);
|
|
|
|
+ if(sip_udp_nat)
|
|
|
|
+ {
|
|
|
|
+ fprintf(conf_sipsetting_fp, "%s", sip_udp_nat);
|
|
|
|
+ }
|
|
}
|
|
}
|
|
pSub = cJSON_GetObjectItem(pJson, "tcp");
|
|
pSub = cJSON_GetObjectItem(pJson, "tcp");
|
|
if(pSub && cJSON_GetObjectItem(pSub, "enable")->valueint == 1){
|
|
if(pSub && cJSON_GetObjectItem(pSub, "enable")->valueint == 1){
|
|
fprintf(conf_sipsetting_fp, "\
|
|
fprintf(conf_sipsetting_fp, "\
|
|
-tcpenable = yes\n\
|
|
|
|
-tcpbindaddr = 0.0.0.0:%d\n\
|
|
|
|
-",\
|
|
|
|
-cJSON_GetObjectItem(pSub, "port")->valueint\
|
|
|
|
|
|
+[transport-tcp]\n\
|
|
|
|
+type=transport\n\
|
|
|
|
+protocol=tcp\n\
|
|
|
|
+bind=0.0.0.0:%d\n\
|
|
|
|
+tos=CS3\n\
|
|
|
|
+cos=3\n\
|
|
|
|
+allow_reload=no\n\
|
|
|
|
+",cJSON_GetObjectItem(pSub, "port")->valueint\
|
|
);
|
|
);
|
|
|
|
+ if(sip_tcp_nat)
|
|
|
|
+ {
|
|
|
|
+ fprintf(conf_sipsetting_fp, "%s", sip_tcp_nat);
|
|
|
|
+ }
|
|
}
|
|
}
|
|
pSub = cJSON_GetObjectItem(pJson, "tls");
|
|
pSub = cJSON_GetObjectItem(pJson, "tls");
|
|
if(pSub && cJSON_GetObjectItem(pSub, "enable")->valueint == 1){
|
|
if(pSub && cJSON_GetObjectItem(pSub, "enable")->valueint == 1){
|
|
fprintf(conf_sipsetting_fp, "\
|
|
fprintf(conf_sipsetting_fp, "\
|
|
-tlsenable = yes\n\
|
|
|
|
-tlsbindaddr = 0.0.0.0:%d\n\
|
|
|
|
-",\
|
|
|
|
-cJSON_GetObjectItem(pSub, "port")->valueint\
|
|
|
|
|
|
+[transport-tls]\n\
|
|
|
|
+type=transport\n\
|
|
|
|
+protocol=tls\n\
|
|
|
|
+bind=0.0.0.0:%d\n\
|
|
|
|
+cert_file=/etc/asterisk/keys/asterisk.pem\n\
|
|
|
|
+ca_list_file=/etc/asterisk/keys/ca.crt\n\
|
|
|
|
+priv_key_file=/etc/asterisk/keys/asterisk.pem\n\
|
|
|
|
+method=tlsv1_3\n\
|
|
|
|
+tos=CS3\n\
|
|
|
|
+cos=3\n\
|
|
|
|
+allow_reload=no\n\
|
|
|
|
+",cJSON_GetObjectItem(pSub, "port")->valueint\
|
|
);
|
|
);
|
|
|
|
+ if(sip_tls_nat)
|
|
|
|
+ {
|
|
|
|
+ fprintf(conf_sipsetting_fp, "%s", sip_tls_nat);
|
|
|
|
+ }
|
|
}
|
|
}
|
|
|
|
+ fprintf(conf_sipsetting_fp, "\
|
|
|
|
+[transport-wss]\n\
|
|
|
|
+type=transport\n\
|
|
|
|
+protocol=wss\n\
|
|
|
|
+bind=0.0.0.0\n\
|
|
|
|
+allow_reload=no\n\
|
|
|
|
+");
|
|
pSub = cJSON_GetObjectItem(pJson, "rtp");
|
|
pSub = cJSON_GetObjectItem(pJson, "rtp");
|
|
if(pSub){
|
|
if(pSub){
|
|
fprintf(conf_rtpsetting_fp, "\
|
|
fprintf(conf_rtpsetting_fp, "\
|
|
@@ -832,23 +680,23 @@ cJSON_GetObjectItem(pSub, "end_port")->valueint\
|
|
pJson = cJSON_Parse(g_row[2]);
|
|
pJson = cJSON_Parse(g_row[2]);
|
|
pSub = cJSON_GetObjectItem(pJson, "bargein");
|
|
pSub = cJSON_GetObjectItem(pJson, "bargein");
|
|
if(cJSON_GetObjectItem(pSub, "enable")->valueint == 1){
|
|
if(cJSON_GetObjectItem(pSub, "enable")->valueint == 1){
|
|
- fprintf(conf_featurecodes_fp, "exten = _%s.,1,Macro(spy-barge,${EXTEN:%ld},${CALLERID(num)})\n",cJSON_GetObjectItem(pSub, "code")->valuestring,strlen(cJSON_GetObjectItem(pSub, "code")->valuestring));
|
|
|
|
|
|
+ fprintf(conf_featurecodes_fp, "exten = _%s.,1,Gosub(spy-barge,s,1(${EXTEN:%ld},${CALLERID(num)}))\n",cJSON_GetObjectItem(pSub, "code")->valuestring,strlen(cJSON_GetObjectItem(pSub, "code")->valuestring));
|
|
}
|
|
}
|
|
pSub = cJSON_GetObjectItem(pJson, "clear");
|
|
pSub = cJSON_GetObjectItem(pJson, "clear");
|
|
if(cJSON_GetObjectItem(pSub, "enable")->valueint == 1){
|
|
if(cJSON_GetObjectItem(pSub, "enable")->valueint == 1){
|
|
- fprintf(conf_featurecodes_fp, "exten = _%s.,1,Macro(exten-clear,${EXTEN:%ld},${CALLERID(num)})\n",cJSON_GetObjectItem(pSub, "code")->valuestring,strlen(cJSON_GetObjectItem(pSub, "code")->valuestring));
|
|
|
|
|
|
+ fprintf(conf_featurecodes_fp, "exten = _%s.,1,Gosub(exten-clear,s,1(${EXTEN:%ld},${CALLERID(num)}))\n",cJSON_GetObjectItem(pSub, "code")->valuestring,strlen(cJSON_GetObjectItem(pSub, "code")->valuestring));
|
|
}
|
|
}
|
|
pSub = cJSON_GetObjectItem(pJson, "syp");
|
|
pSub = cJSON_GetObjectItem(pJson, "syp");
|
|
if(cJSON_GetObjectItem(pSub, "enable")->valueint == 1){
|
|
if(cJSON_GetObjectItem(pSub, "enable")->valueint == 1){
|
|
- fprintf(conf_featurecodes_fp, "exten = _%s.,1,Macro(spy-normal,${EXTEN:%ld},${CALLERID(num)})\n",cJSON_GetObjectItem(pSub, "code")->valuestring,strlen(cJSON_GetObjectItem(pSub, "code")->valuestring));
|
|
|
|
|
|
+ fprintf(conf_featurecodes_fp, "exten = _%s.,1,Gosub(spy-normal,s,1(${EXTEN:%ld},${CALLERID(num)}))\n",cJSON_GetObjectItem(pSub, "code")->valuestring,strlen(cJSON_GetObjectItem(pSub, "code")->valuestring));
|
|
}
|
|
}
|
|
pSub = cJSON_GetObjectItem(pJson, "whisper");
|
|
pSub = cJSON_GetObjectItem(pJson, "whisper");
|
|
if(cJSON_GetObjectItem(pSub, "enable")->valueint == 1){
|
|
if(cJSON_GetObjectItem(pSub, "enable")->valueint == 1){
|
|
- fprintf(conf_featurecodes_fp, "exten = _%s.,1,Macro(spy-whisper,${EXTEN:%ld},${CALLERID(num)})\n",cJSON_GetObjectItem(pSub, "code")->valuestring,strlen(cJSON_GetObjectItem(pSub, "code")->valuestring));
|
|
|
|
|
|
+ fprintf(conf_featurecodes_fp, "exten = _%s.,1,Gosub(spy-whisper,s,1(${EXTEN:%ld},${CALLERID(num)}))\n",cJSON_GetObjectItem(pSub, "code")->valuestring,strlen(cJSON_GetObjectItem(pSub, "code")->valuestring));
|
|
}
|
|
}
|
|
pSub = cJSON_GetObjectItem(pJson, "wakeup");
|
|
pSub = cJSON_GetObjectItem(pJson, "wakeup");
|
|
if(cJSON_GetObjectItem(pSub, "enable")->valueint == 1){
|
|
if(cJSON_GetObjectItem(pSub, "enable")->valueint == 1){
|
|
- fprintf(conf_featurecodes_fp, "exten = %s,1,Macro(wakeup-call,${CALLERID(num)})\n",cJSON_GetObjectItem(pSub, "code")->valuestring);
|
|
|
|
|
|
+ fprintf(conf_featurecodes_fp, "exten = %s,1,Gosub(wakeup-call,s,1(${CALLERID(num)}))\n",cJSON_GetObjectItem(pSub, "code")->valuestring);
|
|
}
|
|
}
|
|
pSub = cJSON_GetObjectItem(pJson, "dnd");
|
|
pSub = cJSON_GetObjectItem(pJson, "dnd");
|
|
if(cJSON_GetObjectItem(pSub, "enable")->valueint == 1){
|
|
if(cJSON_GetObjectItem(pSub, "enable")->valueint == 1){
|
|
@@ -879,7 +727,6 @@ fclose(conf_inbound_fp);
|
|
fclose(conf_global_fp);
|
|
fclose(conf_global_fp);
|
|
fclose(conf_calltrigger_fp);
|
|
fclose(conf_calltrigger_fp);
|
|
fclose(conf_featurecodes_fp);
|
|
fclose(conf_featurecodes_fp);
|
|
-fclose(conf_sip_nat_fp);
|
|
|
|
fclose(conf_sipsetting_fp);
|
|
fclose(conf_sipsetting_fp);
|
|
mysql_free_result(g_res); // 释放结果集
|
|
mysql_free_result(g_res); // 释放结果集
|
|
mysql_close(g_conn); // 关闭链接
|
|
mysql_close(g_conn); // 关闭链接
|