feat: авторизация по client-id, freeturn:// URI и подписки
- internal/clientsdb: БД клиентов с hot-reload + length-prefixed ID wire - internal/uri: parse/encode share-ссылок freeturn:// - internal/sub: загрузка и парсинг подписок (sub.md) - client: флаги -auth, -client-id, -sub; позиционный URI; ID через crypto/rand - server: подкоманда clients (add/remove/list), чтение ID под -clients-file - запись/чтение ID учитывают DTLS record-orientation (буфер на запись целиком) - docs: uri.md, sub.md; правки flags/deploy/quickstart - снят UTF-8 BOM по всем исходникам
This commit is contained in:
1 parent
41d877dc64
commit
e061345089
78 files changed
+1151
-82
No files matched your search
@@ -1,4 +1,4 @@
|
||||
package tcpfwd
|
||||
package tcpfwd
|
||||
|
||||
import (
|
||||
"context"
|
||||
@@ -8,6 +8,7 @@ import (
|
||||
"time"
|
||||
|
||||
"github.com/samosvalishe/free-turn-proxy/internal/client/ish"
|
||||
"github.com/samosvalishe/free-turn-proxy/internal/clientsdb"
|
||||
"github.com/samosvalishe/free-turn-proxy/internal/logx"
|
||||
"github.com/samosvalishe/free-turn-proxy/internal/netconn"
|
||||
"github.com/samosvalishe/free-turn-proxy/internal/proxy/common"
|
||||
@@ -30,6 +31,8 @@ type Params struct {
|
||||
GetCreds GetCredsFunc
|
||||
KCPProfile kcptun.Profile
|
||||
KCPFEC kcptun.FEC
|
||||
ClientID string
|
||||
Auth bool
|
||||
}
|
||||
|
||||
// BondHandler распределяет одно принятое TCP-соединение по всем активным сессиям пула.
|
||||
@@ -255,6 +258,13 @@ func createSmuxSession(ctx context.Context, deps *Deps, params *Params, peer *ne
|
||||
cleanupFns = append(cleanupFns, func() { _ = dtlsConn.Close() })
|
||||
deps.log().Debugf("DTLS connection established")
|
||||
|
||||
if params.Auth {
|
||||
if err := clientsdb.WriteClientID(dtlsConn, params.ClientID); err != nil {
|
||||
cleanup()
|
||||
return nil, nil, fmt.Errorf("send client ID: %w", err)
|
||||
}
|
||||
}
|
||||
|
||||
statsCtx, statsCancel := context.WithCancel(ctx) //nolint:gosec // cancel is held in cleanupFns and invoked via cleanup() LIFO
|
||||
cleanupFns = append(cleanupFns, statsCancel)
|
||||
st := stats.New(deps.log().DebugEnabled())
|
||||
|
||||
Reference in new issue
Block a user