generalized localhost naming.

this is also a preparation for a better IPv6 implementation.
pull/1/head
Michael Peter Christen 13 years ago
parent 77f795756c
commit 96aeb127e3

@ -30,8 +30,8 @@
// javac -classpath .:../classes Blog.java
// if the shell's current path is HTROOT
import java.util.Date;
import java.text.DateFormat;
import java.util.Date;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
@ -39,6 +39,7 @@ import java.util.Locale;
import java.util.Map;
import net.yacy.cora.document.UTF8;
import net.yacy.cora.protocol.Domains;
import net.yacy.cora.protocol.HeaderFramework;
import net.yacy.cora.protocol.RequestHeader;
import net.yacy.peers.NewsPool;
@ -53,12 +54,12 @@ public class Blog {
private static final String DEFAULT_PAGE = "blog_default";
private static DateFormat SimpleFormatter = DateFormat.getDateTimeInstance(DateFormat.DEFAULT,DateFormat.DEFAULT, Locale.getDefault());
/**
* print localized date/time "yyyy/mm/dd HH:mm:ss"
* @param date
* @return
*/
* @return
*/
public static String dateString(final Date date) {
return SimpleFormatter.format(date);
}
@ -100,7 +101,7 @@ public class Blog {
}
String pagename = post.get("page", DEFAULT_PAGE);
final String ip = header.get(HeaderFramework.CONNECTION_PROP_CLIENTIP, "127.0.0.1");
final String ip = header.get(HeaderFramework.CONNECTION_PROP_CLIENTIP, Domains.LOCALHOST);
String strAuthor = post.get("author", "anonymous");

@ -36,6 +36,7 @@ import java.util.Date;
import java.util.Iterator;
import net.yacy.cora.document.UTF8;
import net.yacy.cora.protocol.Domains;
import net.yacy.cora.protocol.HeaderFramework;
import net.yacy.cora.protocol.RequestHeader;
import net.yacy.kelondro.logging.Log;
@ -83,7 +84,7 @@ public class BlogComments {
}
String pagename = post.get("page", DEFAULT_PAGE);
final String ip = post.get(HeaderFramework.CONNECTION_PROP_CLIENTIP, "127.0.0.1");
final String ip = post.get(HeaderFramework.CONNECTION_PROP_CLIENTIP, Domains.LOCALHOST);
String strAuthor = post.get("author", "anonymous");

@ -1,4 +1,4 @@
//Config_Accounts_p.java
//Config_Accounts_p.java
//-----------------------
//part of the AnomicHTTPD caching proxy
//(C) by Michael Peter Christen; mc@yacy.net
@ -29,25 +29,25 @@
//javac -classpath .:../Classes Message.java
//if the shell's current path is HTROOT
import java.util.EnumMap;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import net.yacy.cora.protocol.Domains;
import net.yacy.cora.protocol.RequestHeader;
import net.yacy.kelondro.logging.Log;
import net.yacy.kelondro.order.Base64Order;
import net.yacy.kelondro.order.Digest;
import net.yacy.search.Switchboard;
import net.yacy.search.SwitchboardConstants;
import de.anomic.data.UserDB;
import de.anomic.data.UserDB.AccessRight;
import de.anomic.server.serverObjects;
import de.anomic.server.serverSwitch;
import java.util.EnumMap;
import java.util.Map;
public class ConfigAccounts_p {
public static serverObjects respond(final RequestHeader header, final serverObjects post, final serverSwitch env) {
final serverObjects prop = new serverObjects();
@ -57,7 +57,7 @@ public class ConfigAccounts_p {
// admin password
boolean localhostAccess = sb.getConfigBool("adminAccountForLocalhost", false);
if (post != null && post.containsKey("setAdmin")) {
localhostAccess = "localhost".equals(post.get("access", ""));
localhostAccess = Domains.isLocalhost(post.get("access", ""));
final String user = (post == null) ? "" : post.get("adminuser", "");
final String pw1 = (post == null) ? "" : post.get("adminpw1", "");
final String pw2 = (post == null) ? "" : post.get("adminpw2", "");
@ -68,7 +68,7 @@ public class ConfigAccounts_p {
env.setConfig(SwitchboardConstants.ADMIN_ACCOUNT_B64MD5, Digest.encodeMD5Hex(Base64Order.standardCoder.encodeString(user + ":" + pw1)));
env.setConfig("adminAccount", "");
}
if (localhostAccess) {
sb.setConfig("adminAccountForLocalhost", true);
@ -87,16 +87,16 @@ public class ConfigAccounts_p {
}
}
}
if (env.getConfig(SwitchboardConstants.ADMIN_ACCOUNT_B64MD5, "").length() == 0 && !env.getConfigBool("adminAccountForLocalhost", false)) {
prop.put("passwordNotSetWarning", 1);
}
prop.put("localhost.checked", (localhostAccess) ? 1 : 0);
prop.put("account.checked", (localhostAccess) ? 0 : 1);
prop.put("statusPassword", localhostAccess ? "0" : "1");
prop.put("defaultUser", "admin");
//default values
prop.put("current_user", "newuser");
prop.put("username", "");
@ -115,13 +115,13 @@ public class ConfigAccounts_p {
c++;
}
prop.put("rights", c);
prop.put("users", "0");
if (sb.userDB == null) {
return prop;
}
if (post == null) {
//do nothing
@ -130,7 +130,7 @@ public class ConfigAccounts_p {
//current_user = edited user
} else if (post.containsKey("user") && !"newuser".equals(post.get("user"))){
if (post.containsKey("change_user")) {
//defaults for newuser are set above
//defaults for newuser are set above
entry = sb.userDB.getEntry(post.get("user"));
// program crashes if a submit with empty username was made on previous mask and the user clicked on the
// link: "If you want to manage more Users, return to the user page." (parameter "user" is empty)
@ -176,10 +176,10 @@ public class ConfigAccounts_p {
for(final AccessRight right : rights) {
rightsSet.put(right, post.containsKey(right.toString()) && "on".equals(post.get(right.toString())) ? "true" : "false");
}
final Map<String, String> mem = new HashMap<String, String>();
if( "newuser".equals(post.get("current_user"))){ //new user
if (!"".equals(pw1)) { //change only if set
mem.put(UserDB.Entry.MD5ENCODED_USERPWD_STRING, Digest.encodeMD5Hex(username + ":" + pw1));
}
@ -202,7 +202,7 @@ public class ConfigAccounts_p {
} catch (final IllegalArgumentException e) {
prop.put("error", "3");
}
} else { //edit user
entry = sb.userDB.getEntry(username);
@ -235,7 +235,7 @@ public class ConfigAccounts_p {
}//edit user
prop.putHTML("username", username);
}
//Generate Userlist
final Iterator<UserDB.Entry> it = sb.userDB.iterator(true);
int numUsers=0;

@ -207,7 +207,7 @@ public class CrawlStartScanner_p
"/Crawler_p.html?createBookmark=off&xsstopw=off&crawlingDomMaxPages=10000&intention=&range=domain&indexMedia=on&recrawl=nodoubles&xdstopw=off&storeHTCache=on&sitemapURL=&repeat_time=7&crawlingQ=on&cachePolicy=iffresh&indexText=on&crawlingMode=url&mustnotmatch=&crawlingDomFilterDepth=1&crawlingDomFilterCheck=off&crawlingstart=Start%20New%20Crawl&xpstopw=off&repeat_unit=seldays&crawlingDepth=99&directDocByURL=off";
path += "&crawlingURL=" + url.toNormalform(true, false);
WorkTables.execAPICall(
"localhost",
Domains.LOCALHOST,
(int) sb.getConfigLong("port", 8090),
sb.getConfig(SwitchboardConstants.ADMIN_ACCOUNT_B64MD5, ""),
path,
@ -254,7 +254,7 @@ public class CrawlStartScanner_p
"/Crawler_p.html?createBookmark=off&xsstopw=off&crawlingDomMaxPages=10000&intention=&range=domain&indexMedia=on&recrawl=nodoubles&xdstopw=off&storeHTCache=on&sitemapURL=&repeat_time=7&crawlingQ=on&cachePolicy=iffresh&indexText=on&crawlingMode=url&mustnotmatch=&crawlingDomFilterDepth=1&crawlingDomFilterCheck=off&crawlingstart=Start%20New%20Crawl&xpstopw=off&repeat_unit=seldays&crawlingDepth=99";
path += "&crawlingURL=" + urlString;
WorkTables.execAPICall(
"localhost",
Domains.LOCALHOST,
(int) sb.getConfigLong("port", 8090),
sb.getConfig(SwitchboardConstants.ADMIN_ACCOUNT_B64MD5, ""),
path,

@ -33,6 +33,7 @@ import java.net.MalformedURLException;
import java.util.Date;
import net.yacy.cora.document.UTF8;
import net.yacy.cora.protocol.Domains;
import net.yacy.cora.protocol.HeaderFramework;
import net.yacy.cora.protocol.RequestHeader;
import net.yacy.cora.services.federated.yacy.CacheStrategy;
@ -88,7 +89,7 @@ public class QuickCrawlLink_p {
//host = hostSocket.substring(0, pos);
}
prop.put("mode_host", "localhost");
prop.put("mode_host", Domains.LOCALHOST);
prop.put("mode_port", port);
return prop;

@ -114,7 +114,7 @@ public class SettingsAck_p {
final InetSocketAddress theNewAddress = theServerCore.generateSocketAddress(port);
final String hostName = Domains.getHostName(theNewAddress.getAddress());
prop.put("info_restart", "1");
prop.put("info_restart_ip",(hostName.equals("0.0.0.0"))? "localhost" : hostName);
prop.put("info_restart_ip",(hostName.equals("0.0.0.0"))? Domains.LOCALHOST : hostName);
prop.put("info_restart_port", theNewAddress.getPort());
env.setConfig("port", port);

@ -29,6 +29,7 @@
import java.io.File;
import net.yacy.cora.protocol.Domains;
import net.yacy.cora.protocol.HeaderFramework;
import net.yacy.cora.protocol.RequestHeader;
import net.yacy.kelondro.logging.Log;
@ -46,7 +47,7 @@ public class Steering {
final serverObjects prop = new serverObjects();
prop.put("info", "0"); //no information submitted
final String requestIP = post.get(HeaderFramework.CONNECTION_PROP_CLIENTIP, "127.0.0.1");
final String requestIP = post.get(HeaderFramework.CONNECTION_PROP_CLIENTIP, Domains.LOCALHOST);
// handle access rights
if (!sb.verifyAuthentication(header)) {

@ -29,6 +29,7 @@ import java.util.TreeSet;
import java.util.regex.Pattern;
import net.yacy.cora.document.UTF8;
import net.yacy.cora.protocol.Domains;
import net.yacy.cora.protocol.RequestHeader;
import net.yacy.kelondro.blob.Tables;
import net.yacy.kelondro.index.RowSpaceExceededException;
@ -170,7 +171,7 @@ public class Table_API_p {
}
// now call the api URLs and store the result status
final Map<String, Integer> l = sb.tables.execAPICalls("localhost", (int) sb.getConfigLong("port", 8090), sb.getConfig(SwitchboardConstants.ADMIN_ACCOUNT_B64MD5, ""), pks);
final Map<String, Integer> l = sb.tables.execAPICalls(Domains.LOCALHOST, (int) sb.getConfigLong("port", 8090), sb.getConfig(SwitchboardConstants.ADMIN_ACCOUNT_B64MD5, ""), pks);
// construct result table
prop.put("showexec", l.size() > 0 ? 1 : 0);

@ -32,6 +32,7 @@ import java.io.InputStream;
import java.net.MalformedURLException;
import java.util.Map;
import net.yacy.cora.protocol.Domains;
import net.yacy.cora.protocol.HeaderFramework;
import net.yacy.cora.protocol.RequestHeader;
import net.yacy.cora.services.federated.yacy.CacheStrategy;
@ -67,7 +68,7 @@ public class ViewImage {
String urlString = post.get("url", "");
final String urlLicense = post.get("code", "");
final boolean auth = (header.get(HeaderFramework.CONNECTION_PROP_CLIENTIP, "")).equals("localhost") || sb.verifyAuthentication(header); // handle access rights
final boolean auth = Domains.isLocalhost(header.get(HeaderFramework.CONNECTION_PROP_CLIENTIP, "")) || sb.verifyAuthentication(header); // handle access rights
DigestURI url = null;
if ((urlString.length() > 0) && (auth)) try {

@ -39,6 +39,7 @@ import java.util.Locale;
import java.util.Map;
import net.yacy.cora.document.UTF8;
import net.yacy.cora.protocol.Domains;
import net.yacy.cora.protocol.HeaderFramework;
import net.yacy.cora.protocol.RequestHeader;
import net.yacy.kelondro.util.ByteBuffer;
@ -73,7 +74,7 @@ public class Wiki {
String access = sb.getConfig("WikiAccess", "admin");
final String pagename = get(post, "page", "start");
final String ip = get(post, HeaderFramework.CONNECTION_PROP_CLIENTIP, "127.0.0.1");
final String ip = get(post, HeaderFramework.CONNECTION_PROP_CLIENTIP, Domains.LOCALHOST);
String author = get(post, "author", ANONYMOUS);
if (author.equals(ANONYMOUS)) {
author = WikiBoard.guessAuthor(ip);

@ -24,6 +24,7 @@
// 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.Domains;
import net.yacy.cora.protocol.RequestHeader;
import net.yacy.search.Switchboard;
import net.yacy.search.SwitchboardConstants;
@ -39,7 +40,7 @@ public class opensearchdescription {
String promoteSearchPageGreeting = env.getConfig(SwitchboardConstants.GREETING, "");
if (env.getConfigBool(SwitchboardConstants.GREETING_NETWORK_NAME, false)) promoteSearchPageGreeting = env.getConfig("network.unit.description", "");
String thisaddress = header.get("Host", "127.0.0.1");
String thisaddress = header.get("Host", Domains.LOCALHOST);
if (thisaddress.indexOf(':',0) == -1) thisaddress += ":" + serverCore.getPortNr(env.getConfig("port", "8090"));
int compareyacy = 0;

@ -1075,7 +1075,7 @@ public class yacysearch {
prop.put("depth", "0");
// adding some additional properties needed for the rss feed
String hostName = header.get("Host", "localhost");
String hostName = header.get("Host", Domains.LOCALHOST);
if ( hostName.indexOf(':', 0) == -1 ) {
hostName += ":" + serverCore.getPortNr(env.getConfig("port", "8090"));
}
@ -1136,7 +1136,7 @@ public class yacysearch {
// hostname and port (assume locahost if nothing helps)
final InetAddress hostIP = Domains.myPublicLocalIP();
prop.put("myhost", hostIP != null ? hostIP.getHostAddress() : "localhost");
prop.put("myhost", hostIP != null ? hostIP.getHostAddress() : Domains.LOCALHOST);
prop.put("myport", serverCore.getPortNr(sb.getConfig("port", "8090")));
// return rewrite properties

@ -24,6 +24,7 @@ import java.util.concurrent.LinkedBlockingQueue;
import java.util.concurrent.TimeUnit;
import net.yacy.cora.document.RSSMessage;
import net.yacy.cora.protocol.Domains;
import net.yacy.cora.protocol.HeaderFramework;
import net.yacy.cora.protocol.RequestHeader;
import net.yacy.cora.services.federated.opensearch.SRURSSConnector;
@ -119,7 +120,7 @@ public class yacysearch_location {
if (post == null) return prop;
String promoteSearchPageGreeting = env.getConfig(SwitchboardConstants.GREETING, "");
if (env.getConfigBool(SwitchboardConstants.GREETING_NETWORK_NAME, false)) promoteSearchPageGreeting = env.getConfig("network.unit.description", "");
String hostName = header.get("Host", "localhost");
String hostName = header.get("Host", Domains.LOCALHOST);
if (hostName.indexOf(':',0) == -1) hostName += ":" + serverCore.getPortNr(env.getConfig("port", "8090"));
final String originalquerystring = (post == null) ? "" : post.get("query", post.get("search", "")).trim(); // SRU compliance
final boolean global = post.get("kml_resource", "local").equals("global");

@ -31,6 +31,7 @@ import net.yacy.cora.date.GenericFormatter;
import net.yacy.cora.document.ASCII;
import net.yacy.cora.document.Classification;
import net.yacy.cora.document.Classification.ContentDomain;
import net.yacy.cora.protocol.Domains;
import net.yacy.cora.protocol.HeaderFramework;
import net.yacy.cora.protocol.RequestHeader;
import net.yacy.cora.protocol.RequestHeader.FileType;
@ -70,7 +71,7 @@ public class yacysearchitem {
final String eventID = post.get("eventID", "");
final boolean authenticated = sb.adminAuthenticated(header) >= 2;
final int item = post.getInt("item", -1);
final boolean auth = (header.get(HeaderFramework.CONNECTION_PROP_CLIENTIP, "")).equals("localhost") || sb.verifyAuthentication(header);
final boolean auth = Domains.isLocalhost(header.get(HeaderFramework.CONNECTION_PROP_CLIENTIP, "")) || sb.verifyAuthentication(header);
final RequestHeader.FileType fileType = header.fileType();
// default settings for blank item

@ -41,6 +41,7 @@ import java.util.concurrent.ConcurrentMap;
import net.yacy.cora.document.ASCII;
import net.yacy.cora.document.UTF8;
import net.yacy.cora.order.CloneableIterator;
import net.yacy.cora.protocol.Domains;
import net.yacy.cora.services.federated.yacy.CacheStrategy;
import net.yacy.kelondro.data.meta.DigestURI;
import net.yacy.kelondro.data.meta.URIMetadataRow;
@ -59,7 +60,6 @@ public class Balancer {
private static final String indexSuffix = "A.db";
private static final int EcoFSBufferSize = 1000;
private static final int objectIndexBufferSize = 1000;
private static final String localhost = "localhost";
// class variables filled with external values
private final File cacheStacksPath;
@ -330,7 +330,7 @@ public class Balancer {
private void pushHashToDomainStacks(String host, final byte[] urlhash) throws RowSpaceExceededException {
// extend domain stack
if (host == null) host = localhost;
if (host == null) host = Domains.LOCALHOST;
HandleSet domainList = this.domainStacks.get(host);
if (domainList == null) {
// create new list
@ -345,7 +345,7 @@ public class Balancer {
private void removeHashFromDomainStacks(String host, final byte[] urlhash) {
// reduce domain stack
if (host == null) host = localhost;
if (host == null) host = Domains.LOCALHOST;
final HandleSet domainList = this.domainStacks.get(host);
if (domainList == null) {
this.domainStacks.remove(host);

@ -1,4 +1,4 @@
// BlogBoard.java
// BlogBoard.java
// -------------------------------------
// (C) by Michael Peter Christen; mc@yacy.net
// first published on http://www.anomic.de
@ -38,7 +38,9 @@ import java.util.Date;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.TreeSet;
import javax.xml.parsers.DocumentBuilder;
@ -47,6 +49,7 @@ import javax.xml.parsers.ParserConfigurationException;
import net.yacy.cora.date.GenericFormatter;
import net.yacy.cora.document.UTF8;
import net.yacy.cora.protocol.Domains;
import net.yacy.kelondro.blob.MapHeap;
import net.yacy.kelondro.index.RowSpaceExceededException;
import net.yacy.kelondro.logging.Log;
@ -60,50 +63,48 @@ import org.w3c.dom.NodeList;
import org.xml.sax.SAXException;
import de.anomic.data.wiki.WikiBoard;
import java.util.List;
import java.util.Set;
public class BlogBoard {
private static final int KEY_LENGTH = 64;
private MapHeap database = null;
public BlogBoard(final File actpath) throws IOException {
new File(actpath.getParent()).mkdir();
//database = new MapView(BLOBTree.toHeap(actpath, true, true, keyLength, recordSize, '_', NaturalOrder.naturalOrder, newFile), 500, '_');
database = new MapHeap(actpath, KEY_LENGTH, NaturalOrder.naturalOrder, 1024 * 64, 500, '_');
this.database = new MapHeap(actpath, KEY_LENGTH, NaturalOrder.naturalOrder, 1024 * 64, 500, '_');
}
public int size() {
return database.size();
return this.database.size();
}
/**
* Tells if the database contains an element.
* @param key the ID of the element
* @return true if the database contains the element, else false
*/
public boolean contains(final String key) {
return database.containsKey(UTF8.getBytes(key));
return this.database.containsKey(UTF8.getBytes(key));
}
public synchronized void close() {
database.close();
this.database.close();
}
private static String normalize(final String key) {
return (key == null) ? "null" : key.trim().toLowerCase();
}
public static String webalize(final String key) {
return (key == null) ? "null": key.trim().toLowerCase().replaceAll(" ", "%20");
}
public String guessAuthor(final String ip) {
return WikiBoard.guessAuthor(ip);
}
/**
* Create a new BlogEntry and return it
* @param key
@ -126,7 +127,7 @@ public class BlogBoard {
public String writeBlogEntry(final BlogEntry page) {
String ret = null;
try {
database.insert(UTF8.getBytes(page.key), page.record);
this.database.insert(UTF8.getBytes(page.key), page.record);
ret = page.key;
} catch (IOException ex) {
Log.logException(ex);
@ -135,11 +136,11 @@ public class BlogBoard {
}
return ret;
}
public BlogEntry readBlogEntry(final String key) {
return readBlogEntry(key, database);
return readBlogEntry(key, this.database);
}
private BlogEntry readBlogEntry(final String key, final MapHeap base) {
final String normalized = normalize(key);
Map<String, String> record;
@ -153,10 +154,10 @@ public class BlogBoard {
record = null;
}
return (record == null) ?
newEntry(key, new byte[0], UTF8.getBytes("anonymous"), "127.0.0.1", new Date(), new byte[0], null, null) :
newEntry(key, new byte[0], UTF8.getBytes("anonymous"), Domains.LOCALHOST, new Date(), new byte[0], null, null) :
new BlogEntry(key, record);
}
public boolean importXML(final String input) {
final DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
try {
@ -169,20 +170,20 @@ public class BlogBoard {
} catch (final IOException ex) {
Log.logException(ex);
}
return false;
}
private boolean parseXMLimport(final Document doc) {
if(!"blog".equals(doc.getDocumentElement().getTagName())) {
return false;
}
final NodeList items = doc.getDocumentElement().getElementsByTagName("item");
if(items.getLength() == 0) {
return false;
}
for (int i = 0, n = items.getLength(); i < n; ++i) {
String key = null, ip = null, StrSubject = null, StrAuthor = null, StrPage = null, StrDate = null;
Date date = null;
@ -207,7 +208,7 @@ public class BlogBoard {
StrPage = currentNode.getFirstChild().getNodeValue();
}
}
try {
date = GenericFormatter.SHORT_SECOND_FORMATTER.parse(StrDate);
} catch (final ParseException e1) {
@ -226,31 +227,32 @@ public class BlogBoard {
}
return true;
}
public void deleteBlogEntry(final String key) {
try {
database.delete(UTF8.getBytes(normalize(key)));
this.database.delete(UTF8.getBytes(normalize(key)));
} catch (final IOException e) { }
}
public Iterator<byte[]> keys(final boolean up) throws IOException {
return database.keys(up, false);
return this.database.keys(up, false);
}
/**
* Comparator to sort objects of type Blog according to their timestamps
*/
public class BlogComparator implements Comparator<String> {
private final boolean newestFirst;
/**
* @param newestFirst newest first, or oldest first?
*/
public BlogComparator(final boolean newestFirst){
this.newestFirst = newestFirst;
}
@Override
public int compare(final String obj1, final String obj2) {
final BlogEntry blogEntry1 = readBlogEntry(obj1);
final BlogEntry blogEntry2 = readBlogEntry(obj2);
@ -268,7 +270,7 @@ public class BlogBoard {
return -1;
}
}
public Iterator<String> getBlogIterator(final boolean priv){
final Set<String> set = new TreeSet<String>(new BlogComparator(true));
final Iterator<BlogEntry> iterator = blogIterator(true);
@ -281,7 +283,7 @@ public class BlogBoard {
}
return set.iterator();
}
public Iterator<BlogEntry> blogIterator(final boolean up){
try {
return new BlogIterator(up);
@ -289,7 +291,7 @@ public class BlogBoard {
return new HashSet<BlogEntry>().iterator();
}
}
/**
* Subclass of blogBoard, which provides the blogIterator object-type
*/
@ -300,7 +302,8 @@ public class BlogBoard {
this.blogIter = BlogBoard.this.database.keys(up, false);
//this.nextEntry = null;
}
@Override
public boolean hasNext() {
try {
return this.blogIter.hasNext();
@ -309,7 +312,8 @@ public class BlogBoard {
return false;
}
}
@Override
public BlogEntry next() {
try {
return readBlogEntry(UTF8.String(this.blogIter.next()));
@ -318,7 +322,8 @@ public class BlogBoard {
return null;
}
}
@Override
public void remove() {
// if (this.nextEntry != null) {
// try {
@ -331,14 +336,14 @@ public class BlogBoard {
throw new UnsupportedOperationException("Method not implemented yet.");
}
}
public class BlogEntry {
String key;
Map<String, String> record;
public BlogEntry(final String nkey, final byte[] subject, final byte[] author, final String ip, final Date date, final byte[] page, final List<String> comments, final String commentMode) {
record = new HashMap<String, String>();
this.record = new HashMap<String, String>();
setKey(nkey);
setDate(date);
setSubject(subject);
@ -347,13 +352,13 @@ public class BlogBoard {
setPage(page);
setComments(comments);
setCommentMode(commentMode);
// TODO: implement this function
record.put("privacy", "public");
this.record.put("privacy", "public");
WikiBoard.setAuthor(ip, UTF8.String(author));
}
BlogEntry(final String key, final Map<String, String> record) {
this.key = key;
this.record = record;
@ -364,35 +369,35 @@ public class BlogBoard {
this.record.put("commentMode", "2");
}
}
private void setKey(final String key) {
this.key = key.substring(0, Math.min(key.length(), KEY_LENGTH));
}
public String getKey() {
return key;
return this.key;
}
public byte[] getSubject() {
final String m = record.get("subject");
final String m = this.record.get("subject");
if (m == null) {
return new byte[0];
}
final byte[] b = Base64Order.enhancedCoder.decode(m);
return (b == null) ? new byte[0] : b;
}
private void setSubject(final byte[] subject) {
if (subject == null) {
record.put("subject","");
this.record.put("subject","");
} else {
record.put("subject", Base64Order.enhancedCoder.encode(subject));
this.record.put("subject", Base64Order.enhancedCoder.encode(subject));
}
}
public Date getDate() {
try {
final String date = record.get("date");
final String date = this.record.get("date");
if (date == null) {
if (Log.isFinest("Blog")) {
Log.logFinest("Blog", "ERROR: date field missing in blogBoard");
@ -404,17 +409,17 @@ public class BlogBoard {
return new Date();
}
}
private void setDate(final Date date) {
Date ret = date;
if (ret == null) {
ret = new Date();
}
record.put("date", GenericFormatter.SHORT_SECOND_FORMATTER.format(ret));
this.record.put("date", GenericFormatter.SHORT_SECOND_FORMATTER.format(ret));
}
public String getTimestamp() {
final String timestamp = record.get("date");
final String timestamp = this.record.get("date");
if (timestamp == null) {
if (Log.isFinest("Blog")) {
Log.logFinest("Blog", "ERROR: date field missing in blogBoard");
@ -423,87 +428,87 @@ public class BlogBoard {
}
return timestamp;
}
public byte[] getAuthor() {
final String author = record.get("author");
final String author = this.record.get("author");
if (author == null) {
return new byte[0];
}
final byte[] b = Base64Order.enhancedCoder.decode(author);
return (b == null) ? new byte[0] : b;
}
private void setAuthor(final byte[] author) {
if (author == null)
record.put("author","");
this.record.put("author","");
else
record.put("author", Base64Order.enhancedCoder.encode(author));
this.record.put("author", Base64Order.enhancedCoder.encode(author));
}
public int getCommentsSize() {
// This ist a Bugfix for Version older than 4443.
if (record.get("comments").startsWith(",")) {
record.put("comments", record.get("comments").substring(1));
if (this.record.get("comments").startsWith(",")) {
this.record.put("comments", this.record.get("comments").substring(1));
writeBlogEntry(this);
}
final List<String> commentsize = ListManager.string2arraylist(record.get("comments"));
final List<String> commentsize = ListManager.string2arraylist(this.record.get("comments"));
return commentsize.size();
}
public List<String> getComments() {
return ListManager.string2arraylist(record.get("comments"));
return ListManager.string2arraylist(this.record.get("comments"));
}
private void setComments(final List<String> comments) {
if (comments == null) {
record.put("comments", ListManager.collection2string(new ArrayList<String>()));
this.record.put("comments", ListManager.collection2string(new ArrayList<String>()));
} else {
record.put("comments", ListManager.collection2string(comments));
this.record.put("comments", ListManager.collection2string(comments));
}
}
public String getIp() {
final String ip = record.get("ip");
return (ip == null) ? "127.0.0.1" : ip;
final String ip = this.record.get("ip");
return (ip == null) ? Domains.LOCALHOST : ip;
}
private void setIp(final String ip) {
String ret = ip;
if ((ret == null) || (ret.length() == 0))
ret = "";
record.put("ip", ret);
this.record.put("ip", ret);
}
public byte[] getPage() {
final String page = record.get("page");
final String page = this.record.get("page");
if (page == null) {
return new byte[0];
}
final byte[] page_as_byte = Base64Order.enhancedCoder.decode(page);
return (page_as_byte == null) ? new byte[0] : page_as_byte;
}
}
private void setPage(final byte[] page) {
if (page == null) {
record.put("page", "");
this.record.put("page", "");
} else {
record.put("page", Base64Order.enhancedCoder.encode(page));
this.record.put("page", Base64Order.enhancedCoder.encode(page));
}
}
public void addComment(final String commentID) {
final List<String> comments = ListManager.string2arraylist(record.get("comments"));
final List<String> comments = ListManager.string2arraylist(this.record.get("comments"));
comments.add(commentID);
record.put("comments", ListManager.collection2string(comments));
this.record.put("comments", ListManager.collection2string(comments));
}
public boolean removeComment(final String commentID) {
final List<String> comments = ListManager.string2arraylist(record.get("comments"));
final List<String> comments = ListManager.string2arraylist(this.record.get("comments"));
final boolean success = comments.remove(commentID);
record.put("comments", ListManager.collection2string(comments));
this.record.put("comments", ListManager.collection2string(comments));
return success;
}
/**
* returns the comment mode
* 0 - no comments allowed
@ -512,21 +517,21 @@ public class BlogBoard {
* @return comment mode
*/
public int getCommentMode(){
return Integer.parseInt(record.get("commentMode"));
return Integer.parseInt(this.record.get("commentMode"));
}
private void setCommentMode(final String mode) {
if (mode == null) {
record.put("commentMode", "2");
this.record.put("commentMode", "2");
} else {
record.put("commentMode", mode);
this.record.put("commentMode", mode);
}
}
public boolean isPublic() {
final String privacy = record.get("privacy");
final String privacy = this.record.get("privacy");
return (privacy == null || privacy.equalsIgnoreCase("public")) ? true : false;
}
}
}

@ -46,6 +46,7 @@ import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.ParserConfigurationException;
import net.yacy.cora.document.UTF8;
import net.yacy.cora.protocol.Domains;
import net.yacy.kelondro.blob.MapHeap;
import net.yacy.kelondro.index.RowSpaceExceededException;
import net.yacy.kelondro.logging.Log;
@ -142,7 +143,7 @@ public class BlogBoardComments {
record = null;
}
return (record == null) ?
newEntry(copyOfKey, new byte[0], UTF8.getBytes("anonymous"), "127.0.0.1", new Date(), new byte[0]) :
newEntry(copyOfKey, new byte[0], UTF8.getBytes("anonymous"), Domains.LOCALHOST, new Date(), new byte[0]) :
new CommentEntry(copyOfKey, record);
}
@ -326,7 +327,7 @@ public class BlogBoardComments {
public String getIp() {
final String ip = this.record.get("ip");
if (ip == null)
return "127.0.0.1";
return Domains.LOCALHOST;
return ip;
}
private void setPage(final byte[] page) {

@ -1,4 +1,4 @@
//wikiBoard.java
//wikiBoard.java
//-------------------------------------
//(C) by Michael Peter Christen; mc@yacy.net
//first published on http://www.anomic.de
@ -37,6 +37,7 @@ import java.util.TimeZone;
import net.yacy.cora.document.ASCII;
import net.yacy.cora.document.UTF8;
import net.yacy.cora.protocol.Domains;
import net.yacy.kelondro.blob.MapHeap;
import net.yacy.kelondro.index.RowSpaceExceededException;
import net.yacy.kelondro.logging.Log;
@ -44,7 +45,7 @@ import net.yacy.kelondro.order.Base64Order;
import net.yacy.kelondro.order.NaturalOrder;
/**
*
*
*/
public class WikiBoard {
@ -70,14 +71,14 @@ public class WikiBoard {
*/
public WikiBoard(final File actpath, final File bkppath) throws IOException {
new File(actpath.getParent()).mkdirs();
if (datbase == null) {
if (this.datbase == null) {
//datbase = new MapView(BLOBTree.toHeap(actpath, true, true, keyLength, recordSize, '_', NaturalOrder.naturalOrder, actpathNew), 500, '_');
datbase = new MapHeap(actpath, keyLength, NaturalOrder.naturalOrder, 1024 * 64, 500, '_');
this.datbase = new MapHeap(actpath, keyLength, NaturalOrder.naturalOrder, 1024 * 64, 500, '_');
}
new File(bkppath.getParent()).mkdirs();
if (bkpbase == null) {
if (this.bkpbase == null) {
//bkpbase = new MapView(BLOBTree.toHeap(bkppath, true, true, keyLength + dateFormat.length(), recordSize, '_', NaturalOrder.naturalOrder, bkppathNew), 500, '_');
bkpbase = new MapHeap(bkppath, keyLength + DATE_FORMAT.length(), NaturalOrder.naturalOrder, 1024 * 64, 500, '_');
this.bkpbase = new MapHeap(bkppath, keyLength + DATE_FORMAT.length(), NaturalOrder.naturalOrder, 1024 * 64, 500, '_');
}
}
@ -86,7 +87,7 @@ public class WikiBoard {
* @return number of entries in wiki plus number of old entries.
*/
public int sizeOfTwo() {
return datbase.size() + bkpbase.size();
return this.datbase.size() + this.bkpbase.size();
}
/**
@ -94,15 +95,15 @@ public class WikiBoard {
* @return number of entries in wiki.
*/
public int size() {
return datbase.size();
return this.datbase.size();
}
/**
* Closes database files.
*/
public synchronized void close() {
datbase.close();
bkpbase.close();
this.datbase.close();
this.bkpbase.close();
}
/**
@ -182,7 +183,7 @@ public class WikiBoard {
public class Entry {
private static final String ANONYMOUS = "anonymous";
private String key;
private final String key;
private final Map<String, String> record;
/**
@ -220,7 +221,7 @@ public class WikiBoard {
* @return subject of entry.
*/
public String subject() {
return key;
return this.key;
}
/**
@ -230,7 +231,7 @@ public class WikiBoard {
public Date date() {
Date ret;
try {
final String c = record.get("date");
final String c = this.record.get("date");
if (c == null) {
System.out.println("DEBUG - ERROR: date field missing in wikiBoard");
ret = new Date();
@ -250,7 +251,7 @@ public class WikiBoard {
* @return author of Entry.
*/
public String author() {
final String a = record.get("author");
final String a = this.record.get("author");
final byte[] b;
return (a != null && (b = Base64Order.enhancedCoder.decode(a)) != null) ? UTF8.String(b) : ANONYMOUS;
}
@ -261,7 +262,7 @@ public class WikiBoard {
*/
public String reason() {
final String ret;
final String r = record.get("reason");
final String r = this.record.get("reason");
if (r != null) {
final byte[] b;
ret = ((b = Base64Order.enhancedCoder.decode(r)) != null) ? UTF8.String(b) : "unknown";
@ -276,7 +277,7 @@ public class WikiBoard {
* @return content of Entry.
*/
public byte[] page() {
final String m = record.get("page");
final String m = this.record.get("page");
final byte[] b;
return (m != null && (b = Base64Order.enhancedCoder.decode(m)) != null) ? b : new byte[0];
}
@ -286,7 +287,7 @@ public class WikiBoard {
* @param date date of previous version of Entry.
*/
void setAncestorDate(final Date date) {
record.put("bkp", dateString(date));
this.record.put("bkp", dateString(date));
}
/**
@ -296,7 +297,7 @@ public class WikiBoard {
private Date getAncestorDate() {
Date ret = null;
try {
final String c = record.get("date");
final String c = this.record.get("date");
if (c != null) {
synchronized (SimpleFormatter) {
ret = SimpleFormatter.parse(c);
@ -314,7 +315,7 @@ public class WikiBoard {
*/
public Entry getAncestor() {
final Date ancDate = getAncestorDate();
return (ancDate == null) ? null : read(key + dateString(ancDate), bkpbase);
return (ancDate == null) ? null : read(this.key + dateString(ancDate), WikiBoard.this.bkpbase);
}
/**
@ -322,7 +323,7 @@ public class WikiBoard {
* @param subject subject of child of current Entry.
*/
void setChild(final String subject) {
record.put("child", Base64Order.enhancedCoder.encode(UTF8.getBytes(subject)));
this.record.put("child", Base64Order.enhancedCoder.encode(UTF8.getBytes(subject)));
}
/**
@ -330,7 +331,7 @@ public class WikiBoard {
* @return name of child of this Entry.
*/
private String getChildName() {
final String c = record.get("child");
final String c = this.record.get("child");
final byte[] subject;
return (c != null && (subject = Base64Order.enhancedCoder.decode(c)) != null) ? ASCII.String(subject) : null;
}
@ -340,7 +341,7 @@ public class WikiBoard {
* @return true if has child, else false.
*/
public boolean hasChild() {
final String c = record.get("child");
final String c = this.record.get("child");
return (c != null && Base64Order.enhancedCoder.decode(c) != null) ? true : false;
}
@ -350,7 +351,7 @@ public class WikiBoard {
*/
public Entry getChild() {
final String childName = getChildName();
return (childName == null) ? null : read(childName, datbase);
return (childName == null) ? null : read(childName, WikiBoard.this.datbase);
}
}
@ -370,9 +371,9 @@ public class WikiBoard {
entry.setAncestorDate(oldDate);
oldEntry.setChild(entry.subject());
// write the backup
bkpbase.insert(UTF8.getBytes(entry.key + dateString(oldDate)), oldEntry.record);
this.bkpbase.insert(UTF8.getBytes(entry.key + dateString(oldDate)), oldEntry.record);
// write the new page
datbase.insert(UTF8.getBytes(entry.key), entry.record);
this.datbase.insert(UTF8.getBytes(entry.key), entry.record);
key = entry.key;
} catch (final Exception e) {
Log.logException(e);
@ -386,7 +387,7 @@ public class WikiBoard {
* @return Entry which contains data.
*/
public Entry read(final String key) {
return read(key, datbase);
return read(key, this.datbase);
}
/**
@ -403,7 +404,7 @@ public class WikiBoard {
copyOfKey = copyOfKey.substring(0, keyLength);
}
final Map<String, String> record = base.get(UTF8.getBytes(copyOfKey));
ret = (record == null) ? newEntry(copyOfKey, ANONYMOUS, "127.0.0.1", "New Page", UTF8.getBytes("")) : new Entry(copyOfKey, record);
ret = (record == null) ? newEntry(copyOfKey, ANONYMOUS, Domains.LOCALHOST, "New Page", UTF8.getBytes("")) : new Entry(copyOfKey, record);
} catch (final IOException e) {
Log.logException(e);
} catch (RowSpaceExceededException e) {
@ -418,7 +419,7 @@ public class WikiBoard {
* @return the Entry.
*/
public Entry readBkp(final String key) {
return read(key, bkpbase);
return read(key, this.bkpbase);
}
/**
@ -428,7 +429,7 @@ public class WikiBoard {
* @throws IOException
*/
public Iterator<byte[]> keys(final boolean up) throws IOException {
return datbase.keys(up, false);
return this.datbase.keys(up, false);
}
/**
@ -438,6 +439,6 @@ public class WikiBoard {
* @throws IOException
*/
public Iterator<byte[]> keysBkp(final boolean up) throws IOException {
return bkpbase.keys(up, false);
return this.bkpbase.keys(up, false);
}
}

@ -546,7 +546,7 @@ public final class HTTPDFileHandler {
// implement proxy via url (not in servlet, because we need binary access on ouputStream)
if (path.equals("/proxy.html")) {
final List<Pattern> urlProxyAccess = Domains.makePatterns(sb.getConfig("proxyURL.access", "127.0.0.1"));
final List<Pattern> urlProxyAccess = Domains.makePatterns(sb.getConfig("proxyURL.access", Domains.LOCALHOST));
final UserDB.Entry user = sb.userDB.getUser(requestHeader);
final boolean user_may_see_proxyurl = Domains.matchesList(clientIP, urlProxyAccess) || (user!=null && user.hasRight(UserDB.AccessRight.PROXY_RIGHT));
if (sb.getConfigBool("proxyURL", false) && user_may_see_proxyurl) {

@ -1071,7 +1071,7 @@ public final class HTTPDemon implements serverHandler, Cloneable {
// set rewrite values
final serverObjects tp = new serverObjects();
String clientIP = (String) conProp.get(HeaderFramework.CONNECTION_PROP_CLIENTIP); if (clientIP == null) clientIP = "127.0.0.1";
String clientIP = (String) conProp.get(HeaderFramework.CONNECTION_PROP_CLIENTIP); if (clientIP == null) clientIP = Domains.LOCALHOST;
// check if ip is local ip address
final InetAddress hostAddress = Domains.dnsResolve(clientIP);

@ -169,9 +169,9 @@ public final class serverCore extends AbstractBusyThread implements BusyThread {
public static String clientAddress(final Socket s) {
final InetAddress uAddr = s.getInetAddress();
if (uAddr.isAnyLocalAddress()) return "127.0.0.1";
if (uAddr.isAnyLocalAddress()) return Domains.LOCALHOST;
String cIP = uAddr.getHostAddress();
if (Domains.isLocal(cIP, null)) cIP = "127.0.0.1";
if (Domains.isLocal(cIP, null)) cIP = Domains.LOCALHOST;
return cIP;
}
@ -966,6 +966,7 @@ public final class serverCore extends AbstractBusyThread implements BusyThread {
public Restarter(final int delay) {
this.delay = delay;
}
@Override
public void run() {
// waiting for a while
try {

@ -63,6 +63,8 @@ import com.google.common.util.concurrent.TimeLimiter;
public class Domains {
public static final String LOCALHOST = "127.0.0.1"; // replace with IPv6 0:0:0:0:0:0:0:1 ?
private static String LOCALHOST_NAME = LOCALHOST; // this will be replaced with the actual name of the local host
private static Class<?> InetAddressLocatorClass;
private static Method InetAddressLocatorGetLocaleInetAddressMethod;
@ -687,7 +689,7 @@ public class Domains {
public static final InetAddress parseInetAddress(String ip) {
if (ip == null || ip.length() < 8) return null;
if (isLocalhost(ip)) ip = "127.0.0.1";
if (isLocalhost(ip)) ip = LOCALHOST;
final String[] ips = dotPattern.split(ip);
if (ips.length != 4) return null;
final byte[] ipb = new byte[4];
@ -723,7 +725,6 @@ public class Domains {
return nameCacheNoCachingPatterns.size();
}
private static String localHostName = "127.0.0.1";
private static Set<InetAddress> localHostAddresses = new HashSet<InetAddress>();
private static Set<String> localHostNames = new HashSet<String>();
static {
@ -732,7 +733,7 @@ public class Domains {
if (localHostAddress != null) localHostAddresses.add(localHostAddress);
} catch (final UnknownHostException e) {}
try {
final InetAddress[] moreAddresses = InetAddress.getAllByName(localHostName);
final InetAddress[] moreAddresses = InetAddress.getAllByName(LOCALHOST_NAME);
if (moreAddresses != null) localHostAddresses.addAll(Arrays.asList(moreAddresses));
} catch (final UnknownHostException e) {}
@ -759,13 +760,13 @@ public class Domains {
// now look up the host name
try {
localHostName = getHostName(InetAddress.getLocalHost());
LOCALHOST_NAME = getHostName(InetAddress.getLocalHost());
} catch (final UnknownHostException e) {}
// after the host name was resolved, we try to look up more local addresses
// using the host name:
try {
final InetAddress[] moreAddresses = InetAddress.getAllByName(localHostName);
final InetAddress[] moreAddresses = InetAddress.getAllByName(LOCALHOST_NAME);
if (moreAddresses != null) localHostAddresses.addAll(Arrays.asList(moreAddresses));
} catch (final UnknownHostException e) {
}

@ -157,7 +157,7 @@ public class HTTPClient {
// connections per host (2 default)
clientConnectionManager.setDefaultMaxPerRoute(2);
// Increase max connections for localhost
final HttpHost localhost = new HttpHost("127.0.0.1");
final HttpHost localhost = new HttpHost(Domains.LOCALHOST);
clientConnectionManager.setMaxPerRoute(new HttpRoute(localhost), maxcon);
/**
* HTTP protocol settings
@ -396,7 +396,7 @@ public class HTTPClient {
final MultiProtocolURI url = new MultiProtocolURI(uri);
final HttpPost httpPost = new HttpPost(url.toNormalform(true, false));
String host = url.getHost();
if (host == null) host = "127.0.0.1";
if (host == null) host = Domains.LOCALHOST;
setHost(host); // overwrite resolved IP, needed for shared web hosting DO NOT REMOVE, see http://en.wikipedia.org/wiki/Shared_web_hosting_service
final NonClosingInputStreamEntity inputStreamEntity = new NonClosingInputStreamEntity(instream, length);
// statistics
@ -433,7 +433,7 @@ public class HTTPClient {
final HttpPost httpPost = new HttpPost(url.toNormalform(true, false));
setHost(vhost); // overwrite resolved IP, needed for shared web hosting DO NOT REMOVE, see http://en.wikipedia.org/wiki/Shared_web_hosting_service
if (vhost == null) setHost("127.0.0.1");
if (vhost == null) setHost(Domains.LOCALHOST);
final MultipartEntity multipartEntity = new MultipartEntity();
for (final Entry<String,ContentBody> part : post.entrySet())
@ -463,7 +463,7 @@ public class HTTPClient {
final MultiProtocolURI url = new MultiProtocolURI(uri);
final HttpPost httpPost = new HttpPost(url.toNormalform(true, false));
String host = url.getHost();
if (host == null) host = "127.0.0.1";
if (host == null) host = Domains.LOCALHOST;
setHost(host); // overwrite resolved IP, needed for shared web hosting DO NOT REMOVE, see http://en.wikipedia.org/wiki/Shared_web_hosting_service
final InputStreamEntity inputStreamEntity = new InputStreamEntity(instream, length);

@ -189,9 +189,11 @@ public class ShardSolrConnector implements SolrConnector {
final String[] urlAdmin = new String[this.connectors.size()];
int i = 0;
final InetAddress localhostExternAddress = Domains.myPublicLocalIP();
final String localhostExtern = localhostExternAddress == null ? "127.0.0.1" : localhostExternAddress.getHostAddress();
final String localhostExtern = localhostExternAddress == null ? Domains.LOCALHOST : localhostExternAddress.getHostAddress();
for (String u: this.urls) {
int p = u.indexOf("localhost",0); if (p < 0) p = u.indexOf("127.0.0.1",0);
int p = u.indexOf("localhost",0);
if (p < 0) p = u.indexOf("127.0.0.1",0);
if (p < 0) p = u.indexOf("0:0:0:0:0:0:0:1",0);
if (p >= 0) u = u.substring(0, p) + localhostExtern + u.substring(p + 9);
urlAdmin[i++] = u + (u.endsWith("/") ? "admin/" : "/admin/");
}

@ -107,7 +107,9 @@ public class SingleSolrConnector extends AbstractSolrConnector implements SolrCo
final InetAddress localhostExternAddress = Domains.myPublicLocalIP();
final String localhostExtern = localhostExternAddress == null ? "127.0.0.1" : localhostExternAddress.getHostAddress();
String u = this.solrurl;
int p = u.indexOf("localhost",0); if (p < 0) p = u.indexOf("127.0.0.1",0);
int p = u.indexOf("localhost",0);
if (p < 0) p = u.indexOf("127.0.0.1",0);
if (p < 0) p = u.indexOf("0:0:0:0:0:0:0:1",0);
if (p >= 0) u = u.substring(0, p) + localhostExtern + u.substring(p + 9);
return u + (u.endsWith("/") ? "admin/" : "/admin/");
}

@ -13,6 +13,7 @@ import java.nio.charset.Charset;
import net.yacy.yacy;
import net.yacy.cora.document.ASCII;
import net.yacy.cora.protocol.Domains;
import net.yacy.cora.protocol.RequestHeader;
import net.yacy.cora.protocol.http.HTTPClient;
import net.yacy.document.Document;
@ -155,7 +156,7 @@ public class AugmentHtmlStream {
private static String loadInternal(String path, RequestHeader requestHeader) {
ByteArrayOutputStream buffer = new ByteArrayOutputStream();
String realmProp = requestHeader.get(RequestHeader.AUTHORIZATION);
ServerSideIncludes.writeContent(path, buffer, realmProp, "127.0.0.1", requestHeader); // TODO: ip
ServerSideIncludes.writeContent(path, buffer, realmProp, Domains.LOCALHOST, requestHeader); // TODO: ip
return buffer.toString();
}
@ -210,12 +211,12 @@ public class AugmentHtmlStream {
}
public static StringBuffer process (StringBuffer data, Charset charset, DigestURI url, RequestHeader requestHeader) {
String action = requestHeader.get("YACYACTION");
requestHeader.remove("YACYACTION");
globalrequestHeader = requestHeader;
Switchboard sb = Switchboard.getSwitchboard();
boolean augmented = false;
@ -381,7 +382,7 @@ public class AugmentHtmlStream {
NodeList bodychildren = bt.getChildren();
bodychildren.add(new org.htmlparser.nodes.TextNode(loadInternal("interaction_elements/OverlayInteraction.html?action="+action+"&urlhash="+ ASCII.String(url.hash()) +"&url="+url.toNormalform(false, true), requestHeader)));
bodychildren.add(new org.htmlparser.nodes.TextNode(loadInternal("interaction_elements/Footer.html?action="+action+"&urlhash="+ ASCII.String(url.hash()) +"&url="+url.toNormalform(false, true), requestHeader)));
bt.setChildren(bodychildren);

@ -305,8 +305,8 @@ public class Seed implements Cloneable, Comparable<Seed>, Comparator<Seed>
* @return the IP or null
*/
public final String getIP() {
final String ip = get(Seed.IP, "127.0.0.1");
return (ip == null || ip.length() == 0) ? "127.0.0.1" : ip;
final String ip = get(Seed.IP, Domains.LOCALHOST);
return (ip == null || ip.length() == 0) ? Domains.LOCALHOST : ip;
}
/**
@ -563,7 +563,7 @@ public class Seed implements Cloneable, Comparable<Seed>, Comparator<Seed>
public final String getPublicAddress() {
String ip = getIP();
if ( ip == null || ip.length() < 8 || ip.length() > 60 ) {
ip = "127.0.0.1";
ip = Domains.LOCALHOST;
}
final String port = this.dna.get(Seed.PORT);

@ -277,7 +277,7 @@ public final class Switchboard extends serverSwitch
// check if port is already occupied
final int port = getConfigInt("port", 8090);
try {
if ( TimeoutRequest.ping("127.0.0.1", port, 500) ) {
if ( TimeoutRequest.ping(Domains.LOCALHOST, port, 500) ) {
throw new RuntimeException(
"a server is already running on the YaCy port "
+ port

Loading…
Cancel
Save