-
Notifications
You must be signed in to change notification settings - Fork 251
/
xep0260.ts
79 lines (74 loc) · 2.28 KB
/
xep0260.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
// ====================================================================
// XEP-0260: Jingle SOCKS5 Bytestreams Transport Method
// --------------------------------------------------------------------
// Source: https://xmpp.org/extensions/xep-0260.html
// Version: 1.0.1 (2016-05-17)
// ====================================================================
import {
attribute,
childAttribute,
childBoolean,
DefinitionOptions,
integerAttribute,
JIDAttribute
} from '../jxt';
import { NS_JINGLE_SOCKS5_1 } from '../Namespaces';
import { JingleTransport } from './';
export interface JingleSocks5 extends JingleTransport {
transportType: typeof NS_JINGLE_SOCKS5_1;
sid: string;
mode?: 'tcp' | 'udp';
address?: string;
activated?: string;
candidateUsed?: string;
candidateError?: boolean;
proxyError?: boolean;
candidates?: JingleSocks5Candidate[];
}
export interface JingleSocks5Candidate {
cid: string;
host?: string;
port?: number;
uri?: string;
priority?: number;
type?: string;
}
const Protocol: DefinitionOptions[] = [
{
element: 'transport',
fields: {
activated: childAttribute(null, 'activated', 'cid'),
address: attribute('dstaddr'),
candidateError: childBoolean(null, 'candidate-error'),
candidateUsed: childAttribute(null, 'candidate-used', 'cid'),
mode: attribute('mode', 'tcp'),
proxyError: childBoolean(null, 'proxy-error'),
sid: attribute('sid')
},
namespace: NS_JINGLE_SOCKS5_1,
path: 'iq.jingle.contents.transport',
type: NS_JINGLE_SOCKS5_1,
typeField: 'transportType'
},
{
aliases: [
{
multiple: true,
path: 'iq.jingle.contents.transport.candidates',
selector: NS_JINGLE_SOCKS5_1
}
],
element: 'candidate',
fields: {
cid: attribute('cid'),
host: attribute('host'),
jid: JIDAttribute('jid'),
port: integerAttribute('port'),
priority: integerAttribute('priority'),
type: attribute('type'),
uri: attribute('uri')
},
namespace: NS_JINGLE_SOCKS5_1
}
];
export default Protocol;