mirror of
https://github.com/shadow1ng/fscan.git
synced 2026-09-25 12:41:53 +08:00
refactor(services): 统一数据库插件的DBWrapper
4个数据库插件(MySQL、PostgreSQL、MSSQL、Oracle)都有相同的sql.DB包装代码, 合并为通用的SQLDBWrapper,减少重复。
This commit is contained in:
@@ -104,24 +104,14 @@ func (p *MySQLPlugin) doMySQLAuth(ctx context.Context, info *common.HostInfo, cr
|
||||
|
||||
state.IncrementTCPSuccessPacketCount()
|
||||
|
||||
// MySQL 使用 sql.DB,包装为 io.Closer
|
||||
return &AuthResult{
|
||||
Success: true,
|
||||
Conn: &sqlDBWrapper{db},
|
||||
Conn: &SQLDBWrapper{db},
|
||||
ErrorType: ErrorTypeUnknown,
|
||||
Error: nil,
|
||||
}
|
||||
}
|
||||
|
||||
// sqlDBWrapper 包装 sql.DB 以实现 io.Closer
|
||||
type sqlDBWrapper struct {
|
||||
*sql.DB
|
||||
}
|
||||
|
||||
func (w *sqlDBWrapper) Close() error {
|
||||
return w.DB.Close()
|
||||
}
|
||||
|
||||
// classifyMySQLErrorType MySQL错误分类
|
||||
func classifyMySQLErrorType(err error) ErrorType {
|
||||
if err == nil {
|
||||
|
||||
Reference in New Issue
Block a user