 util = require 'util'
 URL = require 'url'
 auth = require './auth'
+
+udpConReq = (address, un, key, callback) ->
+  [host, port] = address.split(':', 2)
+
+  ts = Math.trunc(Date.now() / 1000)
+  id = Math.trunc(Math.random() * 4294967295)
+  cn = crypto.randomBytes(8).toString('hex')
+  sig = crypto.createHmac('sha1', key).update("#{ts}#{id}#{un}#{cn}").digest('hex')
+  uri = "http://#{address}?ts=#{ts}&id=#{id}&un=#{un}&cn=#{cn}&sig=#{sig}"
+
+  message = Buffer.from("GET #{uri} HTTP/1.1\r\nHost: #{host}:#{port}\r\n\r\n")
+
+  client = dgram.createSocket('udp4')
+
+  count = 3
+  client.send(message, 0, message.length, port, host, f = (err) ->
+    if err or -- count <= 0
+      client.close()
+      return callback(err)
+    client.send(message, 0, message.length, port, host, f)
+  )
 
 
 connectionRequest = (deviceId, callback) ->

            return conReq(connectionRequestUrl, authString, (statusCode) -> callback(statusToError(statusCode)))
          callback(statusToError(statusCode))
        )
      else
        callback(statusToError(statusCode))
    )

# THE SOFTWARE.
###

crypto = require 'crypto'
dgram = require 'dgram'

config = require './config'
db = require './db'
http = require 'http'
