-
-
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.
- Loading branch information
1 parent
aaee923
commit 4caa9c4
Showing
20 changed files
with
362 additions
and
37 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
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
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; | ||
} |
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,27 @@ | ||
-----BEGIN RSA PRIVATE KEY----- | ||
MIIEogIBAAKCAQEAvBn5IVf97VJvdG7Jy/lun30oX6yEOJe4XsJ5C9bcxn6pX5lJ | ||
h+Ayon7Bd0HKsJiT4eG9ecyHeytruAJWdb0ARjg5y3UZO1RpPzt9BNedCkG0aD1b | ||
EYwkBA0nfpmkdQjr4/0CjlK8pFAlwIqKqdYbxiAw9lmQFup90uzcswBigB+WoHK+ | ||
dBMSISS+TvEPyoVEHxBORn7jDm1wYNNPuORFPrI/dArK3VXH4hbCZSkwtInLFzEG | ||
HrgNjIt66lowA50V4nGcGVWMD6ipO6XouL7HFM4FGiaxvYan0J5tLEtNf2v3IfJo | ||
7Rqh6jGh6Qy971KS1wOdGToOsZve9PIi6t54vQIDAQABAoIBADWb2WrtXwtiMS2n | ||
3Y9qmWKPExChZFWUuBEZr9H1/Jn9w1vhnhlBhmzVX2ITuCa4dX0tDwlFh19NMrgQ | ||
wn9vzEI3CBG6X+SO3CgPVkQpBzLDIx2KTwgjPqiA7z6fn0VTs5cYpr/VSLoztW64 | ||
jWh2AxhmWE39nJlLX2zb4NKLS4dj+/GV89hztieVVAxuJsrIaon0bopwmVpgCcLi | ||
olyAA4863Azr74JSCd2jT/yqWnX8s8voeEU3KcesREFB1dcJkGDrlhAihrDqPBwJ | ||
hVgB2DJIXLFwby/tUtAEbIrB4goJ4vOYcBRI2+hPT4v/tw7C1JBHYnBh+lUu73iv | ||
NkCnPikCgYEA6zbfFzFBNVYqMBbRCAmY27TDKYY9gJ085Kqm7aiEH7WttK6tbDxt | ||
aeCxHqh/hR1NMuYW0T+YufWGZJbGNvn7CvxfqciMy1U1ZLk3O3lRJ80P4yiBuLS8 | ||
FMStVSRiL2kuAPwhfLglOl8e1zofMjNAboOq4Al/hWsMEfbtQkrKvp8CgYEAzLlK | ||
xdjg9UgJ/lZblGQzI9NUnsbmoGE3gaqLmFL0OZxyckSHYt+28OIMjlQb6GLBG1J1 | ||
g2I2xwmZ4VF+VGrC+Ojr4qPHiQ/2eXcy0U0JIJSgIW0Ck3DXCWSaN8H6Ghz8hAL0 | ||
3Trk5ly7BUyqkGNeDgZD1z42rNAf83vbnBHl9yMCgYAtbDtIz0o4cptTDhTv6GqM | ||
gyvtKO9XlwXbYtk5rAFX3k3dRp5W+JRojeumcAOwQShXW/esEQv9XVzGsBc3Jq9E | ||
P9h5gTEvUxUsjlgMNDFn7kHTLE9gzAZGPHT8rDoJzdYEeqw82ZLW4uehyKedmign | ||
L2YgPbVSnomGLplC5A6jIQKBgFliVVlItf+h8msPvXBuxz1PGdUxNqSzjY6ZrdVV | ||
8rfsrLNjZFExKCjIKX9DDeRKqdGKETDKAuyoLn2IHUYyTupqmAMeSxJ228Bw4Mkt | ||
f1ywR7IQbF1/mQPK3uKVWONp4H6q48pr2mER/73ymU3tdLVe2uPxj+GoBStD2sCr | ||
t+JNAoGABHm6F51ID5PAMDIqY4t6GptrZYXKGQ878rJv/RUw1b6ZTfB7dLPSMiiR | ||
QT8Qt587WmkhiBXuGY257FbbTmE79qJsrUe7IfBcvtp6ETHEFaJ8AHMFteBEDhch | ||
ABpzlHGdtpRxupXcQFuZrLXUrM67T4LHi82VWE2HJsqkhHwAwnc= | ||
-----END RSA PRIVATE KEY----- |
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,19 @@ | ||
-----BEGIN CERTIFICATE----- | ||
MIIDAzCCAeugAwIBAgIBATANBgkqhkiG9w0BAQsFADA8MTowOAYDVQQDDDFNeVNR | ||
TF9TZXJ2ZXJfOC4wLjMyX0F1dG9fR2VuZXJhdGVkX0NBX0NlcnRpZmljYXRlMB4X | ||
DTIzMDQyNjExNTQxOFoXDTMzMDQyMzExNTQxOFowPDE6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