-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathobfs.ts
53 lines (43 loc) · 1.28 KB
/
obfs.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
import Connection from '../helper/connection'
/**
* The ObfsMethod class is an abstract class that all other,
* extended classes should implement its methods and properties
* every obfuscation method should extend this class
*/
abstract class ObfsMethod {
/**
* Connection object
*/
protected connection: Connection
/**
* The Obfuscation method name
*/
public abstract name: string
public abstract handshakeFlag: boolean
constructor(connection: Connection) {
this.connection = connection
}
/**
* Checks if the message format is Appropriate with
* this obfuscation method
* @param message - The incoming message
*/
public abstract check(message: Buffer): boolean
/**
* Begins the handshake process for the encryption
* @param callback - Emitted after the handshake process
*/
public abstract handshake(callback?: () => void): void
/**
* DeObfuscates the obfuscated message
* @param message - The obfuscated message
*/
public abstract deObfuscate(message: Buffer): Buffer
/**
* Obfuscates the non-obfuscated message
* @param message - The non-obfuscated message
*/
public abstract obfuscate(message: Buffer): Buffer
}
export type ObfsBuilder = (connection: Connection) => ObfsMethod
export default ObfsMethod