浏览代码

More correct error if no addresses are found

tags/v2.1.5^2
9seconds 4 年前
父节点
当前提交
b15a8ec4a5
共有 2 个文件被更改,包括 6 次插入4 次删除
  1. 3
    0
      mtglib/internal/telegram/init.go
  2. 3
    4
      mtglib/internal/telegram/telegram.go

+ 3
- 0
mtglib/internal/telegram/init.go 查看文件

@@ -2,10 +2,13 @@ package telegram
2 2
 
3 3
 import (
4 4
 	"context"
5
+	"errors"
5 6
 
6 7
 	"github.com/9seconds/mtg/v2/essentials"
7 8
 )
8 9
 
10
+var ErrNoAddresses = errors.New("no addresses")
11
+
9 12
 type preferIP uint8
10 13
 
11 14
 const (

+ 3
- 4
mtglib/internal/telegram/telegram.go 查看文件

@@ -28,10 +28,9 @@ func (t Telegram) Dial(ctx context.Context, dc int) (essentials.Conn, error) {
28 28
 		addresses = append(t.pool.getV6(dc), t.pool.getV4(dc)...)
29 29
 	}
30 30
 
31
-	var (
32
-		conn essentials.Conn
33
-		err  error
34
-	)
31
+	var conn essentials.Conn
32
+
33
+	err := ErrNoAddresses
35 34
 
36 35
 	for _, v := range addresses {
37 36
 		conn, err = t.dialer.DialContext(ctx, v.network, v.address)

正在加载...
取消
保存