Permalink
Cannot retrieve contributors at this time
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
87 lines (66 sloc)
2.51 KB
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package module | |
import ( | |
"crypto/tls" | |
"encoding/hex" | |
"github.com/praetorian-inc/trudy/pipe" | |
"net" | |
) | |
//Data is a thin wrapper that provides metadata that may be useful when mangling bytes on the network. | |
type Data struct { | |
FromClient bool //FromClient is true is the data sent is coming from the client (the device you are proxying) | |
Bytes []byte //Bytes is a byte slice that contians the TCP data | |
TLSConfig *tls.Config //TLSConfig is a TLS server config that contains Trudy's TLS server certficiate. | |
ServerAddr net.Addr //ServerAddr is net.Addr of the server | |
ClientAddr net.Addr //ClientAddr is the net.Addr of the client (the device you are proxying) | |
} | |
//DoMangle will return true if Data needs to be sent to the Mangle function. | |
func (input Data) DoMangle() bool { | |
return true | |
} | |
//Mangle can modify/replace the Bytes values within the Data struct. This can | |
//be empty if no programmatic mangling needs to be done. | |
func (input *Data) Mangle() { | |
} | |
//Drop will return true if the Data needs to be dropped before going through | |
//the pipe. | |
func (input Data) Drop() bool { | |
return false | |
} | |
//PrettyPrint returns the string representation of the data. This string will | |
//be the value that is logged to the console. | |
func (input Data) PrettyPrint() string { | |
return hex.Dump(input.Bytes) | |
} | |
//DoPrint will return true if the PrettyPrinted version of the Data struct | |
//needs to be logged to the console. | |
func (input Data) DoPrint() bool { | |
return true | |
} | |
//DoIntercept returns true if data should be sent to the Trudy interceptor. | |
func (input Data) DoIntercept() bool { | |
return false | |
} | |
//Deserialize should replace the Data struct's Bytes with a deserialized bytes. | |
//For example, unpacking a HTTP/2 frame would be deserialization. | |
func (input *Data) Deserialize() { | |
} | |
//Serialize should replace the Data struct's Bytes with the serialized form of | |
//the bytes. The serialized bytes will be sent over the wire. | |
func (input *Data) Serialize() { | |
} | |
//BeforeWriteToClient is a function that will be called before data is sent to | |
//a client. | |
func (input *Data) BeforeWriteToClient(p pipe.Pipe) { | |
} | |
//AfterWriteToClient is a function that will be called after data is sent to | |
//a client. | |
func (input *Data) AfterWriteToClient(p pipe.Pipe) { | |
} | |
//BeforeWriteToServer is a function that will be called before data is sent to | |
//a server. | |
func (input *Data) BeforeWriteToServer(p pipe.Pipe) { | |
} | |
//AfterWriteToServer is a function that will be called after data is sent to | |
//a server. | |
func (input *Data) AfterWriteToServer(p pipe.Pipe) { | |
} |