forked from I2P_Developers/i2p.i2p
Streaming: Return I2PSocketAddress from StandardSocket methods (ticket #1321)
This commit is contained in:
@ -10,6 +10,7 @@ import java.nio.channels.ServerSocketChannel;
|
||||
|
||||
import net.i2p.I2PException;
|
||||
import net.i2p.client.streaming.I2PSocket;
|
||||
import net.i2p.client.streaming.I2PSocketAddress;
|
||||
|
||||
/**
|
||||
* Bridge to I2PServerSocket.
|
||||
@ -99,11 +100,14 @@ class StandardServerSocket extends ServerSocket {
|
||||
}
|
||||
|
||||
/**
|
||||
* @return null always
|
||||
* Port in returned SocketAddress will be zero.
|
||||
*
|
||||
* @return an I2PSocketAddress as of 0.9.26; prior to that, returned null
|
||||
* @since implemented in 0.9.26
|
||||
*/
|
||||
@Override
|
||||
public SocketAddress getLocalSocketAddress() {
|
||||
return null;
|
||||
return new I2PSocketAddress(_socket.getManager().getSession().getMyDestination(), 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -10,6 +10,7 @@ import java.net.SocketException;
|
||||
import java.nio.channels.SocketChannel;
|
||||
|
||||
import net.i2p.client.streaming.I2PSocket;
|
||||
import net.i2p.client.streaming.I2PSocketAddress;
|
||||
import net.i2p.client.streaming.I2PSocketOptions;
|
||||
|
||||
/**
|
||||
@ -117,11 +118,12 @@ class StandardSocket extends Socket {
|
||||
}
|
||||
|
||||
/**
|
||||
* @return null always
|
||||
* @return an I2PSocketAddress as of 0.9.26; prior to that, returned null
|
||||
* @since implemented in 0.9.26
|
||||
*/
|
||||
@Override
|
||||
public SocketAddress getLocalSocketAddress() {
|
||||
return null;
|
||||
return new I2PSocketAddress(_socket.getThisDestination(), _socket.getLocalPort());
|
||||
}
|
||||
|
||||
/**
|
||||
@ -157,11 +159,12 @@ class StandardSocket extends Socket {
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws UnsupportedOperationException always
|
||||
* @return an I2PSocketAddress as of 0.9.26; prior to that, threw UnsupportedOperationException
|
||||
* @since implemented in 0.9.26
|
||||
*/
|
||||
@Override
|
||||
public SocketAddress getRemoteSocketAddress() {
|
||||
throw new UnsupportedOperationException();
|
||||
return new I2PSocketAddress(_socket.getPeerDestination(), _socket.getPort());
|
||||
}
|
||||
|
||||
/**
|
||||
|
Reference in New Issue
Block a user