feat: general protocol rewrite

This commit is contained in:
2020-10-26 19:42:07 +01:00
parent 536100da90
commit 96c1575a0b
20 changed files with 628 additions and 523 deletions

View File

@ -3,6 +3,7 @@ package main
import (
"context"
"flag"
"fmt"
"math/rand"
"time"
@ -11,15 +12,18 @@ import (
"gitlab.com/wpetit/goweb/logger"
)
const sharedKey = "go-tunnel"
const salt = "go-tunnel"
func main() {
var (
clientID string
clientID = fmt.Sprintf("client-%d", time.Now().Unix())
serverAddr = "127.0.0.1:36543"
sharedKey = "go-tunnel"
)
flag.StringVar(&clientID, "id", "", "Client ID")
flag.StringVar(&sharedKey, "shared-key", sharedKey, "shared key")
flag.StringVar(&clientID, "id", clientID, "Client ID")
flag.StringVar(&serverAddr, "server-addr", serverAddr, "server address")
flag.Parse()
ctx := context.Background()
@ -28,12 +32,12 @@ func main() {
logger.SetLevel(slog.LevelDebug)
client := tunnel.NewClient(
tunnel.WithClientServerAddress(serverAddr),
tunnel.WithClientCredentials(clientID),
tunnel.WithClientAESBlockCrypt(sharedKey, salt),
)
defer client.Close()
initialBackoff := time.Second * 10
initialBackoff := time.Second * 2
backoff := initialBackoff
sleep := func() {