-
Notifications
You must be signed in to change notification settings - Fork 251
/
xep0065.ts
75 lines (69 loc) · 1.83 KB
/
xep0065.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
// ====================================================================
// XEP-0065: SOCKS5 Bytestreams
// --------------------------------------------------------------------
// Source: https://xmpp.org/extensions/xep-0065.html
// Version: 1.8.1 (2015-09-17)
// ====================================================================
import { JID } from '../JID';
import {
attribute,
childAttribute,
childJIDAttribute,
childText,
DefinitionOptions,
integerAttribute,
JIDAttribute
} from '../jxt';
import { NS_SOCKS5 } from '../Namespaces';
declare module './' {
export interface IQPayload {
socks5?: SOCKS5;
}
}
export interface SOCKS5 {
mode?: 'tcp' | 'udp';
address?: string;
sid: string;
activate?: string;
candidateUsed?: JID;
udpSuccess?: string;
candidates?: SOCKS5Candidate[];
}
export interface SOCKS5Candidate {
jid?: JID;
host?: string;
port?: number;
uri?: string;
}
const Protocol: DefinitionOptions[] = [
{
element: 'query',
fields: {
activate: childText(null, 'activate'),
address: attribute('dstaddr'),
candidateUsed: childJIDAttribute(null, 'streamhost-used', 'jid'),
mode: attribute('mode', 'tcp'),
sid: attribute('sid'),
udpSuccess: childAttribute(null, 'udpsuccess', 'dstaddr')
},
namespace: NS_SOCKS5,
path: 'iq.socks5'
},
{
aliases: [
{
multiple: true,
path: 'iq.socks5.candidates'
}
],
element: 'streamhost',
fields: {
host: attribute('host'),
jid: JIDAttribute('jid'),
port: integerAttribute('port'),
uri: attribute('uri')
},
namespace: NS_SOCKS5
}
];
export default Protocol;