Mistium / Origin-OS

originOS is a scratch desktop gui made by @Mistium
https://origin.mistium.com
24 stars 9 forks source link

[To Do] OFTPS #153

Open Mistium opened 4 days ago

Mistium commented 4 days ago

A file transfer protocol for accessing origin files remotely from oftps clients

i can probably write this 100% in osl

Requests

{
  "cmd":"lcd",
  "trg":"/"
} // list contents of root directory
{
  "cmd":"cat",
  "trg":"/test.txt"
} // get the contents of test.txt
{
  "cmd":"cdt",
  "trg":"/dir1"
} // move to a directory
{
  "cmd":"set",
  "trg":"/test.txt", // target
  "ent":"the file entry to update" // this tells which of the 14 entries to update
  "dat":"hello world"
} // update a file

Responses

{
  "cde":"", // status code
  "res":""  // response data
}

Status codes

0 - successful

1 - unknown command

2 - unknown file

3 - unknown directory

4 - too much data

MILO123PRO commented 4 days ago

OFTPS Server should be based on a websocket server Example: -Connects to server-

LOGIN

Server: {"action":"login_required"} - Server asks for login User: {"login":"USERNAME:PASSWORD-MD5"} - Login Details. Server (Login Successful): {"login":"OK", "type":"login-ok"} - Everything worked, you are logged in. Server (Login Unsuccessful - Invalid Credentials): {"login":"ERROR", "error":"Invalid Credentials", "type":"invalid_login"} - Username or password wrong. Server (Login Unsuccessful - Banned User): {"login":"ERROR", "error":"You are banned.", "type":"banned"} - You are banned (user) Server (Login Unsuccessful - Banned User): {"login":"ERROR", "error":"You are banned.", "type":"banned-ip"} - You are banned (IP)

LIST FILES

User: {"action":"get-dir"} - List current directory's files and folders. Server: {"files:["file1.txt","file2.txt","file3.txt"], "sizes:["69b","7.8mb","420gb"], "permissions":["ALLOW","ALLOW","DENY"]} - Lists the files, in this case, file1.txt with 69 bytes, file2.txt with 7.8mb and file3.txt with 420gb, permissions show in order which files you can access (for the origin files app to gray them out or something).

SEEING FILES CONTENT

User: {"action":"cat","file":"file1.txt"} - See the content of a file (the permissions of file1.txt allows seeing the content) Server: {"file1.txt":"This text file called file1.txt is 69 bytes long because i am cool :D"}

User: {"action":"cat","file":"file3.txt"} - See the content of a file (the permissions of file3.txt DO NOT ALLOW SEEING THE CONTENT) Server: {"error":"Insufficient Permissions"}

SETTING THE CONTENT OF A FILE:

User: {"action":"set","file":"file1.txt","content":"This file is no longer 69 bytes long XD"} - Tells the server the action, the file to set the content to and the content. Server: {"file1.txt":"This file is no longer 69 bytes long XD"} - Server replies with the content of the file confirming the change.

User: {"action":"set","file":"file3.txt","content":"No more 420gb :D"} - Tells the server the action, the file to set the content to and the content. (Using a file which you do not have permissions on.) Server: {"error":"Insufficient Permissions"} - Not enough permissions

MOVING A FILE

User: {"action":"mv","file":"file1.txt","path":"some-folder/file1.txt"} - Tells the action of moving the file, the file name and the path. Server (if the folder exists): {"mv":"OK"} - The file was moved successfully. Server (if the folder doesnt exist): {"mv":"ERROR","error":"The specified folder doesnt exist"} - The folder where you wanted to move the file doesnt exist.

CREATE A FILE/FOLDER

Folder: User: {"action":"create","type":"folder","name":"some-folder"} - Tells the action of creating a folder and the name of it. Server (enough permissions): {"create":"OK"} - The folder was created. Server (not enough permissions): {"create":"ERROR","error":"Insufficient Permissions"} - The folder wasnt created because you dont have enough permissions. Server (the folder already exists): {"create":"ERROR","error":"The folder already exists."} File: User (file with content): {"action":"create","type":"file","name":"file4.txt","content":"Cool"} - Tells the action of creating a file called file4.txt with the content "Cool". User (file without content): {"action":"create","type":"file","name":"file4.txt","content":""} - Tells the action of creating a blank file called file4.txt Server (enough permissions): {"create":"OK"} - The file was created. Server (not enough permissions): {"create":"ERROR","error":"Insufficient Permissions"} - Not enough permissions. Server (the file already exists): {"create":"ERROR","error":"The file already exists."}

DELETE FILE

User: {"action":"delete","file":"file1.txt"} - Tells the server the action of deleting the file1.txt Server: {"delete":"OK"} - The file was deleted Server: {"delete":"ERROR", "error":"No file with that name."} - There isnt a file with that name.

User: {"action":"delete","file":"file3.txt"} - Tells the server the action of deleting the file3.txt (which you dont have permissions on) Server: {"delete":"ERROR", "error":"Insufficient Permissions"}

DELETE FOLDER

User: {"action":"delete","folder":"some-folder"} - Tells the server the action of deleting the folder "some-folder" Server: {"delete":"OK"} - The folder was deleted Server: {"delete":"ERROR", "error":"No folder with that name."} - There isnt a folder with that name.

User: {"action":"delete","folder":"some-folder"} - Tells the server the action of deleting the folder "some-folder" (which you dont have permissions on) Server: {"delete":"ERROR", "error":"Insufficient Permissions"}

CHANGING PASSWORD

User: {"login":"change_password","password":"PASSWORD-MD5","new":"NEW-PASSWORD-MD5"} - Tells that you wanna realize an action on the login part and the action is changing your password, you also specified the old and new password to the server. Server: {"change_password":"OK"} - The password was changed successfully. Server: {"change_password":"ERROR","error":"Invalid Credentials"} - Your old password isnt correct. Server: {"change_password":"WARNING","warning":"Insecure Password"} - Your password is in the lost of the most common passwords, please use another password. Your password wasnt changed.

LOGIN REQUIREMENT

User: (whatever action while not being logged in) Server: {"login":"ERROR","error":"You are not logged in."}