Skip to content
This repository has been archived by the owner on Apr 21, 2022. It is now read-only.

sagarc03/vinbero

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Vinbero

GitHub release Github All Releases Build Status license Docker Stars Docker Pulls

VinberoVinbero

Intoduction

Vinbero is a modular server written in C, and its main goal is flexibility. Its core is very small; It just loads children modules, initializes them, calls callbacks on them and destroys them. Currently multithreading, tcp, epoll, tls, http, lua modules exist. So you can try it as a simple web application server with lua scripting. But if you add your own module it could be even used as a mailserver, chatserver or gameserver.

Example

docker run -it -d --name vinbero -p 8080:80 vinbero/alpine-vinbero_mt_http_lua
curl localhost:8080
docker run -it -d --name vinbero -p 8080:80 vinbero/alpine-vinbero-blog
#default id: 'admin', default password: 'password'
ngrok http 8080

Warning

Currently this software is under heavy development, so there will be bugs or the architecture can change. Writing new modules is not encouraged yet.

Usage

Usage: vinbero [OPTION]...
A Modular Server.
Options:
  -i --inline-config       Inline JSON-based config.
  -c --config-file         JSON-based config file.
  -f --logging-flag        Set logging level flag.
  -o --logging-option      Set logging option.
  -v --version             Print version info.
  -h --help                Print this help message.

Config file example

{
    "core": {
        "config": {"vinbero.setUid": 1001},
        "next": ["vinbero_tcp"]
    },
    "vinbero_tcp": {
        "path": "/usr/lib/vinbero/vinbero_tcp.so",
        "config": {"vinbero_tcp.port": 80, "vinbero_tcp.reuseAddress": true},
        "next": ["vinbero_mt"]
    }, 
    "vinbero_mt": {
        "path": "/usr/lib/vinbero/vinbero_mt.so",
        "config": {"vinbero_mt.workerCount": 4},
        "next": ["vinbero_tcp_mt_epoll"]
    },
    "vinbero_tcp_mt_epoll": {
        "path": "/usr/lib/vinbero/vinbero_tcp_mt_epoll.so",
        "config": {"vinbero_tcp_mt_epoll.clientTimeoutSeconds": 3},
        "next": ["vinbero_mt_epoll_http"]
    },
    "vinbero_mt_epoll_http": {
        "path": "/usr/lib/vinbero/vinbero_mt_epoll_http.so",
        "config": {},
        "next": ["vinbero_mt_http_lua"]
    },
    "vinbero_mt_http_lua": {
        "path": "/usr/lib/vinbero/vinbero_mt_http_lua.so",
        "config": {
            "vinbero_mt_http_lua.scriptFile": "/srv/app.lua",
            "vinbero_mt_http_lua.scriptArg": {}
        },
        "next": []
    }
}

Logging flags and Logging options

Logging flags and logging options are integer bitmasks:

  • FLAG_TRACE: 1
  • FLAG_DEBUG: 2
  • FLAG_INFO: 4
  • FLAG_WARN: 8
  • FLAG_ERROR: 16
  • FLAG_FATAL: 32
  • default logging flag is 62
  • OPTION_COLOR: 1
  • OPTION_SOURCE: 2
  • defualt logging option is 1

Core module config options

  • vinbero.setUid (int) : Change uid after module initialization.
  • vinbero.setGid (int) : Change gid after module initialization.

History

It is initially started as a hobby project by Byeonggon Lee at Jul, 2016. There have been many architectural changes for two years.

License

MPLv2

Contribution guide

Any type of contribution is welcome! Radical changes like function renaming or small changes like removing extra spacing is allowed too. Please don't hesitate to fork and contribute, this project needs a lot of work to do.

Language

Use English on your commit message so everyone can understand

Naming convention

Modules

Module names are snake case, and should be start with vinbero_

examples:
vinbero_mt_epoll_http
vinbero_mt

Interfaces

Interface names are snake case and should start with vinbero_interface and interface part must be uppercase with underscore.

examples:
vinbero_interface_HTTP

Structs

Struct names are pascal case and start with module names or interface names.

examples:
struct vinbero_mt_epoll_http_Module;
struct vinbero_mt_epoll_http_ParserData;

Functions

Function names are camel case and start with struct names if it act like methods, or start with module names or interface names.

examples:
int vinbero_tcp_mt_epoll_loadChildClModules(struct vinbero_common_ClModule* clModule);
int vinbero_interface_HTTP_onRequestStart(struct vinbero_common_ClModule* clModule);

Macros

Macro naming is same as C macros (uppercase with underscore). But it also starts with module names or interfaces names.

examples:

#define VINBERO_INTERFACE_HTTP_DLSYM(interface, dlHandle, ret)

Variables

Struct variable names are same as function names. but local variables don't start with module names

Reserved namespaces

  • vinbero_core
  • vinbero_common
  • vinbero_interface
  • vinbero_global
  • vinbero_static
  • vinbero_local

Versioning

This project follows semantic versioning

Branching

This project and all sub-projects are going to follow this branching model after vinbero v0.1.0 release.

  • master: Should always be executed without a bug.
  • dev: Development branch, can contain a bug
  • feature: When creating a new feature. this branch will be merged into dev branch
  • release: When creating a new release. this branch will be merged into master branch
  • hotfix: When a bug is found on master branch and you need to fix it fast, create this branch and merge it into master branch
  • bugfix: When a bug is found on dev branch, create this branch and merge it into dev branch

AUTHORS file

To update AUTHORS file, you have to run cmake or make to update AUTHORS file based on commits from origin/master

Example

  1. To start from an environment where all official modules are installed, run a docker container like this:
docker run -it -d --name vinbero vinbero/alpine-vinbero_mt_http_lua:dev
docker exec -it vinbero /bin/sh
  1. Inside the container clone a forked repository, start from a branch you want to improve e.g., dev, feature, release, hotfix, bugfix
cd /
rm -rf vinbero
git clone -b dev https://github.com/YOU/vinbero
  1. Checkout to a new branch
git checkout -b feature-something or git checkout
  1. Edit sources, run cmake, commit and push
  2. Make a pull request

Packages

No packages published

Languages

  • C 82.9%
  • CMake 12.7%
  • Dockerfile 4.4%