Giter VIP home page Giter VIP logo

sehttpd's Introduction

seHTTPd

seHTTPd implements a small and efficient web server with 1K lines of C code. I/O multiplexing is achieved using epoll.

Features

  • Single-threaded, non-blocking I/O based on event-driven model
  • HTTP persistent connection (HTTP Keep-Alive)
  • A timer for executing the handler after having waited the specified time

High-level Design

+----------------------------------------------+
|                                              |
|  +-----------+   wait   +-----------------+  |  copy   +---------+
|  |           +---------->                 +------------>         |
|  | IO Device |    1     | Kernel's buffer |  |   2     | Process |
|  |           <----------+                 <------------+         |
|  +-----------+          +-----------------+  |         +---------+
|                                              |
+----------------------------------------------+

Build from Source

At the moment, seHTTPd supports Linux based systems with epoll system call. Building seHTTPd is straightforward.

$ make

Default server

./sehttpd

Specify the port

./sehttpd -p 8082 

Specify the port number with -p flag, by default the server accepts connections on port 8081.

Specify the web root

./sehttpd -w ./www

Specify the web root with -w flag, by default the web root is "./www".

License

seHTTPd is released under the MIT License. Use of this source code is governed by a MIT License that can be found in the LICENSE file.

sehttpd's People

Contributors

davidleitw avatar jserv avatar julian-chu avatar jwang0306 avatar lgtm-migrator avatar oscarshiang avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

sehttpd's Issues

Failed to load the ebpf program

Running the epbf program

$ sudo python http-parse-sample.py

will get this error:

bpf: Failed to load program: Permission denied
0: (bf) r6 = r1
1: (28) r0 = *(u16 *)skb[12]
2: (55) if r0 != 0x800 goto pc+96
 R0_w=inv2048 R6_w=ctx(id=0,off=0,imm=0) R10=fp0
3: (30) r0 = *(u8 *)skb[23]
4: (55) if r0 != 0x6 goto pc+94
 R0_w=inv6 R6_w=ctx(id=0,off=0,imm=0) R10=fp0
5: (30) r0 = *(u8 *)skb[14]
6: (bf) r8 = r0
7: (67) r8 <<= 2
8: (57) r8 &= 60
9: (b7) r1 = 20
10: (2d) if r1 > r8 goto pc+88
 R0=inv(id=0) R1=inv20 R6=ctx(id=0,off=0,imm=0) R8=inv(id=0,umin_value=20,umax_value=60,var_off=(0x0; 0x3c)) R10=fp0
11: (bf) r7 = r8
12: (07) r7 += 26
13: (50) r0 = *(u8 *)skb[r7 + 0]
14: (bf) r7 = r0
15: (28) r0 = *(u16 *)skb[16]
16: (1f) r0 -= r8
17: (77) r7 >>= 2
18: (57) r7 &= 60
19: (1f) r0 -= r7
20: (67) r0 <<= 32
21: (77) r0 >>= 32
22: (b7) r1 = 7
23: (2d) if r1 > r0 goto pc+75
 R0_w=inv(id=0,umin_value=7,umax_value=4294967295,var_off=(0x0; 0xffffffff)) R1_w=inv7 R6=ctx(id=0,off=0,imm=0) R7_w=inv(id=0,umax_value=60,var_off=(0x0; 0x3c)) R8=inv(id=0,umin_value=20,umax_value=60,var_off=(0x0; 0x3c)) R10=fp0
24: (0f) r7 += r8
25: (bf) r9 = r7
26: (07) r9 += 12
27: (07) r7 += 20
28: (bf) r8 = r9
29: (47) r8 |= 2
30: (50) r0 = *(u8 *)skb[r8 + 0]
31: (bf) r3 = r0
32: (2d) if r7 > r8 goto pc+9
 R0=inv(id=0) R3=inv(id=0) R6=ctx(id=0,off=0,imm=0) R7=inv(id=0,umin_value=40,umax_value=140,var_off=(0x0; 0xfc)) R8=inv(id=0,umin_value=32,umax_value=254,var_off=(0x2; 0xfc)) R9=inv(id=0,umin_value=32,umax_value=132,var_off=(0x0; 0xfc)) R10=fp0
33: (65) if r3 s> 0x47 goto pc+33
 R0=inv(id=0) R3=inv(id=0,smax_value=71) R6=ctx(id=0,off=0,imm=0) R7=inv(id=0,umin_value=40,umax_value=140,var_off=(0x0; 0xfc)) R8=inv(id=0,umin_value=32,umax_value=254,var_off=(0x2; 0xfc)) R9=inv(id=0,umin_value=32,umax_value=132,var_off=(0x0; 0xfc)) R10=fp0
34: (15) if r3 == 0x44 goto pc+41
 R0=inv(id=0) R3=inv(id=0,smax_value=71) R6=ctx(id=0,off=0,imm=0) R7=inv(id=0,umin_value=40,umax_value=140,var_off=(0x0; 0xfc)) R8=inv(id=0,umin_value=32,umax_value=254,var_off=(0x2; 0xfc)) R9=inv(id=0,umin_value=32,umax_value=132,var_off=(0x0; 0xfc)) R10=fp0
35: (15) if r3 == 0x47 goto pc+1

from 35 to 37: R0=inv(id=0) R3=inv71 R6=ctx(id=0,off=0,imm=0) R7=inv(id=0,umin_value=40,umax_value=140,var_off=(0x0; 0xfc)) R8=inv(id=0,umin_value=32,umax_value=254,var_off=(0x2; 0xfc)) R9=inv(id=0,umin_value=32,umax_value=132,var_off=(0x0; 0xfc)) R10=fp0
37: (55) if r2 != 0x54 goto pc+61
R2 !read_ok
processed 41 insns (limit 1000000) max_states_per_insn 0 total_states 3 peak_states 3 mark_read 1

Traceback (most recent call last):
  File "http-parse-sample.py", line 77, in <module>
    function_http_filter = bpf.load_func("http_filter", BPF.SOCKET_FILTER)
  File "/usr/lib/python2.7/dist-packages/bcc/__init__.py", line 413, in load_func
    (func_name, errstr))
Exception: Failed to load BPF program http_filter: Permission denied

Here is my environment:

$ uname -a
Linux desktop 5.8.0-48-generic #54~20.04.1-Ubuntu SMP Sat Mar 20 13:40:25 UTC 2021 x86_64 x86_64 x86_64 GNU/Linux

Check this issue : iovisor/bcc#2035

and this commit : iovisor/bcc@60b0166

Thanks

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.