Skip to content

Commit

Permalink
use isWaitedStarttlsRes flag
Browse files Browse the repository at this point in the history
  • Loading branch information
linyows committed Oct 14, 2023
1 parent f4d97fd commit eb9de1e
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions pipe.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ type Pipe struct {
locked bool
blocker chan interface{}

isWaitedStarttlsRes bool

timeAtConnected time.Time
timeAtDataStarting time.Time

Expand Down Expand Up @@ -91,6 +93,7 @@ func (p *Pipe) mediateOnUpstream(b []byte, i int) ([]byte, int, bool) {
if !p.tls && p.readytls {
p.locked = true
er := p.starttls()
p.isWaitedStarttlsRes = true
if er != nil {
go p.afterCommHook([]byte(fmt.Sprintf("starttls error: %s", er.Error())), pxyToDst)
}
Expand Down Expand Up @@ -123,15 +126,15 @@ func (p *Pipe) mediateOnDownstream(b []byte, i int) ([]byte, int, bool) {
}
}

// time before email input
p.setTimeAtDataStarting(b)

// remove buffering ready response
if p.tls && !p.readytls && p.locked {
// continue
// remove buffering "220 2.0.0 Ready to start TLS" response
if p.isWaitedStarttlsRes {
p.isWaitedStarttlsRes = false
return b, i, true
}

// time before email input
p.setTimeAtDataStarting(b)

if p.isResponseOfEHLOWithoutStartTLS(b) {
go p.afterCommHook(data, pxyToSrc)
} else {
Expand Down

0 comments on commit eb9de1e

Please sign in to comment.