Notice: Any messages purporting to come from this site telling you that your password has expired, or that you need to verify your details, confirm your email, resolve issues, making threats, or asking for money, are
spam. We do not email users with any such messages. If you have lost your password you can obtain a new one by using the
password reset link.
Entire forum
➜ MUSHclient
➜ Lua
➜ Create an internet connection from Lua?
Create an internet connection from Lua?
|
Posting of new messages is disabled at present.
Refresh page
Pages: 1
2
Posted by
| Nick Gammon
Australia (23,122 posts) Bio
Forum Administrator |
Date
| Reply #15 on Tue 09 Jun 2009 06:10 AM (UTC) |
Message
| |
- Nick Gammon
www.gammon.com.au, www.mushclient.com | Top |
|
Posted by
| Nick Gammon
Australia (23,122 posts) Bio
Forum Administrator |
Date
| Reply #16 on Tue 09 Jun 2009 06:13 AM (UTC) Amended on Tue 09 Jun 2009 06:17 AM (UTC) by Nick Gammon
|
Message
| I notice in your error message it doesn't seem to be looking for DLLs. If I type:
I see this:
Run-time error
World: smaug 2
Immediate execution
[string "Command line"]:1: module 'blah' not found:
no field package.preload['blah']
no file '.\blah.lua'
no file 'C:\Program Files\MUSHclient\lua\blah.lua'
no file 'C:\Program Files\MUSHclient\lua\blah\init.lua'
no file 'C:\Program Files\MUSHclient\blah.lua'
no file 'C:\Program Files\MUSHclient\blah\init.lua'
no file '.\blah.dll'
no file 'C:\Program Files\MUSHclient\blah.dll'
no file 'C:\Program Files\MUSHclient\loadall.dll'
stack traceback:
[C]: in function 'require'
[string "Command line"]:1: in main chunk
Note how it looks for blah.dll as well as blah.lua? In your error message it didn't. I think this is the core of your problem, assuming you have the directory structure right. |
- Nick Gammon
www.gammon.com.au, www.mushclient.com | Top |
|
Posted by
| Nick Gammon
Australia (23,122 posts) Bio
Forum Administrator |
Date
| Reply #17 on Tue 09 Jun 2009 06:15 AM (UTC) |
Message
| Check your Lua sandbox. In it are these lines:
package.loaders [3] = nil -- disable DLL loader
package.loaders [4] = nil -- disable all-in-one loader
These apply to non-trusted worlds/plugins. Make sure you are trusting your current world and/or plugin. Otherwise require won't load DLLs, leading to the symptoms you describe. |
- Nick Gammon
www.gammon.com.au, www.mushclient.com | Top |
|
Posted by
| Twisol
USA (2,257 posts) Bio
|
Date
| Reply #18 on Tue 09 Jun 2009 01:48 PM (UTC) |
Message
| That's probably it, because I was definitely preserving the directory structure. I'm not really sure how to "trust" a world or plugin, though? |
'Soludra' on Achaea
Blog: http://jonathan.com/
GitHub: http://github.com/Twisol | Top |
|
Posted by
| Twisol
USA (2,257 posts) Bio
|
Date
| Reply #19 on Tue 09 Jun 2009 02:43 PM (UTC) |
Message
| Okay, I got it working. Thanks for all the help!
My only gripe is really that it's a pain for anyone who'll be using these plugins to get started. Is there any easier way to mark a plugin as trusted besides going into the sandbox? |
'Soludra' on Achaea
Blog: http://jonathan.com/
GitHub: http://github.com/Twisol | Top |
|
Posted by
| Twisol
USA (2,257 posts) Bio
|
Date
| Reply #20 on Tue 09 Jun 2009 09:36 PM (UTC) |
Message
| I have a new problem... I've been thinking about this for the past hour with no luck: when I attempt to make a connection, while it's connecting, the whole client hangs. Lua coroutines are no good, because it's not really multithreading, and it still locks up the client. Is there any way to have the connect operation execute in its own thread? |
'Soludra' on Achaea
Blog: http://jonathan.com/
GitHub: http://github.com/Twisol | Top |
|
Posted by
| Nick Gammon
Australia (23,122 posts) Bio
Forum Administrator |
Date
| Reply #21 on Tue 09 Jun 2009 10:05 PM (UTC) |
Message
|
Quote:
... it's a pain for anyone who'll be using these plugins to get started ...
Well this brings us against the age-old problem with security. It's a trade-off between ease-of-use and how secure it is. Already your players have to install the luasocket DLLs so perhaps one extra step isn't too bad. You really need to get them to insert one line into it. Something like:
1. Edit the Lua sandbox (tell them how to find it) and inside look for:
local trusted_plugins = {
[""] = "", -- trust main script (ie. if no plugin running)
["03ca99c4e98d2a3e6d655c7d"] = "Chat",
["982581e59ab42844527eec80"] = "Random_Socials",
["4a267cd69ba59b5ecefe42d8"] = "Installer_sumcheck",
["83beba4e37b3d0e7f63cedbc"] = "Reconnecter",
} -- end of trusted_plugins
2. Add one line (copy and paste):
local trusted_plugins = {
[""] = "", -- trust main script (ie. if no plugin running)
["03ca99c4e98d2a3e6d655c7d"] = "Chat",
["982581e59ab42844527eec80"] = "Random_Socials",
["5085fca18efdc92274da4ea0"] = "My Great Plugin", ---> add this
["4a267cd69ba59b5ecefe42d8"] = "Installer_sumcheck",
["83beba4e37b3d0e7f63cedbc"] = "Reconnecter",
} -- end of trusted_plugins
3. Restart scripting (Shift+Ctrl+R).
Quote:
Is there any way to have the connect operation execute in its own thread?
Ah, I read recently to avoid threads like the plague (and cliches too). You would open a can of worms trying to multi-thread this part. However luasocket does allow for non-blocking operations, see here:
http://www.lua.org/pil/9.4.html
Now that page doesn't necessarily describe doing the http call in a non-blocking way, but the potential is there to do it. Try googling for some solutions. One example I found was:
require("socket")
local s = socket.connect("www.google.com", 80)
s:send("GET / HTTP/1.1\n")
s:send("Host: www.google.com\n")
s:send("User-Agent: GMod10\n")
s:send("Connection: Close\n")
s:send("\n")
local line = s:receive('*line')
print(line)
s:close()
Now this would still block, but by calling timeout(0), and then coming back into the script from time to time (on a timer), to read the incoming text, you should be able to work around it. |
- Nick Gammon
www.gammon.com.au, www.mushclient.com | Top |
|
Posted by
| Twisol
USA (2,257 posts) Bio
|
Date
| Reply #22 on Wed 10 Jun 2009 12:05 AM (UTC) |
Message
| To the trust issue: True, but if - for example - you could "trust" a plugin by checking a box in the Plugins dialog (or something similar), it would be much more intuitive to so-called laypersons to do what's required, rather than digging through a textbox of Lua code they might not understand. (I don't think the textbox has a Find capability either, does it?)
It also turns out that both the world and the plugin need to be "trusted", which is just another level of annoyance added on, because I can't tell them what their own world ID is. |
'Soludra' on Achaea
Blog: http://jonathan.com/
GitHub: http://github.com/Twisol | Top |
|
Posted by
| Twisol
USA (2,257 posts) Bio
|
Date
| Reply #23 on Wed 08 Jul 2009 12:01 AM (UTC) |
Message
| Has this issue been looked at recently? The points I listed above all complicate the process for an end user, and I know plenty of MUSHclient users who don't know anything about scripting, and aren't computer savvy enough to know how to do this without having me hold their hand the whole way through.
I have so many ideas that I need LuaSocket for - a plugin that can download and update existing plugins, an IRC plugin, a plugin that gets a map from my website and displays it in a miniwindow - but if it's too complex for the user, it's almost not worth it.
Would it be feasible to provide LuaSocket with MUSHclient, like you've done with the mysqli library? It seems like it would solve most of these problems, although I do see potential risks if a plugin tries to download a virus or something. But then, you can still do damage without any sort of network connection, so it's just a matter of knowing who you're getting these plugins from. |
'Soludra' on Achaea
Blog: http://jonathan.com/
GitHub: http://github.com/Twisol | Top |
|
Posted by
| Nick Gammon
Australia (23,122 posts) Bio
Forum Administrator |
Date
| Reply #24 on Wed 08 Jul 2009 11:44 PM (UTC) |
Message
| I suppose that could be looked at. The luasocket code isn't that big, and you are proposing it be incorporated into the MUSHclient .exe file? That way you don't need to enable DLLs.
I don't see how a virus could be downloaded unless you also trusted the io library. Of course, without such trust the luasocket code can't do anything much except download things into memory.
So for example, a plugin that updates plugins requires more than the luasocket code - it requires the ability to write to files. |
- Nick Gammon
www.gammon.com.au, www.mushclient.com | Top |
|
Posted by
| Twisol
USA (2,257 posts) Bio
|
Date
| Reply #25 on Thu 09 Jul 2009 12:06 AM (UTC) Amended on Thu 09 Jul 2009 12:07 AM (UTC) by Twisol
|
Message
| *nod* Right, that's exactly what I'm proposing. :)
The point about the IO library is true too. To be honest, it would be nice if there was some way a plugin could request permission at runtime - like how Windows applications request a security token - so that you could request permission to save a file, or similar operations. And, the only way to run a virus from a plugin would be to use the 'os' library, right? There's no chance that I would need to use that, so the act of saving a file is probably relatively safe... especially if you had some method of limiting it to a specific directory tree.
Anyways, with just LuaSocket incorporated into MUSHclient, it already opens up many avenues for plugin design, so I'd be happy with just that if nothing else can be done. :) |
'Soludra' on Achaea
Blog: http://jonathan.com/
GitHub: http://github.com/Twisol | Top |
|
Posted by
| Twisol
USA (2,257 posts) Bio
|
Date
| Reply #26 on Thu 09 Jul 2009 01:12 AM (UTC) |
Message
| I discovered that I could utilize notepads to save a file to disk without going through the Lua io library, with three simple lines:
SendToNotepad("test", "Hello, world.")
SaveNotepad("test", GetInfo(60) .. "test.txt", 0)
CloseNotepad("test")
I could theoretically use this to save a downloaded plugin to the plugins directory, without having to trust the plugin doing the saving. And also theoretically, someone could use this to download a virus, though again, I doubt it could be run without the 'os' library. Food for thought though. |
'Soludra' on Achaea
Blog: http://jonathan.com/
GitHub: http://github.com/Twisol | Top |
|
Posted by
| Nick Gammon
Australia (23,122 posts) Bio
Forum Administrator |
Date
| Reply #27 on Thu 09 Jul 2009 01:17 AM (UTC) |
Message
| Oh well, so much for security. ;)
Don't tell anyone ... |
- Nick Gammon
www.gammon.com.au, www.mushclient.com | Top |
|
Posted by
| Twisol
USA (2,257 posts) Bio
|
Date
| Reply #28 on Thu 09 Jul 2009 01:18 AM (UTC) Amended on Thu 09 Jul 2009 01:24 AM (UTC) by Twisol
|
Message
| Should I delete my post? XD
EDIT: What if you limited the notepad functions to a specific subdirectory of the MUSH directory tree, like the plugins directory? Or just had MUSHclient request approval from the user for the save, like you do when MUSHclient closes down? (This would also work well for the 'io' library methinks) |
'Soludra' on Achaea
Blog: http://jonathan.com/
GitHub: http://github.com/Twisol | Top |
|
The dates and times for posts above are shown in Universal Co-ordinated Time (UTC).
To show them in your local time you can join the forum, and then set the 'time correction' field in your profile to the number of hours difference between your location and UTC time.
73,987 views.
This is page 2, subject is 2 pages long:
1
2
Posting of new messages is disabled at present.
Refresh page
top