Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add SSL support to MySQL connections #3

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 17 additions & 3 deletions bin/run.dart
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,12 @@ main(List<String> args) async {
"type": "string",
"description": "Database Name",
"placeholder": "mydb"
},
{
"name": "useSSL",
"type": "bool",
"default": false,
"description": "Require SSL"
}
]
}
Expand Down Expand Up @@ -167,7 +173,7 @@ main(List<String> args) async {

var mmm = [];

for (var field in ["host", "port", "user", "password", "db"]) {
for (var field in ["host", "port", "user", "password", "db", "useSSL"]) {
var val = params[field];
var nn = "\$mysql_${field}";
var old = conn.configs[nn];
Expand Down Expand Up @@ -228,13 +234,15 @@ class CreateConnectionNode extends SimpleNode {
var user = params["user"];
var password = params["password"];
var db = params["db"];
var useSSL = params["useSSL"];

var m = {
r"$is": "connection",
r"$mysql_host": host,
r"$mysql_port": port,
r"$$mysql_user": user,
r"$$mysql_password": password
r"$$mysql_password": password,
r"$$mysql_ssl": useSSL
};

if (db != null) {
Expand Down Expand Up @@ -264,8 +272,9 @@ class ConnectionNode extends SimpleNode {
var user = get(r"$$mysql_user");
var password = get(r"$$mysql_password");
var db = get(r"$mysql_db");
var useSSL = get(r"$$mysql_ssl");

var pool = new ConnectionPool(host: host, user: user, port: port, db: db, password: password);
var pool = new ConnectionPool(host: host, user: user, port: port, db: db, password: password, useSSL: useSSL);

try {
RetainedConnection rc = await pool.getConnection();
Expand Down Expand Up @@ -377,6 +386,11 @@ class ConnectionNode extends SimpleNode {
"name": "db",
"type": "string",
"default": db
},
{
"name": "useSSL",
"type": "bool",
"default": false
}
],
r"$columns": [
Expand Down
2 changes: 1 addition & 1 deletion dslink.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "dslink-dart-mysql",
"version": "1.0.0",
"version": "1.0.1",
"description": "MySQL DSLink",
"main": "bin/run.dart",
"engines": {
Expand Down