Skip to content

Commit

Permalink
Fix: redir-host mode crash
Browse files Browse the repository at this point in the history
  • Loading branch information
Dreamacro committed Feb 11, 2019
1 parent 8da19e8 commit 26a87f9
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions tunnel/tunnel.go
Original file line number Diff line number Diff line change
Expand Up @@ -107,15 +107,15 @@ func (t *Tunnel) resolveIP(host string) (net.IP, error) {
return t.resolver.ResolveIP(host)
}

func (t *Tunnel) needLookupIP() bool {
return t.hasResolver() && t.resolver.IsMapping()
func (t *Tunnel) needLookupIP(metadata *C.Metadata) bool {
return t.hasResolver() && t.resolver.IsMapping() && metadata.Host == "" && metadata.IP != nil
}

func (t *Tunnel) handleConn(localConn C.ServerAdapter) {
defer localConn.Close()
metadata := localConn.Metadata()

if t.needLookupIP() {
if t.needLookupIP(metadata) {
host, exist := t.resolver.IPToHost(*metadata.IP)
if exist {
metadata.Host = host
Expand Down

0 comments on commit 26a87f9

Please sign in to comment.