mirror of
https://github.com/ScuroNeko/mtg.git
synced 2026-09-01 03:34:02 +03:00
Remove contexts
This commit is contained in:
+1
-2
@@ -1,7 +1,6 @@
|
||||
package client
|
||||
|
||||
import (
|
||||
"context"
|
||||
"net"
|
||||
|
||||
"github.com/9seconds/mtg/config"
|
||||
@@ -9,4 +8,4 @@ import (
|
||||
"github.com/9seconds/mtg/wrappers"
|
||||
)
|
||||
|
||||
type Init func(context.Context, context.CancelFunc, net.Conn, string, *config.Config) (wrappers.Wrap, *mtproto.ConnectionOpts, error)
|
||||
type Init func(net.Conn, string, *config.Config) (wrappers.Wrap, *mtproto.ConnectionOpts, error)
|
||||
|
||||
+1
-4
@@ -1,7 +1,6 @@
|
||||
package client
|
||||
|
||||
import (
|
||||
"context"
|
||||
"net"
|
||||
"time"
|
||||
|
||||
@@ -15,8 +14,7 @@ import (
|
||||
|
||||
const handshakeTimeout = 10 * time.Second
|
||||
|
||||
func DirectInit(ctx context.Context, cancel context.CancelFunc, socket net.Conn, connID string,
|
||||
conf *config.Config) (wrappers.Wrap, *mtproto.ConnectionOpts, error) {
|
||||
func DirectInit(socket net.Conn, connID string, conf *config.Config) (wrappers.Wrap, *mtproto.ConnectionOpts, error) {
|
||||
if err := config.SetSocketOptions(socket); err != nil {
|
||||
return nil, nil, errors.Annotate(err, "Cannot set socket options")
|
||||
}
|
||||
@@ -37,7 +35,6 @@ func DirectInit(ctx context.Context, cancel context.CancelFunc, socket net.Conn,
|
||||
connOpts.ClientAddr = conn.RemoteAddr()
|
||||
|
||||
conn = wrappers.NewStreamCipher(conn, obfs2.Encryptor, obfs2.Decryptor)
|
||||
conn = wrappers.NewCtx(ctx, cancel, conn)
|
||||
|
||||
return conn, connOpts, nil
|
||||
}
|
||||
|
||||
+2
-4
@@ -1,7 +1,6 @@
|
||||
package client
|
||||
|
||||
import (
|
||||
"context"
|
||||
"net"
|
||||
|
||||
"github.com/9seconds/mtg/config"
|
||||
@@ -9,9 +8,8 @@ import (
|
||||
"github.com/9seconds/mtg/wrappers"
|
||||
)
|
||||
|
||||
func MiddleInit(ctx context.Context, cancel context.CancelFunc, socket net.Conn, connID string,
|
||||
conf *config.Config) (wrappers.Wrap, *mtproto.ConnectionOpts, error) {
|
||||
conn, opts, err := DirectInit(ctx, cancel, socket, connID, conf)
|
||||
func MiddleInit(socket net.Conn, connID string, conf *config.Config) (wrappers.Wrap, *mtproto.ConnectionOpts, error) {
|
||||
conn, opts, err := DirectInit(socket, connID, conf)
|
||||
if err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user