net/stun.lua
changeset 12363 f81488951f81
parent 12360 0f77e28df5c8
child 12364 0801db678f5e
equal deleted inserted replaced
12362:d77d8fba44ad 12363:f81488951f81
     1 local base64 = require "util.encodings".base64;
     1 local base64 = require "util.encodings".base64;
     2 local hashes = require "util.hashes";
     2 local hashes = require "util.hashes";
     3 local net = require "util.net";
     3 local net = require "util.net";
     4 local random = require "util.random";
     4 local random = require "util.random";
     5 local struct = require "util.struct";
     5 local struct = require "util.struct";
     6 
     6 local sxor = require"util.strbitop".sxor;
     7 --- Private helpers
       
     8 
       
     9 -- XORs a string with another string
       
    10 local function sxor(x, y)
       
    11 	local r = {};
       
    12 	for i = 1, #x do
       
    13 		r[i] = string.char(bit32.bxor(x:byte(i), y:byte(i)));
       
    14 	end
       
    15 	return table.concat(r);
       
    16 end
       
    17 
     7 
    18 --- Public helpers
     8 --- Public helpers
    19 
     9 
    20 -- Following draft-uberti-behave-turn-rest-00, convert a 'secret' string
    10 -- Following draft-uberti-behave-turn-rest-00, convert a 'secret' string
    21 -- into a username/password pair that can be used to auth to a TURN server
    11 -- into a username/password pair that can be used to auth to a TURN server