|
|
@@ -27,6 +27,7 @@ type Proxy struct {
|
|
27
|
27
|
telegram *telegram.Telegram
|
|
28
|
28
|
|
|
29
|
29
|
secret Secret
|
|
|
30
|
+ network Network
|
|
30
|
31
|
antiReplayCache AntiReplayCache
|
|
31
|
32
|
timeAttackDetector TimeAttackDetector
|
|
32
|
33
|
ipBlocklist IPBlocklist
|
|
|
@@ -139,13 +140,13 @@ func (p *Proxy) doFakeTLSHandshake(ctx *streamContext) error {
|
|
139
|
140
|
}
|
|
140
|
141
|
|
|
141
|
142
|
if p.antiReplayCache.SeenBefore(hello.SessionID) {
|
|
142
|
|
- p.logger.Warning("anti replay attack was detected")
|
|
143
|
|
-
|
|
144
|
|
- return fmt.Errorf("anti replay attack from %s", ctx.ClientIP().String())
|
|
|
143
|
+ return errReplayAttackDetected
|
|
145
|
144
|
}
|
|
146
|
145
|
|
|
147
|
146
|
if err := faketls.SendWelcomePacket(ctx.clientConn, p.secret.Key[:], hello); err != nil {
|
|
148
|
|
- return fmt.Errorf("cannot send a welcome packet: %w", err)
|
|
|
147
|
+ p.logger.InfoError("cannot send welcome packet", err)
|
|
|
148
|
+
|
|
|
149
|
+ return errCannotSendWelcomePacket
|
|
149
|
150
|
}
|
|
150
|
151
|
|
|
151
|
152
|
ctx.clientConn = &faketls.Conn{
|
|
|
@@ -249,6 +250,7 @@ func NewProxy(opts ProxyOpts) (*Proxy, error) { // nolint: cyclop, funlen
|
|
249
|
250
|
ctx: ctx,
|
|
250
|
251
|
ctxCancel: cancel,
|
|
251
|
252
|
secret: opts.Secret,
|
|
|
253
|
+ network: opts.Network,
|
|
252
|
254
|
antiReplayCache: opts.AntiReplayCache,
|
|
253
|
255
|
timeAttackDetector: opts.TimeAttackDetector,
|
|
254
|
256
|
ipBlocklist: opts.IPBlocklist,
|