GithubHelp home page GithubHelp logo

water-melon / portal Goto Github PK

View Code? Open in Web Editor NEW
3.0 2.0 0.0 62 KB

Portal is a TCP tunnel written in C working on Linux. It does not only support web but also MySQL and anything running on TCP.

License: BSD 2-Clause "Simplified" License

Makefile 1.46% Shell 0.57% C 97.98%
proxy tunnel broadcast tcp c event-driven multiprocess network

portal's Introduction

Guide

Portal is a TCP Tunnel. It only support IPv4 now.

It helps that a service on Internet to fetch sets of data from an Intranet service. This is its common usage case. Besides that, it can help to build up a tunnel across many servers (whether or not on Internet) for decreasing network delay.

  • Environment
  • Install
  • Configure
  • Run

Environment

Portal is tested on Ubuntu 16.04 x86_64. It is written in C, so we need a C compiler (most Linux distribution already installed).

Portal only can working on Linux now, so you may need a Linux server to install it.

Install

Installation is very easy, just one command.

sudo make

It will get the newest version of Melon and compile it and Portal.

The target execute file will be built in current directory (portal/).

Configure

Where is configuration file

There are five configuration files under directory confs.

Configuration format

Portal is built up based on Melon (Melon is a framework library written in C), so its configuration file will derived from Melon's.

/*
 * log level, it has 5 levels, from lowest priority to highest, they are,
 * none, report, debug, warn and error.
 * This configuration Item means that logger records that messages those only higher or
 * equal to level 'none'.
 */
log_level "none";
/*
 * Process's uid in runtime.
 */
user "root";
daemon off;
/*
 * core file size if it generated unfortunately :-(.
 */
core_file_size "unlimited";
/*
 * The maximum of opened file descriptors.
 */
max_nofile 1024;
/*
 * Number of worker process.
 */
worker_proc 1;/*must be 1*/
thread_mode off; /*ignore this*/
framework on;/*ignore this*/
/*
 * Log file path.
 * You can modify this path and reload process in runtime.
 * For more detail, please see Melon's developer guide.
 */
log_path "/usr/local/melon/logs/melon.log";

...(ignore some useless items)

/*
 * All portal's configurations.
 */
portal {
    certify_token "abcdfg"; /*rc4 secret key, client's and server's must be identical.*/
    tunnel_number 100; /*only used on Tunnel client*/
    outerAddr "127.0.0.1:9999"; /*the address for accessing all other service*/
    innerAddr "0.0.0.0:1234";/*the address for accessing client or server*/
    role "server";/* "server" or "client" */
    /*
     * timeout:
     * -1 means never timeout.
     * < -1 will raise a fault while starting up.
     */
    inner_timeout 3000;/*ms -- ping timeout in Tunnel, connection timeour in Proxy.*/
    outer_timeout 3000;/*ms -- connection timeout (not used on Tunnel client)*/
    retry_timeout 3000;/*ms -- re-connect timeout (only used on Tunnel client)*/
    /*
     * mode only used on Tunnel.
     * There are two cases.
     * 1. A client connects to the server and it will send TCP data at first.
     * 2. A client connects to the server and wait for receiving data from server.
     * 1 -- positive.
     * 2 -- negative.
     * For mysql, it should be set negative.
     * This configuration item only works on client.
     */
    mode "positive";/* "positive" or "negative" */
    as "proxy";/*proxy, tunnel or broadcaster
                 indicates Portal will be used as a proxy, tunnel or broadcaster*/
}

Run

There are five modes of Portal manipulated by configuration file.

  • tunnel server

  • tunnel client

  • proxy server

  • proxy client

  • broadcaster

You can find these configuration templates in directory confs.

If we execute

./portal

Program will try to look for the configuration file in Melon's (core framework) installation directory.

So, we can designate the configuration file path through the -c parameter.

./portal -c /.../path/to/conf

portal's People

Contributors

water-melon avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar

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.