Is it possible to emulate an ftp server? - c#

We have devices that can sync their data with an ftp server.
Each device should contain their own set of data (video files).
We do not want to duplicate this data for each device.
I was thinking along the lines of faking the ftp file list repsonse and rerouting each file request to another location using something similar to an httphandler. This way we only have to host our video files on one location and each device will still be able to get their own "set".
sftp is a "should have" for this scenario.
I tried searching anything along the lines of "ftp handler" but have not come up with any helpful results.

SUSE used to have a product (not written in C# though, and only for Linux) that does exactly what you want, the now abandoned Proxy Suite. I can confirm it works but I was never satisfied with its performance. Check it out, it might at least give you some ideas to work with should you want to develop such a contraption yourself.

Is it possible to emulate an ftp server?
No, it is not.
I was thinking along the lines of faking the ftp file list repsonse and rerouting each file request to another
location using something similar to an httphandler.
Do it.
Te problem is that this is not "faking", your server IS a FTP server implementing the FTP protocol. A "Fake" is impossible logically - either you implement the protocol, then you are a FTP server, or you do not, then you are not.
I tried searching anything along the lines of "ftp handler" but have not come up with any helpful results.
Google for "rfc ftp" and take it from there. That is RFC 959 and likely a dozen other ones. http://de.wikipedia.org/wiki/File_Transfer_Protocol lists 5 relevant RFC - 959, 1579, 2228, 2428 and 2640.
Alternatively looking for a programmable proxy may work - it is not that common, though, people seem to use HTTP more these days for file transfer, or system intrinsic protocols that have other features.

Related

How to detect if connecting client was modified (Server: C#, Client: AS3)

Sorry, tried looking for existing thread, lucked out.
Just curious if anyone has tactics to protect a vulnerable game client that basically all anyone has to do is use a flash decompiler to modify hacks into it. Does anyone know how I can upload the "legit" Flash client online and then people can ONLY connect to it by playing on the website its uploaded to, or by using the URL inside of flash projector? If they download the client and try to load it as a file then it rejects, i think its called a "domain lock" or something like that. Or if I can figure out a way for the client to be uploaded to my site, but IMPOSSIBLE to download off of it (like they cant just press CTRL+S and save the file to their desktop), that would be cool too.
Or if anyone has other suggestions involving hardcode to be placed into the C# server or the AS3 client.
Just please help if you can, most likely with that first part of the paragraph, that part seems like a solid plan, as long as they cant download the client, they cant modify it so then I wouldnt even have to care if they can connect or not.
You're focusing on the wrong problem.
You can do a number of things to make life difficult for someone trying to use an unauthorized client. You could, for example, embed a cryptographic one-time use token in the client that's good only for a given session and make the client encrypt any communication with the server with it- until the person designs a mod that downloads the client every time and extracts the token.
You can use javascript to try and make it non-trivial to download the client- until the user writes a Tampermonkey script that disables your protections.
Ultimately, if the code is running client-side there is literally nothing you can do to completely guarantee a determined actor won't be modifying it or even building their own client to connect to your servers. What you should be doing instead is working on your server code to detect actions that an unmodified client would never send. Treat all clients as untrustworthy and validate the data you're receiving from them. Assume your server is going to be receiving inputs that are completely unreasonable and handle edge cases accordingly. (Also, don't immediately assume the unreasonable inputs you receive are deliberate cheating- they could just as easily be the result of bugs in the client or even faulty hardware on the user's end.)

Access video on secured FTP Site for streaming

I have a situation where videos reside on an FTP server, and I need to stream them through my Website Project.
Using a very crude method of including the FTP username and password in the URL, I can just drop the formed URL in as a link in the HTML video player.
http(s)://username:password#server
I am a bit stuck on how to proceed with consuming the video from this remote secured FTP site. There is no web server running to "serve" the videos over http. It is a dedicated FTP server.
Initially, I have played around with making a physical FTP connection from code, but the streaming seemed to be a problem using this method. I just temporarily used the URL authentication method, and it is time to revisit.
Unfortunately, I do not have the original code where I attempted to make the FTP connection through code.
I need to re-visit this, and would like some input before I proceed.
Video streaming is quite a specialist area, especially if you want to use techniques like Adaptive Bit Rate streaming (ABR - see note below) to give your users the best possible user experience.
Given this I think the best approach might be for your to FTP the videos to a streaming server where they can be prepared and made available for streaming properly.
There are open source and commercial streaming servers available, some cloud SaaS based, which means you don't have to invent and develop all this yourself. Some examples are:
https://gstreamer.freedesktop.org (opensource)
https://www.wowza.com (commercial with free trial)
Note: ABR - this essential means you have multiple versions of your video available on the server. Each is a different bit rate, and all are broken into (for example) 10 second chunks. The client requests the next chunk of the video from whatever is the most appropriate bit rate for the current network conditions. Many clients will also request a low bit rate to start the video to ensure a quick start and then 'step up' through the bit rates to the most appropriate one. You can see this when you start a new video on sites like Netflix etc.

Send and receive a file using .NET WebClient or related objects

First of all, I'm completely open to suggestions for alternative strategies, since this is not a space I'm hugely familiar with.
I have what I think is a simple problem. I have a client app and a server app, and I want to send a bunch of files from the client to the server. I don't want to require the user to set up file shares or anything, so my thinking was:
I'll have an app on the "server" using HttpListener to listen to file transfer requests from the client.
I'll have an app on the client using WebClient.UploadFile to initiate the transfers.
Twist: The server is a Mac, and I need to use things that are supported by Mono. I'm not looking to have the server install ASP.NET / IIS / whatever. In fact, the less the user has to do, the better. (The user in this case will be in control of both the client and the server, by the way.)
So, short questions:
Is there a better/easier way than WebClient/HttpListener to send a bunch of files from one machine on a LAN to another? TCP-something? Sockets-something-or-other? (You can see my ignorance.)
Assuming I use HTTP, are there more straightforward ways to download files than using an HttpListener and manually parsing the requests to get rid of headers, etc.?

Question about C#, servers, XML

So I'm working on a project for my internship and have hit a bit of a brick wall. Unfortunately, the only people I know who are qualified to help me at the office are on vacation at the moment, and Google has been unfortunately unhelpful (or my search skills inadequate), so I thought I'd ask here.
The project is basically to make a server to mimic one that the company (which makes phone apps) already has. What I need to do is have one of their apps send a request to my server (I will have to modify the app to do this, but don't know how), and have my server reply with an XML response that the app already knows how to process. (The main purpose is so that we can see how the app responds when the real server sends it an error by simulating it on my server.)
Now, I already have a few sample HTTP requests and their associated XML responses handy, taken from simulations with the app and the real server. The app is written in C#, and currently sends HTTP web requests to the real server's online location, which responds to these HTTP web requests with XML. My server, however, will not have an online location, so the app will have to be modified to work with sockets on a local host.
My questions:
1) My boss said to create an XML file to associate certain requests with certain XML responses, but I have no idea what he means or how to do this. (He said it could also be done with a .ini file.) Does anyone know?
2) Once I have this XML file that can make these associations, how can I incorporate it into my server so that my server can check the request it received against its table of valid requests and figure out which response to send back?
3) How can one modify the app from using HTTP web requests and responses to using sockets?
If you have any questions/clarifications that you need in order to better answer this, please don't hesitate to ask me.
Thanks!
What you're describing is a web service. Unfortunately, his advice to change a setting in an .ini file make it sound like they have a proprietary system for doing this, rather than using a standard ASMX (which requires IIS) or WCF (which can either run in IIS or as a standalone service, which it sounds like is what you'd want) service.
Without more information about what they're using, I don't know that you'll be able to get much help here.
In response to question #3:
HTTP is a protocol that already runs on a specific socket (normally using port 80).
An internet socket is an endpoint that is used to transport data between processes. If you want to run your own protocol, you will need to create a new socket (with TCP or UDP) on a specific port.
This will however require you to create your own client and server in order to exchange data between them.
To get started, here is a very simple client-server example in C# using a custom socket.
Good luck!
Ask your boss if this client communicates with soap, if so then just go to MSDN and find tutorials on implementing an ASMX webservice, follow the tutorial through and you'll have a shell to start with.
First I'd like to say that it sounds like you have some unclear requirements that you should probably clarify with your boss. If you're not exactly sure what he means you should find out because nothing sucks more than having to support someone's creative interpretation of requirements.
1) It sounds like your boss just wants a way to easily change associations for testing without having to rebuild the app so he's asking you to store those associations in an xml/ini file that can easily be modified. In c# you can easily go between XML and DataSet objects so this should be trivial. I would create the data structure in a DataSet first and then use the GetXml method of the DataSet to output the xml format.
2) In .NET you can store objects in Cache and create a Cache Dependency that is a file association. Thus whenever the file is modified the Cache is purged. Whenever your program handles a request it pulls the object from Cache, if the object isn't in Cache then you have a condition block rebuild it from the xml/ini file on disk. I would have that condition block call out to a function that then loads the above mentioned xml format into a dataset that is then stored in the Cache with a Cache Dependency.
3) If you are trying to test an applications i/o, modifying it to use a different transport layer sounds like a bad idea. If the app currently works over HTTP to send requests then just route the HTTP request. I would suspect that the app probably has a configuration somewhere defining the path of the webservice it currently calls out to, once you know what that path is you can either change it, or if that's not possible setup a DNS rule on the server running the app to route it to the location of your application. On windows this is as simple as adding a line to the hosts file.

Available options for hosting FTP server in .NET application

I need to implement an FTP service inside my .NET application (running as a Windows Service) and have not had much luck finding good/current source code or vendors. Ideally it needs to be able to respond to the basic FTP Protocol and accept the data stream from an upload via a stream, enabling me to process the data as it is being received (think on the fly hashing).
I need to be able to integrate it into my service because it will stack on top of our current code base with an existing custom TCP/IP communication protocol. I don't want to write (and then spend time debugging and performance testing) my own protocol, or implementation.
I have already found plenty of ftp client implementations, I just need an acceptable server solution.
There is an article about rolling your own FTP server in C# here. It's a bit old, but it might be complete enough for your requirements.
If you can get away from the need to process inbound data on-the-fly, I'd suggest just using an off-the-shelf FTP server (maybe even IIS), and process the received files from a folder. Your service could easily monitor this folder for new files. The other benefit of this is that files could be received even if your service is not running or restarting, and testing would be easier as you can drop your own files into the monitored folder.
Good luck!
Hope you find RemObjects free IP nice to use,
http://www.remobjects.com/ip.aspx
After installation you will see the samples.

Categories

Resources