Skip to content

Commit 2c7c50f

Browse files
committed
revert hostname md5
1 parent 90aacd6 commit 2c7c50f

File tree

2 files changed

+0
-34
lines changed

2 files changed

+0
-34
lines changed

mysql/mysql_test.go

Lines changed: 0 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
package mysql
22

33
import (
4-
"crypto/md5"
5-
"encoding/hex"
64
"strings"
75
"testing"
86

@@ -120,30 +118,6 @@ func (t *mysqlTestSuite) TestMysqlGTIDContain(c *check.C) {
120118
c.Assert(g1.Contain(g2), check.Equals, false)
121119
}
122120

123-
func (t *mysqlTestSuite) TestHostnameMd5sum(c *check.C) {
124-
// if os.Hostname() lengther than 60, use md5sum instead
125-
tbl := []struct {
126-
hashStr string
127-
sum int
128-
}{
129-
{`app-f084ccc2f5dd37da027539dc9d2cb1581c2237d4-1-7ff988bd9f-t2cx7`, 32},
130-
{`jianhaiqingxxx`, 14},
131-
{`dfmpzqy7wjvwotpadgkiinkl5bjtdkuu.aliyundunwaf.com.dfmpzqy7wjvwotpadgkiinkl5bjtdkuu.aliyundunwaf.com.dfmpzqy7wjvwotpadgkiinkl5bjtdkuu.aliyundunwaf.com.`, 32},
132-
}
133-
var get int
134-
for _, t := range tbl {
135-
if len(t.hashStr) > 60 {
136-
hasher := md5.New()
137-
hasher.Write([]byte(t.hashStr))
138-
get = len(hex.EncodeToString(hasher.Sum(nil)))
139-
} else {
140-
get = len(t.hashStr)
141-
}
142-
c.Assert(get == t.sum, check.IsTrue)
143-
}
144-
145-
}
146-
147121
func (t *mysqlTestSuite) TestMysqlParseBinaryInt8(c *check.C) {
148122
i8 := ParseBinaryInt8([]byte{128})
149123
c.Assert(i8, check.Equals, int8(-128))

replication/binlogsyncer.go

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,8 @@ package replication
22

33
import (
44
"context"
5-
"crypto/md5"
65
"crypto/tls"
76
"encoding/binary"
8-
"encoding/hex"
97
"fmt"
108
"net"
119
"os"
@@ -498,12 +496,6 @@ func (b *BinlogSyncer) writeBinlogDumpMariadbGTIDCommand(gset GTIDSet) error {
498496
func (b *BinlogSyncer) localHostname() string {
499497
if len(b.cfg.Localhost) == 0 {
500498
h, _ := os.Hostname()
501-
// if os.Hostname() lengther than 60, use md5sum instead
502-
if len(h) > 60 {
503-
hasher := md5.New()
504-
hasher.Write([]byte(h))
505-
return hex.EncodeToString(hasher.Sum(nil))
506-
}
507499
return h
508500
}
509501
return b.cfg.Localhost

0 commit comments

Comments
 (0)