mirror of
https://github.com/ScuroNeko/mtg.git
synced 2026-08-31 22:24:02 +03:00
Merge pull request #230 from 9seconds/simplify-sockopts
Simplify sockopts
This commit is contained in:
+3
-6
@@ -9,6 +9,7 @@ import (
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
"github.com/9seconds/mtg/v2/essentials"
|
||||
"github.com/9seconds/mtg/v2/mtglib/internal/faketls"
|
||||
"github.com/9seconds/mtg/v2/mtglib/internal/faketls/record"
|
||||
"github.com/9seconds/mtg/v2/mtglib/internal/obfuscated2"
|
||||
@@ -25,7 +26,6 @@ type Proxy struct {
|
||||
|
||||
allowFallbackOnUnknownDC bool
|
||||
tolerateTimeSkewness time.Duration
|
||||
bufferSize int
|
||||
domainFrontingPort int
|
||||
workerPool *ants.PoolWithFunc
|
||||
telegram *telegram.Telegram
|
||||
@@ -46,7 +46,7 @@ func (p *Proxy) DomainFrontingAddress() string {
|
||||
|
||||
// ServeConn serves a connection. We do not check IP blocklist and
|
||||
// concurrency limit here.
|
||||
func (p *Proxy) ServeConn(conn net.Conn) {
|
||||
func (p *Proxy) ServeConn(conn essentials.Conn) {
|
||||
p.streamWaitGroup.Add(1)
|
||||
defer p.streamWaitGroup.Done()
|
||||
|
||||
@@ -85,7 +85,6 @@ func (p *Proxy) ServeConn(conn net.Conn) {
|
||||
relay.Relay(
|
||||
ctx,
|
||||
ctx.logger.Named("relay"),
|
||||
p.bufferSize,
|
||||
ctx.telegramConn,
|
||||
ctx.clientConn,
|
||||
)
|
||||
@@ -276,7 +275,6 @@ func (p *Proxy) doDomainFronting(ctx *streamContext, conn *connRewind) {
|
||||
relay.Relay(
|
||||
ctx,
|
||||
ctx.logger.Named("domain-fronting"),
|
||||
p.bufferSize,
|
||||
frontConn,
|
||||
conn,
|
||||
)
|
||||
@@ -306,14 +304,13 @@ func NewProxy(opts ProxyOpts) (*Proxy, error) {
|
||||
logger: opts.getLogger("proxy"),
|
||||
domainFrontingPort: opts.getDomainFrontingPort(),
|
||||
tolerateTimeSkewness: opts.getTolerateTimeSkewness(),
|
||||
bufferSize: opts.getBufferSize(),
|
||||
allowFallbackOnUnknownDC: opts.AllowFallbackOnUnknownDC,
|
||||
telegram: tg,
|
||||
}
|
||||
|
||||
pool, err := ants.NewPoolWithFunc(opts.getConcurrency(),
|
||||
func(arg interface{}) {
|
||||
proxy.ServeConn(arg.(net.Conn))
|
||||
proxy.ServeConn(arg.(essentials.Conn))
|
||||
},
|
||||
ants.WithLogger(opts.getLogger("ants")),
|
||||
ants.WithNonblocking(true))
|
||||
|
||||
Reference in New Issue
Block a user