|
From: <gr...@us...> - 2009-08-13 14:31:04
|
Revision: 4480
http://phex.svn.sourceforge.net/phex/?rev=4480&view=rev
Author: gregork
Date: 2009-08-13 14:30:49 +0000 (Thu, 13 Aug 2009)
Log Message:
-----------
don't send ggep data in pongs in case not supported
Modified Paths:
--------------
phex/trunk/src/main/java/phex/connection/ConnectionEngine.java
phex/trunk/src/main/java/phex/host/Host.java
phex/trunk/src/main/java/phex/msg/PongFactory.java
phex/trunk/src/main/java/phex/msg/PongMsg.java
phex/trunk/src/main/java/phex/msghandling/MessageDispatcher.java
Modified: phex/trunk/src/main/java/phex/connection/ConnectionEngine.java
===================================================================
--- phex/trunk/src/main/java/phex/connection/ConnectionEngine.java 2009-07-26 13:37:12 UTC (rev 4479)
+++ phex/trunk/src/main/java/phex/connection/ConnectionEngine.java 2009-08-13 14:30:49 UTC (rev 4480)
@@ -628,6 +628,13 @@
{
connectedHost.setVendorMessageSupported( true );
}
+
+ header = theirHeadersRead.getHeader(
+ GnutellaHeaderNames.GGEP );
+ if ( header != null && !header.getValue().equals("") )
+ {
+ connectedHost.setGgepSupported( true );
+ }
}
private void sendStringToHost( String str )
Modified: phex/trunk/src/main/java/phex/host/Host.java
===================================================================
--- phex/trunk/src/main/java/phex/host/Host.java 2009-07-26 13:37:12 UTC (rev 4479)
+++ phex/trunk/src/main/java/phex/host/Host.java 2009-08-13 14:30:49 UTC (rev 4480)
@@ -263,6 +263,7 @@
private SendEngine sendEngine;
private boolean isVendorMessageSupported;
+ private boolean isGgepSupported;
private MessagesSupportedVMsg supportedVMsgs;
private CapabilitiesVMsg capabilitiesVMsgs;
@@ -286,6 +287,7 @@
isUPQueryRoutingSupported = false;
isDynamicQuerySupported = false;
isVendorMessageSupported = false;
+ isGgepSupported = false;
receivedMsgCount = 0;
sentMsgCount = 0;
sentDropMsgCount = 0;
@@ -497,6 +499,16 @@
return isVendorMessageSupported;
}
+ public void setGgepSupported( boolean state )
+ {
+ this.isGgepSupported = state;
+ }
+
+ public boolean isGgepSupported()
+ {
+ return isGgepSupported;
+ }
+
public void setCapabilitiesVMsgs( CapabilitiesVMsg capabilitiesVMsgs )
{
this.capabilitiesVMsgs = capabilitiesVMsgs;
Modified: phex/trunk/src/main/java/phex/msg/PongFactory.java
===================================================================
--- phex/trunk/src/main/java/phex/msg/PongFactory.java 2009-07-26 13:37:12 UTC (rev 4479)
+++ phex/trunk/src/main/java/phex/msg/PongFactory.java 2009-08-13 14:30:49 UTC (rev 4480)
@@ -201,9 +201,13 @@
*/
public PongMsg createMyOutgoingPong( GUID msgId, DestAddress localAddress,
byte ttl, int sharedFileCount, int sharedFileSize, boolean isUltrapeer,
- int avgDailyUptime )
+ int avgDailyUptime, boolean isGgepSupported )
{
- GGEPBlock ggepBlock = createMyGGEPBlock( avgDailyUptime, isUltrapeer );
+ GGEPBlock ggepBlock = null;
+ if ( isGgepSupported )
+ {
+ ggepBlock = createMyGGEPBlock( avgDailyUptime, isUltrapeer );
+ }
IpAddress localIp = localAddress.getIpAddress();
IpAddress pongIp;
@@ -212,7 +216,10 @@
pongIp = IpAddress.UNSET_IP;
// in case we have a unset ip address we need to use the Phex.EXTDEST
// GGEP extension to specify our pong destination.
- addPhexExtendedDestinationGGEP( localAddress, ggepBlock );
+ if ( isGgepSupported )
+ {
+ addPhexExtendedDestinationGGEP( localAddress, ggepBlock );
+ }
}
else
{
@@ -253,11 +260,16 @@
return pong;
}
- public PongMsg createFromCachePong( GUID newGuid, byte newTTL, PongMsg pongMsg )
+ public PongMsg createFromCachePong( GUID newGuid, byte newTTL, PongMsg pongMsg,
+ boolean isGgepSupported )
{
MsgHeader header = new MsgHeader( newGuid, MsgHeader.PONG_PAYLOAD,
newTTL, (byte)0, 0 );
PongMsg pong = new PongMsg( header, pongMsg.getBody(), securityService );
+ if ( !isGgepSupported )
+ {
+ pong.stripGgepBlock();
+ }
return pong;
}
Modified: phex/trunk/src/main/java/phex/msg/PongMsg.java
===================================================================
--- phex/trunk/src/main/java/phex/msg/PongMsg.java 2009-07-26 13:37:12 UTC (rev 4479)
+++ phex/trunk/src/main/java/phex/msg/PongMsg.java 2009-08-13 14:30:49 UTC (rev 4480)
@@ -245,6 +245,13 @@
return body;
}
+ public void stripGgepBlock()
+ {
+ ggepBlock = null;
+ buildBody();
+ getHeader().setDataLength( body.length );
+ }
+
/**
* {@inheritDoc}
*/
Modified: phex/trunk/src/main/java/phex/msghandling/MessageDispatcher.java
===================================================================
--- phex/trunk/src/main/java/phex/msghandling/MessageDispatcher.java 2009-07-26 13:37:12 UTC (rev 4479)
+++ phex/trunk/src/main/java/phex/msghandling/MessageDispatcher.java 2009-08-13 14:30:49 UTC (rev 4480)
@@ -335,7 +335,7 @@
// Get my host:port for InitResponse.
PongMsg pong = pongFactory.createMyOutgoingPong( header.getMsgID(),
servent.getLocalAddress(), newTTL, shareFileCount, shareFileSize,
- servent.isUltrapeer(), avgDailyUptime );
+ servent.isUltrapeer(), avgDailyUptime, sourceHost.isGgepSupported() );
sourceHost.queueMessageToSend( pong );
// send pongs from pong cache
@@ -353,8 +353,9 @@
{
continue;
}
- sourceHost.queueMessageToSend( pongFactory.createFromCachePong(
- guid, newTTL, pMsg ) );
+ PongMsg pongCpy = pongFactory.createFromCachePong(
+ guid, newTTL, pMsg, sourceHost.isGgepSupported() );
+ sourceHost.queueMessageToSend( pongCpy );
}
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|