Menet is a TCP network middleware that can be dynamically modified through HTTP requests.

Overview

Melon logo

Menet

Menet is a TCP network middleware that can be dynamically modified through HTTP requests.

This is an experimental project, do NOT use it in production.

Menet is like a combination of Nginx UNIT and FRP. On the one hand, users can use Menet to build their own tunnel or proxy services like FRP, and on the other hand, these services can dynamically configure routing like Nginx UNIT.

Installation

Menet is written by Melang which is a script language. So we just Install melang, please refer to the README of Melang repository.

Usage

Start the service

$ melang menet.m

Configuration

The configuration file is conf.m. The code in this file is a Melang array structure.

conf = [
    'admin': [ //HTTP API listen address
        'ip': '0.0.0.0', 
        'port': '1234'
    ],
    'tunnel': [ //tunnel server listen address
        'ip': '0.0.0.0',
        'port': '4321'
    ],
];

Menet is both a tunnel client and a tunnel server.

APIs

There are four APIs:

  • tunnel
  • service
  • bind
  • config
tunnel

Add or remove a tunnel, and complete the establishment of tunnel TCP and information synchronization.

http://ip:port/tunnel
  • HTTP Method: POST|DELETE

  • HTTP Body:

    {
        "name": "tunnel name",
        "dest": ["ip", "port"]
    }

    name will be synchronized to tunnel server automatically.

service

Add or remove a service. There are two kinds of services:

  • local
  • remote

local service represents the service that listens on the port locally, and the remote service represents which service to establish a TCP connection to.

http://ip:port/service
  • HTTP Method: POST|DELETE

  • HTTP Body:

    {
        "name": "service name",
        "key": "rc4 key",
        "timeout": 1000, //Connection timeout, in milliseconds. It's optional. If omitted, it means no timeout.
        "type": "local|remote",
        "addr": ["ip", "port"]"
    }
    
bind

Add or remove a tunnel-service mapping relationship. And of course, because there are two types of services, the mapping relationship is also divided into local and remote.

If you want to build a tunnel proxy service, you need to set the bind of the local service (assumed to be named service1) and the tunnel (assumed to be named tunnel1) on a Menet service, then you need to set up a remote service (also named service1) and tunnel (also named tunnel1) bind on the peer tunnel.

http://ip:port/bind
  • HTTP Method: POST|DELETE

  • HTTP Body:

    {
        "tunnel": "tunnel name",
        "service": "service name",
        "type": "local|remote"
    }
config

Display the configuration on Menet service.

http://ip:port/config
  • HTTP Method: GET
  • HTTP Body: None
Example
                  |---------------|                      |------------------|
    service1      |192.168.1.2    |        tunnel1       |192.168.1.3       |   service1
----------------> |8080    Menet  |--------------------->|4321      Menet   |-------------->192.168.1.3:80
                  |admin port:1234|                      |admin port:1234   |
                  |---------------|                      |------------------|

If we expect to get the 80 service content of 192.168.1.3 by accessing the 8080 port of 192.168.1.2, we need to make the following API calls:

$ curl -XPOST -d '{"name":"tunnel1", "dest":["192.168.1.3", "4321"]}' http://192.168.1.2:1234/tunnel
$ curl -XPOST -d '{"name":"service1", "key":"UHI@&s8sa*S", "type": "local", "addr":["0.0.0.0", "8080"]}' http://192.168.1.2:1234/service
$ curl -XPOST -d '{"name":"service1", "key":"UHI@&s8sa*S", "type": "remote", "addr":["192.168.1.3", "80"]}' http://192.168.1.3:1234/service
$ curl -XPOST -d '{"tunnel": "tunnel1", "service":"service1", "type": "local"}' http://192.168.1.2:1234/bind
$ curl -XPOST -d '{"tunnel": "tunnel1", "service":"service1", "type": "remote"}' http://192.168.1.3:1234/bind

We don't have to send tunnel request to 192.168.1.3, because the first command will help us to establish TCP and synchronize tunnel name to it.

You can now check the configuration of both Menet services using the config request.

License

GNU Affero General Public License v3.0

Copyright (c) 2022-present, Niklaus F. Schen

You might also like...
Say goodbye to the Fat ugly singleton Network Manager with this Network Layer

MHNetwork Protocol Oriented Network Layer Aim to avoid having bloated singleton NetworkManager Philosophy the main philosophy behind MHNetwork is to h

