Software /
code /
prosody
Annotate
util/rfc3484.lua @ 5545:d22416f8a836
prosodyctl: Add message describing the distinguished name input expected
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Mon, 29 Apr 2013 13:59:39 +0200 |
parent | 4830:ea907059a90e |
rev | line source |
---|---|
4420
4314eeeed394
util.rfc3484: New util implementing RFC3484 sorting
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
1 -- Prosody IM |
4314eeeed394
util.rfc3484: New util implementing RFC3484 sorting
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
2 -- Copyright (C) 2008-2011 Florian Zeitz |
4314eeeed394
util.rfc3484: New util implementing RFC3484 sorting
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
3 -- |
4314eeeed394
util.rfc3484: New util implementing RFC3484 sorting
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
4 -- This project is MIT/X11 licensed. Please see the |
4314eeeed394
util.rfc3484: New util implementing RFC3484 sorting
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
5 -- COPYING file in the source package for more information. |
4314eeeed394
util.rfc3484: New util implementing RFC3484 sorting
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
6 -- |
4314eeeed394
util.rfc3484: New util implementing RFC3484 sorting
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
7 |
4314eeeed394
util.rfc3484: New util implementing RFC3484 sorting
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
8 local commonPrefixLength = require"util.ip".commonPrefixLength |
4314eeeed394
util.rfc3484: New util implementing RFC3484 sorting
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
9 local new_ip = require"util.ip".new_ip; |
4314eeeed394
util.rfc3484: New util implementing RFC3484 sorting
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
10 |
4423
ded726418b16
util.rfc3484: Use a stable sorting algorithm
Florian Zeitz <florob@babelmonkeys.de>
parents:
4420
diff
changeset
|
11 local function t_sort(t, comp) |
ded726418b16
util.rfc3484: Use a stable sorting algorithm
Florian Zeitz <florob@babelmonkeys.de>
parents:
4420
diff
changeset
|
12 for i = 1, (#t - 1) do |
ded726418b16
util.rfc3484: Use a stable sorting algorithm
Florian Zeitz <florob@babelmonkeys.de>
parents:
4420
diff
changeset
|
13 for j = (i + 1), #t do |
ded726418b16
util.rfc3484: Use a stable sorting algorithm
Florian Zeitz <florob@babelmonkeys.de>
parents:
4420
diff
changeset
|
14 local a, b = t[i], t[j]; |
ded726418b16
util.rfc3484: Use a stable sorting algorithm
Florian Zeitz <florob@babelmonkeys.de>
parents:
4420
diff
changeset
|
15 if not comp(a,b) then |
ded726418b16
util.rfc3484: Use a stable sorting algorithm
Florian Zeitz <florob@babelmonkeys.de>
parents:
4420
diff
changeset
|
16 t[i], t[j] = b, a; |
ded726418b16
util.rfc3484: Use a stable sorting algorithm
Florian Zeitz <florob@babelmonkeys.de>
parents:
4420
diff
changeset
|
17 end |
ded726418b16
util.rfc3484: Use a stable sorting algorithm
Florian Zeitz <florob@babelmonkeys.de>
parents:
4420
diff
changeset
|
18 end |
ded726418b16
util.rfc3484: Use a stable sorting algorithm
Florian Zeitz <florob@babelmonkeys.de>
parents:
4420
diff
changeset
|
19 end |
ded726418b16
util.rfc3484: Use a stable sorting algorithm
Florian Zeitz <florob@babelmonkeys.de>
parents:
4420
diff
changeset
|
20 end |
ded726418b16
util.rfc3484: Use a stable sorting algorithm
Florian Zeitz <florob@babelmonkeys.de>
parents:
4420
diff
changeset
|
21 |
4830
ea907059a90e
util.rfc3484: Don't pollute the global scope.
Kim Alvefur <zash@zash.se>
parents:
4423
diff
changeset
|
22 local function source(dest, candidates) |
4420
4314eeeed394
util.rfc3484: New util implementing RFC3484 sorting
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
23 local function comp(ipA, ipB) |
4314eeeed394
util.rfc3484: New util implementing RFC3484 sorting
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
24 -- Rule 1: Prefer same address |
4314eeeed394
util.rfc3484: New util implementing RFC3484 sorting
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
25 if dest == ipA then |
4314eeeed394
util.rfc3484: New util implementing RFC3484 sorting
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
26 return true; |
4314eeeed394
util.rfc3484: New util implementing RFC3484 sorting
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
27 elseif dest == ipB then |
4314eeeed394
util.rfc3484: New util implementing RFC3484 sorting
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
28 return false; |
4314eeeed394
util.rfc3484: New util implementing RFC3484 sorting
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
29 end |
4314eeeed394
util.rfc3484: New util implementing RFC3484 sorting
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
30 |
4314eeeed394
util.rfc3484: New util implementing RFC3484 sorting
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
31 -- Rule 2: Prefer appropriate scope |
4314eeeed394
util.rfc3484: New util implementing RFC3484 sorting
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
32 if ipA.scope < ipB.scope then |
4314eeeed394
util.rfc3484: New util implementing RFC3484 sorting
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
33 if ipA.scope < dest.scope then |
4314eeeed394
util.rfc3484: New util implementing RFC3484 sorting
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
34 return false; |
4314eeeed394
util.rfc3484: New util implementing RFC3484 sorting
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
35 else |
4314eeeed394
util.rfc3484: New util implementing RFC3484 sorting
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
36 return true; |
4314eeeed394
util.rfc3484: New util implementing RFC3484 sorting
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
37 end |
4314eeeed394
util.rfc3484: New util implementing RFC3484 sorting
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
38 elseif ipA.scope > ipB.scope then |
4314eeeed394
util.rfc3484: New util implementing RFC3484 sorting
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
39 if ipB.scope < dest.scope then |
4314eeeed394
util.rfc3484: New util implementing RFC3484 sorting
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
40 return true; |
4314eeeed394
util.rfc3484: New util implementing RFC3484 sorting
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
41 else |
4314eeeed394
util.rfc3484: New util implementing RFC3484 sorting
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
42 return false; |
4314eeeed394
util.rfc3484: New util implementing RFC3484 sorting
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
43 end |
4314eeeed394
util.rfc3484: New util implementing RFC3484 sorting
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
44 end |
4314eeeed394
util.rfc3484: New util implementing RFC3484 sorting
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
45 |
4314eeeed394
util.rfc3484: New util implementing RFC3484 sorting
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
46 -- Rule 3: Avoid deprecated addresses |
4314eeeed394
util.rfc3484: New util implementing RFC3484 sorting
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
47 -- XXX: No way to determine this |
4314eeeed394
util.rfc3484: New util implementing RFC3484 sorting
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
48 -- Rule 4: Prefer home addresses |
4314eeeed394
util.rfc3484: New util implementing RFC3484 sorting
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
49 -- XXX: Mobility Address related, no way to determine this |
4314eeeed394
util.rfc3484: New util implementing RFC3484 sorting
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
50 -- Rule 5: Prefer outgoing interface |
4314eeeed394
util.rfc3484: New util implementing RFC3484 sorting
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
51 -- XXX: Interface to address relation. No way to determine this |
4314eeeed394
util.rfc3484: New util implementing RFC3484 sorting
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
52 -- Rule 6: Prefer matching label |
4314eeeed394
util.rfc3484: New util implementing RFC3484 sorting
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
53 if ipA.label == dest.label and ipB.label ~= dest.label then |
4314eeeed394
util.rfc3484: New util implementing RFC3484 sorting
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
54 return true; |
4314eeeed394
util.rfc3484: New util implementing RFC3484 sorting
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
55 elseif ipB.label == dest.label and ipA.label ~= dest.label then |
4314eeeed394
util.rfc3484: New util implementing RFC3484 sorting
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
56 return false; |
4314eeeed394
util.rfc3484: New util implementing RFC3484 sorting
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
57 end |
4314eeeed394
util.rfc3484: New util implementing RFC3484 sorting
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
58 |
4314eeeed394
util.rfc3484: New util implementing RFC3484 sorting
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
59 -- Rule 7: Prefer public addresses (over temporary ones) |
4314eeeed394
util.rfc3484: New util implementing RFC3484 sorting
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
60 -- XXX: No way to determine this |
4314eeeed394
util.rfc3484: New util implementing RFC3484 sorting
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
61 -- Rule 8: Use longest matching prefix |
4314eeeed394
util.rfc3484: New util implementing RFC3484 sorting
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
62 if commonPrefixLength(ipA, dest) > commonPrefixLength(ipB, dest) then |
4314eeeed394
util.rfc3484: New util implementing RFC3484 sorting
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
63 return true; |
4314eeeed394
util.rfc3484: New util implementing RFC3484 sorting
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
64 else |
4314eeeed394
util.rfc3484: New util implementing RFC3484 sorting
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
65 return false; |
4314eeeed394
util.rfc3484: New util implementing RFC3484 sorting
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
66 end |
4314eeeed394
util.rfc3484: New util implementing RFC3484 sorting
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
67 end |
4314eeeed394
util.rfc3484: New util implementing RFC3484 sorting
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
68 |
4314eeeed394
util.rfc3484: New util implementing RFC3484 sorting
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
69 t_sort(candidates, comp); |
4314eeeed394
util.rfc3484: New util implementing RFC3484 sorting
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
70 return candidates[1]; |
4314eeeed394
util.rfc3484: New util implementing RFC3484 sorting
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
71 end |
4314eeeed394
util.rfc3484: New util implementing RFC3484 sorting
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
72 |
4830
ea907059a90e
util.rfc3484: Don't pollute the global scope.
Kim Alvefur <zash@zash.se>
parents:
4423
diff
changeset
|
73 local function destination(candidates, sources) |
4420
4314eeeed394
util.rfc3484: New util implementing RFC3484 sorting
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
74 local sourceAddrs = {}; |
4314eeeed394
util.rfc3484: New util implementing RFC3484 sorting
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
75 local function comp(ipA, ipB) |
4314eeeed394
util.rfc3484: New util implementing RFC3484 sorting
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
76 local ipAsource = sourceAddrs[ipA]; |
4314eeeed394
util.rfc3484: New util implementing RFC3484 sorting
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
77 local ipBsource = sourceAddrs[ipB]; |
4314eeeed394
util.rfc3484: New util implementing RFC3484 sorting
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
78 -- Rule 1: Avoid unusable destinations |
4314eeeed394
util.rfc3484: New util implementing RFC3484 sorting
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
79 -- XXX: No such information |
4314eeeed394
util.rfc3484: New util implementing RFC3484 sorting
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
80 -- Rule 2: Prefer matching scope |
4314eeeed394
util.rfc3484: New util implementing RFC3484 sorting
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
81 if ipA.scope == ipAsource.scope and ipB.scope ~= ipBsource.scope then |
4314eeeed394
util.rfc3484: New util implementing RFC3484 sorting
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
82 return true; |
4314eeeed394
util.rfc3484: New util implementing RFC3484 sorting
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
83 elseif ipA.scope ~= ipAsource.scope and ipB.scope == ipBsource.scope then |
4314eeeed394
util.rfc3484: New util implementing RFC3484 sorting
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
84 return false; |
4314eeeed394
util.rfc3484: New util implementing RFC3484 sorting
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
85 end |
4314eeeed394
util.rfc3484: New util implementing RFC3484 sorting
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
86 |
4314eeeed394
util.rfc3484: New util implementing RFC3484 sorting
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
87 -- Rule 3: Avoid deprecated addresses |
4314eeeed394
util.rfc3484: New util implementing RFC3484 sorting
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
88 -- XXX: No way to determine this |
4314eeeed394
util.rfc3484: New util implementing RFC3484 sorting
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
89 -- Rule 4: Prefer home addresses |
4314eeeed394
util.rfc3484: New util implementing RFC3484 sorting
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
90 -- XXX: Mobility Address related, no way to determine this |
4314eeeed394
util.rfc3484: New util implementing RFC3484 sorting
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
91 -- Rule 5: Prefer matching label |
4314eeeed394
util.rfc3484: New util implementing RFC3484 sorting
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
92 if ipAsource.label == ipA.label and ipBsource.label ~= ipB.label then |
4314eeeed394
util.rfc3484: New util implementing RFC3484 sorting
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
93 return true; |
4314eeeed394
util.rfc3484: New util implementing RFC3484 sorting
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
94 elseif ipBsource.label == ipB.label and ipAsource.label ~= ipA.label then |
4314eeeed394
util.rfc3484: New util implementing RFC3484 sorting
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
95 return false; |
4314eeeed394
util.rfc3484: New util implementing RFC3484 sorting
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
96 end |
4314eeeed394
util.rfc3484: New util implementing RFC3484 sorting
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
97 |
4314eeeed394
util.rfc3484: New util implementing RFC3484 sorting
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
98 -- Rule 6: Prefer higher precedence |
4314eeeed394
util.rfc3484: New util implementing RFC3484 sorting
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
99 if ipA.precedence > ipB.precedence then |
4314eeeed394
util.rfc3484: New util implementing RFC3484 sorting
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
100 return true; |
4314eeeed394
util.rfc3484: New util implementing RFC3484 sorting
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
101 elseif ipA.precedence < ipB.precedence then |
4314eeeed394
util.rfc3484: New util implementing RFC3484 sorting
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
102 return false; |
4314eeeed394
util.rfc3484: New util implementing RFC3484 sorting
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
103 end |
4314eeeed394
util.rfc3484: New util implementing RFC3484 sorting
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
104 |
4314eeeed394
util.rfc3484: New util implementing RFC3484 sorting
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
105 -- Rule 7: Prefer native transport |
4314eeeed394
util.rfc3484: New util implementing RFC3484 sorting
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
106 -- XXX: No way to determine this |
4314eeeed394
util.rfc3484: New util implementing RFC3484 sorting
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
107 -- Rule 8: Prefer smaller scope |
4314eeeed394
util.rfc3484: New util implementing RFC3484 sorting
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
108 if ipA.scope < ipB.scope then |
4314eeeed394
util.rfc3484: New util implementing RFC3484 sorting
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
109 return true; |
4314eeeed394
util.rfc3484: New util implementing RFC3484 sorting
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
110 elseif ipA.scope > ipB.scope then |
4314eeeed394
util.rfc3484: New util implementing RFC3484 sorting
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
111 return false; |
4314eeeed394
util.rfc3484: New util implementing RFC3484 sorting
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
112 end |
4314eeeed394
util.rfc3484: New util implementing RFC3484 sorting
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
113 |
4314eeeed394
util.rfc3484: New util implementing RFC3484 sorting
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
114 -- Rule 9: Use longest matching prefix |
4314eeeed394
util.rfc3484: New util implementing RFC3484 sorting
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
115 if commonPrefixLength(ipA, ipAsource) > commonPrefixLength(ipB, ipBsource) then |
4314eeeed394
util.rfc3484: New util implementing RFC3484 sorting
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
116 return true; |
4314eeeed394
util.rfc3484: New util implementing RFC3484 sorting
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
117 elseif commonPrefixLength(ipA, ipAsource) < commonPrefixLength(ipB, ipBsource) then |
4314eeeed394
util.rfc3484: New util implementing RFC3484 sorting
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
118 return false; |
4314eeeed394
util.rfc3484: New util implementing RFC3484 sorting
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
119 end |
4314eeeed394
util.rfc3484: New util implementing RFC3484 sorting
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
120 |
4314eeeed394
util.rfc3484: New util implementing RFC3484 sorting
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
121 -- Rule 10: Otherwise, leave order unchanged |
4314eeeed394
util.rfc3484: New util implementing RFC3484 sorting
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
122 return true; |
4314eeeed394
util.rfc3484: New util implementing RFC3484 sorting
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
123 end |
4314eeeed394
util.rfc3484: New util implementing RFC3484 sorting
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
124 for _, ip in ipairs(candidates) do |
4314eeeed394
util.rfc3484: New util implementing RFC3484 sorting
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
125 sourceAddrs[ip] = source(ip, sources); |
4314eeeed394
util.rfc3484: New util implementing RFC3484 sorting
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
126 end |
4314eeeed394
util.rfc3484: New util implementing RFC3484 sorting
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
127 |
4314eeeed394
util.rfc3484: New util implementing RFC3484 sorting
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
128 t_sort(candidates, comp); |
4314eeeed394
util.rfc3484: New util implementing RFC3484 sorting
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
129 return candidates; |
4314eeeed394
util.rfc3484: New util implementing RFC3484 sorting
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
130 end |
4314eeeed394
util.rfc3484: New util implementing RFC3484 sorting
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
131 |
4314eeeed394
util.rfc3484: New util implementing RFC3484 sorting
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
132 return {source = source, |
4314eeeed394
util.rfc3484: New util implementing RFC3484 sorting
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
133 destination = destination}; |