Skip to content

A network proxy server library that supports rewriting https packages

License

Notifications You must be signed in to change notification settings

hellohublot/HTSocket

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

HTSocket

HTSocket is a asynchronous network proxy server library that supports rewriting https packages, You can import the certificate, and then you can read the https packages on the iOS device, and you can rewrite the https package

Features

  • Support domain name resolution to ip address
  • Support simulated TCP TLS handshake
  • Support for UDP connections
  • Support HTTP packet automatic parsing
  • Support for reading and writing HTTPS request and response packets
  • Support logging to Console.app because it usually runs in Extension

Install

pod 'HTSocket', :git => 'https://github.com/hellohublot/HTSocket.git'

Usage

View Full Example

// tcp client
let socket = TCP.init(Address.init("www.baidu.com", 443))
self.socket = socket
socket.delegate = self
socket.connect()
socket.starttls()
socket.write("GET / HTTP/1.0\r\n\r\n".data(using: .ascii)!)

func didRead(socket: TCP, data: Data) {
    print("The message received from TCP\n\(String.init(data: data, encoding: .ascii) ?? "")")
}
// webProxy
let webProxy = WebProxy.init(Address.init("127.0.0.1", 9527))
self.webProxy = webProxy
webProxy.manager = self
webProxy.start()

func clientRead(data: Data, isheaderMessage: Bool, host: String, connectionIndex: Int) -> Data {
    print("The message received from client\n\(String.init(data: data, encoding: .ascii) ?? "")")
    return data
}

func remoteRead(data: Data, isheaderMessage: Bool, host: String, requestData: Data, connectionIndex: Int) -> Data {
    print("The message received from server (\(host))\n\(String.init(data: data, encoding: .ascii) ?? "")")
    return data
}

// Returns a tlspair if https is required, nil otherwise
tlspair.remotetls = TLS.init(validate: .require)
tlspair.clienttls = `A sub-certificate created based on the domain name to spoof the client`
func tlsHandShakeFromHost(_ host: String, connectionIndex: Int) -> TLSPair? {
	return nil
}

Contact

hellohublot, hublot@aliyun.com

About

A network proxy server library that supports rewriting https packages

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published