Jump to content




FileServ - File Storage Client-Server


  • You cannot reply to this topic
6 replies to this topic

#1 Egor305

  • Members
  • 34 posts

Posted 13 December 2013 - 01:26 AM

FileServ - File Storage Client-Server program!

--WARNING--
This is early beta. If you find a way to exploit/crash it, don't punch me. Instead try a thing called "reporting bug".

Downloads:
CLIENT: rZwUAu4Y
SERVER: dkTqF8RX

How to install:
CLIENT: Download it on your computer. Change modem side and server id to match yours.
SERVER: Download it on dedicated computer. Change modem side to match yours. Make directory called "data". Add it to your startup script.

How to use:
Server gives everyone a directory to upload and download files. (More like Dropbox/Mediafire/Google Disk/Skydrive/Яндекс.Диск/Облако@mail.ru but w/o sync and stuff)
fileserv send <localname> <servername> -- Sends <localname> file to server under name <servername>
fileserv get [id] <servername> <localname> -- Downloads file <servername> from [id] directory and saves it under name <localname>. If you not specify id, your id will be used.
fileserv dir -- Shows all files in your directory.
fileserv del <servername> -- Deletes <servername> in your directory.
If your filename starts with !, only you can download it.
For security reasons, you can only dir your own directory.

Server directory structure:
FileServ Computer
|	server
|	startup
|  
\---data
	+---~1
	|	luatutorial.txt
	|	what_jeff_touches
	|	  
	\---~2
		 mailverseinstaller
		 screensaver

Edited by Egor305, 07 April 2014 - 04:19 PM.


#2 oeed

    Oversimplifier

  • Members
  • 2,095 posts
  • LocationAuckland, New Zealand

Posted 13 December 2013 - 04:07 AM

Looks good!

Now, this may be rather hard, but what about being able to 'mount' your folder. Similar to how Dropbox makes a folder it syncs.

#3 gknova61

  • Members
  • 74 posts

Posted 14 December 2013 - 02:59 PM

View Postoeed, on 13 December 2013 - 04:07 AM, said:


Looks good!

Now, this may be rather hard, but what about being able to 'mount' your folder. Similar to how Dropbox makes a folder it syncs.
You would need something running in the background on startup checking that folder every x time. The hard part is that it can override rednet message recieving for another program you have running or vice versa since only 1 function (thread) at a time can be checking for rednet messages. If more than 1 function is checking (like running on parallel), only 1 function is going to get that message.

Here is some example code:
function fileServThread()
while true do
os.pullEvent("rednet_message")
end
end

function mainProgramThread()
while true do
os.pullEvent("rednet_message")
end
end

parallel.waitForAny(fileServThread,mainProgramThread()

In the above code only 1 function is going to get that rednet message (usually the one called first, I think). The crazy workaround is writing another function for recieving all rednet messages then when it does, queue an event (like rnet_message1 or rnet_message2 to designate threads) to the other threads waiting for a 'sub' rednet message event like so:

function listenForRednet()
while true do
ev,id,msg = os.pullEvent("rednet_message") --Can also be rednet.recieve
if msg == "for file serv" then
os.queueEvent("rnet_message1",id,msg) --send this event to fileServThread
elseif msg == "for main prog" then
os.queueEvent("rnet_message2",id,msg) --send this event to mainProgramThread
end
end

function fileServThread()
while true do
os.pullEvent("rnet_message1") --recieving one type of event
end
end

function mainProgramThread()
while true do
os.pullEvent("rnet_message2") --recieving the other type of event
end
end

parallel.waitForAny(fileServThread,mainProgramThread,listenForRednet)

Edited by gknova61, 14 December 2013 - 03:10 PM.


#4 logsys

  • Members
  • 171 posts

Posted 14 December 2013 - 05:21 PM

man, u saved mah life! I was gonna build it. But meh!

#5 KillaVanilla

  • Members
  • 303 posts

Posted 21 December 2013 - 06:52 PM

View Postgknova61, on 14 December 2013 - 02:59 PM, said:

-snip-

That's not true. parallel.waitForAll / parallel.waitForAny ensures that every function passed to it receives the same events; both functions will get the rednet_message event.

Also:you could just have a function that listens for all rednet events as above, but simply passes the event data as a function call:

local function listener()
    while true do
	    local ev, id, msg = os.pullEvent("rednet_message")
	    if msg == "main_program" then
		    process_main(id, msg)
	    elseif msg == "fileserv" then
		    process_fileserver(id, msg)
	    end
    end
end

local function process_main(id, msg)
	 -- do things (like responding to the message) here
end
local function process_fileserver(id, msg)
    -- do other things here
end

listener()

Edited by KillaVanilla, 21 December 2013 - 06:57 PM.


#6 tesla1889

  • Members
  • 351 posts
  • LocationSt. Petersburg

Posted 28 December 2013 - 10:49 PM

you should split the files into packets so that people arent sending huge files at once across servers

#7 Egor305

  • Members
  • 34 posts

Posted 07 April 2014 - 04:49 AM

(and so, I decided to jump in and necrobump this thread)

Thanks to everybody for feedback!

View Postoeed, on 13 December 2013 - 04:07 AM, said:

Now, this may be rather hard, but what about being able to 'mount' your folder. Similar to how Dropbox makes a folder it syncs.
This would be hard to make, and will make big load on both server and client sides. Also there would be need in addition of login/password system, because current id system makes one account per device, making sync useless.

View Posttesla1889, on 28 December 2013 - 10:49 PM, said:

you should split the files into packets so that people arent sending huge files at once across servers
This is huge misconception. Rednet messages aren't sent byte-by-byte, at least at java level. They are just sent from one computer to another as event, which already have whole message. (more like copy-paste) Sending them as packets does in fact, slows down proccess of sending whole thing.





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users