1 Star 0 Fork 0

gngpp / vproxy

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
README.md 7.12 KB
一键复制 编辑 原始数据 按行查看 历史
wkgcass 提交于 2021-01-15 18:18 . add travis ci badge in README

vproxy

Build Status

中文文档

Intro

VProxy is a zero-dependency TCP Loadbalancer based on Java NIO. The project only requires Java 11 to run.

Clone it, compile it, then everything is ready for running.

Features

  1. TCP Loadbalancer with TLS termination
  2. HTTP/1.x and HTTP/2 Loadbalancer with Host header consideration
  3. Other tcp based protocol loadbalancer, such as grpc, dubbo
  4. Socks5 server
  5. DNS server and customizable A|AAAA records
  6. Kubernetes integration
  7. Many other standalone extended apps, such as WebSocksProxyAgent and WebSocksProxyServer

Make

use pre-built releases

See the release page.

For linux

Use the latest vproxy-linux binary file in release page.

Or

Use the jlink built runtime here.

For macos

Use the latest vproxy-macos binary file in release page.

For windows

Java runtime can be found here.

For musl

Use the jlink built runtime here.

NOTE: the runtime is in beta state.

pack
./gradlew clean jar
java -jar build/libs/vproxy.jar -Deploy=HelloWorld
jlink
make jlink
./build/image/bin/vproxy -Deploy=HelloWorld
docker
docker build --no-cache -t vproxy:latest https://raw.githubusercontent.com/wkgcass/vproxy/master/docker/Dockerfile
docker run --rm vproxy -Deploy=HelloWorld
graal native-image
./gradlew clean jar
native-image -jar build/libs/vproxy.jar --enable-all-security-services --no-fallback --no-server vproxy
./vproxy -Deploy=HelloWorld
use native fds impl

Only macos(bsd)/linux supported. And you might need to set the JAVA_HOME env variable before compiling.

make vfdposix
java -Dvfd=posix -Djava.library.path=./base/src/main/c -jar build/libs/vproxy.jar -Deploy=HelloWorld

For info about F-Stack, check the doc fstack-how-to.md.

And there's a special version for windows to support Tap devices: -Dvfd=windows, however the normal fds and event loop are stll based on jdk selector channel.

make vfdwindows
java -Dvfd=posix -Djava.library.path=./base/src/main/c -jar build/libs/vproxy.jar -Deploy=HelloWorld
test

Run test cases:

./gradlew runTest

Test vswitch, docker network plugin, vpctl, k8s controller:

# requires virtualbox installed

cd ./misc/auto-setup/
./auto-setup.sh
./auto-verify.sh

Aim

  • Zero dependency: no dependency other than java standard library, and no jni extensions.
  • Simple: keep code simple and clear.
  • Modifiable when running: no need to reload for configuration update.
  • Fast: performance is one of our main priorities.
  • TCP Loadbalancer: we now support TCP and TCP based protocols, also allow your own protocols.
  • Kubernetes: integrate vproxy resources into k8s.

How to use

use vproxy with kubernetes

Add crd, launch vproxy and controller

kubectl apply -f https://github.com/vproxy-tools/vpctl/blob/master/misc/crd.yaml
kubectl apply -f https://github.com/vproxy-tools/vpctl/blob/master/misc/k8s-vproxy.yaml

Launch the example app

kubectl apply -f https://github.com/vproxy-tools/vpctl/blob/master/misc/cr-example.yaml

Detailed info can be found here.

vpctl

A command line client application is provided to manipulate the vproxy instance. You may see more info in vpctl repo.

This tool is fully tested and simple to use. Some examples are provided in the tool repo for reference.

Simple mode

You can start a simple loadbalancer in one command:

java -Deploy=Simple -jar vproxy.jar \  
                bind {port} \
                backend {host1:port1,host2:port2} \
                [ssl {path of cert1,cert2} {path of key} \]
                [protocol {...} \]

Use help to view the parameters.

Standard mode

Use help to view the launching parameters.

When launching the vproxy instance, a http-controller on port 18776 and a resp-controller on port 16309 will be started. Then you can operate the vproxy instance using curl or redis-cli. You may also operate the vproxy instance directly using standard input (stdin).

See command.md and api doc for more info.
Questions about implementation detail are also welcome (in issues).

Doc

Contribute

Currently only I myself is working on this project. I would be very happy if you want to join :)

Thanks to Jetbrains for their great IDEs and the free open source license.

马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/gngpp/vproxy.git
git@gitee.com:gngpp/vproxy.git
gngpp
vproxy
vproxy
master

搜索帮助

Bbcd6f05 5694891 0cc6727d 5694891