Building42 / Telegraph

Secure Web Server for iOS, tvOS and macOS

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Get client hostname when web socket connects to server

chajuss opened this issue · comments

Hi,

Is there a way to get the client hostname when it connects to the web socket server?

Thanks

@chajuss I've just released Telegraph 0.24. It adds endpoint information to the WebSocket protocol.
If you handle this delegate call on the Server, you can extract the client endpoint information:

public func server(_ server: Server, webSocketDidConnect webSocket: WebSocket, 
                   handshake: HTTPRequest) {
   let clientEndpoint = webSocket.remoteEndpoint
   let clientHost = clientEndpoint?.host
   let clientPort = clientEndpoint?.port
}

The new version is already available for Carthage and should be available for CocoaPods in a few minutes.

Feel free to reopen this if you run into any issues!