Skip to content

Commit

Permalink
nilaway: retrier,dnscrypt/certs,pipws
Browse files Browse the repository at this point in the history
  • Loading branch information
ignoramous committed Oct 29, 2024
1 parent 407e760 commit dfa5a03
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 12 deletions.
13 changes: 4 additions & 9 deletions intra/dialers/retrier.go
Original file line number Diff line number Diff line change
Expand Up @@ -220,11 +220,8 @@ func (r *retrier) dialLocked() (c core.DuplexConn, err error) {

begin := time.Now()
c, err = r.doDialLocked(strat)
if c == nil {
err = core.OneErr(err, errNoConn)
}

rtt := time.Since(begin)

r.conn = c // c may be nil
r.timeout = calcTimeout(rtt)

Expand All @@ -250,10 +247,8 @@ func (r *retrier) doDialLocked(dialStrat int32) (_ core.DuplexConn, err error) {
default:
}
conn, err = r.dialer.DialTCP(r.raddr.Network(), r.laddr, r.raddr)
if err != nil {
if err != nil || conn == nil {
return nil, err
} else if conn == nil {
return nil, errNoConn
}
// todo: strat must be tcp or tls
return &splitter{conn: conn, strat: dialStrat}, nil
Expand All @@ -265,8 +260,8 @@ func (r *retrier) doDialLocked(dialStrat int32) (_ core.DuplexConn, err error) {
func (r *retrier) retryWriteReadLocked(buf []byte) (int, error) {
// r.dialLocked also closes provisional socket
newConn, err := r.dialLocked()
if err != nil {
return 0, err
if err != nil || newConn == nil {
return 0, core.OneErr(err, errNoConn)
}

var nw int
Expand Down
4 changes: 2 additions & 2 deletions intra/dnscrypt/certs.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,9 +69,9 @@ func fetchCurrentDNSCryptCert(proxy *DcMulti, serverName *string, pk ed25519.Pub
}
log.I("dnscrypt: [%v] Fetching DNSCrypt certificate for [%s] at [%v]", *serverName, providerName, serverAddress)
in, rtt, err := dnsExchange(proxy.dialer, &query, serverAddress, serverName)
if err != nil {
if err != nil || in == nil {
log.W("dnscrypt: [%s] TIMEOUT %v", *serverName, err)
return certinfo{}, err
return certinfo{}, core.OneErr(err, errFetchingCerts)
}
now := uint32(time.Now().Unix())
certInfo := certinfo{CryptoConstruction: xdns.UndefinedConstruction}
Expand Down
3 changes: 2 additions & 1 deletion intra/ipn/pipws.go
Original file line number Diff line number Diff line change
Expand Up @@ -322,7 +322,8 @@ func (t *pipws) forward(network, addr string) (protect.Conn, error) {
rurl := u.String()
c, res, err := t.wsconn(rurl, msg)
t.lastdial = time.Now()
if err != nil {
if err != nil || res == nil { // nilaway
err = core.OneErr(err, errNoProxyConn)
core.CloseConn(c)
log.E("pipws: req %s err: %v", rurl, err)
t.status.Store(TKO)
Expand Down

0 comments on commit dfa5a03

Please sign in to comment.