Coder Social home page Coder Social logo

kttp_server's Introduction

The KTTP Server - v0.4

The KTTP Server is a simple http server made by me, a hobbist programmer. I like C and i like networking, so... here we are!

Current features

  • Supports GET requests for static pages
  • Supports HEAD requests
  • Supports Multiple connections

Installation

To install the kttp_server, run

git clone https://github.com/gabricampaa/kttp_server.git
cd kttp_server
sudo make install
#optional 
sudo reboot

Now if you go and visit the public ip of your machine, you should see the index page.

Uninstall

To uninstall the kttp_server

cd /usr/lib/kttp_server_src/
sudo make uninstall

Documentation

PLEASE NOTE: this is a hobby project. It's not production ready, it's not safe, it's not optimized.

  • This is a list of all the folders that will be created:
      /usr/lib/kttp_server_src/ #src files and the executables 
      /etc/kttp_server/CONFs/  #config files
      /var/kttp_server_files/html_docs/ #default html docs folder
      /var/log/kttp_log #contains the log
    
  • Under the folder
    /etc/systemd/system/
    will be created the service file, kttp_server.service

Customization

  • The customization file is located here:
      /etc/kttp_server/CONFs/ 
    you can choose on what port you want the server to be running and which one is the default folder for html docs. DO NOT MODIFY what's left of the '=' sign, things might go wrong.

License

MIT

Free Software, Hell Yeah!

What changed in v0.4

  • better logging
  • memory leaking fixed (kinda)
  • see issues

kttp_server's People

Contributors

gabricampaa avatar

Stargazers

 avatar

Watchers

 avatar

kttp_server's Issues

Cambia

Makefile no, python installer con classi per managare creazione e gestione dirs

Future of the project

Some thoughts from browsing through the code:

• ⁠try to learn not to use strcpy() and especially strcat(), not even the n variants, they're inefficient at best, dangerous at worst - maybe sue snprintf?
• ⁠as previous commenter mentioned, be extra careful about your buffer sizes in network programming. Assume the remote end is trying to break you. In your code, probable stack layout saves from stack corruption, due to the method / path struct residing before the input buffer in memory
• ⁠the code leaks a file descriptor (and some memory) for each / request
• ⁠(also, usually / redirections would be handled internally, not made visible to the browser)
• ⁠you should not free() a pointer returned by fopen()
• ⁠the configuration handling code also leaks a little
• ⁠the file sending code uses unlimited size for reading a file, but then places the data in a constant sized buffer, ignoring the rest

For further studies:

• ⁠if you wish to handle binary files, you cannot use NUL-terminated strings anymore
• ⁠write() might not use the whole data provided and similarly, read() might not give you all the data you need at once ->>>Utilizzo di send() e recv() con il flag MSG_WAITALL:

**

• ⁠HEAD is a required method in the spec :)

**

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.