From: lostgallifreyan <los...@gm...> - 2009-10-25 15:21:05
|
Andreas Krinke wrote: (Sun, 25 Oct 2009 07:19:27 -0700) > Great it works now! > Yep. :) Thankyou, that incremental read is a particularly nice idea for viewing an incoming page as it is still arriving. Though I am utterly confuzzled as to what changed, but at least if it stops I have something certain to work with. My guess is some DNS server out there went strange during the week and got fixed during the quiet time that sunday mornings allow. >lostgallifreyan wrote: >> If I carry on with this, the main thing I need to know is how to set >> up wxLua as a simple local proxy so I can design a web filter. I'll >> sort the filter details in my own time, but if someone can help me >> with a minimal template for the connections part of that, please do. >> Now that I've seen something work, I'll give it the effort it >> deserves if someone can give me that core template for connecting >> wxLua as local proxy between a browser and the net. > > Did you consider using Lua and LuaSocket [1] instead of wxLua? I think > this would simplify the whole socket and proxy programming. > I did. :) Though I wasn't sure if it was the best way. I do like to use Lua functions directly, given the choice, which is why I thought to extend Lua with LuaSocket rather than use wxLua. But I do really like wxLua! If I didn't I wouldn't be so enthusiastic one moment, disappointed the next. I do really care about wxLua. Long ago someone told me about Girder and the power it would give me in the OS at large, and I didn't get it. Now I have wxLua and I DO get it, at least well enough to frequently make my own tools, and having seen Girder since, I know where I'm better off, and I stay with wxLua. I'm guessing I'll have to compile Lua with LuaSocket but I think I can do it, I managed to compile my copies of v5.1.4 Lua and Luac and Lua.dll with TCC compiler, so that could be a nice way to go. On the other hand, that means console windows popping up, and for something like a web proxy based filter system it's nice if it runs very much in the background. If I try both I'll learn more though. All that aside, wxLua really needs nice simple examples of this stuff. In actual wxLua... I thought the whole point was to alleviate the austerity of C and platform based limitations and make consistent and highly configurable tools available to more people. Not every driver is a master mechanic, and it would be a strange world if people expected them to be in order to drive on anything but the motorways... I'm going to try a (very) minimal browser using that wxURL and an HTML control, with basic back/forward navigation, visited URL memory, a view source window. It will use a toolbar rather than a menu. If it works ok I'll post a cleaned and commented copy as an example. One thing wxLua would be well placed for is a simple FTP client. That would be a great example, as it both sends and receives with a relatively simple protocol. And a tool to do pings and traces and whois inquiries. And a minimal HTTP file server. Ideas could easily run amock, but I think a few standard core tools done in wxLua would be a valuable part of the examples library. So far the search for the word 'socket' in the text of those is singularly uninspiring. And a search for wxURL produces exactly zero results! > Here is some example code: > > -- load namespace > local socket = require "socket" > -- create a TCP socket and bind it to the local host, at port 8080 > local server = assert(socket.bind("*", 8080)) > > while 1 do > -- wait for a connection from any client > local client = server:accept() > -- receive the line > local line, err = client:receive() > -- if there was no error, send a simple webpage as example > if not err then > client:send([[ > <html> > <body> > <h1>Proxy Test</h1> > </body> > </html> > ]]) > print(line) > end > -- done with client, close the object > client:close() > end Nice one. Thanks for that, I'll try it. Nice to have something I can get my teeth into. I always prefer a three pipe problem to skating on thin ice in the dark without knowing if the edge of the pond is actually there... Got to have a few easy certainties to start with, like seeing something work before I break it. Seriously. If I break it carefully, I learn. If I've never seen it work, I do NOT learn because the foundation's not there. That's the core of my occasional dissent with wxLua. I think many who see this problem don't speak of it, they either know enough to get by, or they vanish silently and go elsewhere, in which case I think they don't know what a good thing they're missing, but I can see their point. I've seen enough to stay with it, but more diverse examples would have made that a lot easier. Reading manuals is fun when you have that, otherwise it's hell with no way to know if will work and be worth it. |