Add public method DomainFrontingAddress

This commit is contained in:
9seconds
2021-03-29 12:09:23 +03:00
parent daa8b9c798
commit 75b05b9b14
+10 -7
View File
@@ -24,7 +24,7 @@ type Proxy struct {
idleTimeout time.Duration
bufferSize int
domainFrontAddress string
domainFrontingPort int
workerPool *ants.PoolWithFunc
telegram *telegram.Telegram
@@ -37,6 +37,10 @@ type Proxy struct {
logger Logger
}
func (p *Proxy) DomainFrontingAddress() string {
return net.JoinHostPort(p.secret.Host, strconv.Itoa(p.domainFrontingPort))
}
func (p *Proxy) ServeConn(conn net.Conn) {
ctx := newStreamContext(p.ctx, p.logger, conn)
defer ctx.Close()
@@ -247,7 +251,7 @@ func (p *Proxy) doDomainFronting(ctx *streamContext, conn *connRewind) {
conn.Rewind()
frontConn, err := p.network.DialContext(ctx, "tcp", p.domainFrontAddress)
frontConn, err := p.network.DialContext(ctx, "tcp", p.DomainFrontingAddress())
if err != nil {
p.logger.WarningError("cannot dial to the fronting domain", err)
@@ -324,11 +328,10 @@ func NewProxy(opts ProxyOpts) (*Proxy, error) { // nolint: cyclop, funlen
ipBlocklist: opts.IPBlocklist,
eventStream: opts.EventStream,
logger: opts.Logger.Named("proxy"),
domainFrontAddress: net.JoinHostPort(opts.Secret.Host,
strconv.Itoa(domainFrontingPort)),
idleTimeout: idleTimeout,
bufferSize: int(bufferSize),
telegram: tg,
domainFrontingPort: int(domainFrontingPort),
idleTimeout: idleTimeout,
bufferSize: int(bufferSize),
telegram: tg,
}
pool, err := ants.NewPoolWithFunc(int(concurrency), func(arg interface{}) {