模块传参的重构

写过opensips脚本的同学,往往对函数的传参感到困惑。 例如: ds_select_dst()可以接受整数或者值为正数的变量作为第一个参数,但是nat_uac_test()的第一个参数就只能是整数,而不能是变量 为什么rl_check()可以接受格式化的字符串,而save()只能接受字符串。 为什么ds_select_dst("1", "4") 作为整数也要加上双引号? 为什么变量要加上双引号? ds_select_dst("$var(aa)", "4") 为什么t_on_branch("1")路由的钩子要加上双引号? 为什么route(go_to_something);这里又不需要加上引号? ds_select_dst("1", "0"); $var(aa)=1; ds_select_dst("$var(aa)", "0"); rl_check("gw_$ru", "$var(limit)"); #格式化的gw_$ru save("location"); #单纯的字符串作为参数 从3.0开始,传参可以更加自然。 整数可以直接传参,不用加双引号 do_something(1, 1); 输入或者输出的$var(), 不用加双引号,加了反而会报错 do_something($var(a), $var(b)); 格式化字符串,需要加双引号 do_something(1, "$var(bb)_$var(b)"); 参考 https://blog.opensips.org/2019/11/05/the-module-function-interface-rework-in-opensips-3-0/ https://www.opensips.org/Documentation/Script-Syntax-3-0#

2022-12-03 21:01:02 · 1 min · Eddie Wang

Pdf学习资料

TelNYX.pdf OpenSIPS 2.3 mediasoup Cutting Edge WebRTC Video COnferencing FreeSWITCH-driven routing in OpenSIPS Voicenter: Contact center on Steroids Vlad_Paiu-Distributed_OpenSIPS_Systems_Cluecon14.pdf Vlad_Paiu-OpenSIPS_Summit_Austin_2015-Async.pdf Ionut_Ionita-OpenSIPS_Summit2017-Capturing_beyond_SIP FLAVIO_GONCALVES-Fraud_in_VoIP_Today.pdf Alexandr_Dubovikov-OpenSIPS_Summit2017-RTC_Threat_Intelligence_Exchange.pdf OpenSIPS_LoadBalancing.pdf Vlad_Paiu-OpenSIPS_Summit_2104-OpenSIPS_End_User_Services.pdf Razvan_Crainea-OpenSIPS_Summit2017-From_SIPI_Trunks_to_End_Users.pdf Razvan_Crainea-OpenSIPS_Summit-Scaling_Asterisk.pdf Vlad_Paiu-OpenSIPS_Summit-Service_Enabling_for_Asterisk.pdf Jonas_Borjesson-OpenSIPS_Summit_Austin_2015.pdf Michele_Pinasi-OpenSIPS_Summit2017-How_we_did_VoIP.pdf Bogdan_Iancu-OpenSIPS_Summit_Keynotes.pdf Giovanni_Maruzselli-OpenSIPS_Summit2017-Scaling_FreeSWITCHes.pdf Maksym_Sobolyev-OpenSIPS_Summit2017-Sippy_Labs_update.pdf docker-cluster.pdf voip malware attack tool .pdf Bogdan_Iancu-OpenSIPS_Summit-OpenSIPS_2_1.pdf Pete_Kelly-OpenSIPS_Workshop_Chicago_2015-Calling_Cards_B2BUA.pdf Bogdan_Iancu-OpenSIPS_Summit-keynotes.pdf Alex_Goulis-Opensips_CNAME.pdf OpenSIPS_2.0_Framework.pdf Norman_Brandinger-OpenSIPS_Summit_2014-Advanced_SIP_Routing_with_OpenSIPS_modules.pdf

2022-12-03 16:02:18 · 1 min · Eddie Wang

西安之旅 不仅有羊肉泡馍 也有长恨歌

一年过半以后,偶然打开微信公众号,看到草稿箱里的篇文章。我才回想起去年带女友去西安的那个遥远的夏天。 如今女友已经变成老婆,这篇文章我才想起来发表。 day 1 钟楼 鼓楼 回民街 那是六月末的时候,和女友一起坐火车去了趟西安。 为什么要去西安呢?据吃货女友说,西安有非常多的好吃的。所以人生是必须要去一趟的。 清晨,我们从南京南站出发坐动车,一路向西,坐了5个多小时,到达西安北站。 路上我带了一个1500ml的水瓶,以及1500ml的酸奶。 女友吐槽说,还好没做飞机,不然我就像宝强一样,要在机场干完一大瓶酸奶了。 下了动车,立即前往钟楼订的宾馆,放置行李。 西安钟楼位于西安市中心,是中国现存钟楼中形制最大、保存最完整的一座。建于明太祖洪武十七年,初建于今广济街口,与鼓楼相对,明神宗万历十年整体迁移于今址。 沿着钟楼附近,我们逛了一圈回民街。 回民街是西安著名的美食文化街区,是西安小吃街区。 西安回民街作为西安风情的代表之一,是回民街区多条街道的统称,由北广济街、北院门、西羊市、大皮院、化觉巷、洒金桥等数条街道组成,在钟鼓楼后。 钟楼 day 2 大唐芙蓉城 大唐不夜城 大雁塔 大唐芙蓉城是一座仿唐建筑,里面有许多景点,或许我们不应该早上来,因为上午太热了。 唯一庆幸的是,我们带了一个很大的水杯,而且芙蓉城里提供免费的开水,所以我们才没有被渴死。 大唐芙蓉城 西游师徒四人 雕塑 傍晚的 大唐不夜城 夜幕降临的 大唐不夜城 遗憾之一:大雁塔没有去看,因为当时正在维修,周围全是脚手架。 遗憾之二:没有到陕西历史博物馆看看,因为没有早点预约 女友埋怨我说我不早点做攻略,害得这么多景点去不了。 我说我是做了攻略的,还记在备忘录里面呢。 女友打开我的备忘录一看,笑出眼泪说:你做的啥狗屁攻略,就这几个字!男人果然靠不住! 我说: 这你就不懂了吧,啥都写清楚,一个一个点打卡多没意思。 day3 华清宫 兵马俑 长恨歌 由于西安攻略做的太过肤浅,所以第二天晚上决定直接跟团。在网上买了两张华清宫兵马俑和长恨歌的一日游。 说实在的,华清宫没啥意思,都是洗澡池子。 蒋介石洗过澡的池子,杨贵妃的洗澡池子,唐明皇的洗澡池子,大臣们的洗澡池子。 逛完之后,下午我们坐着旅游大巴,前往兵马俑。 一号坑 一号坑 一号坑 一号坑 一号坑 兵马俑有三个坑。 一号坑最大,兵马俑也是最多的。然而当时游客比肩接踵,加上天气炎热,大家都在里面像蒸桑拿一样。 出了一号坑,我心里想:这么大个坑,这么热为啥不装空调,难道是因为要保护文物吗? 后来据博物馆的讲解员介绍:不装空调是因为审核手续复杂,可能要要个几十年手续才能完成。像二号坑和三号坑都已经装好空调了。 二号坑真的是个坑,没有兵马俑,仅仅是个大坑。 ...

