-
Notifications
You must be signed in to change notification settings - Fork 1
/
README.protean
31 lines (19 loc) · 2.11 KB
/
README.protean
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
# Protean
Protean is a pluggable transport that allows you to configure your own obfuscation.
## Using Protean
### Swift Version:
Protean is one of the transports available in the [Shapeshifter-Swift-Transports library](https://github.com/OperatorFoundation/Shapeshifter-Swift-Transports). We recommend that you add this library to your Swift project using [Swift Package Manager](https://swift.org/package-manager/).
You can see example code for making a connection using Protean in the [example.swift](https://github.com/OperatorFoundation/Shapeshifter-Swift-Transports/blob/master/example.swift) file in the Shapeshifter-Swift-Transports project. Here is a summary of how you might make a connection with Optimizer:
1. First you will need to create the sequences, encryption, and header you want to use. Use these to create a protean config object:
1. `let sequenceModel = ByteSequenceShaper.SequenceModel(index: 0, offset: 0, sequence: sequence, length: 256)
let sequenceConfig = ByteSequenceShaper.Config(addSequences: [sequenceModel], removeSequences: [sequenceModel])`
2. `let bytes = Data(count: 32)
let encryptionConfig = EncryptionShaper.Config(key: bytes)`
3. `let header = Data([139, 210, 37])
let headerConfig = HeaderShaper.Config(addHeader: header, removHeader: header)`
4. `let proteanConfig = Protean.Config(byteSequenceConfig: sequenceConfig, encryptionConfig: encryptionConfig, headerConfig: headerConfig)`
2. Create an instance of ProteanConnectionFactory using your new Config instance:
`let proteanConnectionFactory = ProteanConnectionFactory(host: host, port: port, config: proteanConfig)`
3. An optional connection is created by calling connect on your connection factory (this is designed to look and behave in the same way as Apple’s Network.framework):
`let possibleConnection = proteanConnectionFactory.connect(using: .tcp)`
4. The rest of your networking code should be the same as if you were just using Network.framework. You can get state updates on your unwrapped connection via connection.stateUpdate handler, and you start your connection by calling connection.start.