2006-07-18 13:07:30 +02:00
package www ;
2012-07-05 09:14:04 +02:00
// welcome.java
2005-04-07 21:19:42 +02:00
// -----------------------
// part of the AnomicHTTPD caching proxy
2008-07-20 19:14:51 +02:00
// (C) by Michael Peter Christen; mc@yacy.net
2005-04-07 21:19:42 +02:00
// first published on http://www.anomic.de
// Frankfurt, Germany, 2004
2005-09-19 01:07:29 +02:00
//
// $LastChangedDate$
// $LastChangedRevision$
// $LastChangedBy$
2005-04-07 21:19:42 +02:00
//
// 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
2008-07-20 02:21:07 +02:00
2005-05-12 19:50:45 +02:00
// You must compile this file with
2005-09-19 01:07:29 +02:00
// javac -classpath .:../classes index.java
2005-04-07 21:19:42 +02:00
// if the shell's current path is HTROOT
2007-11-04 11:36:25 +01:00
import java.io.File ;
2012-07-05 09:14:04 +02:00
2010-09-14 17:27:27 +02:00
import net.yacy.cora.protocol.Domains ;
2010-08-23 14:32:02 +02:00
import net.yacy.cora.protocol.HeaderFramework ;
import net.yacy.cora.protocol.RequestHeader ;
2011-10-04 11:06:24 +02:00
import net.yacy.peers.Seed ;
2011-09-25 18:59:06 +02:00
import net.yacy.search.Switchboard ;
2012-09-21 15:48:16 +02:00
import net.yacy.server.serverCore ;
import net.yacy.server.serverObjects ;
import net.yacy.server.serverSwitch ;
2005-04-07 21:19:42 +02:00
public class welcome {
2012-07-05 09:14:04 +02:00
public static serverObjects respond ( final RequestHeader header , @SuppressWarnings ( " unused " ) final serverObjects post , final serverSwitch env ) {
2009-07-19 22:37:44 +02:00
final Switchboard sb = ( Switchboard ) env ;
2012-07-05 09:14:04 +02:00
2005-09-19 01:07:29 +02:00
// return variable that accumulates replacements
final serverObjects prop = new serverObjects ( ) ;
2005-04-07 21:19:42 +02:00
// update seed info
2008-06-04 23:34:57 +02:00
sb . updateMySeed ( ) ;
2005-04-07 21:19:42 +02:00
2011-01-28 11:12:17 +01:00
prop . putHTML ( " peername " , sb . peers . mySeed ( ) . getName ( ) ) ;
prop . putHTML ( " peerdomain " , sb . peers . mySeed ( ) . getName ( ) . toLowerCase ( ) ) ;
2009-05-28 16:26:05 +02:00
prop . putHTML ( " peeraddress " , sb . peers . mySeed ( ) . getPublicAddress ( ) ) ;
2009-10-11 02:12:19 +02:00
prop . put ( " hostname " , env . myPublicIP ( ) ) ;
2012-07-05 09:14:04 +02:00
prop . put ( " hostip " , Domains . dnsResolve ( env . myPublicIP ( ) ) . getHostAddress ( ) ) ;
2011-01-28 11:54:13 +01:00
prop . put ( " port " , serverCore . getPortNr ( env . getConfig ( " port " , " 8090 " ) ) ) ;
2009-07-19 22:37:44 +02:00
prop . put ( " clientip " , header . get ( HeaderFramework . CONNECTION_PROP_CLIENTIP , " " ) ) ;
2005-04-07 21:19:42 +02:00
2011-10-04 11:06:24 +02:00
final String peertype = ( sb . peers . mySeed ( ) = = null ) ? Seed . PEERTYPE_JUNIOR : sb . peers . mySeed ( ) . get ( Seed . PEERTYPE , Seed . PEERTYPE_VIRGIN ) ;
final boolean senior = ( peertype . equals ( Seed . PEERTYPE_SENIOR ) ) | | ( peertype . equals ( Seed . PEERTYPE_PRINCIPAL ) ) ;
2005-09-19 01:07:29 +02:00
if ( senior ) { prop . put ( " couldcan " , " can " ) ; } else { prop . put ( " couldcan " , " could " ) ; }
2007-10-24 23:38:19 +02:00
if ( senior ) { prop . put ( " seniorinfo " , " This peer runs in senior mode which means that your peer can be accessed using the addresses shown above. " ) ; } else { prop . putHTML ( " seniorinfo " , " <b>Nobody can access your peer from the outside of your intranet. You must open your firewall and/or set a 'virtual server' in the settings of your router to enable access to the addresses as shown below.</b> " ) ; }
2010-09-02 21:24:22 +02:00
final File wwwpath = env . getDataPath ( " htDocsPath " , " DATA/HTDOCS " ) ;
2007-11-04 11:36:25 +01:00
prop . putHTML ( " wwwpath " , wwwpath . isAbsolute ( ) ? wwwpath . getAbsolutePath ( ) : " <application_root_path>/ " + env . getConfig ( " htDocsPath " , " DATA/HTDOCS " ) ) ;
2005-09-19 01:07:29 +02:00
// return rewrite properties
return prop ;
2005-04-07 21:19:42 +02:00
}
}