go-mysql library to avoid printing password in cleartext
This commit is contained in:
parent
83416fbb19
commit
fcda14634d
@ -41,7 +41,7 @@ func NewGoMySQLReader(connectionConfig *mysql.ConnectionConfig) (binlogReader *G
|
|||||||
|
|
||||||
serverId := uint32(binlogReader.MigrationContext.ReplicaServerId)
|
serverId := uint32(binlogReader.MigrationContext.ReplicaServerId)
|
||||||
|
|
||||||
binlogSyncerConfig := &replication.BinlogSyncerConfig{
|
binlogSyncerConfig := replication.BinlogSyncerConfig{
|
||||||
ServerID: serverId,
|
ServerID: serverId,
|
||||||
Flavor: "mysql",
|
Flavor: "mysql",
|
||||||
Host: connectionConfig.Key.Hostname,
|
Host: connectionConfig.Key.Hostname,
|
||||||
|
2
vendor/github.com/siddontang/go-mysql/README.md
generated
vendored
2
vendor/github.com/siddontang/go-mysql/README.md
generated
vendored
@ -25,7 +25,7 @@ cfg := replication.BinlogSyncerConfig {
|
|||||||
User: "root",
|
User: "root",
|
||||||
Password: "",
|
Password: "",
|
||||||
}
|
}
|
||||||
syncer := replication.NewBinlogSyncer(&cfg)
|
syncer := replication.NewBinlogSyncer(cfg)
|
||||||
|
|
||||||
// Start sync with sepcified binlog file and position
|
// Start sync with sepcified binlog file and position
|
||||||
streamer, _ := syncer.StartSync(mysql.Position{binlogFile, binlogPos})
|
streamer, _ := syncer.StartSync(mysql.Position{binlogFile, binlogPos})
|
||||||
|
2
vendor/github.com/siddontang/go-mysql/canal/canal.go
generated
vendored
2
vendor/github.com/siddontang/go-mysql/canal/canal.go
generated
vendored
@ -265,7 +265,7 @@ func (c *Canal) prepareSyncer() error {
|
|||||||
Password: c.cfg.Password,
|
Password: c.cfg.Password,
|
||||||
}
|
}
|
||||||
|
|
||||||
c.syncer = replication.NewBinlogSyncer(&cfg)
|
c.syncer = replication.NewBinlogSyncer(cfg)
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
2
vendor/github.com/siddontang/go-mysql/cmd/go-mysqlbinlog/main.go
generated
vendored
2
vendor/github.com/siddontang/go-mysql/cmd/go-mysqlbinlog/main.go
generated
vendored
@ -45,7 +45,7 @@ func main() {
|
|||||||
SemiSyncEnabled: *semiSync,
|
SemiSyncEnabled: *semiSync,
|
||||||
}
|
}
|
||||||
|
|
||||||
b := replication.NewBinlogSyncer(&cfg)
|
b := replication.NewBinlogSyncer(cfg)
|
||||||
|
|
||||||
pos := mysql.Position{*file, uint32(*pos)}
|
pos := mysql.Position{*file, uint32(*pos)}
|
||||||
if len(*backupPath) > 0 {
|
if len(*backupPath) > 0 {
|
||||||
|
9
vendor/github.com/siddontang/go-mysql/replication/binlogsyncer.go
generated
vendored
9
vendor/github.com/siddontang/go-mysql/replication/binlogsyncer.go
generated
vendored
@ -54,7 +54,7 @@ type BinlogSyncerConfig struct {
|
|||||||
type BinlogSyncer struct {
|
type BinlogSyncer struct {
|
||||||
m sync.RWMutex
|
m sync.RWMutex
|
||||||
|
|
||||||
cfg *BinlogSyncerConfig
|
cfg BinlogSyncerConfig
|
||||||
|
|
||||||
c *client.Conn
|
c *client.Conn
|
||||||
|
|
||||||
@ -71,8 +71,13 @@ type BinlogSyncer struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// NewBinlogSyncer creates the BinlogSyncer with cfg.
|
// NewBinlogSyncer creates the BinlogSyncer with cfg.
|
||||||
func NewBinlogSyncer(cfg *BinlogSyncerConfig) *BinlogSyncer {
|
func NewBinlogSyncer(cfg BinlogSyncerConfig) *BinlogSyncer {
|
||||||
|
|
||||||
|
// Clear the Password to avoid outputing it in log.
|
||||||
|
pass := cfg.Password
|
||||||
|
cfg.Password = ""
|
||||||
log.Infof("create BinlogSyncer with config %v", cfg)
|
log.Infof("create BinlogSyncer with config %v", cfg)
|
||||||
|
cfg.Password = pass
|
||||||
|
|
||||||
b := new(BinlogSyncer)
|
b := new(BinlogSyncer)
|
||||||
|
|
||||||
|
2
vendor/github.com/siddontang/go-mysql/replication/replication_test.go
generated
vendored
2
vendor/github.com/siddontang/go-mysql/replication/replication_test.go
generated
vendored
@ -271,7 +271,7 @@ func (t *testSyncerSuite) setupTest(c *C, flavor string) {
|
|||||||
Password: "",
|
Password: "",
|
||||||
}
|
}
|
||||||
|
|
||||||
t.b = NewBinlogSyncer(&cfg)
|
t.b = NewBinlogSyncer(cfg)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (t *testSyncerSuite) testPositionSync(c *C) {
|
func (t *testSyncerSuite) testPositionSync(c *C) {
|
||||||
|
Loading…
Reference in New Issue
Block a user