2022-12-02 20:38:46 · 1 min · Eddie Wang

1.1 脚本结构 - 全局参数、模块配置、路由

1. Structure The structure of the kamailio.cfg can be seen as three parts: global parameters modules settings routing blocks For clarity and making it easy to maintain, it is recommended to keep them in this order, although some of them can be mixed. ✅ 这三个部分可以混合,但为了清晰和维护的方便,建议按照这个顺序排列。 2. Global Parameters Section This is the first part of the configuration file, containing the parameters for the core of kamailio and custom global parameters. ...

2 min · Eddie Wang

1.10 SCTP参数

1. disable_sctp Global parameter to disable SCTP support in the SIP server. see enable_sctp Default value is ‘auto’. Example of usage: disable_sctp=yes 2. enable_sctp enable_sctp = 0/1/2 - SCTP disabled (0)/ SCTP enabled (1)/auto (2), default auto (2) 3. sctp_children sctp children no (similar to udp children) sctp_children = number 4. sctp_socket_rcvbuf Size for the sctp socket receive buffer Alias name: sctp_socket_receive_buffer sctp_socket_rcvbuf = number 5. sctp_socket_sndbuf Size for the sctp socket send buffer ...

6 min · Eddie Wang

1.11 UDP参数

1. udp4_raw Enables raw socket support for sending UDP IPv4 datagrams (40-50% performance increase on linux multi-cpu). Possible values: 0 - disabled (default), 1 - enabled, -1 auto. In “auto” mode it will be enabled if possible (sr started as root or with CAP_NET_RAW). udp4_raw can be used on Linux and FreeBSD. For other BSDs and Darwin one must compile with -DUSE_RAW_SOCKS. On Linux one should also set udp4_raw_mtu if the MTU on any network interface that could be used for sending is smaller than 1500. ...

2 min · Eddie Wang

1.12 黑名单参数

1. dst_blocklist_expire Alias name: dst_blocklist_ttl How much time a blocklisted destination will be kept in the blocklist (w/o any update). dst_blocklist_expire = time in s (default 60 s) 2. dst_blocklist_gc_interval How often the garbage collection will run (eliminating old, expired entries). dst_blocklist_gc_interval = time in s (default 60 s) 3. dst_blocklist_init If off, the blocklist is not initialized at startup and cannot be enabled at runtime, this saves some memory. ...

1 min · Eddie Wang

1.13 实时参数

1. real_time Sets real time priority for all the Kamailio processes, or the timers (bitmask). Possible values: 0 - off 1 - the "fast" timer 2 - the "slow" timer 4 - all processes, except the timers Example: real_time= 7 => everything switched to real time priority. real_time = <int> (flags) (default off) 2. rt_policy Real time scheduling policy, 0 = SCHED_OTHER, 1= SCHED_RR and 2=SCHED_FIFO rt_policy= <0..3> (default 0) 3. rt_prio Real time priority used for everything except the timers, if real_time is enabled. ...

1 min · Eddie Wang

1.14 核心函数

Functions exported by core that can be used in route blocks. 1. add_local_rport ⭐️ Add rport parameter to local generated Via header – see RFC3581. In effect for forwarded SIP requests. Example of usage: add_local_rport(); 2. avpflags 3. break ‘break’ statement can be used to end a ‘case’ block in a ‘switch’ statement or exit from a ‘while’ statement. 4. drop ⭐️ Stop the execution of the configuration script and alter the implicit action which is done afterwards. ...

9 min · Eddie Wang

1.15 自定义全局参数

These are parameters that can be defined by the writer of kamailio.cfg in order to be used inside routing blocks. One of the important properties for custom global parameters is that their value can be changed at runtime via RPC commands, without restarting Kamailio. The definition of a custom global parameter must follow the pattern: group.variable = value desc "description" The value can be a quoted string or integer number. ...

1 min · Eddie Wang