对SNCP的Address进行IPv4判断

This commit is contained in:
Redkale
2017-12-04 09:48:52 +08:00
parent e97e6b8262
commit 1da73429f7
2 changed files with 3 additions and 1 deletions

View File

@@ -103,6 +103,7 @@ public final class SncpClient {
this.actions = methodens.toArray(new SncpAction[methodens.size()]);
this.addrBytes = clientAddress == null ? new byte[4] : clientAddress.getAddress().getAddress();
this.addrPort = clientAddress == null ? 0 : clientAddress.getPort();
if (this.addrBytes.length != 4) throw new RuntimeException("SNCP clientAddress only support IPv4");
}
static List<SncpAction> getSncpActions(final Class serviceClass) {
@@ -342,7 +343,7 @@ public final class SncpClient {
final Type[] myparamtypes = action.paramTypes;
final Class[] myparamclass = action.paramClass;
if (action.addressSourceParamIndex >= 0) params[action.addressSourceParamIndex] = this.clientAddress;
if(bsonConvert == null) bsonConvert = BsonConvert.root();
if (bsonConvert == null) bsonConvert = BsonConvert.root();
final BsonWriter writer = bsonConvert.pollBsonWriter(transport.getBufferSupplier()); // 将head写入
writer.writeTo(DEFAULT_HEADER);
for (int i = 0; i < params.length; i++) { //params 可能包含: 3 个 boolean

View File

@@ -49,6 +49,7 @@ public final class SncpResponse extends Response<SncpContext, SncpRequest> {
super(context, request);
this.addrBytes = context.getServerAddress().getAddress().getAddress();
this.addrPort = context.getServerAddress().getPort();
if (this.addrBytes.length != 4) throw new RuntimeException("SNCP serverAddress only support IPv4");
}
public void finish(final int retcode, final BsonWriter out) {