Jump to content




[1.3+?] Rednet Database Server - Now Supports Guest Access!

wireless networking utility

24 replies to this topic

#1 KillaVanilla

  • Members
  • 303 posts

Posted 20 October 2012 - 02:13 AM

Hello all.

This program can store files in a "database", with a set of commands. However, there is a major difference between your typical "FTP" server and this: Each "commit", or file change, is logged and can be undone/rolled back. This server also supports authentication, so only trusted users can modify your database.
All commands are sent to the server in the form of a table, like so:
{sCommand, vParameter1, vParameter2, ...}

Commands:
  • "login" - Allows a client to modify the database, provided a correct username/password combination is provided. Only parameters needed are the username/password combination.
  • "logout" - Prevents a client from modifying the database until he/she logs back in. This requires no parameters.
  • "commit" - Sends a file to the server for storage. These are logged and can be undone. Parameters are the file's name, the data to store on the file, and an optional commit message.
  • "delete" - Deletes a file from the server. Can be undone. Parameters are the file's name.
  • "undo" or "revert" - Rolls back changes to a specific commit ID (see below). Parameters are the file's name and the commit ID to revert to.
  • "list_commits" - Sends a list of commits and associated changes for a file to the client. The only parameter needed is the file's name.
  • "read" - Retrieves a file from the database. The only parameter needed is the file's name.
  • "list" - Retrieves a list of files in the current branch.
  • "switch" - Switches to another branch (that doesn't need to exist). Only parameter needed is the branch name.
  • "clone_branch" or "copy_branch" - Copies the current branch's to form a new branch, which must not exist. Only parameter needed is the new branch's name.
  • "pastebin_get" - Downloads a file from Pastebin. Parameters needed are the paste's code, and the filename.
  • "github_get" - Downloads a file from Github. Parameters needed are the file to download to, the owner of the repository, the repository's name, the branch to download from (usually "master"), and the file's name in the repository.
How To Set Up:
  • Download the server. Ensure that the HTTP API is enabled.

  • Run the server software, but immediately terminate it as soon as it reports that it has "Found ARC4 Cipher".

  • You should see a few new folders and a new file named "newUser".

  • Run newUser like so: "newUser <user_name> <password>" for everyone who can access the database.

  • Run "dbServ".
How to use the Client:
First, keep these things in mind:
  • Any files you download will be placed in the current directory.
  • You need to run the database software like this:
    db <server> <action> <parameters>
    
  • You may need to log in multiple times, because the server software automatically logs you out after 15 minutes.
  • All actions are performed in the current branch.
  • If the server has guest read-only access enabled, then you don't need to log in to use "list" and "read".
Now, to log in to a server, do this:
db <server> login <username> <password>

To list files in your current branch, do this:
db <server> list

To send files to the server, do this:
db <server> sendfile <path/to/local/file> <name of file on the server> <commit_message>

To just put raw data into a file on the server, do this:
db <server> commit <file> <data> <commit_message>

To revert to a commit:
db <server> undo <file> <commitID>

To get files from the server, run this:
db <server> read <file>

Deleting files is done similarly:
db <server> delete <file>

To move or copy files, do this:
db <server> <move/copy> <name_of_file> <name_of_new_file>

To list the commits for a particular file, do this:
db <server> list_commits <file>

To switch branches, do this:
db <server> switch <name_of_branch>

The target branch doesn't need to exist.
If you want to copy an entire branch, do this:
db <server> clone_branch <new_branch_name>
This clones the current branch.

To get the data for a commit, do:
db <server> get_commit <file> <commitID>

To make the server download a file from Pastebin, do:
db <server> pastebin_get <pastebin_code> <name_of_file> <commit_message>

To make the server download a file from Github, do:
db <server> github_get <name_of_file> <user> <repository> <branch> <file> <commit_message>

An example user might do this:
db 20 login admin adad2sx2
db 20 sendFile dev/my_awesome_program my_awesome_program
db 20 read my_other_program
db 20 logout

The user above:
  • Logged in
  • Sent a file to the server
  • Downloaded a file from the server
  • Logged out



Guest Access
If you run "dbServ" with the option "-guest_read" then the "list" and "read" functions become available without requiring the user to log in.
Guests are only allowed to get files from the "master" branch, however.

Guest Access Mode:
dbServ -guest_read


You can get it here, from pastebin: Rednet Database Server
Or you can download it from in-game by running this:
pastebin get t1StZK2k dbServ

The client can be found here: Database Server Client
Or download it from in-game by running this:
pastebin get 48aP8hfF db_client

If the HTTP API is disabled, than all passwords will be stored on the password in cleartext, but the server will attempt to use the RC4 cipher (automatically downloaded) whenever possible, which may cause problems. This is easily fixed though, only requiring that the person running the database add the users again.

Also, I'm looking for someone to make an actual UI for the client. If you'd like to (or already have one), please PM me.</password></user_name>

#2 ChunLing

  • Members
  • 2,027 posts

Posted 20 October 2012 - 02:34 AM

Nice. Lots of people ask for stuff like this in suggestions.

#3 PixelToast

  • Signature Abuser
  • 2,265 posts
  • Location3232235883

Posted 20 October 2012 - 03:54 AM

i have my own version but it has a metatable interface, basically you can update a variable in realtime just by modifying a tables index
i can PM you the code if you want, it uses my decentralized networking system so it might take some time to convert to normal rednet

#4 KillaVanilla

  • Members
  • 303 posts

Posted 20 October 2012 - 05:47 AM

View PostPixelToast, on 20 October 2012 - 03:54 AM, said:

i have my own version but it has a metatable interface, basically you can update a variable in realtime just by modifying a tables index
i can PM you the code if you want, it uses my decentralized networking system so it might take some time to convert to normal rednet

No thank you, I like my code to be "home-grown" (with a few exceptions). Besides, this is modeled after a certain SCM, and is not supposed to be a variable persistence solution.

#5 chrdov

  • Members
  • 86 posts
  • Locationchrdov's Domain, Cyberspace

Posted 21 October 2012 - 04:35 PM

View PostChunLing, on 20 October 2012 - 02:34 AM, said:

Nice. Lots of people ask for stuff like this in suggestions.
ikr. I Want To Try it.

#6 KillaVanilla

  • Members
  • 303 posts

Posted 21 October 2012 - 08:51 PM

View Postchrdov, on 21 October 2012 - 04:35 PM, said:

View PostChunLing, on 20 October 2012 - 02:34 AM, said:

Nice. Lots of people ask for stuff like this in suggestions.
ikr. I Want To Try it.

Well then, you're in luck. I'm developing a client program for it right now.

EDIT: Okay, the client's done. It's only command-line based for now, I hate making UIs. The code is
48aP8hfF


#7 computercraftprogrammer

  • Members
  • 122 posts
  • Location$house->Earth->MilkyWay->Universe;

Posted 22 October 2012 - 08:53 PM

Nice, I am going to be starting a Database called ccSQL here soon, instead of storing files, it will be just like MySQL databases, and have commands such as "SELECT * FROM `ccDatabase`.`computer_positions` WHERE `computerID`='45';"

#8 KillaVanilla

  • Members
  • 303 posts

Posted 22 October 2012 - 11:19 PM

View PostUMayBleed, on 22 October 2012 - 08:53 PM, said:

Nice, I am going to be starting a Database called ccSQL here soon, instead of storing files, it will be just like MySQL databases, and have commands such as "SELECT * FROM `ccDatabase`.`computer_positions` WHERE `computerID`='45';"

Good luck!

#9 iRiky

  • Members
  • 24 posts

Posted 25 October 2012 - 07:24 PM

i've got a problem

bios:207: Attempt to write to global

how i can solve it ??

#10 KillaVanilla

  • Members
  • 303 posts

Posted 25 October 2012 - 08:54 PM

View PostiRiky, on 25 October 2012 - 07:24 PM, said:

i've got a problem

bios:207: Attempt to write to global

how i can solve it ??

I'm looking into it...

EDIT: Waaaait a minute. In the latest version (1.46), line 207 in bios.lua is empty. Have you modified your BIOS?

#11 iRiky

  • Members
  • 24 posts

Posted 26 October 2012 - 12:05 PM

i use 1.42 for 1.2.5

#12 computercraftprogrammer

  • Members
  • 122 posts
  • Location$house->Earth->MilkyWay->Universe;

Posted 26 October 2012 - 12:07 PM

View PostKillaVanilla, on 22 October 2012 - 11:19 PM, said:

View PostUMayBleed, on 22 October 2012 - 08:53 PM, said:

Nice, I am going to be starting a Database called ccSQL here soon, instead of storing files, it will be just like MySQL databases, and have commands such as "SELECT * FROM `ccDatabase`.`computer_positions` WHERE `computerID`='45';"

Good luck!

Well i have alot of experience, and it will be something quite easy to me, just time consuming.

#13 iRiky

  • Members
  • 24 posts

Posted 26 October 2012 - 05:21 PM

scuse me another error with 1.45...
it said me:

Server at 0 reports error:not logged in

how i solve it ??

#14 ChunLing

  • Members
  • 2,027 posts

Posted 26 October 2012 - 06:12 PM

That's not an error in the program, it's just saying that you aren't logged in to the Server.

Though it might be a good idea to not use "error" this and that outputs, that can be confusing and make people think that there is something wrong with the program.

#15 KillaVanilla

  • Members
  • 303 posts

Posted 27 October 2012 - 03:27 AM

View PostChunLing, on 26 October 2012 - 06:12 PM, said:

That's not an error in the program, it's just saying that you aren't logged in to the Server.

Though it might be a good idea to not use "error" this and that outputs, that can be confusing and make people think that there is something wrong with the program.

Yeah, i definitely need to make the error messages more user-friendly.

EDIT: Okay, made the errors a little easier to understand. Does this help?

#16 iRiky

  • Members
  • 24 posts

Posted 27 October 2012 - 01:12 PM

how i use the commands to login ?

#17 KillaVanilla

  • Members
  • 303 posts

Posted 27 October 2012 - 01:24 PM

View PostiRiky, on 27 October 2012 - 01:12 PM, said:

how i use the commands to login ?
db <server> login <username> <password>
On that note, I need to make documentation for this...

#18 mibac138

  • Members
  • 132 posts
  • LocationPoland

Posted 28 November 2012 - 08:47 AM

In dbServ is fail you writed allowGues you should write allowGuest ;)

#19 KillaVanilla

  • Members
  • 303 posts

Posted 28 November 2012 - 11:41 AM

View Postmibac138, on 28 November 2012 - 08:47 AM, said:

In dbServ is fail you writed allowGues you should write allowGuest ;)

Thanks, I'll look into it.

Edit: And now it's fixed.

#20 Dlcruz129

    What's a Lua?

  • Members
  • 1,423 posts

Posted 28 November 2012 - 01:33 PM

Nice, Github in ComputerCraft, very cool.





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users