diff --git a/irc/dline.go b/irc/dline.go index e0b173b8..c92b2b67 100644 --- a/irc/dline.go +++ b/irc/dline.go @@ -28,9 +28,9 @@ var ( // IPRestrictTime contains the expiration info about the given IP. type IPRestrictTime struct { // Duration is how long this block lasts for. - Duration time.Duration + Duration time.Duration `json:"duration"` // Expires is when this block expires. - Expires time.Time + Expires time.Time `json:"expires"` } // IsExpired returns true if the time has expired. @@ -41,11 +41,11 @@ func (iptime *IPRestrictTime) IsExpired() bool { // IPBanInfo holds info about an IP/net ban. type IPBanInfo struct { // Reason is the ban reason. - Reason string + Reason string `json:"reason"` // OperReason is an oper ban reason. OperReason string `json:"oper_reason"` // Time holds details about the duration, if it exists. - Time *IPRestrictTime + Time *IPRestrictTime `json:"time"` } // dLineAddr contains the address itself and expiration time for a given network. diff --git a/irc/rest_api.go b/irc/rest_api.go index ede4bca9..1d73aad1 100644 --- a/irc/rest_api.go +++ b/irc/rest_api.go @@ -36,8 +36,9 @@ type restStatusResp struct { Channels int `json:"channels"` } -type restDLinesResp struct { +type restXLinesResp struct { DLines map[string]IPBanInfo `json:"dlines"` + KLines map[string]IPBanInfo `json:"klines"` } type restAcct struct { @@ -84,9 +85,10 @@ func restStatus(w http.ResponseWriter, r *http.Request) { } } -func restGetDLines(w http.ResponseWriter, r *http.Request) { - rs := restDLinesResp{ +func restGetXLines(w http.ResponseWriter, r *http.Request) { + rs := restXLinesResp{ DLines: restAPIServer.dlines.AllBans(), + KLines: restAPIServer.klines.AllBans(), } b, err := json.Marshal(rs) if err != nil { @@ -175,7 +177,7 @@ func (s *Server) startRestAPI() { rg := r.Methods("GET").Subrouter() rg.HandleFunc("/info", restInfo) rg.HandleFunc("/status", restStatus) - rg.HandleFunc("/dlines", restGetDLines) + rg.HandleFunc("/xlines", restGetXLines) rg.HandleFunc("/accounts", restGetAccounts) // PUT methods