NWReachability - a pure Swift library for monitoring the network connection of iOS devices using Apple's Network framework.

NWReachability is a pure Swift library for monitoring the network connection of iOS devices using Apple's Network framework.

ServiceData is an HTTP networking library written in Swift which can download different types of data.

ServiceData Package Description : ServiceData is an HTTP networking library written in Swift which can download different types of data. Features List

SwiftCANLib is a library used to process Controller Area Network (CAN) frames utilizing the Linux kernel open source library SOCKETCAN.

SwiftCANLib SwiftCANLib is a library used to process Controller Area Network (CAN) frames utilizing the Linux kernel open source library SOCKETCAN. Th

🌸 Powerful Codable API requests builder and manager for iOS.
🌸 Powerful Codable API requests builder and manager for iOS.

This lib is about network requests with blackjack, roulette and craps! Using it you will be able to convert your massive API layer code into an awesom

a NSURLCache subclass for handling all web requests that use NSURLRequest

EVURLCache What is this? This is a NSURLCache subclass for handeling all web requests that use NSURLRequest. (This includes UIWebView) The EVURLCache

Synchronous requests for AFNetworking 1.x, 2.x, and 3.x
Synchronous requests for AFNetworking 1.x, 2.x, and 3.x

AFNetworking-Synchronous A minimal category which extends AFNetworking to support synchronous requests. Usage 3.x pod 'AFNetworking', '~ 3.0' pod

Request adapter for URL requests from "MovieLister" demo app (Swift for Good book, a chapter by Ben Scheirman)

RequestAdapter Request adapter for URL requests from "MovieLister" demo app (Swift for Good book, a chapter by Ben Scheirman) The code is taken from:

Quickstart-ios-swift-grpc - Quickstart for integrating Approov with iOS apps in Swift that make API requests you wish to protect using GRPC
Owner
Nik
Nik
Minimal web framework and middleware for Swift

Kunugi Kunugi(怚) is minimal web framework and middleware systems for Swift. This is inpired by Node.js' Koa. Kunugi doesn't provide http server its se

Yusuke Ito 35 Apr 18, 2022
πŸ”Œ Non-blocking TCP socket layer, with event-driven server and client.

Original authors Honza Dvorsky - http://honzadvorsky.com, @czechboy0 Matthias Kreileder - @matthiaskr1 At the request of the original authors, we ask

Vapor Community 574 Dec 7, 2022
Thin wrapper around NSURLSession in swift. Simplifies HTTP requests.

SwiftHTTP SwiftHTTP is a thin wrapper around NSURLSession in Swift to simplify HTTP requests. Features Convenient Closure APIs Simple Queue Support Pa

Dalton 1.9k Dec 7, 2022
Easy to use CFNetwork wrapper for HTTP requests, Objective-C, Mac OS X and iPhone

ASIHTTPRequest is an easy to use wrapper around the CFNetwork API that makes some of the more tedious aspects of communicating with web servers easier

Ben Copsey 5.8k Dec 14, 2022
A frida tool that capture GET/POST HTTP requests of iOS Swift library 'Alamofire' and disable SSL Pinning.

FridaHookSwiftAlamofire A frida tool that capture GET/POST HTTP requests of iOS Swift library 'Alamofire' and disable SSL Pinning. δΈ­ζ–‡ζ–‡ζ‘£εŠθΏ‡η¨‹ Features Ca

neilwu 69 Dec 16, 2022
CoreNetwork module with the basic functionality of requests to the network

CoreNetwork module with the basic functionality of requests to the network

Moscow Metro 4 Apr 27, 2022
VFNetwork is a protocol-oriented network layer that will help you assemble your requests in just a few steps.

Simple, Fast and Easy. Introduction VFNetwork is a protocol-oriented network layer that will help you assemble your requests in just a few steps. How

Victor Freitas 4 Aug 22, 2022
Http - Demo for Http Layer

http Example To run the example project, clone the repo, and run pod install fro

null 0 Jan 24, 2022
Another network wrapper for URLSession. Built to be simple, small and easy to create tests at the network layer of your application.

Another network wrapper for URLSession. Built to be simple, small and easy to create tests at the network layer of your application. Install Carthage

Ronan Rodrigo Nunes 89 Dec 26, 2022
A network extension app to block a user input URI. Meant as a network extension filter proof of concept.

URIBlockNE A network extension app to block a user input URI. Meant as a network extension filter proof of concept. This is just a research effort to

Charles Edge 5 Oct 17, 2022