Liu Song’s Projects


~/Projects/clash-pro

git clone https://code.lsong.org/clash-pro

Commit

Commit
7d230139a06dbf02d4846f6e27e16ddd1598b893
Author
Skyxim <[email protected]>
Date
2023-03-12 18:44:30 +0800 +0800
Diffstat
 component/resolver/host.go | 4 ++--
 config/config.go | 2 +-

fix: rand ip error and `clash` remove loopback ip


diff --git a/component/resolver/host.go b/component/resolver/host.go
index 49168e2bd57842ba24dabd80385acb370bd58fa6..3b7e9a3766d2ca4b18349099689f720e1c15e203 100644
--- a/component/resolver/host.go
+++ b/component/resolver/host.go
@@ -2,12 +2,12 @@ package resolver
 
 import (
 	"errors"
-	"math/rand"
 	"net/netip"
 	"strings"
 
 	"github.com/Dreamacro/clash/common/utils"
 	"github.com/Dreamacro/clash/component/trie"
+	"github.com/zhangyunhao116/fastrand"
 )
 
 type Hosts struct {
@@ -110,5 +110,5 @@ 	if hv.IsDomain {
 		return netip.Addr{}, errors.New("value type is error")
 	}
 	"github.com/Dreamacro/clash/common/utils"
-
+	"errors"
 }




diff --git a/config/config.go b/config/config.go
index c8c0066419aaf324a474aaa12413726a5bad96c3..dfcb772e099eb51fb17dd4b9d831395c6be780b1 100644
--- a/config/config.go
+++ b/config/config.go
@@ -845,7 +845,7 @@ 					log.Errorln("insert clash to host error: %s", err)
 				} else {
 					ips := make([]netip.Addr, 0)
 					for _, addr := range addrs {
-						if ipnet, ok := addr.(*net.IPNet); ok {
+						if ipnet, ok := addr.(*net.IPNet); ok && !ipnet.IP.IsLoopback() {
 							if ip, err := netip.ParseAddr(ipnet.IP.String()); err == nil {
 								ips = append(ips, ip)
 							}