Software /
code /
prosody
Comparison
net/stun.lua @ 12359:f81488951f81
net.stun: Use util.strbitop
Improves performance since the whole procedure is done in C
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Fri, 04 Mar 2022 16:55:32 +0100 |
parent | 12356:0f77e28df5c8 |
child | 12360:0801db678f5e |
comparison
equal
deleted
inserted
replaced
12358:d77d8fba44ad | 12359: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 |