WriteResult 写入扫描结果
(result ScanResult)
| 56 | |
| 57 | // WriteResult 写入扫描结果 |
| 58 | func (cw *CSVWriter) WriteResult(result ScanResult) error { |
| 59 | record := []string{ |
| 60 | result.IP, |
| 61 | result.Origin, |
| 62 | strconv.Itoa(result.Port), |
| 63 | result.CertDomain, |
| 64 | result.CertIssuer, |
| 65 | result.TLSVersion, |
| 66 | result.ALPN, |
| 67 | result.Curve, |
| 68 | result.GeoCode, |
| 69 | strconv.FormatBool(result.Feasible), |
| 70 | strconv.FormatInt(result.ResponseTime, 10), |
| 71 | result.Error, |
| 72 | time.Now().Format("2006-01-02 15:04:05"), |
| 73 | } |
| 74 | |
| 75 | if err := cw.writer.Write(record); err != nil { |
| 76 | return fmt.Errorf("写入CSV记录失败: %v", err) |
| 77 | } |
| 78 | |
| 79 | cw.writer.Flush() |
| 80 | return nil |
| 81 | } |
| 82 | |
| 83 | // Close 关闭CSV写入器 |
| 84 | func (cw *CSVWriter) Close() error { |