瀏覽代碼

better logging

master
Vladimir Smagin 3 月之前
父節點
當前提交
e4ce551441
共有 1 個文件被更改,包括 2 次插入3 次删除
  1. +2
    -3
      main.go

+ 2
- 3
main.go 查看文件

@@ -224,7 +224,6 @@ func HandlerList(w http.ResponseWriter, r *http.Request) {

func HandlerSet(w http.ResponseWriter, r *http.Request) {
vars := mux.Vars(r)
log.Println("Got set request", vars)

ip := IP{
IP: vars["ip"],
@@ -254,13 +253,13 @@ func HandlerSet(w http.ResponseWriter, r *http.Request) {
}

if count > 0 {
log.Println("Update IP timestamp:", ip.IP)
log.Println("State: UPDATE", "IP:", ip.IP, "Origin:", ip.Origin, "Port:", ip.Port, "Protocol:", ip.Protocol)
_, err := blockIP.HandlerDB.Exec("update ip set origin=?, updated=strftime('%s','now') where blocktable=? and ip=?", ip.Origin, ip.BlockTable, ip.IP)
if err != nil {
log.Println(err)
}
} else {
log.Println("New IP:", ip.IP)
log.Println("State: NEW", "IP:", ip.IP, "Origin:", ip.Origin, "Port:", ip.Port, "Protocol:", ip.Protocol)
_, err := blockIP.HandlerDB.Exec("insert into ip(origin, ip, protocol, port, updated, blocktable) values(?, ?, ?, ?, strftime('%s','now'), ?)", ip.Origin, ip.IP, ip.Protocol, ip.Port, ip.BlockTable)
if err != nil {
log.Println(err)


Loading…
取消
儲存