Fix: redir-host
mode crash
This commit is contained in:
parent
8da19e81a4
commit
26a87f9d34
1 changed files with 3 additions and 3 deletions
|
@ -107,15 +107,15 @@ func (t *Tunnel) resolveIP(host string) (net.IP, error) {
|
||||||
return t.resolver.ResolveIP(host)
|
return t.resolver.ResolveIP(host)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (t *Tunnel) needLookupIP() bool {
|
func (t *Tunnel) needLookupIP(metadata *C.Metadata) bool {
|
||||||
return t.hasResolver() && t.resolver.IsMapping()
|
return t.hasResolver() && t.resolver.IsMapping() && metadata.Host == "" && metadata.IP != nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (t *Tunnel) handleConn(localConn C.ServerAdapter) {
|
func (t *Tunnel) handleConn(localConn C.ServerAdapter) {
|
||||||
defer localConn.Close()
|
defer localConn.Close()
|
||||||
metadata := localConn.Metadata()
|
metadata := localConn.Metadata()
|
||||||
|
|
||||||
if t.needLookupIP() {
|
if t.needLookupIP(metadata) {
|
||||||
host, exist := t.resolver.IPToHost(*metadata.IP)
|
host, exist := t.resolver.IPToHost(*metadata.IP)
|
||||||
if exist {
|
if exist {
|
||||||
metadata.Host = host
|
metadata.Host = host
|
||||||
|
|
Loading…
Reference in a new issue