blob: 02a4e82851eb9c6d7aba4f41aa3a3acb2f69de9d (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
|
// Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.jrt;
import java.io.IOException;
import java.nio.ByteBuffer;
import java.nio.channels.SocketChannel;
/**
* A CryptoSocket with no encryption
**/
public class NullCryptoSocket implements CryptoSocket {
private final boolean isServer;
private SocketChannel channel;
private final TransportMetrics metrics = TransportMetrics.getInstance();
public NullCryptoSocket(SocketChannel channel, boolean isServer) { this.channel = channel; this.isServer = isServer; }
@Override public SocketChannel channel() { return channel; }
@Override public HandshakeResult handshake() throws IOException {
if (isServer) {
metrics.incrementServerUnencryptedConnectionsEstablished();
} else {
metrics.incrementClientUnencryptedConnectionsEstablished();
}
return HandshakeResult.DONE;
}
@Override public void doHandshakeWork() {}
@Override public int getMinimumReadBufferSize() { return 1; }
@Override public int read(ByteBuffer dst) throws IOException { return channel.read(dst); }
@Override public int drain(ByteBuffer dst) throws IOException { return 0; }
@Override public int write(ByteBuffer src) throws IOException { return channel.write(src); }
@Override public FlushResult flush() throws IOException { return FlushResult.DONE; }
@Override public void dropEmptyBuffers() {}
}
|