Hello,
I've changed the code in order to achieve my objective, that is accept a anonymous connection.
I got the 1.4.0-SNAPSHOT version of sctp-impl component.
I'm not familiarized with all the code so I can't assure that I found the better way, but it's working for me.
On SelectorThread class, I changed the doAccept method.
Orignal code:
try {
this.management.getServerListener().onNewRemoteConnection(srv, anonymAssociation);
} catch (Throwable e) {
logger.warn(String.format("Exception when invoking ServerListener.onNewRemoteConnection() Ass=%s", anonymAssociation), e);
try {
socketChannel.close();
} catch (Exception ee) {
}
return;
}
if (!anonymAssociation.isStarted()) {
// connection is rejected
logger.info(String.format("Rejected anonymous %s", anonymAssociation));
try {
socketChannel.close();
} catch (Exception ee) {
}
return;
}
I added some lines, to get a anonymous association created:
try {
this.management.getServerListener().onNewRemoteConnection(srv, anonymAssociation);
} catch (Throwable e) {
logger.warn(String.format("Exception when invoking ServerListener.onNewRemoteConnection() Ass=%s", anonymAssociation), e);
try {
socketChannel.close();
} catch (Exception ee) {
}
return;
}
// changes begin
// get anonymAssociation created
try {
AssociationImpl tmpAssociation = (AssociationImpl)this.management.getAssociation(anonymAssociation.getPeerAddress() +":"+anonymAssociation.getPeerPort());
if (tmpAssociation != null) {
tmpAssociation.setSocketChannel(socketChannel);
tmpAssociation.setManagement(this.management);
anonymAssociation = tmpAssociation;
}
} catch (Exception e) {
logger.error(String.format("Rejected anonymous %s", anonymAssociation), e);
}
// changes - end
if (!anonymAssociation.isStarted()) {
// connection is rejected
logger.info(String.format("Rejected anonymous %s", anonymAssociation));
try {
socketChannel.close();
} catch (Exception ee) {
}
return;
}
On ServerImpl the attribute acceptAnonymousConnections was initialized with true value, so by default the server must accept anonymous connection:
Original code:
private String name;
private String hostAddress;
private int hostport;
private volatile boolean started = false;
private IpChannelType ipChannelType;
private boolean acceptAnonymousConnections;
private int maxConcurrentConnectionsCount;
private String[] extraHostAddresses;
private ManagementImpl management = null;
My change:
private String name;
private String hostAddress;
private int hostport;
private volatile boolean started = false;
private IpChannelType ipChannelType;
private boolean acceptAnonymousConnections = true; // changed
private int maxConcurrentConnectionsCount;
private String[] extraHostAddresses;
private ManagementImpl management = null;