Giter VIP home page Giter VIP logo

Comments (24)

stuicey avatar stuicey commented on May 23, 2024

If you don't want to use wsProxy/node you can make the following modifications to the code as suggested in #4

This would enable you to use websocket proxies that operate via binary blobs ( such as websockify ). You may have issues multiplexing your connection to multiple SSH servers though unless your chosen websocket proxy also supports target servers in the URI.

e.g.
ws://${websocket_proxy}:${port}/${SSH_server}:${SSH_port}

These changes would be done in index.html or wrapper.html

// Opens the websocket!
ws = new WebSocket(wsproxyURL);
ws.binaryType = "arraybuffer";

// Send all recieved messages to SSHyClient.Transport.handle()
ws.onmessage = function(e) {
	// ArrayBuffer to String
	var enc = new TextDecoder("utf-8");
	var clearMessage = enc.decode(e.data);
	console.log(clearMessage);
	transport.parceler.handle(clearMessage);
};

ws.sendB64 = function(e){
	var enc = new TextEncoder();
	this.send(enc.encode(e)); // String to ArrayBuffer conversion
	console.log("sendB64", e);
	
	transport.parceler.transmitData += e.length;
	transport.settings.setNetTraffic(transport.parceler.transmitData, false);
};

from sshy.

kidygetnada avatar kidygetnada commented on May 23, 2024

Thanks for a quick reply.. So I just need to add this or also remove something?

from sshy.

kidygetnada avatar kidygetnada commented on May 23, 2024

The idea is just to connect to localhost:22

from sshy.

stuicey avatar stuicey commented on May 23, 2024

Would be replacing websocket definition & the onmessage() / sendB64() functions which are around here:

https://github.com/stuicey/SSHy/blob/master/index.html#L221
https://github.com/stuicey/SSHy/blob/master/index.html#L232
https://github.com/stuicey/SSHy/blob/master/index.html#L258

from sshy.

kidygetnada avatar kidygetnada commented on May 23, 2024

Uncaught TypeError: Cannot set property 'onopen' of undefined
at startSSHy (wrapper.html:226)
at HTMLInputElement.onclick (wrapper.html:491)

from sshy.

stuicey avatar stuicey commented on May 23, 2024

If you're using the wrapper you'll need to modify this in SSHyClient.js and rebuild the min files (instructions in readme).

from sshy.

kidygetnada avatar kidygetnada commented on May 23, 2024

i am actually using index.html, but I copied a modified code as per your instructions to wrapper.html... It's still throwing errors

from sshy.

stuicey avatar stuicey commented on May 23, 2024

What browser are you using? and can you check what websocket proxy URL is being passed to the function? console.log(wsproxyURL) just before ws = new WebSocket(wsproxyURL);

from sshy.

kidygetnada avatar kidygetnada commented on May 23, 2024

I am using the latest Chrome.. Even when adding that I don't see anything else in the console but this:

Uncaught TypeError: Cannot set property 'onopen' of undefined
at startSSHy (wrapper.html:226)
at HTMLInputElement.onclick (wrapper.html:492)

from sshy.

stuicey avatar stuicey commented on May 23, 2024

That doesn't sound right, if you're not getting any logs out for a wsproxyURL it suggests its not set which would be why the websocket connection can't open.

Do you have your console sidebar configured to only show errors?

from sshy.

kidygetnada avatar kidygetnada commented on May 23, 2024

No, it's showing everything.. It's not showing anything, because it's within function startSSHy(), which is not starting

from sshy.

stuicey avatar stuicey commented on May 23, 2024

The stack trace indicates that the startSSHy function does start and crashes when trying to set ws.onopen. If you've replaced the code that was there with the modified version provided at the top of this chain then this shouldn't happen.

Do you want to attach the file and I'll have a look?

from sshy.

kidygetnada avatar kidygetnada commented on May 23, 2024

Sure..
https://jsfiddle.net/3umdx2nh/

from sshy.

stuicey avatar stuicey commented on May 23, 2024

You've added that code block in after ws.onopen so it will be erroring as it hasn't set ws to anything at that stage.

from sshy.

kidygetnada avatar kidygetnada commented on May 23, 2024

Thanks, I moved it up at this point.. But now I get this error:

wrapper.html:238 WebSocket connection to 'ws://localhost:5999/localhost:22' failed: Error in connection establishment: net::ERR_CONNECTION_REFUSED

from sshy.

kidygetnada avatar kidygetnada commented on May 23, 2024

image

from sshy.

kidygetnada avatar kidygetnada commented on May 23, 2024

https://jsfiddle.net/yo43fc7w/

from sshy.

stuicey avatar stuicey commented on May 23, 2024

You'll need to change how the wsproxy URL is generated and set the new proxy URL appropriately.

Currently it expects the proxy to be on either port 5999(ws://) or 6001(wss://). Additionally it appends the IP/port of your target to the uri. This likely won't work with other websocket proxies so you will need to configure this yourself based on whatever proxy you choose.

from sshy.

OoLunar avatar OoLunar commented on May 23, 2024

Well y'all are a lot closer to SSHing online than I am. My page keeps trying to connect to:

WebSocket connection to 'wss://wss//ebdev:6001/:6001/' failed: Error in connection establishment: net::ERR_NAME_NOT_RESOLVED

I'm not even sure how that happened...

Edit:
I do believe that the "ebdev:6001" is referencing my user account, webdev

from sshy.

stuicey avatar stuicey commented on May 23, 2024

You probably set the full webproxy url as wsProxyURL at the top. You'll need to modify or remove the buildWSProxyURL() function.

https://github.com/stuicey/SSHy/blob/master/index.html#L74

This function constructs the URL in the form:
$protocol://$websocketProxy:$websocketURL/$SSHServer:$SshPort

from sshy.

OoLunar avatar OoLunar commented on May 23, 2024
WebSocket connection to 'wss://ebdev:6001/' failed: Error in connection establishment: net::ERR_NAME_NOT_RESOLVED

Progress... I downloaded the latest commit, and I haven't touched anything either. Not quite sure if something else is wrong, or if I missed a step. Sorry if I'm being a difficult.

from sshy.

OoLunar avatar OoLunar commented on May 23, 2024

Debugging through Chrome, and it seems to be complaining about this...

ws = new WebSocket(wsproxyURL); //PROBLEM ACCORDING TO CHROME
ws.binaryType = "arraybuffer";

// Send all recieved messages to SSHyClient.Transport.handle()
ws.onmessage = function(e) {
	// ArrayBuffer to String
	var enc = new TextDecoder("utf-8");
	var clearMessage = enc.decode(e.data);
	console.log(clearMessage);
	transport.parceler.handle(clearMessage);
};

ws.sendB64 = function(e){
	var enc = new TextEncoder();
	this.send(enc.encode(e)); // String to ArrayBuffer conversion
	console.log("sendB64", e);

from sshy.

stuicey avatar stuicey commented on May 23, 2024

The error suggests it can't resolve the domain name ebdev. Have you configured a custom DNS or setup the IP for this in your hosts file?

from sshy.

OoLunar avatar OoLunar commented on May 23, 2024

Hosts file? The only time I've touched that is to just setup my main domain. Unless if there is a hosts file in this project that I am unaware of, I have not.

from sshy.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.