diff options
Diffstat (limited to 'config/notify_device')
-rwxr-xr-x | config/notify_device | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/config/notify_device b/config/notify_device new file mode 100755 index 0000000..7d5ff2a --- /dev/null +++ b/config/notify_device @@ -0,0 +1,30 @@ +#!/usr/bin/lua +require("socket") +require("validator") + +if not arg or #arg == 0 then + print("Error - IP Address must be specified") + return 1 +end + +local address = arg[1] +local user = arg[2] or "" +if not validator.is_ipv4(address) then + print("Error - Invalid IP Address") + return 1 +end + +local msg = "NOTIFY sip:"..user.."@"..address..":5060 SIP/2.0\n".. +"Via: SIP/2.0/UDP 127.0.0.1\n".. +"From: <sip:provisioning@127.0.0.1>\n".. +"To: <sip:"..user.."@"..address..">\n".. +"Event: check-sync\n".. +"Date: "..os.date().."\n".. +"Call-ID: "..os.time().."msgto0@"..address.."\n".. +"CSeq: 102 NOTIFY\n".. +"Contact: <sip:provisioning@127.0.0.1>\n".. +"Content-Length: 0\n\n" + +local s = assert(socket.udp()) +assert(s:sendto(msg, address, 5060)) +s:close() |