怎么做网站服务器系统/营销最好的方法
Kamailio:调用set_contact_alias()之后,在原有的contact的后面增加参数,具体地说,就是网络地址,网络端口和transport,好处是收到后续请求之时可以恢复原有contact的内容(当然也有坏处,就是增加参数之后导致包大,可能超过MTU)
OpenSIPS:调用fix_nated_contact()之后,用网络地址和网络端口直接覆盖了在原有的contact,那么当收到后续请求时不太可能恢复原有contact的内容。窃以为,一定要慎重
比如,下图所示,OpenSIPS就不要修改uac的contact,显然如此
UAC--->第三方Proxy--->OpenSIPS--->FreeSWITCH
参考链接:
https://kb.smartvox.co.uk/opensips/nat-contact-and-via-fixing-in-sip-part-3/
当然,我们可以模仿set_contact_alias函数
route[set_contact_alias] {if (is_present_hf("contact")) {$var(sut) = $si + "~" + $sp + "~" + $socket_in(proto); # 远端网络地址$var(ct) = $(ct{re.subst,/^(.*)<(.*)>/\2/}); # 取contact <> 里面的内容# 更换成新的contact$var(new_ct) = "<" + $var(ct) + ";my_alias=" + $var(sut) + ">";remove_hf("contact");insert_hf("Contact: $var(new_ct)\r\n", "Call-ID");}
}route[restore_contact_by_alias] {if (!has_totag()) { # 对话内请求才能调用这个路由return;}# xlog("***ru = $ru, du = $du\n");if ($du != NULL) { # 如果已经设置了$du,那么不能再调用这个路由return;}$var(my_alias) = $(ru{nameaddr.param,my_alias});# xlog("***my_alias = $var(my_alias)\n");if ($var(my_alias) != NULL) {$var(ip) = $(var(my_alias){s.select,0,~});$var(port) = $(var(my_alias){s.select,1,~});$var(transport) = $(var(my_alias){s.select,2,~});$var(url) = "sip:" + $var(ip) + ":" + $var(port) + ";transport=" + $var(transport);# xlog("url = $var(url)\n");setdsturi($var(url));$ru = $(ru{re.subst,/^(sip:.*);my_alias=.*/\1/}); # 删除ru里面的my_alias以及内容 }
}
完整的路由脚本如下:
####### Global Parameters #########/* uncomment the following lines to enable debugging */
#debug_mode=yeslog_level=3
xlog_level=3
stderror_enabled=no
syslog_enabled=yes
syslog_facility=LOG_LOCAL0udp_workers=4/* uncomment the next line to enable the auto temporary blacklisting ofnot available destinations (default disabled) */
#disable_dns_blacklist=no/* uncomment the next line to enable IPv6 lookup after IPv4 dnslookup failures (default disabled) */
#dns_try_ipv6=yessocket=udp:172.20.10.6:5060 # CUSTOMIZE ME
socket=tcp:172.20.10.6:5060 # CUSTOMIZE ME####### Modules Section #########set module path
mpath="/usr/lib/x86_64-linux-gnu/opensips/modules/"#### SIGNALING module
loadmodule "signaling.so"#### StateLess module
loadmodule "sl.so"#### Transaction Module
loadmodule "tm.so"
modparam("tm", "fr_timeout", 5)
modparam("tm", "fr_inv_timeout", 30)
modparam("tm", "restart_fr_on_each_reply", 0)
modparam("tm", "onreply_avp_mode", 1)#### Record Route Module
loadmodule "rr.so"
/* do not append from tag to the RR (no need for this script) */
modparam("rr", "append_fromtag", 0)#### MAX ForWarD module
loadmodule "maxfwd.so"#### SIP MSG OPerationS module
loadmodule "sipmsgops.so"#### FIFO Management Interface
loadmodule "mi_fifo.so"
modparam("mi_fifo", "fifo_name", "/tmp/opensips_fifo")
modparam("mi_fifo", "fifo_mode", 0666)#### MYSQL module
loadmodule "db_mysql.so"#### HTTPD module
loadmodule "httpd.so"
modparam("httpd", "port", 8888)#### USeR LOCation module
loadmodule "usrloc.so"
modparam("usrloc", "nat_bflag", "NAT")
modparam("usrloc", "working_mode_preset", "single-instance-sql-write-back")
modparam("usrloc", "db_url","mysql://opensips:opensipsrw@localhost/opensips") # CUSTOMIZE ME#### REGISTRAR module
loadmodule "registrar.so"
modparam("registrar", "tcp_persistent_flag", "TCP_PERSISTENT")
modparam("registrar", "received_avp", "$avp(received_nh)")/* uncomment the next line not to allow more than 10 contacts per AOR */
#modparam("registrar", "max_contacts", 10)#### ACCounting module
loadmodule "acc.so"
/* what special events should be accounted ? */
modparam("acc", "early_media", 0)
modparam("acc", "report_cancels", 0)
/* by default we do not adjust the direct of the sequential requests.if you enable this parameter, be sure to enable "append_fromtag"in "rr" module */
modparam("acc", "detect_direction", 0)#### NAT modules
loadmodule "nathelper.so"
modparam("nathelper", "natping_interval", 10)
modparam("nathelper", "ping_nated_only", 1)
modparam("nathelper", "sipping_bflag", "SIP_PING_FLAG")
modparam("nathelper", "sipping_from", "sip:pinger@127.0.0.1") #CUSTOMIZE ME
modparam("nathelper", "received_avp", "$avp(received_nh)")# loadmodule "rtpproxy.so"
# modparam("rtpproxy", "rtpproxy_sock", "udp:localhost:12221") # CUSTOMIZE ME#### MI_HTTP module
loadmodule "mi_http.so"loadmodule "proto_udp.so"
loadmodule "proto_tcp.so"
####### Routing Logic ######### main request routing logicroute{xlog("$rm|$fU|$tU|$ci from $si:$sp\n");# initial NAT handling; detect if the request comes from behind a NAT# and apply contact fixingforce_rport();#if (nat_uac_test(23)) {if (true) {if (is_method("REGISTER")) {fix_nated_register();setbflag("NAT");} else {# fix_nated_contact();route(set_contact_alias);setflag("NAT");}}if (!mf_process_maxfwd_header(10)) {send_reply(483,"Too Many Hops");exit;}if (has_totag()) {# handle hop-by-hop ACK (no routing required)if ( is_method("ACK") && t_check_trans() ) {t_relay();exit;}# sequential request within a dialog should# take the path determined by record-routingif ( !loose_route() ) {# we do record-routing for all our traffic, so we should not# receive any sequential requests without Route hdr.send_reply(404,"Not here");exit;}route(restore_contact_by_alias);if (is_method("BYE")) {# do accounting even if the transaction failsdo_accounting("log","failed");}if (check_route_param("nat=yes"))setflag("NAT");# route it out to whatever destination was set by loose_route()# in $du (destination URI).route(relay);exit;}# CANCEL processingif (is_method("CANCEL")) {if (t_check_trans())t_relay();exit;}# absorb retransmissions, but do not create transactiont_check_trans();if ( !(is_method("REGISTER") ) ) {if (is_myself("$fd")) {} else {# if caller is not local, then called number must be localif (!is_myself("$rd")) {send_reply(403,"Relay Forbidden");exit;}}}# preloaded route checkingif (loose_route()) {xlog("L_ERR","Attempt to route with preloaded Route's [$fu/$tu/$ru/$ci]");if (!is_method("ACK"))send_reply(403,"Preload Route denied");exit;}# record routingif (!is_method("REGISTER|MESSAGE"))record_route();# account only INVITEsif (is_method("INVITE")) {do_accounting("log");}if (!is_myself("$rd")) {append_hf("P-hint: outbound\r\n");route(relay);}# requests for my domainif (is_method("PUBLISH|SUBSCRIBE")) {send_reply(503, "Service Unavailable");exit;}if (is_method("REGISTER")) {if ($socket_in(proto) == "tcp")setflag("TCP_PERSISTENT");if (isflagset("NAT")) {setbflag("SIP_PING_FLAG");}# store the registration and generate a SIP replyif (!save("location"))xlog("failed to register AoR $tu\n");exit;}if ($rU==NULL) {# request with no Username in RURIsend_reply(484,"Address Incomplete");exit;}# do lookup with method filteringif (!lookup("location", "method-filtering")) {t_reply(404, "Not Found");exit;}if (isbflagset("NAT")) setflag("NAT");# when routing via usrloc, log the missed calls alsodo_accounting("log","missed");route(relay);
}route[relay] {# for INVITEs enable some additional helper routesif (is_method("INVITE")) {# if (isflagset("NAT") && has_body("application/sdp")) {# rtpproxy_offer("ro");# }t_on_branch("per_branch_ops");t_on_reply("handle_nat");t_on_failure("missed_call");}if (isflagset("NAT")) {add_rr_param(";nat=yes");}if (!t_relay()) {send_reply(500,"Internal Error");}exit;
}branch_route[per_branch_ops] {xlog("new branch at $ru\n");
}onreply_route[handle_nat] {#if (nat_uac_test(1))# fix_nated_contact();route(set_contact_alias);# if ( isflagset("NAT") && has_body("application/sdp") )# rtpproxy_answer("ro");xlog("incoming reply\n");
}failure_route[missed_call] {if (t_was_cancelled()) {exit;}# uncomment the following lines if you want to block client# redirect based on 3xx replies.##if (t_check_status("3[0-9][0-9]")) {##t_reply(404,"Not found");## exit;##}
}route[set_contact_alias] {if (is_present_hf("contact")) {$var(sut) = $si + "~" + $sp + "~" + $socket_in(proto); # 远端网络地址$var(ct) = $(ct{re.subst,/^(.*)<(.*)>/\2/}); # 取contact <> 里面的内容# 更换成新的contact$var(new_ct) = "<" + $var(ct) + ";my_alias=" + $var(sut) + ">";remove_hf("contact");insert_hf("Contact: $var(new_ct)\r\n", "Call-ID");}
}route[restore_contact_by_alias] {if (!has_totag()) { # 对话内请求才能调用这个路由return;}# xlog("***ru = $ru, du = $du\n");if ($du != NULL) { # 如果已经设置了$du,那么不能再调用这个路由return;}$var(my_alias) = $(ru{nameaddr.param,my_alias});# xlog("***my_alias = $var(my_alias)\n");if ($var(my_alias) != NULL) {$var(ip) = $(var(my_alias){s.select,0,~});$var(port) = $(var(my_alias){s.select,1,~});$var(transport) = $(var(my_alias){s.select,2,~});$var(url) = "sip:" + $var(ip) + ":" + $var(port) + ";transport=" + $var(transport);# xlog("url = $var(url)\n");setdsturi($var(url));$ru = $(ru{re.subst,/^(sip:.*);my_alias=.*/\1/}); # 删除ru里面的my_alias以及内容 }
}
以上脚本在OpenSIPS3.4.3上调试通过,但没测试其他版本
于2024年2月8日(次日即除夕)
全文完
相关文章:

比较Kamailio和OpenSIPS的重写contact函数
Kamailio:调用set_contact_alias()之后,在原有的contact的后面增加参数,具体地说,就是网络地址,网络端口和transport,好处是收到后续请求之时可以恢复原有contact的内容(当然也有坏处࿰…...

【ETOJ P1046】斐波那契数列 题解(数学+动态规划)
题目描述 给定一个整数 T T T,表示样例数。 对于每个样例,给定一个整数 n n n,求斐波那契数列的第 n n n 项。 斐波那契数列定义为 f ( 1 ) f ( 2 ) 1 f(1) f(2) 1 f(1)f(2)1, f ( n ) f ( n − 1 ) f ( n − 2 ) f(…...

编码技巧——基于RedisTemplate的RedisClient实现、操作Lua脚本
1. 背景 在新公司的脚手架中开发,需要用到redis,发现没有封装好一套能集成各种常用命令、包括Lua脚本的方便使用的RedisTemplateClient,于是自己来实现下; springboot整合redis之后,提供了操作redis的简便方式&#…...

Asp .Net Core 系列:Asp .Net Core 集成 Panda.DynamicWebApi
文章目录 简介Asp .Net Core 集成 Panda.DynamicWebApi配置原理什么是POCO Controller?POCO控制器原理ControllerFeatureProvider实现自定义判断规则IApplicationModelConventionPanda.DynamicWebApi中的实现ConfigureApiExplorer()ConfigureSelector()ConfigurePar…...

【PTA浙大版《C语言程序设计(第4版)》|编程题】习题7-3 判断上三角矩阵(附测试点)
目录 输入格式: 输出格式: 输入样例: 输出样例: 代码呈现 测试点 上三角矩阵指主对角线以下的元素都为0的矩阵;主对角线为从矩阵的左上角至右下角的连线。 本题要求编写程序,判断一个给定的方阵是否…...

JVM 性能调优 - 参数调优(3)
查看 JVM 内存的占用情况 编写代码 package com.test;public class PrintMemoryDemo {public static void main(String[] args) {// 堆内存总量long totalMemory Runtime.getRuntime().totalMemory();// jvm 试图使用的最大堆内存long maxMemory Runtime.getRuntime().maxM…...

Django(十)
1. Ajax请求 浏览器向网站发送请求时:URL 和 表单的形式提交。 GETPOST 特点:页面刷新。 除此之外,也可以基于Ajax向后台发送请求(偷偷的发送请求)。 依赖jQuery编写ajax代码 $.ajax({url:"发送的地址"…...

OpenHarmony开源鸿蒙开发之旅
文章目录 一、op系统架构二、op系统构建1. op源代码目录2. op系统构建3. op开发环境搭建 三、op系统的子系统四、op系统芯片移植五、op系统启动流程六、op系统组件七、驱动框架 一、op系统架构 二、op系统构建 1. op源代码目录 2. op系统构建 3. op开发环境搭建 三、op系统…...

SpringBoot之整合PageHelper分页插件
SpringBoot之整合PageHelper分页插件 文章目录 SpringBoot之整合PageHelper分页插件1. 引入坐标2. application.yml配置3. 基本使用4. 对多个查询执行分页1. 默认第一个Select语句会执行分页2. 让Pagehelper也能执行多个分页的方法3. 完整案例 详细配置请查看官网或MyBatis分页…...

Android java基础_类的封装
一.面向对象编程的引入 写一个简单的程序输出张三,李四的名字 class Person {String name;String getName() {return "guangdong "name;} };public class Oop {public static void main(String args[]) {Person p1 new Person();p1.name "zhangs…...

Vue-57、Vue技术路由的参数如何传递
query参数传递 1、传递参数 <!-- 跳转路由并携带query参数,to的字符串写法--> <router-link :to"/home/message/detail?id${p.id}&title${p.title}"> {{p.title}} </router-link><!-- 跳转路由…...

《MySQL 简易速速上手小册》第1章:MySQL 基础和安装(2024 最新版)
文章目录 1.1 MySQL 概览:版本、特性和生态系统1.1.1 基础知识1.1.2 重点案例:使用 Python 实现 MySQL 数据的 CRUD 操作1.1.3 拓展案例 1:使用 Python 实现 MySQL 数据备份**1.1.4 拓展案例 2:使用 Python 分析 MySQL 数据 1.2 安…...

Linux 软件管理(YUM RPM)
1 YUM yum(全称为 Yellow dog Updater, Modified)是一个在Fedora和RedHat以及CentOS中的Shell前端软件包管理器。基于RPM包管理,能够从指定的服务器自动处理依赖性关系,并且一次安装所有依赖的软件包,无须繁琐地一次次…...

【Makefile语法 05】动静态库编译链接
目录 一、多文件项目源代码 二、静态库编译链接 三、动态库编译链接 一、多文件项目源代码 // include/add.hpp#pragma once int add(int a, int b); // include/sub.hpp#pragma once int sub(int a, int b); // src/add.cpp#include "add.hpp"int add(int a, …...

JS - 处理元素滚动
业务功能中时常有元素滚动的功能,现在就总结一下一些常用的事件。 一、定位滚动元素 做一切滚动操作之前都应该先定位到滚动元素,再做其他操作,如滚动顶部,获取滚动距离、禁止滚动等。 把以下代码复制粘贴到浏览器 Console 面板…...

JavaScript滚动事件
🧑🎓 个人主页:《爱蹦跶的大A阿》 🔥当前正在更新专栏:《VUE》 、《JavaScript保姆级教程》、《krpano》、《krpano中文文档》 ✨ 前言 滚动是网页交互不可或缺的一部分。监听页面和元素的滚动事件,可以帮助…...

4.0 Zookeeper Java 客户端搭建
本教程使用的 IDE 为 IntelliJ IDEA,创建一个 maven 工程,命名为 zookeeper-demo,并且引入如下依赖,可以自行在maven中央仓库选择合适的版本,介绍原生 API 和 Curator 两种方式。 IntelliJ IDEA 相关介绍:…...

C#既然数组长度不可改变,那么如何动态调整集合类型数组大小,以便添加或删除元素?
目录 1.使用动态数组(ArrayList): 2.使用 jagged array(不规则数组): 3.使用 List : 4.使用数组复制: 在C#中,数组的长度是固定的,一旦声明和初始化&…...

3.1 Verilog 连续赋值
关键词:assign, 全加器 连续赋值语句是 Verilog 数据流建模的基本语句,用于对 wire 型变量进行赋值。: 格式如下 assign LHS_target RHS_expression ; LHS(left hand side) 指赋值操作…...

【http】2、http request header Origin 属性、跨域 CORS、同源、nginx 反向代理、预检请求
文章目录 一、Origin 含义二、跨源资源共享:**Cross-Origin Resource Sharing** CORS2.1 跨域的定义2.2 功能概述2.3 场景示例2.3.1 简单请求2.3.2 Preflighted requests:预检请求 2.4 header2.4.1 http request header2.4.1.1 Origin2.4.1.2 Access-Con…...

LangChain pdf的读取以及向量数据库的使用
以下使用了3399.pdf, Rockchip RK3399 TRM Part1 import ChatGLM from langchain.chains import LLMChain from langchain_core.output_parsers import StrOutputParser from langchain_core.prompts import ChatPromptTemplate from langchain.chains import Simp…...

VUE学习——事件修饰符
阻止默认事件 <template><a click"onClickHandle" href"https://www.baidu.com">baidu</a><a click.prevent"onClickHandle" href"https://www.baidu.com">baidu</a> </template> <script>…...

开放平台技术架构设计与实现的实战总结
开放平台是企业向外部开发者提供API接口和服务的平台,促进生态系统的建设和业务拓展。本文将介绍开放平台技术架构的设计原则和实现方法,帮助读者了解如何构建一个稳健、安全且易于扩展的开放平台。 1. 什么是开放平台? - 解释了开放平台…...

飞桨自然语言处理框架 paddlenlp的 trainer
飞桨(PaddlePaddle)的NLP库PaddleNLP中的Trainer类是一个用于训练和评估模型的简单但功能完整的循环。它被优化用于与PaddleNLP一起使用。Trainer类简化了训练过程,提供了自动的批处理、模型保存、日志记录等特性。 以下是Trainer类的主要参数…...

SQL世界之命令语句Ⅲ
目录 一、SQL JOIN 1.JOIN 和 Key 2.使用 JOIN 3.不同的 SQL JOIN 二、SQL INNER JOIN 关键字 1.SQL INNER JOIN 关键字 2.INNER JOIN 关键字语法 3.内连接(INNER JOIN)实例 三、SQL LEFT JOIN 关键字 1.SQL LEFT JOIN 关键字 2.LEFT JOIN 关…...

Snoop Version 2 Packet Capture File Format
RFC1761 - Snoop Version 2 Packet Capture File Format, FEBRUARY 1995 本备忘录的状态 本备忘录为互联网社区提供帮助信息。 本备忘录不作为任何类型的互联网标准。 本备忘录的分发不受限制。 Status of this Memo This memo provides information for the Internet communit…...

扩展说明: 指令微调 Llama 2
这篇博客是一篇来自 Meta AI,关于指令微调 Llama 2 的扩展说明。旨在聚焦构建指令数据集,有了它,我们则可以使用自己的指令来微调 Llama 2 基础模型。 目标是构建一个能够基于输入内容来生成指令的模型。这么做背后的逻辑是,模型如…...

VUE 全局设置防重复点击
请求后端防止重复点击,用户点击加入遮罩层,请求完毕关闭遮罩层 我们利用请求拦截器,在用户点击的时候,弹出遮罩层 本文采用i18n国际化 element plus UI,提取你想要的,这里不做简化 完整代码如下…...

备战蓝桥杯---动态规划(基础1)
先看几道比较简单的题: 直接f[i][j]f[i-1][j]f[i][j-1]即可(注意有马的地方赋值为0) 下面是递推循环方式实现的AC代码: #include<bits/stdc.h> using namespace std; #define int long long int a[30][30]; int n,m,x,y; …...

CVE-2018-19518 漏洞复现
CVE-2018-19518 漏洞介绍 IMAP协议(因特网消息访问协议)它的主要作用是邮件客户端可以通过这种协议从邮件服务器上获取邮件的信息,下载邮件等。它运行在TCP/IP协议之上,使用的端口是143。在php中调用的是imap_open函数。 PHP 的…...