Skip to content

Commit 55165d7

Browse files
committed
Adding support for SSL connections to a source MySQL server
1 parent 05bbcc1 commit 55165d7

File tree

3 files changed

+21
-1
lines changed

3 files changed

+21
-1
lines changed

sql/binlogreplication/binlog_replication.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,7 @@ type BinaryLogStatus struct {
131131
type ReplicaStatus struct {
132132
SourceHost string
133133
SourceUser string
134+
SourceSsl bool
134135
SourcePort uint
135136
ConnectRetry uint32
136137
SourceRetryCount uint64

sql/mysql_db/replica_source_info.go

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ import (
2727
type ReplicaSourceInfo struct {
2828
Host string
2929
User string
30+
Ssl bool
3031
Password string
3132
Port uint16
3233
Uuid string
@@ -58,6 +59,12 @@ func ReplicaSourceInfoToRow(ctx *sql.Context, v *ReplicaSourceInfo) (sql.Row, er
5859
row[replicaSourceInfoTblColIndex_Connect_retry] = v.ConnectRetryInterval
5960
row[replicaSourceInfoTblColIndex_Retry_count] = v.ConnectRetryCount
6061

62+
if v.Ssl {
63+
row[replicaSourceInfoTblColIndex_Enabled_ssl] = 1
64+
} else {
65+
row[replicaSourceInfoTblColIndex_Enabled_ssl] = 0
66+
}
67+
6168
return row, nil
6269
}
6370

@@ -66,9 +73,15 @@ func ReplicaSourceInfoFromRow(ctx *sql.Context, row sql.Row) (*ReplicaSourceInfo
6673
return nil, err
6774
}
6875

76+
ssl := false
77+
if row[replicaSourceInfoTblColIndex_Enabled_ssl] == 1 {
78+
ssl = true
79+
}
80+
6981
return &ReplicaSourceInfo{
7082
Host: row[replicaSourceInfoTblColIndex_Host].(string),
7183
User: row[replicaSourceInfoTblColIndex_User_name].(string),
84+
Ssl: ssl,
7285
Password: row[replicaSourceInfoTblColIndex_User_password].(string),
7386
Port: row[replicaSourceInfoTblColIndex_Port].(uint16),
7487
Uuid: row[replicaSourceInfoTblColIndex_Uuid].(string),
@@ -79,6 +92,7 @@ func ReplicaSourceInfoFromRow(ctx *sql.Context, row sql.Row) (*ReplicaSourceInfo
7992

8093
func ReplicaSourceInfoEquals(left, right *ReplicaSourceInfo) bool {
8194
return left.User == right.User &&
95+
left.Ssl == right.Ssl &&
8296
left.Host == right.Host &&
8397
left.Port == right.Port &&
8498
left.Password == right.Password &&

sql/rowexec/show.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -807,6 +807,11 @@ func (b *BaseBuilder) buildShowReplicaStatus(ctx *sql.Context, n *plan.ShowRepli
807807
lastIoErrorTimestamp := formatReplicaStatusTimestamp(status.LastIoErrorTimestamp)
808808
lastSqlErrorTimestamp := formatReplicaStatusTimestamp(status.LastSqlErrorTimestamp)
809809

810+
sslAllowed := "No"
811+
if status.SourceSsl {
812+
sslAllowed = "Yes"
813+
}
814+
810815
row = sql.Row{
811816
"", // Replica_IO_State
812817
status.SourceHost, // Source_Host
@@ -834,7 +839,7 @@ func (b *BaseBuilder) buildShowReplicaStatus(ctx *sql.Context, n *plan.ShowRepli
834839
"None", // Until_Condition
835840
nil, // Until_Log_File
836841
nil, // Until_Log_Pos
837-
"Ignored", // Source_SSL_Allowed
842+
sslAllowed, // Source_SSL_Allowed
838843
nil, // Source_SSL_CA_File
839844
nil, // Source_SSL_CA_Path
840845
nil, // Source_SSL_Cert

0 commit comments

Comments
 (0)