feat: general protocol rewrite
This commit is contained in:
@ -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() {
|
||||
|
Reference in New Issue
Block a user