From 4769992918157aad0b9570454f0534242565d8c1 Mon Sep 17 00:00:00 2001 From: hongqiaowei Date: Thu, 27 Oct 2022 09:55:02 +0800 Subject: [PATCH] Fix ip validation problem in app --- fizz-core/src/main/java/we/plugin/auth/App.java | 10 ++++------ fizz-core/src/main/java/we/plugin/auth/AppService.java | 10 ++++++---- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/fizz-core/src/main/java/we/plugin/auth/App.java b/fizz-core/src/main/java/we/plugin/auth/App.java index 38795db..df5e2c3 100644 --- a/fizz-core/src/main/java/we/plugin/auth/App.java +++ b/fizz-core/src/main/java/we/plugin/auth/App.java @@ -84,16 +84,14 @@ public class App { String subnet = ip.substring(0, i).trim(); String addrSeg = ip.substring(i + 1).trim(); if ("*".equals(addrSeg)) { - this.ips.put(subnet, Collections.singletonList(new String[]{"1", "255"})); + // this.ips.put(subnet, Collections.singletonList(new String[]{"1", "255"})); + List segs = this.ips.computeIfAbsent(subnet, k -> new ArrayList<>()); + segs.add(new String[]{"1", "255"}); } else if (addrSeg.indexOf('-') > 0) { String[] a = StringUtils.split(addrSeg, '-'); String beg = a[0].trim(); String end = a[1].trim(); - List lst = this.ips.get(subnet); - if (lst == null) { - lst = new ArrayList<>(); - this.ips.put(subnet, lst); - } + List lst = this.ips.computeIfAbsent(subnet, k -> new ArrayList<>()); lst.add(new String[]{beg, end}); } else { this.ips.put(ip, null); diff --git a/fizz-core/src/main/java/we/plugin/auth/AppService.java b/fizz-core/src/main/java/we/plugin/auth/AppService.java index 00026de..0913999 100644 --- a/fizz-core/src/main/java/we/plugin/auth/AppService.java +++ b/fizz-core/src/main/java/we/plugin/auth/AppService.java @@ -90,9 +90,10 @@ public class AppService { updateAppMap(app, appMapTmp); return Flux.just(e); } catch (Throwable t) { - throwable[0] = t; - log.info(json, t); - return Flux.error(t); + // throwable[0] = t; + log.warn(json, t); + // return Flux.error(t); + return Flux.just(e); } }).blockLast())).flatMap( e -> { @@ -107,7 +108,8 @@ public class AppService { } ).block(); if (error != ReactorUtils.EMPTY_THROWABLE) { - throw error; + // throw error; + log.error(Consts.S.EMPTY, error); } appMap = appMapTmp;