Add Readme

This commit is contained in:
lucheng
2024-04-24 12:25:43 +08:00
parent 6c43555035
commit 7982bfc5f4
4 changed files with 136 additions and 1 deletions
+65
View File
@@ -0,0 +1,65 @@
# virtuallan
## Description
virtuallan is a l2vpn. It can setup an virtual Ethernet LAN network in WAN.
## Features
* Basic auth for vpn endpoint
* AES encrypt for ethernet traffic
* Ethernet traffic in udp
## How it work
![architecture](./docs/statics/architecture.png)
* server create a linux bridge for each virtual ethernet network
* server create a tap interface for each authed endpoint
* client create a tap interface
* encrypt ethernet traffic that on tap interface and send to udp conn
* receive udp stream from conn and decrypt then send to tap interface
An udp connection just like a cable connect dc and ep taps. And the taps became to a pair linux veth peer, connected to a linux bridge.
## Build
```
➜ virtuallan git:(master) ✗ make
go generate pkg/cipher/cipher.go
go build -o virtuallan main.go
```
## Getting started
**Server**
```
➜ virtuallan git:(master) ✗ ./virtuallan server -h
NAME:
virtuallan server - run virtuallan server
USAGE:
virtuallan server [command options] [arguments...]
OPTIONS:
--config-dir value, -d value config directory to launch virtuallan server, conf.yaml as config file, users as user storage
--help, -h show help
```
config dir files:
* config.yaml: server config file
* users: user database csv format \<username>,\<user passwd base64 encode>
**Endpoint**
```
➜ virtuallan git:(master) ✗ ./virtuallan client -h
NAME:
virtuallan client - connect to virtuallan server
USAGE:
virtuallan client [command options] [arguments...]
OPTIONS:
--target value, -t value socket virtuallan server listened on
--addr value, -a value ipv4 address of current endpoint
--user value, -u value username of virtuallan endpoint
--passwd value, -p value password of virtuallan endpoint user
--help, -h show help
```
If not set -u and -p flags, you need to input user name and passwd in console
+70
View File
@@ -0,0 +1,70 @@
<mxfile host="65bd71144e">
<diagram id="kRQDh5C0-zVZ1US-Nkx1" name="Page-1">
<mxGraphModel dx="1094" dy="798" grid="1" gridSize="10" guides="1" tooltips="1" connect="1" arrows="1" fold="1" page="1" pageScale="1" pageWidth="850" pageHeight="1100" math="0" shadow="0">
<root>
<mxCell id="0"/>
<mxCell id="1" parent="0"/>
<mxCell id="23" value="" style="rounded=0;whiteSpace=wrap;html=1;" vertex="1" parent="1">
<mxGeometry x="50" y="30" width="690" height="460" as="geometry"/>
</mxCell>
<mxCell id="15" value="virtual ethernet network" style="ellipse;whiteSpace=wrap;html=1;dashed=1;" parent="1" vertex="1">
<mxGeometry x="125" y="140" width="570" height="310" as="geometry"/>
</mxCell>
<mxCell id="2" value="Date Center" style="rounded=0;whiteSpace=wrap;html=1;verticalAlign=top;align=left;" parent="1" vertex="1">
<mxGeometry x="240" y="75" width="340" height="105" as="geometry"/>
</mxCell>
<mxCell id="3" value="linux bridge" style="rounded=0;whiteSpace=wrap;html=1;verticalAlign=top;align=left;" parent="1" vertex="1">
<mxGeometry x="270" y="110" width="280" height="50" as="geometry"/>
</mxCell>
<mxCell id="5" style="edgeStyle=none;html=1;exitX=0.5;exitY=1;exitDx=0;exitDy=0;" parent="1" source="4" target="3" edge="1">
<mxGeometry relative="1" as="geometry"/>
</mxCell>
<mxCell id="4" value="tap" style="rounded=0;whiteSpace=wrap;html=1;" parent="1" vertex="1">
<mxGeometry x="290" y="140" width="50" height="20" as="geometry"/>
</mxCell>
<mxCell id="6" value="tap" style="rounded=0;whiteSpace=wrap;html=1;" parent="1" vertex="1">
<mxGeometry x="355" y="140" width="50" height="20" as="geometry"/>
</mxCell>
<mxCell id="7" value="" style="endArrow=none;dashed=1;html=1;dashPattern=1 3;strokeWidth=2;entryX=0.786;entryY=0.8;entryDx=0;entryDy=0;entryPerimeter=0;" parent="1" target="3" edge="1">
<mxGeometry width="50" height="50" relative="1" as="geometry">
<mxPoint x="440" y="150" as="sourcePoint"/>
<mxPoint x="490" y="100" as="targetPoint"/>
</mxGeometry>
</mxCell>
<mxCell id="10" value="Endpoint 1" style="rounded=0;whiteSpace=wrap;html=1;verticalAlign=top;align=left;" parent="1" vertex="1">
<mxGeometry x="80" y="400" width="160" height="50" as="geometry"/>
</mxCell>
<mxCell id="12" value="tap" style="rounded=0;whiteSpace=wrap;html=1;" parent="1" vertex="1">
<mxGeometry x="180" y="410" width="50" height="20" as="geometry"/>
</mxCell>
<mxCell id="13" value="Endpoint 2" style="rounded=0;whiteSpace=wrap;html=1;verticalAlign=top;align=left;" parent="1" vertex="1">
<mxGeometry x="550" y="400" width="160" height="50" as="geometry"/>
</mxCell>
<mxCell id="14" value="tap" style="rounded=0;whiteSpace=wrap;html=1;" parent="1" vertex="1">
<mxGeometry x="650" y="410" width="50" height="20" as="geometry"/>
</mxCell>
<mxCell id="16" value="" style="endArrow=none;html=1;exitX=0.5;exitY=0;exitDx=0;exitDy=0;entryX=0.5;entryY=1;entryDx=0;entryDy=0;" parent="1" source="12" target="4" edge="1">
<mxGeometry width="50" height="50" relative="1" as="geometry">
<mxPoint x="400" y="430" as="sourcePoint"/>
<mxPoint x="450" y="380" as="targetPoint"/>
</mxGeometry>
</mxCell>
<mxCell id="17" style="edgeStyle=none;html=1;exitX=0.5;exitY=1;exitDx=0;exitDy=0;entryX=0.5;entryY=0;entryDx=0;entryDy=0;endArrow=none;endFill=0;" parent="1" source="6" target="14" edge="1">
<mxGeometry relative="1" as="geometry"/>
</mxCell>
<mxCell id="19" value="NAT" style="rounded=0;whiteSpace=wrap;html=1;" parent="1" vertex="1">
<mxGeometry x="470" y="250" width="90" height="30" as="geometry"/>
</mxCell>
<mxCell id="20" value="send heartbet pkt to keep ct entry fresh" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=0;" parent="1" vertex="1">
<mxGeometry x="570" y="270" width="110" height="70" as="geometry"/>
</mxCell>
<mxCell id="21" value="switch io between udp connect and tap interface" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=0;" parent="1" vertex="1">
<mxGeometry x="150" y="260" width="110" height="60" as="geometry"/>
</mxCell>
<mxCell id="22" value="encrypted ethernet traffic in udp&amp;nbsp;" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=0;" parent="1" vertex="1">
<mxGeometry x="460" y="200" width="110" height="40" as="geometry"/>
</mxCell>
</root>
</mxGraphModel>
</diagram>
</mxfile>
Binary file not shown.

After

Width:  |  Height:  |  Size: 43 KiB

+1 -1
View File
@@ -91,7 +91,7 @@ func Run(cCtx *cli.Context) error {
case packet.P_RESPONSE:
switch pkt.VLBody.(*packet.RspBody).Code {
case packet.RSP_AUTH_REQUIRED:
log.Error("need reauth")
log.Error("auth failed")
os.Exit(1)
case packet.RSP_IP_CONFLICET:
log.Error("conflicet ip ", ipAddr)