Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The final luasocket API and its documentation #10

Open
wants to merge 33 commits into
base: master.old
Choose a base branch
from

Conversation

tcz717
Copy link

@tcz717 tcz717 commented Jul 30, 2018

Lunatik Socket Library

The Lunatik socket library is developed by Chengzhi Tan (@tcz717). It provides most frequently used APIs that available for IPv4, TCP and UDP. I/O multiplex API, poll is also included in this library. The testcase file is socket/examples/test.lua.

Compile

Compile the kernel module:

make -C /lib/modules/$(uname -r)/build M=LUNATIC_ROOT_PATH modules ARCH=x86_64

Compile with luadata and poc driver enabled:

make -C /lib/modules/$(uname -r)/build M=LUNATIC_ROOT_PATH modules ARCH=x86_64 CONFIG_LUADATA=y CONFIG_LUNATIK_POC=y

Or see the wiki to use BuildRoot.

SOCKSv4 Demo

This demo shows how to run a SOCKSv4 proxy server in kernel. After the lunatik module loaded, type cat proxy.lua > /dev/luadrv. Then the server will start to listen SOCKSv4 request at 8080 port. (The path of the demo file is socket/examples/proxy.lua)

Benchmark

The speed of the proxy demo is tested.

Environment

  • Server: qemu x86_64 virtual machine running Linux 4.17.0

  • Client: the host of qemu, Ubuntu 18.04/Linux 4.15.0

The proxy server is running inside a QEMU virtual machine, which can access the Internet via NAT and forwards 8080 port on the host. After the proxy starts, the client on the host will use the proxy to download a fake zip file from a remote server.

Method

Use proxy to download two file 5MB and 100MB (The average ping is 96.904ms):

# the server of tsocks is set to localhost:8080

# test for no proxy:
wget -O /dev/null http://ipv4.download.thinkbroadband.com/5MB.zip -o raw-5mb
wget -O /dev/null http://ipv4.download.thinkbroadband.com/100MB.zip -o raw-100mb

# test for user-space c language proxy
# server side: ./socks4server (https://github.com/tclin914/Socks4Server)
tsocks wget -O /dev/null http://ipv4.download.thinkbroadband.com/5MB.zip -o user-5mb
tsocks wget -O /dev/null http://ipv4.download.thinkbroadband.com/100MB.zip -o user-100mb

# test for ssh dynamic forward proxy
# server side: ssh -N -D 0.0.0.0:8080 localhost
tsocks wget -O /dev/null http://ipv4.download.thinkbroadband.com/5MB.zip -o ssh-5mb
tsocks wget -O /dev/null http://ipv4.download.thinkbroadband.com/100MB.zip -o ssh-100mb

# test for lunatik proxy
# server side: cat proxy.lua > /dev/luadrv
tsocks wget -O /dev/null http://ipv4.download.thinkbroadband.com/5MB.zip -o lunatik-5mb
tsocks wget -O /dev/null http://ipv4.download.thinkbroadband.com/100MB.zip -o lunatik-100mb

# collect result
grep "[0-9.]\+ [KM]*B/s" *mb -o

Result

  • lunatik-100mb:8.64 MB/s
  • lunatik-5mb:4.60 MB/s
  • raw-100mb:14.1 MB/s
  • raw-5mb:5.08 MB/s
  • ssh-100mb:3.12 MB/s
  • ssh-5mb:2.72 MB/s
  • user-100mb:10.6 MB/s
  • user-5mb:4.88 MB/s
Raw User space Lunatik SSH
5MB.zip 5.08 MB/s 4.88 MB/s 4.60 MB/s 2.72 MB/s
100MB.zip 14.1 MB/s 10.6 MB/s 8.64 MB/s 3.12 MB/s

@tcz717 tcz717 changed the title The final luasocket API and its documents The final luasocket API and its documentation Aug 6, 2018
@tcz717 tcz717 self-assigned this Aug 6, 2018
@tcz717 tcz717 requested review from tammela and lneto August 6, 2018 23:43
@tammela tammela added the GSoC'18 label Mar 7, 2019
@tammela tammela changed the base branch from master to master.old March 7, 2019 16:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Development

Successfully merging this pull request may close these issues.

2 participants