summaryrefslogtreecommitdiffstats
path: root/config/notify_device
blob: 7d5ff2a1a6fc9124c24c657e5216cbee4d7e08f2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
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()