porting of https://github.com/mhzed/wstunnel for nodejs