Skip to content

feat: support openresty#25

Open
oowl wants to merge 3 commits into
guysv:masterfrom
oowl:master
Open

feat: support openresty#25
oowl wants to merge 3 commits into
guysv:masterfrom
oowl:master

Conversation

@oowl

@oowl oowl commented Aug 18, 2022

Copy link
Copy Markdown

support openresty luajit interactive

@guysv

guysv commented Aug 18, 2022

Copy link
Copy Markdown
Owner

Hey thanks for the PR! Could you please instruct me on how to use it?

@oowl

oowl commented Aug 18, 2022

Copy link
Copy Markdown
Author

Ok, https://github.com/openresty/lua-nginx-module running luajit on Nginx, And it impl some nginx api in luajit, so i want to use ilua online to execute this nginx related api. i use websocket to connect openresty server, use websocket message to trigger lua execute and complete, and return result to jupyter. Just install openresty, and then exec
ilua -i openresty

@guysv

guysv commented Aug 18, 2022

Copy link
Copy Markdown
Owner

Okay I managed to try it out!
First, there's a missing module exception for autobahn. consider adding it to the dependencies.

Second, very cool.
image

I see ssl is not implemented. Maybe we can self-sign ssl certs and configure openresty to use them so the console will have access to the ssl module. But maybe that's a feature for later 🤣


Now regarding actually merging this.
I'd like to ask you to consider publishing this as a stand-alone package. You can depend on ilua for the kernel classes and override what you need. If you need help API-wise for such integration i'd love to help! But I actually think you can manage to get this working just by subclassing my kernel.

Comment thread ilua/kernel.py Outdated

import twisted

from ilua import websocket

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

from . import websocket

Comment thread ilua/openresty/nginx.conf
http {
lua_package_path './lua/?.lua;{LUALIB};';
server {
listen {PORT};

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see nginx is listening on 0.0.0.0, and that route goes into the unsandboxed lua interpreter
image
Not good for security.

@guysv guysv Aug 19, 2022

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well to solve this the first step would be to switch to 127.0.0.1. But even then is vulnerable to dns rebind.

This is (semi? not really?) mitigated in the native lua implementation by sticking to FIFOs. I don't plan on adding HMAC to the lua implementation soon 🤣 , so I guess you can for now at least listen too on a unix socket instead of tcp.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, i switched to TCP that does not using a UNIX socket, because twisted WebSocket not support UNIX socket. I debug this long time.

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

pretty sure you can, let me get back to you with a POC.

@oowl

oowl commented Aug 22, 2022

Copy link
Copy Markdown
Author

I will consider creating iresty repo to achieve this( using ilua for the kernel classes ), but now I have no more time to do this. This implement looks dirty now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants