浏览代码

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 2 个月前
父节点
当前提交
b153a55149
没有帐户链接到提交者的电子邮件
共有 1 个文件被更改,包括 8 次插入1 次删除
  1. 8
    1
      mtglib/proxy.go

+ 8
- 1
mtglib/proxy.go 查看文件

@@ -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
 

正在加载...
取消
保存