Use CloseRead and CloseWrites

This commit is contained in:
9seconds
2021-12-01 10:37:31 +03:00
parent 7b1f86b75d
commit ffad717829
32 changed files with 320 additions and 99 deletions
+3 -2
View File
@@ -2,7 +2,8 @@ package telegram
import (
"context"
"net"
"github.com/9seconds/mtg/v2/essentials"
)
type preferIP uint8
@@ -82,5 +83,5 @@ var (
)
type Dialer interface {
DialContext(ctx context.Context, network, address string) (net.Conn, error)
DialContext(ctx context.Context, network, address string) (essentials.Conn, error)
}
+4 -3
View File
@@ -3,8 +3,9 @@ package telegram
import (
"context"
"fmt"
"net"
"strings"
"github.com/9seconds/mtg/v2/essentials"
)
type Telegram struct {
@@ -13,7 +14,7 @@ type Telegram struct {
pool addressPool
}
func (t Telegram) Dial(ctx context.Context, dc int) (net.Conn, error) {
func (t Telegram) Dial(ctx context.Context, dc int) (essentials.Conn, error) {
var addresses []tgAddr
switch t.preferIP {
@@ -28,7 +29,7 @@ func (t Telegram) Dial(ctx context.Context, dc int) (net.Conn, error) {
}
var (
conn net.Conn
conn essentials.Conn
err error
)