mirror of
https://github.com/ScuroNeko/mtg.git
synced 2026-09-01 16:01:55 +03:00
Add public method DomainFrontingAddress
This commit is contained in:
+7
-4
@@ -24,7 +24,7 @@ type Proxy struct {
|
|||||||
|
|
||||||
idleTimeout time.Duration
|
idleTimeout time.Duration
|
||||||
bufferSize int
|
bufferSize int
|
||||||
domainFrontAddress string
|
domainFrontingPort int
|
||||||
workerPool *ants.PoolWithFunc
|
workerPool *ants.PoolWithFunc
|
||||||
telegram *telegram.Telegram
|
telegram *telegram.Telegram
|
||||||
|
|
||||||
@@ -37,6 +37,10 @@ type Proxy struct {
|
|||||||
logger Logger
|
logger Logger
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (p *Proxy) DomainFrontingAddress() string {
|
||||||
|
return net.JoinHostPort(p.secret.Host, strconv.Itoa(p.domainFrontingPort))
|
||||||
|
}
|
||||||
|
|
||||||
func (p *Proxy) ServeConn(conn net.Conn) {
|
func (p *Proxy) ServeConn(conn net.Conn) {
|
||||||
ctx := newStreamContext(p.ctx, p.logger, conn)
|
ctx := newStreamContext(p.ctx, p.logger, conn)
|
||||||
defer ctx.Close()
|
defer ctx.Close()
|
||||||
@@ -247,7 +251,7 @@ func (p *Proxy) doDomainFronting(ctx *streamContext, conn *connRewind) {
|
|||||||
|
|
||||||
conn.Rewind()
|
conn.Rewind()
|
||||||
|
|
||||||
frontConn, err := p.network.DialContext(ctx, "tcp", p.domainFrontAddress)
|
frontConn, err := p.network.DialContext(ctx, "tcp", p.DomainFrontingAddress())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
p.logger.WarningError("cannot dial to the fronting domain", err)
|
p.logger.WarningError("cannot dial to the fronting domain", err)
|
||||||
|
|
||||||
@@ -324,8 +328,7 @@ func NewProxy(opts ProxyOpts) (*Proxy, error) { // nolint: cyclop, funlen
|
|||||||
ipBlocklist: opts.IPBlocklist,
|
ipBlocklist: opts.IPBlocklist,
|
||||||
eventStream: opts.EventStream,
|
eventStream: opts.EventStream,
|
||||||
logger: opts.Logger.Named("proxy"),
|
logger: opts.Logger.Named("proxy"),
|
||||||
domainFrontAddress: net.JoinHostPort(opts.Secret.Host,
|
domainFrontingPort: int(domainFrontingPort),
|
||||||
strconv.Itoa(domainFrontingPort)),
|
|
||||||
idleTimeout: idleTimeout,
|
idleTimeout: idleTimeout,
|
||||||
bufferSize: int(bufferSize),
|
bufferSize: int(bufferSize),
|
||||||
telegram: tg,
|
telegram: tg,
|
||||||
|
|||||||
Reference in New Issue
Block a user