Explorar el Código

Merge pull request #379 from 9seconds/fix-telegram-ips

Show ip of telegram endpoints in event stream
tags/v2.2.2^2^2
Sergei Arkhipov hace 1 mes
padre
commit
b153a55149
No account linked to committer's email address
Se han modificado 1 ficheros con 8 adiciones y 1 borrados
  1. 8
    1
      mtglib/proxy.go

+ 8
- 1
mtglib/proxy.go Ver fichero

@@ -259,9 +259,16 @@ func (p *Proxy) doTelegramCall(ctx *streamContext) error {
259 259
 		ctx:      ctx,
260 260
 	}
261 261
 
262
+	telegramHost, _, err := net.SplitHostPort(foundAddr.Address)
263
+	if err != nil {
264
+		conn.Close() //nolint: errcheck
265
+
266
+		return fmt.Errorf("cannot parse telegram address %s: %w", foundAddr.Address, err)
267
+	}
268
+
262 269
 	p.eventStream.Send(ctx,
263 270
 		NewEventConnectedToDC(ctx.streamID,
264
-			conn.RemoteAddr().(*net.TCPAddr).IP, //nolint: forcetypeassert
271
+			net.ParseIP(telegramHost),
265 272
 			ctx.dc),
266 273
 	)
267 274
 

Loading…
Cancelar
Guardar