S3 API for SMB File Share [closed] - c#

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 2 years ago.
Improve this question
I have a couple of machines in the house which each have varying amounts of disk space, and i would like to make these accessible via an S3 compatible API. I have found many tools that will convert S3 into an SMB file share or into a Windows/Linux/OSX drive, but nothing that does it the other way around.
Are there any examples of implementing an S3 compatible API that uses a disk or file share as a backing store? I am not too worried about redundancy (have already looked at OpenStack, but for my needs it seems over kill). I'm a .NET Dev, so C# code would be preferable, but even code in another language to see how to implement a compatible API may help.
[Clarification: I know lots of people are looking at moving their storage out of house and use S3 as one of the main storage systems, but some of our clients need the data stored in house due to legal reasons or speed issues. Implementing something that would use the same API for either S3 or an In-house system, backed by a SAN, would be handy.]

I found the following Java based project, s3proxy, which proxies S3 requests to a few different providers, file system included. I have not fully tried it out yet, but its a start to where i want to go, meaning i dont have to manage my own API and keys for storage...

I understand the reasons for you doing this but I urge caution.
Rather than using the S3 as an interface to storage in your application, I'd suggest that create an abstract API that will act as the interface to storage. In this way you can create any adaptor underneath that will connect to any sorge API you like - local disk/remote disk/db/S3/Azure etc etc.
This I believe is a better architectural pattern than the one you're proposing. The Beauty is many fold. The first is that you get your 'I don't care where storage is' code. The second is that you've freed yourself from the constraint OF S3 as you can add any feature you like on top of S3 without your code being affected. Another benefit is that you can probably find good pre written code for all the different stores you want to work with.

Related

