소스 검색

detect any ip

Darien Raymond 7 년 전
부모
커밋
2858b769dd
1개의 변경된 파일10개의 추가작업 그리고 1개의 파일을 삭제
  1. 10 1
      proxy/freedom/freedom.go

+ 10 - 1
proxy/freedom/freedom.go

@@ -65,12 +65,21 @@ func (h *Handler) resolveIP(ctx context.Context, domain string) net.Address {
 	return net.IPAddress(ips[dice.Roll(len(ips))])
 }
 
+func isValidAddress(addr *net.IPOrDomain) bool {
+	if addr == nil {
+		return false
+	}
+
+	a := addr.AsAddress()
+	return a != net.AnyIP
+}
+
 // Process implements proxy.Outbound.
 func (h *Handler) Process(ctx context.Context, link *core.Link, dialer proxy.Dialer) error {
 	destination, _ := proxy.TargetFromContext(ctx)
 	if h.config.DestinationOverride != nil {
 		server := h.config.DestinationOverride.Server
-		if server.Address != nil {
+		if isValidAddress(server.Address) {
 			destination.Address = server.Address.AsAddress()
 		}
 		if server.Port != 0 {