-
Notifications
You must be signed in to change notification settings - Fork 251
/
xep0176.ts
118 lines (111 loc) · 3.72 KB
/
xep0176.ts
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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
// ====================================================================
// XEP-0176: Jingle ICE-UDP Transport Method
// --------------------------------------------------------------------
// Source: https://xmpp.org/extensions/xep-0176.html
// Version: 1.0 (2009-06-10)
//
// Additional:
// - tcpType candidate attribute (matching XEP-0371)
// - gatheringComplete flag (matching XEP-0371)
//
// --------------------------------------------------------------------
// XEP-0371: Jingle ICE-UDP Transport Method
// --------------------------------------------------------------------
// Source: https://xmpp.org/extensions/xep-0371.html
// Version: 0.2 (2017-09-11)
// ====================================================================
import { attribute, childBoolean, DefinitionOptions, integerAttribute } from '../jxt';
import { NS_JINGLE_ICE_0, NS_JINGLE_ICE_UDP_1 } from '../Namespaces';
import { JingleTransport } from './';
export interface JingleIce extends JingleTransport {
transportType: typeof NS_JINGLE_ICE_0 | typeof NS_JINGLE_ICE_UDP_1;
password?: string;
usernameFragment?: string;
gatheringComplete?: boolean;
remoteCandidate?: JingleIceRemoteCandidate;
candidates?: JingleIceCandidate[];
iceLite?: boolean;
}
export interface JingleIceCandidate {
component: number;
generation?: number;
foundation: string;
id?: string;
ip: string;
network?: number;
port: number;
priority: number;
protocol?: 'tcp' | 'udp';
relatedAddress?: string;
relatedPort?: number;
tcpType?: 'active' | 'passive' | 'so';
type: 'host' | 'prflx' | 'srflx' | 'relay';
}
export interface JingleIceRemoteCandidate {
component: number;
ip: string;
port: number;
}
const ice = (transportType: string): DefinitionOptions[] => [
{
element: 'transport',
fields: {
gatheringComplete: childBoolean(null, 'gathering-complete'),
password: attribute('pwd'),
usernameFragment: attribute('ufrag')
},
namespace: transportType,
path: 'iq.jingle.contents.transport',
type: transportType,
typeField: 'transportType'
},
{
aliases: [
{
impliedType: true,
path: 'iq.jingle.contents.transport.remoteCandidate',
selector: transportType
}
],
element: 'remote-candidate',
fields: {
component: integerAttribute('component'),
ip: attribute('ip'),
port: integerAttribute('port')
},
namespace: transportType,
type: transportType,
typeField: 'transportType'
},
{
aliases: [
{
impliedType: true,
multiple: true,
path: 'iq.jingle.contents.transport.candidates',
selector: transportType
}
],
element: 'candidate',
fields: {
component: integerAttribute('component'),
foundation: attribute('foundation'),
generation: integerAttribute('generation'),
id: attribute('id'),
ip: attribute('ip'),
network: integerAttribute('network'),
port: integerAttribute('port'),
priority: integerAttribute('priority'),
protocol: attribute('protocol'),
relatedAddress: attribute('rel-addr'),
relatedPort: attribute('rel-port'),
tcpType: attribute('tcptype'),
type: attribute('type')
},
namespace: transportType,
type: transportType,
typeField: 'transportType'
}
];
const Protocol: DefinitionOptions[] = [...ice(NS_JINGLE_ICE_0), ...ice(NS_JINGLE_ICE_UDP_1)];
export default Protocol;