- - GScript FTP Server
(https://forums.graalonline.com/forums/showthread.php?t=134261400)
cbk1994
12-25-2010 07:17 AM
GScript FTP Server
1 Attachment(s)
Remember how I said I wasn't going to do any more scripts in GScript?
Out of my obsession with backing up servers on Graal, I've made GBall, a system for compressing and expanding files on Graal servers. I've gone a step further now and written a complete FTP server for Graal, supporting file downloads and uploads, as well as complex rights control systems.
The server binds to a random port (it's not possible to specify a port to bind to with TSocket unless it's enabled by Stefan) and listens for incoming FTP connections. You can connect using any FTP client. I've tested the FTP client built into Windows Explorer, Filezilla, Transmit, and Cyberduck.
The port will change every time the server restarts or the FTP DBNPC is updated. You can use "/npc ftp" in RC to get the new port and host.
Features
Download files or entire folders (easy backups)
Compatible with virtually any FTP client, tested in several (see above; be sure to report unsupported FTP clients so I can fix the error)
Complex rights control based on the player's folder rights, prevents accidently giving a user too many rights (see below)
Writing is supported (see below for issues with uploading), and can be disabled for any user or for every user easily
Move, rename, or create directories
Active transfer mode is not supported; you must use passive mode.
Disclaimer
I wrote this out of sheer boredom, since I have no use for it now since I don't run a server, but I hope this may be useful. Keep in mind that while I have tested this as much as possible and can't find any security holes, they may exist. Please report any bugs and I will release a fix as fast as I can.
A note about uploads
Due to my nemesis, the flood alert, it's not possible to upload too much data. If you do, no scripts on the server will be able to write (or read?) to/from files. It is to your advantage not to cross this limit. There is no limit for reading. You shouldn't run into this problem unless you are uploading more than 10 MB of files in a short time. GScript also can not write to some file extensions. I don't have a list of allowed extensions, but most, such as txt, will work. Some folders also cannot be written to by script, such as logs and all script folders (weapons, scripts, npcs).
Rights system
Folder rights are inherited from the folder rights of the account of the user being used. If the NPC-server doesn't have rights to a folder, that user won't be able to upload or download files there. You can also completely disable writing in the script. If you are worried about security, don't give the NPC-server rights to any folders with confidential files, or just don't use this script.
Setup instructions
Download the attached file and unzip it
Create classes for each of the files named ftp_*.txt in the zip folder, and copy the scripts into them.
Create a new DBNPC named FTP and place the script inside FTP.txt into it.
Give your NPC-server folder rights to any folders you want to be able to access. You can give read or read/write rights. Note that it is a security risk to give the NPC-server rights, so do this with care. You can give rights to specific folders or blanket (e.g. rw */*, rw */*/*)
Setup users in the DBNPC FTP. Follow the format in there and be sure to remove me. The users must be the account name of a player, and they will share that player's folder rights. Community names are not supported for obvious reasons.
Use the command "/npc ftp" in RC to see where the FTP server is currently listening. If your client separates the host and port fields, the host is before the colon and the port is after.
Please report any bugs. Feedback is appreciated.
Thanks to death_striker for lending me his server to develop this on.
Fulg0reSama
12-25-2010 07:22 AM
That's very impressive :oo:
WhiteDragon
12-25-2010 07:25 AM
Wow.
Matt
12-25-2010 07:28 AM
Very impressive, nice work man. :) This will be more than useful to a lot of people. Chris for GST?! :p
fowlplay4
12-25-2010 07:43 AM
Neat, wasn't aware that you could use TSockets without getting Stefan to enable the socket.
zephirot
12-25-2010 08:11 AM
Man you get **** done.
12171217
12-25-2010 08:30 AM
This is very cool o.o
You could assign users a public FTP space for uploads and whatnot, their own little folder.. Very awesome.
adam
12-25-2010 08:48 AM
Very awesome, very wow. ;) Nice job.
Crow
12-25-2010 09:26 AM
Quote:
Originally Posted by WhiteDragon
(Post 1618044)
Wow.
My thought exactly. On a side note, I have to spread rep.
Fulg0reSama
12-25-2010 09:34 AM
Quote:
Originally Posted by Crow
(Post 1618056)
My thought exactly. On a side note, I have to spread rep.
I have to wait twenty four hours :(
Twinny
12-25-2010 09:56 AM
Awesome work! I would have repp'd except the rep window hides behind the video =x
LordSquirt
12-25-2010 11:16 AM
wow, I don't understand anything you just said, but just wow
Seich
12-25-2010 11:20 AM
Quote:
Originally Posted by WhiteDragon
(Post 1618044)
Wow.
^Ditto.
cyan3
12-25-2010 11:57 AM
Nice work.
Deas_Voice
12-25-2010 01:04 PM
wow :megaeek:
Elk
12-25-2010 01:17 PM
Impressed...
Soala
12-25-2010 02:12 PM
Nicely done.
James
12-26-2010 03:05 AM
sweetness
PowerProNL
12-27-2010 05:06 PM
who likes: fsdlfjsjfskadfjsf?
i like this system =]
benpoke103
12-27-2010 11:13 PM
Keep getting "Binding of port 0 is not allowed, blocking." echoed in RC~
cbk1994
12-28-2010 03:00 AM
Quote:
Originally Posted by benpoke103
(Post 1618486)
Keep getting "Binding of port 0 is not allowed, blocking." echoed in RC~
Very weird, maybe Stefan has started blocking it...? I tried it on Testbed after restarting the server and it's still working.
I'd try it on a UC server but my gold ran out. Maybe try restarting the NPC-server? That's all I can think of...are you on a UC server?
Chompy
12-28-2010 03:49 AM
Quote:
Originally Posted by cbk1994
(Post 1618513)
Very weird, maybe Stefan has started blocking it...? I tried it on Testbed after restarting the server and it's still working.
I'd try it on a UC server but my gold ran out. Maybe try restarting the NPC-server? That's all I can think of...are you on a UC server?
The Testbed Server is a classic-enabled server, might be why if there is a connection.
_Zelph
12-28-2010 04:16 AM
So it's a little wrapper for FTP. That's cool. Wish TSockets were a little more ... usable though. Anything that requires Stefan's intervention is pretty hard to get done.
Would still be nice to have a "real" FTP connection too.
cbk1994
12-28-2010 04:17 AM
Quote:
Originally Posted by Chompy
(Post 1618524)
The Testbed Server is a classic-enabled server, might be why if there is a connection.
It was working on a UC server when I released it.
Chompy
12-28-2010 05:08 AM
Quote:
Originally Posted by cbk1994
(Post 1618536)
It was working on a UC server when I released it.
Ah, then I don't see why it doesn't work. Might be the server the playerworld is on?
benpoke103
12-28-2010 10:22 AM
It's on Bomy Island, actually had problems restarting the server too..hm. Restarting the NPCServer showed no improvements however
Crow
01-03-2011 11:58 PM
Tried it out, and I can connect! That's quite awesome already. Thing is, I'm seeing files as folders (levels folder, folders such as blablabla.nw) and no files at all in the folders that I gave the NPC server read rights for. Something's broken it seems. Using the latest FileZilla version.
Edit: Can't use the ".." entry in the folder list to go back one folder either.
cbk1994
01-04-2011 12:46 AM
Quote:
Originally Posted by Crow
(Post 1620136)
Tried it out, and I can connect! That's quite awesome already. Thing is, I'm seeing files as folders (levels folder, folders such as blablabla.nw)
Are you sure the NPC-server has rights (at least read rights)? It will display files it doesn't have rights to but they might display as folders since fileExists doesn't work (even though loadFolder does). If it does have rights, does it happen with only one extension or all?
Quote:
and no files at all in the folders that I gave the NPC server read rights for.
Does giving rw fix this?
Quote:
Edit: Can't use the ".." entry in the folder list to go back one folder either.
I'll fix this when I fix the above bugs.
Sorry I can't help more, just trying to get some info since I don't have a server to test on.
Crow
01-04-2011 01:02 AM
Quote:
Originally Posted by cbk1994
(Post 1620157)
Are you sure the NPC-server has rights (at least read rights)? It will display files it doesn't have rights to but they might display as folders since fileExists doesn't work (even though loadFolder does). If it does have rights, does it happen with only one extension or all?
With all extensions, most likely. It's just a thing I noticed, not a big problem. Also, the NPC server does not have any rights to the folder this is happening in, so that makes sense now.
Quote:
Originally Posted by cbk1994
(Post 1620157)
Does giving rw fix this?
Nope.
cbk1994
01-04-2011 01:04 AM
Quote:
Originally Posted by Crow
(Post 1620163)
Nope.
Do you have rights to the files (do you see them in File Browser)?
Crow
01-04-2011 01:05 AM
Quote:
Originally Posted by cbk1994
(Post 1620166)
Do you have rights to the files (do you see them in File Browser)?
Yep.
Emera
09-24-2011 11:53 PM
Decided to set this up on Lexia, but am having some issues. I keep getting this error message in RC when updating the FTP database NPC.
HTML Code:
FTP: Bound to The automation file has moved. <a href='http://www.whatismyip.com/faq/automation.asp'>click here</a><br><br><br><br><br><br><br><br><br> :51687, waiting for connections...
Mark Sir Link
09-25-2011 12:09 AM
probably need to edit the FTP text file and replace the request url to this URL
But I think you're going to run into bigger problems because afaik Stefan has disabled listening to random ports and now requires you to get all listening services cleared with him (and then he'll give you a port you can use). It's possible to listen, but it appears that it can't be reached from the outside. We tried unsuccessfully on Kingdoms Debug a few days ago and couldn't figure out any way past it. Maybe that's just a server-specific thing though?
If he disabled outgoing connections (not sure if he did or not), then that could also be the cause of the lack of IP shown.
Matt
12-08-2012 03:47 PM
I'll try again when i get back from work and post the results.