PLNK accepts connections

Next up exension time
This commit is contained in:
Alex 2022-09-13 00:57:48 -04:00
parent 455e87c168
commit 3878032d80
Signed by: technically
GPG Key ID: 46E0A080F69E83F1
6 changed files with 68 additions and 8 deletions

7
Cargo.lock generated
View File

@ -198,6 +198,7 @@ version = "0.0.0"
dependencies = [
"cfg-if 0.1.10",
"console_error_panic_hook",
"md5",
"serde",
"serde_json",
"worker",
@ -267,6 +268,12 @@ version = "0.4.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9376a4f0340565ad675d11fc1419227faf5f60cd7ac9cb2e7185a471f30af833"
[[package]]
name = "md5"
version = "0.7.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "490cc448043f947bae3cbee9c203358d62dbee0db12107a74be5c30ccfd09771"
[[package]]
name = "memchr"
version = "2.5.0"

View File

@ -14,6 +14,7 @@ cfg-if = "0.1.2"
worker = "0.0.9"
serde_json = "1.0.67"
serde = "1.0.144"
md5 = "0.7.0"
# The `console_error_panic_hook` crate provides better debugging of panics by
# logging them with `console.error`. This is great for development, but requires

19
examples/asterisk.conf Normal file
View File

@ -0,0 +1,19 @@
[options]
; If we want to start Asterisk with a default verbosity for the verbose
; or debug logger channel types, then we use these settings (by default
; they are disabled).
verbose = 5
debug = 2
; User and group to run asterisk as. NOTE: This will require changes to
; directory and device permissions.
runuser = gonk ; The user to run as. The default is root.
rungroup = gonk ; The group to run as. The default is root
; Gonk settings
defaultlanguage = en
initcrypto = yes
timestamp = yes
autosystemname = yes
astctlowner = gonk
astctlgroup = gonk

26
examples/pjsip.conf Normal file
View File

@ -0,0 +1,26 @@
[global]
type=global
default_realm=gonk
default_from_user=gonk
[transport-udp]
type=transport
protocol=udp
bind=0.0.0.0
local_net=192.168.0.0/16
local_net=10.0.0.0/8
local_net=172.16.0.0/12
local_net=127.0.0.1/32
external_media_address=##EXTERNAL_IP##
external_signaling_address=##EXTERNAL_IP##
[transport-tcp]
type=transport
protocol=tcp
bind=0.0.0.0
local_net=192.168.0.0/16
local_net=10.0.0.0/8
local_net=172.16.0.0/12
local_net=127.0.0.1/32
external_media_address=##EXTERNAL_IP##
external_signaling_address=##EXTERNAL_IP##

View File

@ -1,4 +1,4 @@
[##EXT##]
[##CALL##]
type=endpoint
auth=##EXT##
aors=##EXT##
@ -14,14 +14,12 @@ rewrite_contact=yes
rtp_symmetric=yes
force_rport=yes
[##EXT##]
[##CALL##-auth]
type=auth
auth_type=userpass
password=##CALL##
username=##PASS##
md5_cred=##MD5_CRED##
[##EXT##]
[##CALL##]
type=aor
max_contacts=1
max_contacts=10
mailboxes=##EXT##@default

View File

@ -1,3 +1,4 @@
use md5;
use serde;
use worker::{kv::KvStore, *};
@ -99,7 +100,15 @@ pub async fn main(req: Request, env: Env, _ctx: worker::Context) -> Result<Respo
user = user.replace("##CALL##", u);
user = user.replace("##EXT##", &info.ext);
user = user.replace("##PASSWD##", &info.passwd);
user = user.replace(
"##MD5_CRED##",
&format!(
"{:x}",
md5::compute(format!("{}:gonk:{}", u, &info.passwd))
),
);
// user = user.replace("##PASSWD##", &info.passwd);
conf = conf + &user;
}