@ -96,13 +96,11 @@ public final class yacyClient {
// this works of course only if we know the other peer's hash.
// this works of course only if we know the other peer's hash.
HashMap result = null ;
HashMap result = null ;
String salt ;
final serverObjects post = yacyNetwork . basicRequestPost ( plasmaSwitchboard . getSwitchboard ( ) , null ) ;
try {
try {
// generate request
// generate request
final serverObjects obj = new serverObjects ( ) ;
post . putASIS ( "count" , "20" ) ;
salt = yacyNetwork . enrichRequestPost ( obj , plasmaSwitchboard . getSwitchboard ( ) , null ) ;
post . putASIS ( "seed" , yacyCore . seedDB . mySeed . genSeedStr ( post . get ( "key" , "" ) ) ) ;
obj . putASIS ( "count" , "20" ) ;
obj . putASIS ( "seed" , yacyCore . seedDB . mySeed . genSeedStr ( salt ) ) ;
yacyCore . log . logFine ( "yacyClient.publishMySeed thread '" + Thread . currentThread ( ) . getName ( ) + "' contacting peer at " + address ) ;
yacyCore . log . logFine ( "yacyClient.publishMySeed thread '" + Thread . currentThread ( ) . getName ( ) + "' contacting peer at " + address ) ;
// send request
// send request
result = nxTools . table (
result = nxTools . table (
@ -112,7 +110,7 @@ public final class yacyClient {
null ,
null ,
null ,
null ,
proxyConfig ( ) ,
proxyConfig ( ) ,
obj ,
post ,
null
null
) , "UTF-8"
) , "UTF-8"
) ;
) ;
@ -140,7 +138,7 @@ public final class yacyClient {
if ( seed . length ( ) > yacySeed . maxsize ) {
if ( seed . length ( ) > yacySeed . maxsize ) {
yacyCore . log . logInfo ( "hello/client 0: rejected contacting seed; too large (" + seed . length ( ) + " > " + yacySeed . maxsize + ")" ) ;
yacyCore . log . logInfo ( "hello/client 0: rejected contacting seed; too large (" + seed . length ( ) + " > " + yacySeed . maxsize + ")" ) ;
} else {
} else {
otherPeer = yacySeed . genRemoteSeed ( seed , salt , true ) ;
otherPeer = yacySeed . genRemoteSeed ( seed , post. get ( "key" , "" ) , true ) ;
if ( otherPeer = = null | | ! otherPeer . hash . equals ( otherHash ) ) {
if ( otherPeer = = null | | ! otherPeer . hash . equals ( otherHash ) ) {
yacyCore . log . logFine ( "yacyClient.publishMySeed: consistency error: other peer '" + ( ( otherPeer = = null ) ? "unknown" : otherPeer . getName ( ) ) + "' wrong" ) ;
yacyCore . log . logFine ( "yacyClient.publishMySeed: consistency error: other peer '" + ( ( otherPeer = = null ) ? "unknown" : otherPeer . getName ( ) ) + "' wrong" ) ;
return - 1 ; // no success
return - 1 ; // no success
@ -168,7 +166,7 @@ public final class yacyClient {
* /
* /
if ( ! serverCore . portForwardingEnabled | | otherPeerVersion > = yacyVersion . YACY_SUPPORTS_PORT_FORWARDING ) {
if ( ! serverCore . portForwardingEnabled | | otherPeerVersion > = yacyVersion . YACY_SUPPORTS_PORT_FORWARDING ) {
String mytype = ( String ) result . get ( yacySeed . YOURTYPE ) ;
String mytype = ( String ) result . get ( yacySeed . YOURTYPE ) ;
if ( mytype = = null ) { mytype = yacySeed . PEERTYPE_JUNIOR ; }
if ( mytype = = null ) { mytype = "" ; }
yacyAccessible accessible = new yacyAccessible ( ) ;
yacyAccessible accessible = new yacyAccessible ( ) ;
if ( mytype . equals ( yacySeed . PEERTYPE_SENIOR ) | | mytype . equals ( yacySeed . PEERTYPE_PRINCIPAL ) ) {
if ( mytype . equals ( yacySeed . PEERTYPE_SENIOR ) | | mytype . equals ( yacySeed . PEERTYPE_PRINCIPAL ) ) {
accessible . IWasAccessed = true ;
accessible . IWasAccessed = true ;
@ -200,8 +198,13 @@ public final class yacyClient {
}
}
}
}
}
}
} else if ( ( mytype . equalsIgnoreCase ( yacySeed . PEERTYPE_SENIOR ) ) | |
( mytype . equalsIgnoreCase ( yacySeed . PEERTYPE_PRINCIPAL ) ) ) {
yacyCore . log . logFine ( "yacyClient.publishMySeed: Peer '" + ( ( otherPeer = = null ) ? "unknown" : otherPeer . getName ( ) ) + "' reported us as " + mytype + ", accepted other peer." ) ;
} else {
} else {
yacyCore . log . logFine ( "yacyClient.publishMySeed: Peer '" + ( ( otherPeer = = null ) ? "unknown" : otherPeer . getName ( ) ) + "' reported us as " + mytype + "." ) ;
// wrong type report
yacyCore . log . logFine ( "yacyClient.publishMySeed: Peer '" + ( ( otherPeer = = null ) ? "unknown" : otherPeer . getName ( ) ) + "' reported us as " + mytype + ", rejecting other peer." ) ;
return - 1 ;
}
}
if ( yacyCore . seedDB . mySeed . orVirgin ( ) . equals ( yacySeed . PEERTYPE_VIRGIN ) )
if ( yacyCore . seedDB . mySeed . orVirgin ( ) . equals ( yacySeed . PEERTYPE_VIRGIN ) )
yacyCore . seedDB . mySeed . put ( yacySeed . PEERTYPE , mytype ) ;
yacyCore . seedDB . mySeed . put ( yacySeed . PEERTYPE , mytype ) ;
@ -226,7 +229,7 @@ public final class yacyClient {
if ( seedStr . length ( ) > yacySeed . maxsize ) {
if ( seedStr . length ( ) > yacySeed . maxsize ) {
yacyCore . log . logInfo ( "hello/client: rejected contacting seed; too large (" + seedStr . length ( ) + " > " + yacySeed . maxsize + ")" ) ;
yacyCore . log . logInfo ( "hello/client: rejected contacting seed; too large (" + seedStr . length ( ) + " > " + yacySeed . maxsize + ")" ) ;
} else {
} else {
if ( yacyCore . peerActions . peerArrival ( yacySeed . genRemoteSeed ( seedStr , salt , true ) , ( i = = 1 ) ) ) count + + ;
if ( yacyCore . peerActions . peerArrival ( yacySeed . genRemoteSeed ( seedStr , post. get ( "key" , "" ) , true ) , ( i = = 1 ) ) ) count + + ;
}
}
}
}
return count ;
return count ;
@ -234,8 +237,7 @@ public final class yacyClient {
public static yacySeed querySeed ( yacySeed target , String seedHash ) {
public static yacySeed querySeed ( yacySeed target , String seedHash ) {
// prepare request
// prepare request
final serverObjects post = new serverObjects ( ) ;
final serverObjects post = yacyNetwork . basicRequestPost ( plasmaSwitchboard . getSwitchboard ( ) , target . hash ) ;
String salt = yacyNetwork . enrichRequestPost ( post , plasmaSwitchboard . getSwitchboard ( ) , target . hash ) ;
post . putASIS ( "object" , "seed" ) ;
post . putASIS ( "object" , "seed" ) ;
post . putASIS ( "env" , seedHash ) ;
post . putASIS ( "env" , seedHash ) ;
@ -255,7 +257,7 @@ public final class yacyClient {
if ( result = = null | | result . size ( ) = = 0 ) { return null ; }
if ( result = = null | | result . size ( ) = = 0 ) { return null ; }
//final Date remoteTime = yacyCore.parseUniversalDate((String) result.get(yacySeed.MYTIME)); // read remote time
//final Date remoteTime = yacyCore.parseUniversalDate((String) result.get(yacySeed.MYTIME)); // read remote time
return yacySeed . genRemoteSeed ( ( String ) result . get ( "response" ) , salt , true ) ;
return yacySeed . genRemoteSeed ( ( String ) result . get ( "response" ) , post. get ( "key" , "" ) , true ) ;
} catch ( Exception e ) {
} catch ( Exception e ) {
yacyCore . log . logSevere ( "yacyClient.querySeed error:" + e . getMessage ( ) ) ;
yacyCore . log . logSevere ( "yacyClient.querySeed error:" + e . getMessage ( ) ) ;
return null ;
return null ;
@ -264,8 +266,7 @@ public final class yacyClient {
public static int queryRWICount ( yacySeed target , String wordHash ) {
public static int queryRWICount ( yacySeed target , String wordHash ) {
// prepare request
// prepare request
final serverObjects post = new serverObjects ( ) ;
final serverObjects post = yacyNetwork . basicRequestPost ( plasmaSwitchboard . getSwitchboard ( ) , target . hash ) ;
yacyNetwork . enrichRequestPost ( post , plasmaSwitchboard . getSwitchboard ( ) , target . hash ) ;
post . putASIS ( "object" , "rwicount" ) ;
post . putASIS ( "object" , "rwicount" ) ;
post . putASIS ( "ttl" , "0" ) ;
post . putASIS ( "ttl" , "0" ) ;
post . putASIS ( "env" , wordHash ) ;
post . putASIS ( "env" , wordHash ) ;
@ -297,8 +298,7 @@ public final class yacyClient {
if ( yacyCore . seedDB . mySeed = = null ) return - 1 ;
if ( yacyCore . seedDB . mySeed = = null ) return - 1 ;
// prepare request
// prepare request
final serverObjects post = new serverObjects ( ) ;
final serverObjects post = yacyNetwork . basicRequestPost ( plasmaSwitchboard . getSwitchboard ( ) , target . hash ) ;
yacyNetwork . enrichRequestPost ( post , plasmaSwitchboard . getSwitchboard ( ) , target . hash ) ;
post . putASIS ( "object" , "lurlcount" ) ;
post . putASIS ( "object" , "lurlcount" ) ;
post . putASIS ( "ttl" , "0" ) ;
post . putASIS ( "ttl" , "0" ) ;
post . putASIS ( "env" , "" ) ;
post . putASIS ( "env" , "" ) ;
@ -367,9 +367,8 @@ public final class yacyClient {
// duetime : maximum time that a peer should spent to create a result
// duetime : maximum time that a peer should spent to create a result
// prepare request
// prepare request
final serverObjects post = new serverObjects ( ) ;
final serverObjects post = yacyNetwork . basicRequestPost ( plasmaSwitchboard . getSwitchboard ( ) , target . hash ) ;
final String salt = yacyNetwork . enrichRequestPost ( post , plasmaSwitchboard . getSwitchboard ( ) , target . hash ) ;
post . putASIS ( "myseed" , yacyCore . seedDB . mySeed . genSeedStr ( post . get ( "key" , "" ) ) ) ;
post . putASIS ( "myseed" , yacyCore . seedDB . mySeed . genSeedStr ( salt ) ) ;
post . put ( "count" , Math . max ( 10 , count ) ) ;
post . put ( "count" , Math . max ( 10 , count ) ) ;
post . putASIS ( "resource" , ( ( global ) ? "global" : "local" ) ) ;
post . putASIS ( "resource" , ( ( global ) ? "global" : "local" ) ) ;
post . put ( "partitions" , partitions ) ;
post . put ( "partitions" , partitions ) ;
@ -580,8 +579,7 @@ public final class yacyClient {
if ( yacyCore . seedDB = = null | | yacyCore . seedDB . mySeed = = null ) { return null ; }
if ( yacyCore . seedDB = = null | | yacyCore . seedDB . mySeed = = null ) { return null ; }
// prepare request
// prepare request
final serverObjects post = new serverObjects ( ) ;
final serverObjects post = yacyNetwork . basicRequestPost ( plasmaSwitchboard . getSwitchboard ( ) , targetHash ) ;
yacyNetwork . enrichRequestPost ( post , plasmaSwitchboard . getSwitchboard ( ) , targetHash ) ;
post . putASIS ( "process" , "permission" ) ;
post . putASIS ( "process" , "permission" ) ;
// send request
// send request
@ -609,10 +607,9 @@ public final class yacyClient {
// this post a message to the remote message board
// this post a message to the remote message board
// prepare request
// prepare request
final serverObjects post = new serverObjects ( ) ;
final serverObjects post = yacyNetwork . basicRequestPost ( plasmaSwitchboard . getSwitchboard ( ) , targetHash ) ;
final String salt = yacyNetwork . enrichRequestPost ( post , plasmaSwitchboard . getSwitchboard ( ) , targetHash ) ;
post . putASIS ( "process" , "post" ) ;
post . putASIS ( "process" , "post" ) ;
post . putASIS ( "myseed" , yacyCore . seedDB . mySeed . genSeedStr ( salt ) ) ;
post . putASIS ( "myseed" , yacyCore . seedDB . mySeed . genSeedStr ( post. get ( "key" , "" ) ) ) ;
post . putASIS ( "subject" , subject ) ;
post . putASIS ( "subject" , subject ) ;
try {
try {
post . putASIS ( "message" , new String ( message , "UTF-8" ) ) ;
post . putASIS ( "message" , new String ( message , "UTF-8" ) ) ;
@ -657,8 +654,7 @@ public final class yacyClient {
public static HashMap transferPermission ( String targetAddress , long filesize , String filename ) {
public static HashMap transferPermission ( String targetAddress , long filesize , String filename ) {
// prepare request
// prepare request
final serverObjects post = new serverObjects ( ) ;
final serverObjects post = yacyNetwork . basicRequestPost ( plasmaSwitchboard . getSwitchboard ( ) , null ) ;
yacyNetwork . enrichRequestPost ( post , plasmaSwitchboard . getSwitchboard ( ) , null ) ;
post . putASIS ( "process" , "permission" ) ;
post . putASIS ( "process" , "permission" ) ;
post . putASIS ( "purpose" , "crcon" ) ;
post . putASIS ( "purpose" , "crcon" ) ;
post . putASIS ( "filename" , filename ) ;
post . putASIS ( "filename" , filename ) ;
@ -690,8 +686,7 @@ public final class yacyClient {
public static HashMap transferStore ( String targetAddress , String access , String filename , byte [ ] file ) {
public static HashMap transferStore ( String targetAddress , String access , String filename , byte [ ] file ) {
// prepare request
// prepare request
final serverObjects post = new serverObjects ( ) ;
final serverObjects post = yacyNetwork . basicRequestPost ( plasmaSwitchboard . getSwitchboard ( ) , null ) ;
yacyNetwork . enrichRequestPost ( post , plasmaSwitchboard . getSwitchboard ( ) , null ) ;
post . putASIS ( "process" , "store" ) ;
post . putASIS ( "process" , "store" ) ;
post . putASIS ( "purpose" , "crcon" ) ;
post . putASIS ( "purpose" , "crcon" ) ;
post . putASIS ( "filename" , filename ) ;
post . putASIS ( "filename" , filename ) ;
@ -757,8 +752,7 @@ public final class yacyClient {
assert ( yacyCore . seedDB . mySeed ! = target ) ;
assert ( yacyCore . seedDB . mySeed ! = target ) ;
// prepare request
// prepare request
final serverObjects post = new serverObjects ( ) ;
final serverObjects post = yacyNetwork . basicRequestPost ( plasmaSwitchboard . getSwitchboard ( ) , target . hash ) ;
yacyNetwork . enrichRequestPost ( post , plasmaSwitchboard . getSwitchboard ( ) , target . hash ) ;
post . putASIS ( "process" , "crawl" ) ;
post . putASIS ( "process" , "crawl" ) ;
if ( url . length = = 1 ) {
if ( url . length = = 1 ) {
post . putASIS ( "url" , crypt . simpleEncode ( url [ 0 ] . toNormalform ( true , true ) ) ) ;
post . putASIS ( "url" , crypt . simpleEncode ( url [ 0 ] . toNormalform ( true , true ) ) ) ;
@ -830,14 +824,13 @@ public final class yacyClient {
* /
* /
// prepare request
// prepare request
final serverObjects post = new serverObjects ( ) ;
final serverObjects post = yacyNetwork . basicRequestPost ( plasmaSwitchboard . getSwitchboard ( ) , target . hash ) ;
String salt = yacyNetwork . enrichRequestPost ( post , plasmaSwitchboard . getSwitchboard ( ) , target . hash ) ;
post . putASIS ( "process" , process ) ;
post . putASIS ( "process" , process ) ;
post . putASIS ( "urlhash" , ( ( entry = = null ) ? "" : entry . hash ( ) ) ) ;
post . putASIS ( "urlhash" , ( ( entry = = null ) ? "" : entry . hash ( ) ) ) ;
post . putASIS ( "result" , result ) ;
post . putASIS ( "result" , result ) ;
post . putASIS ( "reason" , reason ) ;
post . putASIS ( "reason" , reason ) ;
post . putASIS ( "wordh" , wordhashes ) ;
post . putASIS ( "wordh" , wordhashes ) ;
post . putASIS ( "lurlEntry" , ( ( entry = = null ) ? "" : crypt . simpleEncode ( entry . toString ( ) , salt ) ) ) ;
post . putASIS ( "lurlEntry" , ( ( entry = = null ) ? "" : crypt . simpleEncode ( entry . toString ( ) , post. get ( "key" , "" ) ) ) ) ;
// determining target address
// determining target address
final String address = target . getClusterAddress ( ) ;
final String address = target . getClusterAddress ( ) ;
@ -958,8 +951,7 @@ public final class yacyClient {
if ( address = = null ) { return null ; }
if ( address = = null ) { return null ; }
// prepare post values
// prepare post values
final serverObjects post = new serverObjects ( ) ;
final serverObjects post = yacyNetwork . basicRequestPost ( plasmaSwitchboard . getSwitchboard ( ) , targetSeed . hash ) ;
yacyNetwork . enrichRequestPost ( post , plasmaSwitchboard . getSwitchboard ( ) , targetSeed . hash ) ;
// enabling gzip compression for post request body
// enabling gzip compression for post request body
if ( ( gzipBody ) & & ( targetSeed . getVersion ( ) > = yacyVersion . YACY_SUPPORTS_GZIP_POST_REQUESTS ) ) {
if ( ( gzipBody ) & & ( targetSeed . getVersion ( ) > = yacyVersion . YACY_SUPPORTS_GZIP_POST_REQUESTS ) ) {
@ -1025,8 +1017,7 @@ public final class yacyClient {
if ( address = = null ) { return null ; }
if ( address = = null ) { return null ; }
// prepare post values
// prepare post values
final serverObjects post = new serverObjects ( 5 + urls . length ) ;
final serverObjects post = yacyNetwork . basicRequestPost ( plasmaSwitchboard . getSwitchboard ( ) , targetSeed . hash ) ;
yacyNetwork . enrichRequestPost ( post , plasmaSwitchboard . getSwitchboard ( ) , targetSeed . hash ) ;
// enabling gzip compression for post request body
// enabling gzip compression for post request body
if ( ( gzipBody ) & & ( targetSeed . getVersion ( ) > = yacyVersion . YACY_SUPPORTS_GZIP_POST_REQUESTS ) ) {
if ( ( gzipBody ) & & ( targetSeed . getVersion ( ) > = yacyVersion . YACY_SUPPORTS_GZIP_POST_REQUESTS ) ) {
@ -1077,8 +1068,7 @@ public final class yacyClient {
public static HashMap getProfile ( yacySeed targetSeed ) {
public static HashMap getProfile ( yacySeed targetSeed ) {
// this post a message to the remote message board
// this post a message to the remote message board
final serverObjects post = new serverObjects ( 2 ) ;
final serverObjects post = yacyNetwork . basicRequestPost ( plasmaSwitchboard . getSwitchboard ( ) , targetSeed . hash ) ;
yacyNetwork . enrichRequestPost ( post , plasmaSwitchboard . getSwitchboard ( ) , targetSeed . hash ) ;
String address = targetSeed . getClusterAddress ( ) ;
String address = targetSeed . getClusterAddress ( ) ;
if ( address = = null ) { address = "localhost:8080" ; }
if ( address = = null ) { address = "localhost:8080" ; }