diff --git a/src/main/kotlin/net/eviltak/adbnmap/net/protocol/AdbServicesProtocol.kt b/src/main/kotlin/net/eviltak/adbnmap/net/protocol/AdbServicesProtocol.kt new file mode 100644 index 0000000..da0c1d9 --- /dev/null +++ b/src/main/kotlin/net/eviltak/adbnmap/net/protocol/AdbServicesProtocol.kt @@ -0,0 +1,30 @@ +package net.eviltak.adbnmap.net.protocol + +import java.net.Socket + +/** + * The protocol used by the ADB client to communicate with the ADB server + */ +class AdbServicesProtocol(override val socket: Socket) : Protocol { + + /** + * Send a test message in this communication protocol to a host through the [socket], eliciting a response + * from the target host confirming whether it supports this protocol or not. + * + * @param socket The socket connected to the host to which to send the test message. + */ + override fun sendTestMessage() { + + } + + /** + * Check if the host the [socket] is connected to uses this communication protocol. + * + * @param socket The socket connected to the host. + * + * @return true if the connected host uses this protocol, false otherwise. + */ + override fun hostUsesProtocol(): Boolean { + return false + } +} diff --git a/src/main/kotlin/net/eviltak/adbnmap/net/protocol/AdbTransportProtocol.kt b/src/main/kotlin/net/eviltak/adbnmap/net/protocol/AdbTransportProtocol.kt index 088823a..e809309 100644 --- a/src/main/kotlin/net/eviltak/adbnmap/net/protocol/AdbTransportProtocol.kt +++ b/src/main/kotlin/net/eviltak/adbnmap/net/protocol/AdbTransportProtocol.kt @@ -31,8 +31,6 @@ class AdbTransportProtocol(override val socket: Socket) : Protocol { /** * Send a test message in this communication protocol to a host through the [socket], eliciting a response * from the target host confirming whether it supports this protocol or not. - * - * @param socket The socket connected to the host to which to send the test message. */ override fun sendTestMessage() { val outBuffer = ByteBuffer.allocate(4 * 6).order(ByteOrder.LITTLE_ENDIAN) @@ -51,8 +49,6 @@ class AdbTransportProtocol(override val socket: Socket) : Protocol { /** * Check if the host the [socket] is connected to uses this communication protocol. * - * @param socket The socket connected to the host. - * * @return true if the connected host uses this protocol, false otherwise. */ override fun hostUsesProtocol(): Boolean { diff --git a/src/main/kotlin/net/eviltak/adbnmap/net/protocol/Protocol.kt b/src/main/kotlin/net/eviltak/adbnmap/net/protocol/Protocol.kt index 65dde28..5320460 100644 --- a/src/main/kotlin/net/eviltak/adbnmap/net/protocol/Protocol.kt +++ b/src/main/kotlin/net/eviltak/adbnmap/net/protocol/Protocol.kt @@ -6,13 +6,14 @@ import java.net.Socket * A communication protocol that may be used by devices on a network. */ interface Protocol { + /** + * The socket connected to the target host. + */ val socket: Socket /** * Send a test message in this communication protocol to a host through the [socket], eliciting a response * from the target host confirming whether it supports this protocol or not. - * - * @param socket The socket connected to the host to which to send the test message. */ fun sendTestMessage() @@ -20,8 +21,6 @@ interface Protocol { * Check if the host the [socket] is connected to uses this communication protocol. An implementation would * ideally use [sendTestMessage] and listen for a valid response. * - * @param socket The socket connected to the host. - * * @return true if the connected host uses this protocol, false otherwise. */ fun hostUsesProtocol(): Boolean