How to config socks proxy in Java NIO

烂漫一生 提交于 2019-12-03 09:48:49

This is seriously difficult. I wrote an SSLSocketChannel class some years ago and I ended up having to write my own SSLSelectorProvider, SSLSelector, and SSLSelectionKey classes as well. You can't just add a SocketChannel-derived class into the existing infrastructure: it is specifically designed to prevent it.

EJP is right, this is hard stuff. You can use a dirty trick to register the OPs to the original SocketChannel and then swap the channel on-the-fly to your own implementation once the OPs are triggered. But the correct approach is to write your own SelectorProvider, Selector and SelectionKey which will make you seriously consider using stunnel for SSL if you can.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!