-
-
Notifications
You must be signed in to change notification settings - Fork 65
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* support tls * delete test * optimize according to the comment * skip mariadb:latest
- Loading branch information
1 parent
6904845
commit 62cddec
Showing
10 changed files
with
155 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,4 +4,5 @@ node_modules | |
mysql.log | ||
docs | ||
.DS_Store | ||
.idea | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,27 @@ | ||
enum ServerCapabilities { | ||
CLIENT_PROTOCOL_41 = 0x00000200, | ||
CLIENT_CONNECT_WITH_DB = 0x00000008, | ||
CLIENT_LONG_FLAG = 0x00000004, | ||
CLIENT_DEPRECATE_EOF = 0x01000000, | ||
CLIENT_LONG_PASSWORD = 0x00000001, | ||
CLIENT_TRANSACTIONS = 0x00002000, | ||
CLIENT_MULTI_RESULTS = 0x00020000, | ||
CLIENT_PLUGIN_AUTH_LENENC_CLIENT_DATA = 0x00200000, | ||
CLIENT_PLUGIN_AUTH = 0x80000, | ||
CLIENT_SECURE_CONNECTION = 0x8000, | ||
CLIENT_FOUND_ROWS = 0x00000002, | ||
CLIENT_CONNECT_ATTRS = 0x00100000, | ||
CLIENT_LONG_FLAG = 0x00000004, | ||
CLIENT_CONNECT_WITH_DB = 0x00000008, | ||
CLIENT_NO_SCHEMA = 0x00000010, | ||
CLIENT_COMPRESS = 0x00000020, | ||
CLIENT_ODBC = 0x00000040, | ||
CLIENT_LOCAL_FILES = 0x00000080, | ||
CLIENT_IGNORE_SPACE = 0x00000100, | ||
CLIENT_PROTOCOL_41 = 0x00000200, | ||
CLIENT_INTERACTIVE = 0x00000400, | ||
CLIENT_SSL = 0x00000800, | ||
CLIENT_IGNORE_SIGPIPE = 0x00001000, | ||
CLIENT_TRANSACTIONS = 0x00002000, | ||
CLIENT_RESERVED = 0x00004000, | ||
CLIENT_SECURE_CONNECTION = 0x00008000, | ||
CLIENT_MULTI_STATEMENTS = 0x00010000, | ||
CLIENT_MULTI_RESULTS = 0x00020000, | ||
CLIENT_PS_MULTI_RESULTS = 0x00040000, | ||
CLIENT_PLUGIN_AUTH = 0x00080000, | ||
CLIENT_CONNECT_ATTRS = 0x00100000, | ||
CLIENT_PLUGIN_AUTH_LENENC_CLIENT_DATA = 0x00200000, | ||
CLIENT_DEPRECATE_EOF = 0x01000000, | ||
} | ||
|
||
export default ServerCapabilities; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import ServerCapabilities from "../../constant/capabilities.ts"; | ||
import type { HandshakeBody } from "../parsers/handshake.ts"; | ||
|
||
export function clientCapabilities( | ||
packet: HandshakeBody, | ||
params: { db?: string; ssl?: boolean }, | ||
): number { | ||
return (params.db ? ServerCapabilities.CLIENT_CONNECT_WITH_DB : 0) | | ||
ServerCapabilities.CLIENT_PLUGIN_AUTH | | ||
ServerCapabilities.CLIENT_LONG_PASSWORD | | ||
ServerCapabilities.CLIENT_PROTOCOL_41 | | ||
ServerCapabilities.CLIENT_TRANSACTIONS | | ||
ServerCapabilities.CLIENT_MULTI_RESULTS | | ||
ServerCapabilities.CLIENT_SECURE_CONNECTION | | ||
(ServerCapabilities.CLIENT_LONG_FLAG & packet.serverCapabilities) | | ||
(ServerCapabilities.CLIENT_PLUGIN_AUTH_LENENC_CLIENT_DATA & | ||
packet.serverCapabilities) | | ||
(ServerCapabilities.CLIENT_DEPRECATE_EOF & packet.serverCapabilities) | | ||
(params.ssl ? ServerCapabilities.CLIENT_SSL : 0); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import { BufferWriter } from "../../buffer.ts"; | ||
import { Charset } from "../../constant/charset.ts"; | ||
import type { HandshakeBody } from "../parsers/handshake.ts"; | ||
import { clientCapabilities } from "./client_capabilities.ts"; | ||
|
||
export function buildSSLRequest( | ||
packet: HandshakeBody, | ||
params: { db?: string }, | ||
): Uint8Array { | ||
const clientParam: number = clientCapabilities(packet, { | ||
db: params.db, | ||
ssl: true, | ||
}); | ||
const writer = new BufferWriter(new Uint8Array(32)); | ||
writer | ||
.writeUint32(clientParam) | ||
.writeUint32(2 ** 24 - 1) | ||
.write(Charset.UTF8_GENERAL_CI) | ||
.skip(23); | ||
return writer.wroteData; | ||
} |