ソースを参照

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)


読み込み中…
キャンセル
保存