Telefoon2.0
Project Telefoon2.0 | |
---|---|
+31 70 569 0105 / EPVPN REV0 (7380) | |
Status | In progress |
Contact | flimpie / eloy |
Last Update | 2024-01-27 |
Om voor in de toekomst(tm) gepruts met analoge telefoons mogelijk te maken is er een Asterisk bak ingericht, met daar aan een 070-nummer, een EPVPN-nummer en en een SIP2SIM (die zit in slot 2 van de spacetelefoon op de bar)
Gebruik
Om van buiten naar de space (via de asterisk-bak) te bellen: bel REV0 via EPVPN, of +31 70 569 0105.
Om vanaf de space naar EPVPN te bellen: bel 01999 + nummer via de spacetelefoon, en kies sim-kaart 2 (Vodafone NL)
Dialplan (op volgorde)
- `01999.`: naar EPVPN
- `+491999.`: naar EPVPN
- `+31[1-8].`: naar CheapConnect (om 0900 uit te filteren)
- `0[1-8].`: naar CheapConnect (om 0900 uit te filteren)
- terugvallen naar een 'dit mag je niet bellen' recording
Bijbehorende infra
revphone.flimpie.net
Debian 12 bak, draait Asterisk. eloy en flimpie hebben toegang. ssh'en naar poort 20422
Configuratie
ledbanner
aankondiging van gesprekken
De CID wordt op de ledbanner getoond (inclusief censuuroverlay op de camera, zoals voor doorduino opt-outs) als er in wordt gebeld
shell-bullseye
ssh-tunnel
De Asterisk-bak kan niet in het Revspace-net draaien omdat CheapConnect geen IPv6 doet, dus is er voor een hetzner bak gekozen dus moet er een tunnel draaien.
[Unit] Description=Tunnel revspace MQTT to revphone.flimpie.net After=network.target [Service] ExecStart=/usr/bin/ssh -vvvv -p 20422 -i /home/flimpie/.ssh/id_rsa -NT -o ServerAliveInterval=60 -o ExitOnForwardFailure=yes -R 127.0.0.1:41883:mosquitto.space.revspace.nl:1883 portforward@revphone.flimpie.net # Restart every >2 seconds to avoid StartLimitInterval failure RestartSec=5 Restart=always [Install] WantedBy=default.target
revphone.flimpie.net
ssh-tunnel
/etc/ssh/sshd_config
(alleen het relevante deel om de portforward user te sperren)
Match User portforward AllowTcpForwarding yes X11Forwarding no AllowAgentForwarding no ForceCommand /bin/false
ledbanner-scriptje
/usr/local/bin/banner-cid.sh
#!/bin/bash NUMBER=$1 mosquitto_pub -h "127.0.0.1" -p 41883 -t "revspace/telefoon" -m "telefoon: $NUMBER"
asterisk
extensions.conf
[inbound] ; the generic inbound call context. if specific treatment (like CID translation) is needed per trunk, create a separate context and let it call 'inbound' using Gosub exten => s,1,NoOp() exten => s,n,Log(NOTICE, Incoming call from ${CALLERID(all)}, cid num ${CALLERID(num)}, cdr ${CDR}, all cid ${CALLERID(all)}, dnid ${CALLERID(dnid)}, exten ${EXTEN}, to ${PJSIP_HEADER(read,To)}) exten => s,n,System(/usr/bin/bash /usr/local/bin/banner-cid.sh ${CALLERID(num)}) exten => s,n,Answer() exten => s,n,AGI(revspace-state.sh) exten => s,n,Verbose(result is: ${open}) exten => s,n,GotoIf($["${open}" = "0"]?closed) ; jump to "sorry, nobody is available to take your call" if the space is closed exten => s,n,Ringing() exten => s,n,Dial(PJSIP/sip2sim,30) exten => s,n,Hangup() exten => s,n(closed),Playback(sorry) exten => s,n,Playback(nbdy-avail-to-take-call) exten => s,n,Hangup() [inbound_epvpn] ; rewrite the CID, prefix it with 00491999 if it is from inside EPVPN, if it's from the EPVPN DID rewrite it to a proper public phone number rewrite CID before handling as normal inbound call exten => 7380,1,Set(OLDCID=${CALLERID(all)}) ; if the caller number starts with 0000, it's from the DID, rerite the number ; if it doesnt start with 0000, it's internal to EPVPN so only rewrite the number and keep the name (may be set by caller and is used by some phones) same = n,ExecIf($["${CALLERID(NUM):0:4}" != "0000"]?set(CALLERID(num)=00491999${CALLERID(num:1)})) same = n,ExecIf($["${CALLERID(NUM):0:4}" = "0000"]?set(CALLERID(all)=<00${CALLERID(num):4}>)) same = n,Log(NOTICE, Rewrote CID for EPVPN call from ${OLDCID} to <${CALLERID(all)}>) same = n,Gosub(inbound,s,1) same = n,Hangup() [inbound_pstn] ; rewrite CID before handling as normal inbound call exten => s,1,Set(OLDCID=${CALLERID(all)}) exten => s,2,Set(OLDNUM=${CALLERID(num)}) ; extremely bodgey, but the gist of this is that it will rewrite local numbers to +31 numbers, rewrite anonymous CIDs to +31979999999999 (a bogus number, I don't know how A&A expects anonymous numbers) exten => s,3,ExecIf($["${CALLERID(NUM):0:2}" != "00"]?ExecIf($["${CALLERID(NUM)}" != ""]?ExecIf($["${CALLERID(NUM)}" != "anonymous"]?set(CALLERID(num)=0031${CALLERID(num):1})))) exten => s,4,ExecIf($["${CALLERID(NUM)}" = "anonymous"]?set(CALLERID(all)=+3197999999999)) ; another pain: numbers starting with + aren't handled properly exten => s,5,ExecIf($["${OLDNUM:0:1}" = "+"]?set(CALLERID(num)=00${OLDNUM:1}))) exten => s,6,Log(NOTICE, ${OLDNUM:0:1}) exten => s,7,Log(NOTICE, Rewrote CID for PSTN (CheapConnect) call from ${OLDCID} to <${CALLERID(all)}>) exten => s,8,Gosub(inbound,s,1) exten => s,9,Hangup() [phones] ;toestellen exten => 0198123456,1,Answer(500) same = n,Playback(hello-world) same = n,Hangup() exten => _01999.,1,Log(NOTICE, Dialing out from ${CALLERID(all)} to ${EXTEN:5} through EPVPN) same = n,Set(CALLERID(all)=RevSpace<7380>) same = n,Dial(PJSIP/${EXTEN:5}@epvpn_endpoint, 45) ;same = n,Goto(s-${DIALSTATUS},1) same = n,Log(NOTICE,${DIALSTATUS}) same = n,Hangup() exten => _+491999.,1,Log(NOTICE, Dialing out from ${CALLERID(all)} to ${EXTEN:7} through EPVPN) same = n,Set(CALLERID(all)=RevSpace<7380>) same = n,Dial(PJSIP/${EXTEN:7}@epvpn_endpoint, 45) ;same = n,Goto(s-${DIALSTATUS},1) same = n,Log(NOTICE,${DIALSTATUS}) same = n,Hangup() exten => _+31[1-8].,1,Log(NOTICE, Dialing out to ${EXTEN} via public phone network) same = n,Dial(PJSIP/${EXTEN}@cheapconnect_endpoint, 45) same = n,HangUp() exten => _0[1-8].,1,Log(NOTICE, Dialing out to ${EXTEN} via public phone network) same = n,Dial(PJSIP/${EXTEN}@cheapconnect_endpoint, 45) same = n,HangUp() exten => _.,1,Log(NOTICE, Call to ${EXTEN} forbidden!) same = n,Answer() same = n,Playback(invalid) same = n,Hangup()
pjsip.conf
[transport-udp-internet-v4] type=transport bind=49.13.171.67:45060 protocol=udp [transport-udp-internet-v6] type=transport bind=[2a01:4f8:1c1b:56aa::1]:45060 protocol=udp [sip2sim] type=endpoint transport=transport-udp-internet-v6 context=phones disallow=all allow=alaw aors=sip2sim auth=sip2sim direct_media=no [sip2sim] type=auth auth_type=userpass username=geheim password=geheim [sip2sim] type=identify endpoint=sip2sim match=81.187.30.111 match=81.187.30.113 match=2001:8b0:0:30:5060::1 match=2001:8b0:0:30:5060::3 match=81.187.30.112 match=81.187.30.114 match=2001:8b0:0:30:5060::2 match=2001:8b0:0:30:5060::4 [sip2sim] type=aor max_contacts=1 [epvpn] type = registration contact_user = 7380 transport = transport-udp-internet-v4 outbound_auth = epvpn_auth server_uri = sip:hg.eventphone.de:5060 client_uri = sip:7380@hg.eventphone.de:5060 [epvpn_auth] type = auth auth_type = userpass password = geheim username = 7380 [epvpn_endpoint] type = endpoint transport = transport-udp-internet-v4 aors = epvpn_aor context = inbound_epvpn disallow = all allow = alaw outbound_auth = epvpn_auth direct_media = no from_domain = hg.eventphone.de [epvpn_identify] type = identify endpoint = epvpn_endpoint match=hg.eventphone.de [epvpn_aor] type = aor contact = sip:hg.eventphone.de:5060 qualify_frequency = 30 [cheapconnect] type = registration transport = transport-udp-internet-v4 outbound_auth = cheapconnect_auth server_uri = sip:voip.cheapconnect.net:5060 client_uri = sip:31705690105@voip.cheapconnect.net:5060 [cheapconnect_auth] type = auth auth_type = userpass password = geheim username = 31705690105 [cheapconnect_endpoint] type = endpoint transport = transport-udp-internet-v4 aors = cheapconnect_aor context = inbound_pstn disallow = all allow = alaw outbound_auth = cheapconnect_auth direct_media = no from_domain = voip.cheapconnect.net [cheapconnect_identify] type = identify endpoint = cheapconnect_endpoint match = voip.cheapconnect.net [cheapconnect_aor] type = aor contact = sip:voip.cheapconnect.net:5060 qualify_frequency = 30
/var/lib/asterisk/agi-bin/revspace-state.sh
#!/bin/bash STATE=`curl --silent https://revspace.nl/status/status.php | jq .open` if [ $? -eq 0 ]; then if [ "$STATE" = "true" ]; then echo 'SET VARIABLE open "1"' exit fi echo 'SET VARIABLE open "0"' exit fi # something went wrong when getting the spacestate, assume it is open (fail-safe) echo 'SET VARIABLE open "1"'