NS日志增加remoteAddr字段

This commit is contained in:
GoEdgeLab
2021-08-09 15:19:38 +08:00
parent 43fdcd3d62
commit db11331c4e
3 changed files with 18 additions and 16 deletions

View File

@@ -241,7 +241,7 @@ func findNSAccessLogTable(db *dbs.DB, day string, force bool) (string, error) {
} }
// 创建表格 // 创建表格
_, err = db.Exec("CREATE TABLE `" + tableName + "` (\n `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT COMMENT 'ID',\n `nodeId` int(11) unsigned DEFAULT '0' COMMENT '节点ID',\n `domainId` int(11) unsigned DEFAULT '0' COMMENT '域名ID',\n `recordId` int(11) unsigned DEFAULT '0' COMMENT '记录ID',\n `content` json DEFAULT NULL COMMENT '访问数据',\n `requestId` varchar(128) DEFAULT NULL COMMENT '请求ID',\n `createdAt` bigint(11) unsigned DEFAULT '0' COMMENT '创建时间',\n PRIMARY KEY (`id`),\n KEY `nodeId` (`nodeId`),\n KEY `domainId` (`domainId`),\n KEY `recordId` (`recordId`),\n KEY `requestId` (`requestId`)\n) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='域名服务访问日志';") _, err = db.Exec("CREATE TABLE `" + tableName + "` (\n `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT COMMENT 'ID',\n `nodeId` int(11) unsigned DEFAULT '0' COMMENT '节点ID',\n `domainId` int(11) unsigned DEFAULT '0' COMMENT '域名ID',\n `recordId` int(11) unsigned DEFAULT '0' COMMENT '记录ID',\n `content` json DEFAULT NULL COMMENT '访问数据',\n `requestId` varchar(128) DEFAULT NULL COMMENT '请求ID',\n `createdAt` bigint(11) unsigned DEFAULT '0' COMMENT '创建时间',\n `remoteAddr` varchar(128) DEFAULT NULL COMMENT 'IP',\n PRIMARY KEY (`id`),\n KEY `nodeId` (`nodeId`),\n KEY `domainId` (`domainId`),\n KEY `recordId` (`recordId`),\n KEY `requestId` (`requestId`),\n KEY `remoteAddr` (`remoteAddr`)\n) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='域名服务访问日志';")
if err != nil { if err != nil {
return tableName, err return tableName, err
} }

View File

@@ -9,6 +9,7 @@ type NSAccessLog struct {
Content string `field:"content"` // 访问数据 Content string `field:"content"` // 访问数据
RequestId string `field:"requestId"` // 请求ID RequestId string `field:"requestId"` // 请求ID
CreatedAt uint64 `field:"createdAt"` // 创建时间 CreatedAt uint64 `field:"createdAt"` // 创建时间
RemoteAddr string `field:"remoteAddr"` // IP
} }
type NSAccessLogOperator struct { type NSAccessLogOperator struct {
@@ -19,6 +20,7 @@ type NSAccessLogOperator struct {
Content interface{} // 访问数据 Content interface{} // 访问数据
RequestId interface{} // 请求ID RequestId interface{} // 请求ID
CreatedAt interface{} // 创建时间 CreatedAt interface{} // 创建时间
RemoteAddr interface{} // IP
} }
func NewNSAccessLogOperator() *NSAccessLogOperator { func NewNSAccessLogOperator() *NSAccessLogOperator {

File diff suppressed because one or more lines are too long