如何创建 X 个端点?

如何创建 X 个端点?

我对pjsip.conf每个端点的定义如下:

[my-endpoint](!)
type=endpoint
context=default
disallow=all
allow=ulaw
transport=simpletrans


[1234](my-endpoint)
auth=auth1234
aors=1234

[auth1234](auth-userpass)
password=<super_secret_password>
username=1234

[1234](aor-single-reg)
contact=sip:1234@<hostname>

对于一个或两个端点来说,这没问题,但如果我想添加 10 个或 100 个端点,管理起来就会变得乏味。我希望找到一种解决方案,可以让我创建某种通配符端点,例如123X可以创建端点1230-1239,但这似乎不存在。或者甚至可以参数化端点创建的东西会更好,例如

[my-endpoint](!)
type=endpoint
...
endpoint/1234 = <password>
endpoint/1235 = <password>
endpoint/1236 = <password>

除了弃用的设置之外,我没有发现太多东西autocreatepeer,这对于我尝试做的事情来说太不安全了。是否存在这样的事情,还是我只能为每个端点设置 10 行配置。

答案1

您可以使用即时的机制并将端点放入数据库中。

不,您不能在端点中使用模式。您已经在使用模板了,仅此而已。

https://wiki.asterisk.org/wiki/display/AST/Setting+up+PJSIP+Realtime

答案2

@Woodsy 我也遇到了同样的问题,我用下面的方法解决了:(可能不是您正在寻找的确切解决方案)

方法 1: 我在 Java 中制作了一个实用程序,它具有创建和删除 API,可以自动写入和删除 pjsip.conf 中的端点,并使用模板渲染来获取端点属性。

方法 2: 我为 PJSIP-Peer Properties、AOR、AUTH 创建了一些通用上下文,供对等端使用。这使我的每个端点从 24 多行减少到只有 8 行。

[common-pjsip-peer](!)
type=endpointcontext=IBD-context
transport=transport-wss
disallow=all
allow=opus,alaw,ulaw
webrtc=yes
max_audio_streams=1
rtp_timeout=30
rtp_keepalive=10
direct_media=yes
moh_passthrough=yes
media_encryption=sdes
media_encryption_optimistic=yes

[common-webrtc-aor](!)
type=aor
max_contacts=1
qualify_frequency=30
qualify_timeout=15.0
remove_existing=yes
remove_unavailable=yes
maximum_expiration=36000

[common-auth](!)
type=auth
auth_type=userpass


;**Actual Endpoint**
[1234567890](common-pjsip-peer)
callerid=<1234567890>
auth=1234567890
aors=1234567890
[1234567890](common-webrtc-aor)
[1234567890](common-auth)
username=1234567890
password=4611

相关内容