Uploading/Download (server/client both created wit - WeOnlyDo Discussion board

Uploading/Download (server/client both created wit (General questions)

by Dennis, Friday, December 17, 2004, 07:51 (7280 days ago)

Hi,

I just started trying out the evalution copys of SSH and SSHServer.
The resond for that was to see how easy it would be to creat a Secure Transfer server/client with WOD's components.

My ideas is to first implement some basic stuff like logging on, listing online users, send/recv messages, listing files on the server and then downloading files.

My problem comes at downloading/uploading files from and to the server.
I couldn't see a single demo that shows how to do this sadly enough and I hoped you guys could help me out.

I'm using VB6 as the enviroment.

Any help/pointers would be appreciated.

Cheers,

Dennis

Re: Uploading/Download (server/client both created

by wodSupport, Friday, December 17, 2004, 10:28 (7280 days ago) @ Dennis

Dennis,

My problem comes at downloading/uploading files from and to the server.
I couldn't see a single demo that shows how to do this sadly enough and I hoped you guys could help me out.

you need file-transfer component for the client side too. I suggest you try out wodSFTP, it will do file transfers for you.

Regards,
Kreso

Re: Uploading/Download (server/client both created

by Dennis, Friday, December 17, 2004, 19:00 (7279 days ago) @ wodSupport

Dennis,

you need file-transfer component for the client side too. I suggest you try out wodSFTP, it will do file transfers for you.

Regards,
Kreso

Thx for the fast reply.

I tried wodSFTP, great component.
But after doing some coding, I realized I can't let the client do ANYTHING during file transfer due to the fact that it will packet integrity.

And the info SSHD1_RECIEVED said I cannot use any custom code in there.. that makes it impossible to extend the protocol for my needs (online users, send messages and such)

Is there anyway to get around this with your components or do I need to look for other components/ways to do this?


Basically what I need is to create a secure servers that allowed people to login, get a list of online users, gets the servers file list, Upload/Download files, send private messages.
And I need to be able to upload/download files without interfering or locking the client during the transfer.

This will be an application for our students to talk to teachers/eachother while uploading and downloading work on our Intranet.. so it doesn't need to be fancy.. but some files are 1Gb plus and at high load they might get 100KB/sec.. can't have the client locked for that long.. so it's a must that they can chat while downloading.

Cheers,
Dennis

Re: Uploading/Download (server/client both created

by wodSupport, Friday, December 17, 2004, 19:44 (7279 days ago) @ Dennis

I agree - you cannot do anything while transfer is in progress. But - you can use another instance (or other component, such as wodSSH) at the same time and it will not intefere with the transfer.

Re: Uploading/Download (server/client both created

by Dennis, Friday, December 17, 2004, 21:01 (7279 days ago) @ wodSupport

I agree - you cannot do anything while transfer is in progress. But - you can use another instance (or other component, such as wodSSH) at the same time and it will not intefere with the transfer.

Yeah I thought about that but I couldn't see how that could be done without requireing dual logins.
I'd have to login with both the wodSSH component aswell as the wofSFTP component.
And I would have to run them on different ports aswell.

If you or someone else have any pointers/tips on how to do this I would greatly appreciate the help.

Cheers,
Dennis

Re: Uploading/Download (server/client both created

by wodSupport, Friday, December 17, 2004, 21:11 (7279 days ago) @ Dennis

Dual login, yes. Different ports - why? I don't understand that one.

Re: Uploading/Download (server/client both created

by Dennis, Friday, December 17, 2004, 22:02 (7279 days ago) @ wodSupport

Dual login, yes. Different ports - why? I don't understand that one.

Well, the resond for that is because dual logins would render the program useless.
The client needs to see a userlist and have the ability to send private messages to other users on the server.
If people are logged on with dual logins, you wouldn't know what user to send a message to.

There for the server would have to listen on two ports, one for wodSSH (the component used by the client to do Users Online listnings, private messages and such) and the other port for filetransfer.

That way one could seperate the two and only list the wodSSH online clients.

I guess that's pretty much like an FTP server using so called DataPorts (sending data through a port range to the client, like glftpd for an example).

So, as I see it, I'll be forced to do dual logins, dual ports for it to work with the wod components.

/Dennis

Re: Uploading/Download (server/client both created

by wodSupport, Friday, December 17, 2004, 22:14 (7279 days ago) @ Dennis

Dennis,

I am not sure here - so please check this out. It is questionable if 'login' is same as 'session'. Perhaps when wodSFTP is used you don't see him on userlist - since he didn't actually start the console.

How will you look for connected users? Using 'finger' or 'who' perhaps? Can't you just silently ignore users not using specific tty(s)?

Re: Uploading/Download (server/client both created

by Dennis, Friday, December 17, 2004, 23:25 (7279 days ago) @ wodSupport

Dennis,

I am not sure here - so please check this out. It is questionable if 'login' is same as 'session'. Perhaps when wodSFTP is used you don't see him on userlist - since he didn't actually start the console.

How will you look for connected users? Using 'finger' or 'who' perhaps? Can't you just silently ignore users not using specific tty(s)?


Well, I tried logging in with both the SSH and SFTP from the same client and both logins will be visible in the server.

I will be doing something like this to get and send the userlist to a client requesting it:

[code]Dim x as Long
Dim UserList as String

For x = 0 to Users.Count - 1
UserList = UserList & Users.Item(x).Login & vbcrlf
Next x
User.Send UserList[/code]

But I thought of something that MIGHT, work, you could give me an opnion on this one.

When someone logson with the wodSFTP component, I can have it send a tag infront of the username, like  ›down:

Upon connecting to the server, I'll do this:

[code]
If Left(Login, 6) = ›down: Login = Right(Login, Len(Login) - 6) = joe And Password = joe Then
Login = ›Download
Action = Allow
ElseIf Login = joe and Password = joe then
Action = Allow
Else
Action = Deny
End If
User.HomeDir = c:program files [/code]

Above we check for the wodSFTP tag, if it excists, we rename the Login to download to keep track of it as a downloading client. (not the › character, to make sure no one can make a login like that).
We can do the same for uploads.

No, when someone requests, the UserList, we jsut do this:

[code]Dim x as Long
Dim UserList as String

For x = 0 to Users.Count - 1
If not Users.Item(x).Login = ›Download then
UserList = UserList & Users.Item(x).Login & vbcrlf
End If
Next x
User.Send UserList[/code]

We can do the same thing for uploads I guess.

And with this trick we could also see information about a user, what he's doing right now, by removing If not in the UserList code, and checking ip on each userdownloading, comparing it to the user we want info about, and we can see if he/she is uploading/downloading.

Any ideas? Does it look like it could work?

Cheers,

Dennis

Re: Uploading/Download (server/client both created

by wodSupport, Friday, December 17, 2004, 23:39 (7279 days ago) @ Dennis

I think there's no need to use such special tags in Login property. You can use User.Service property. It tells you exactly what user is doing (in respect to the service he uses). Why don't you use that one?

Re: Uploading/Download (server/client both created

by Dennis, Saturday, December 18, 2004, 00:09 (7279 days ago) @ wodSupport

I think there's no need to use such special tags in Login property. You can use User.Service property. It tells you exactly what user is doing (in respect to the service he uses). Why don't you use that one?

Thanks for that info.
I'm just trying to discover all the functions in the components.. have to dig though the Help files since the samples included only give at very best the most simple ideas on how to perform stuff.

One thing still puzzles me though.
I'm using the SFTP Server sample as a model for the server I'll be using for this project since it handles uploads/downloads automaticaly.
But in the code it says this:

[code]
Private Sub SSHD1_Received(ByVal User As wodSSHDComLIB.ISSHUser, ByVal ServiceIndex As Long, ByVal BytesCount As Long)
' you can NOT put anything here for SFTP connections

' even more, don't try to use Send method !!!
' if you do so, you will interfere with packet integrity!
End Sub[/code]

If I can't recieve or send data to the client, how would I go about sending/recieving commands like for the 'UserList' and such?


Again, a BIG thanks for the great support and speedy replies I recieved so far. Great support on this forum.

/Dennis

Re: Uploading/Download (server/client both created

by wodSupport, Saturday, December 18, 2004, 00:22 (7279 days ago) @ Dennis

One thing still puzzles me though.
I'm using the SFTP Server sample as a model for the server I'll be using for this project since it handles uploads/downloads automaticaly.
But in the code it says this:

[code]
Private Sub SSHD1_Received(ByVal User As wodSSHDComLIB.ISSHUser, ByVal ServiceIndex As Long, ByVal BytesCount As Long)
' you can NOT put anything here for SFTP connections

' even more, don't try to use Send method !!!
' if you do so, you will interfere with packet integrity!
End Sub[/code]

If I can't recieve or send data to the client, how would I go about sending/recieving commands like for the 'UserList' and such?

You don't have to deal with SFTP related server stuff. wodSSHServer deals with it - you just have to allow/deny actions in corresponding events.

And, since SFTP is protocol that runs on top of encrypted SSH layer - trying User.Send would send raw data on that SSH layer. Client would be confused, since it received packets which he thinks are SFTP packets (and are not), and would probably drop connection since he wouldn't understand them.

Hope it helps.

Re: Uploading/Download (server/client both created

by Dennis, Saturday, December 18, 2004, 00:53 (7279 days ago) @ wodSupport


You don't have to deal with SFTP related server stuff. wodSSHServer deals with it - you just have to allow/deny actions in corresponding events.

And, since SFTP is protocol that runs on top of encrypted SSH layer - trying User.Send would send raw data on that SSH layer. Client would be confused, since it received packets which he thinks are SFTP packets (and are not), and would probably drop connection since he wouldn't understand them.

Hope it helps.

I'm not sure if we're missunderstanding eachother here or if I'm getting totally lost.

The server I'm building needs to be able to do more then a FTP (that is list online users, send private messages and such), aswell as uploading/downloading files.
There for I MUST be able to let the client and server speak with eachother using my own protocol.

The only sample included that could upload/download files was the SFTP sample.
So in order for me to be able to give my users the ability to upload/download I take it I have to use this:

[code]Private Sub SSHD1_ServiceRequest(ByVal User As wodSSHDComLIB.ISSHUser, ByVal ServiceIndex As Long, ServiceType As wodSSHDComLIB.SSHServiceTypes, ServicePath As String, Action As wodSSHDComLIB.SSHActions)
If ServiceType <> stSubsystem Then Action = Deny
End Sub[/code]

Am I right?
And if I do so, I can no longer take control over the data sent to/from the client.

Since I haven't seen any information or samples on how to run different services on the same component I take it you can't do it.
But if one can.. I really could you some help on that.

To sum thing up, here's what I'm trying to do:

Client:
Upload/Download Files without locking the software.
The Ability to list remote files.
The ability to list online users.
The ability to send pm's to users.

In other words, being able to perform tasks while down/up -loading.

Server:
The ability to send/recieve files from users
The ability to send online user list.
The ability to send file list.
The ability to take input from the client like UserList, PrivateMessages and sent em to the target user.


I'm having a hard time doing this.
The client part, I think we figured out how that could be done by using 2 of your components.

But the servers is another deal.. cause I'm not sure how I can both use it to send/rec. files and still being able to recieve/send data to users.

Should I work with one of the others samples provided in the package?
Or could I use some other ServiceType so I still can work with wodSSHD1_Received to perform additional tasks?

Cheers,

Dennis

Re: Uploading/Download (server/client both created

by wodSupport, Saturday, December 18, 2004, 00:56 (7279 days ago) @ Dennis

You can make requirement that ServiceType = Shell (or None) must be connected first. Then you can use your own protocol for communication between server and the client. When client wants to upload/download file, it will just open new connection (using same login/pass) download/upload, and disconnect. If you need to notify it somehow during this transfer, you could send notification packet through first (wodSSH) connection, and your client app could close second (wodSFTP) immediately if needed.

Does this make sense?

Re: Uploading/Download (server/client both created

by Dennis, Saturday, December 18, 2004, 01:04 (7279 days ago) @ wodSupport

You can make requirement that ServiceType = Shell (or None) must be connected first. Then you can use your own protocol for communication between server and the client. When client wants to upload/download file, it will just open new connection (using same login/pass) download/upload, and disconnect. If you need to notify it somehow during this transfer, you could send notification packet through first (wodSSH) connection, and your client app could close second (wodSFTP) immediately if needed.

Does this make sense?

Ahh, that's a nice one, thank you.
I'll do some testing on that approach tonight and I'll let you off the hook.
You answerd more than enough for one day. :)

THank you very much for your support.
I'll be back tomorrow and tell you how it goes. :)

/Dennis