diff options
| author | Michael Peter Christen <mc@yacy.net> | 2021-01-23 15:14:49 +0100 |
|---|---|---|
| committer | Michael Peter Christen <mc@yacy.net> | 2021-01-23 15:14:49 +0100 |
| commit | 198826c362cd31aa573f15b171ad7714fd1ab4e5 (patch) | |
| tree | 3db91e70ff531418b04b61a9f475d95d25a56675 /htroot/api | |
| parent | d9602e83251fc1154e0b03db4ed06f1fb434b965 (diff) | |
added network scanner process to discover all YaCy peers in the intranet
this will be used to wire YaCy peers in a kubernetes cluster
Diffstat (limited to 'htroot/api')
| -rw-r--r-- | htroot/api/localpeers.java | 41 | ||||
| -rw-r--r-- | htroot/api/localpeers.json | 5 |
2 files changed, 46 insertions, 0 deletions
diff --git a/htroot/api/localpeers.java b/htroot/api/localpeers.java new file mode 100644 index 000000000..ba933d125 --- /dev/null +++ b/htroot/api/localpeers.java @@ -0,0 +1,41 @@ +// localpeers.java +// ------------ +// (C) 2021 by Michael Peter Christen; mc@yacy.net +// first published 23.01.2021 on http://yacy.net +// +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 2 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + +import net.yacy.cora.protocol.RequestHeader; +import net.yacy.search.Switchboard; +import net.yacy.server.serverObjects; +import net.yacy.server.serverSwitch; +import net.yacy.server.servletProperties; + +public class localpeers { + + public static serverObjects respond(@SuppressWarnings("unused") final RequestHeader header, @SuppressWarnings("unused") final serverObjects post, @SuppressWarnings("unused") final serverSwitch env) { + final servletProperties prop = new servletProperties(); + int c = 0; + for (String urlstub: Switchboard.getSwitchboard().localpeers) { + prop.putJSON("peers_" + c + "_urlstub", urlstub); + c++; + } + prop.put("peers", c); + + // return rewrite properties + return prop; + } + +} diff --git a/htroot/api/localpeers.json b/htroot/api/localpeers.json new file mode 100644 index 000000000..e2be9012d --- /dev/null +++ b/htroot/api/localpeers.json @@ -0,0 +1,5 @@ +{ +"peers" : [#{peers|,}# +{"urlstub":"#[urlstub]#"} +#{/peers}#] +}
\ No newline at end of file |