Using JSON file as database in a ASP.NET App(C#) [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 5 months ago.
Improve this question
I am developing a light weight web app in ASP.NET with C# and I would like to store some data such as site analytics etc.
Instead of using a SQL server database could I use a JSON file instead? So I would open the JSON file and write into it when done. Could there be problems with simultaneous connection?
Is this standard/ common practice?
Any help will be highly appreciated.
It is probably a VERY bad idea. I would only do this if it was some text file to display a wee bit of information.
If you need updating? Then what happens if two users are on the site. The last person to update will over write the text based json file.
I suppose you could write out a "id" and json file for each record you edit, and that way a save of one record value would not over write others. But, putting more then one reocrd in a json file, and if users are to edit such values, then no, it will not work, since a simple save of that text json file will overwrite any other changes made by any other user who also happens to hit the same button.
It is VERY hard to find a web site hosting, even those for super cheap - less then $10 per month that does not include a database server system. And be it MySQL, SQL server, postgres sql and more? They all have free verisons you can use.
And I suppose you could consider the file based sqlLite. That would even be better. While it not considered thread safe, it can work if you only say have a a few users like 2-4 users working at the same time.
Because you have OH SO MANY choices here? The only reason to use a text based json file is if no other options exist - and boatloads of options exist in near all cases.
And if some database was not available? The I would simple include sqlLite in the project and use that.
I'm not super experienced but i would like to explain why i would never do that.
First of all everything (if you are brave enough) can be a database, as long as it is some kind of file that can give persistency to your data. Database are basically optimized one purpose software to store data. Mainly the problem in your solution is that you would need to read the file and load it in memory storing it as an object and then writing data to it like you would do with a static factory object and then serialise it back to JSON after you are don with it. Personally i don't like this idea because i think is very prone to human error (like deleting the file by accident during mantainance) and it can be hard-er to debug if it starts accumulating a sizeable chunk of data. There are very lightweight data persistency solutions that implements SQLite that is a database for small applications, like Pocket Base. Since you are already developing a backend it would require you near to no effort to add a little table to store the analytics.

How to Implement On the Fly Cryptography [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 6 years ago.
Improve this question
I'm working on a windows desktop application (WPF) written in C# that download some files from a server at each startup. These files play a huge role in making the application work.
I would like to protect the content of these files with some form of encryption such as AES. These files should remain encrypted even when they are read by the application. So I am looking for a way to decrypt the files on the fly when they are being accessed by the application. In other words, only the application could understand the files but if users open them with other programs, they will be encrypted still.
It would be great if you could share some ideas or articles about the implementations. Thanks!
Edit 1:
The application make use of CefSharp to browse the HTML/JS/CSS files that are downloaded from the server at each startup.
Edit 2: I'm trying to implement something like TrueCrypt.
Edit 3: I would like to how to do what TrueCrypt can do. It encrypts the files and the encrypted files can be opened by any program normally because it decrypts them on the fly whenever the file are opened. I need this because I want to protect the HTML/JS/CSS files loaded by my application's embedded browser (CefSharp).
You need to realize that you cannot prevent users from accessing your unprotected files on an open platform like the PC. That is what DRM tries to achieve for decades now, however this goal is unachievable by definition.
The only thing you can do is to make it harder / more cumbersome to access the unprotected files, however in the end, if someone decides to put enough effort into circumventing your protection, she or he will always succeed.
For instance, you may obfuscate your source files (by dedicated obfuscators or simply by minimizing them), you can use some non-standard file encoding (reverse of base64) or you may use some kind of encryption method. Because you need to ship your key as well, any encryption method will do, no matter how secure or insecure it is.
Finally, as others have already mentioned, the crypto primitives are located in the System.Security.Cryptography namespace. Note however that for security sensitive systems I would not recommend to use them directly, because there are many nuances and getting it right is actually quite hard. You should have a look at libraries like SecurityDriven.Inferno, which wrap the crypto primitives with secure defaults.
You should use the System.Security.Cryptography Namespace of the .NET-Framework.
Here and here you'll find two examples you can use.
Note: First, you have to read the content of the file AS BYTES[] using a FileStream or System.IO.File.ReadAllBytes. And you have to implement your KEY - which means it is hardcoded in your application and can be found using a decompiler!
So, it is almost impossible to prevent the user from reading the data.
As Thomas said, using System.Security.Cryptography is the best way to encrypt data. However you'll need to include the cryptography keys in the client application and it is very easy for anyone with access to this application to extract the keys.
You're probably better off not wasting your time encrypting the files.

Local Server for Gaming C# [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 6 years ago.
Improve this question
[C#] Hello all, I am curious on how I can go about creating my own local server and allowing people outside to connect an return data stored on it. I am not looking for an "XNA" solution. I would like to kind of digest the bare bones of client to server. Here is an outline for what I am looking for:
My PC
[Server] -> Constantly Updates/Receives Player data so it can be obtained by other PC's. Stores data from other clients.
[Client PC] -> Writes to server (Creates new player data/updates) and obtains further information to update visuals, other players, etc.
This isn't something small that anyone can just do, especially if you are just getting into programming. I would first start out small, make a few smaller applications, play around with the .NET framework libraries and get comfortable (I would specifically look at System.Net/System.Net.Sockets as well as possibly System.Security for SSL encryption). The networking component will be huge in this as you'll need to implement a system to handle the constant communication and be able to respond quickly (any lag can be seen as dropped packets from a networking standpoint and cause client time outs). You'll also want to think about what kind of data you are serving up (saved games, player data, whether it's personal information (such as passwords, email addresses, etc)) and how you are going to store that data. There are many paid and free technologies for this (Postgres, SQL, MySQL, etc). Please do a quick google on some of thee items I have mentioned and you'll see why it takes years to develop games and the back end systems to support multiplayer.
If you are the type of learner to plug things in and learn by tearing someone else's code apart, I would take a look at some of the articles below.
http://www.codeproject.com/Articles/1415/Introduction-to-TCP-client-server-in-C
http://csharp.net-informations.com/communications/csharp-multi-threaded-server-socket.htm
Here's some MSDN articles dissecting the different classes of the System.Net namespace and functions of it.
https://msdn.microsoft.com/en-us/library/system.net(v=vs.110).aspx
https://msdn.microsoft.com/en-us/library/system.net.sockets(v=vs.110).aspx
https://msdn.microsoft.com/en-us/library/system.security.cryptography(v=vs.110).aspx
https://msdn.microsoft.com/en-us/library/system.security.cryptography.x509certificates.x509certificate(v=vs.110).aspx
You'll also want to look at using threading to make sure the server isn't only processing one request at a time. There are many approaches to this but here is some basic examples of using threads.
http://www.dotnetperls.com/thread
When to use Multithread? (Some pointers how on and when to use threads on our very own S/O site :) ).
Here's the DL on threading from MSDN
https://msdn.microsoft.com/en-us/library/system.threading.thread(v=vs.110).aspx
Not meant to discourage you but more to show you the type of effort you'll have to put in to this sort of project. What you want to do is completely doable, but will require some brain training and head scratching. Apologies if it sound condescending, just trying to coach and am unsure of your level of expertise in c#! Best of luck to you though friend, hopefully this turns into a great learning experience!

Changing variable of an application from another application [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 8 years ago.
Improve this question
I have a question about changing an variable of an application from another application.
For example: If in 1.exe I have defined string a="a", how will I be able to change a="a" to a="b" by using another application?
Do I have to get the memory address of string and then change it's content to b? Or Is there any another easier way?
You can set up a shared resource for the two applications and read the values from there. It could, be a database, cache or even a simple text file.
Refresh the variables from the shared resource when appropriate.
Given the scenario you have mentioned (i.e. you do not control the code for the 1st application).. The general idea of opening the target process with admin privileges, finding the memory location you want to update, and then updating it applies..
However, be warned that it will generally not be that simple. For example,
It can be extremely hard to predict, how many copies, of the variable are maintained by the applications logic, and where?
Without disassembling the code (no way a trivial task.. none of this is), scanning for the value and guessing the memory location is the only option which comes to mind. But it has the risk of making wrong guesses, and corrupting the entire process.
PS - There are freely available software, which attempt to do exactly what I've described above.. I'd advise that you try to examine how they work (scenarios they support), to get better idea of what you are trying to accomplish.
PPS - Also be careful what you download.. Applications like these, if downloaded from un-reliable sites, can be damaging / security risk.
I think the easiest way is communication with network sockets in localhost via UDP or TCP. It gives you a good event mechanism so you can easily handle your data without checking the new data changes frequently, also will be doesn't matter how amount of application communicating each other in same time. Other solutions like shared memory etc. will be hard to control especially when you running three and more apps.

Developing a program that serves as a web program in C# [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 8 years ago.
Improve this question
I'm not sure if I'm going to be able to explain it right since I'm quite sure I don't know the correct terminology involved with it, which is also why I'm having a difficult time Googling for answers.
Essentially, I'm looking to develop a program that serves as a web site. It'll run constantly (like a service) and will return HTML when an outside user sends an HTTP request thru a browser or similar to a specific port on the computer this program runs on. Basically, this program will perform various background errands throughout the day but I want to be able to expose a web front end (almost like how you would with standard WinForms, but I want to be able to access it remotely) to be able to configure it, check the status of tasks, and otherwise interact with it.
I'm looking to use .Net, but I'm open to using something more universal like Java too. Someone with experience in this area would be helpful to explain any pain points you've encountered and suggestions on how to get started.
You can do it in C# with the HttpListener class.
I published an example some time back. See A Simple Http Server.
Although you might consider whether you really want to operate at that low level. I have written a fairly complex server based on HttpListener, and if I had it to do over again I'd probably just bite the bullet and use ASP.NET. There is a bit of a learning curve, but unless your server is incredibly small and simple, an ASP.NET application will be a lot easier to write and will likely be more robust.
Here is a simple example on how to do it in C# using the HttpServer class:
http://www.codeproject.com/Articles/137979/Simple-HTTP-Server-in-C
You are doing at least 2 different things, so you should probably create a Solution in Visual Studio.NET with one project for each purpose (You can have many projects in a solution), probably with at least one Data Access project as well (of type Class Library). If the solution does things at certain times of the day, then those can be Console Applications that run through task scheduler, rather than one of more services. Services are better suited to things other than simple scheduled tasks. A Web Application project can serve up your html.

Categories