174 return inet.String()
175}
176
177func (ipb *IPBan) IsBanned(ipStr string) (bool, error) {178 ipn, err := gcutil.GetIPRangeSubnet(ipb.RangeStart, ipb.RangeEnd)
179 if err != nil {
180 return false, err
163// implemented. This is here as a fallback for templates
164//
165// Deprecated: Use the RangeStart and RangeEnd fields or gcutil.GetIPRangeSubnet
166func (ipb *IPBan) IP() string {167 if ipb.RangeStart == ipb.RangeEnd {
168 return ipb.RangeStart
169 }
67
68// ApplyIPBan bans the given IP if it posted a banned image
69// If BanIP is false, it returns with no error
70func (fb *FileBan) ApplyIPBan(postIP string) error { 71 if !fb.BanIP {
72 return nil
73 }
519 return fb.BoardID == nil
520}
521
522func (fb FileBan) Deactivate(_ int) error {523 const deleteQuery = `DELETE FROM DBPREFIXfile_ban WHERE id = ?`
524 _, err := ExecSQL(deleteQuery, fb.ID)
525 return err
515 return &ban, nil
516}
517
518func (fb *FileBan) IsGlobalBan() bool {519 return fb.BoardID == nil
520}
521
(Go's FAQ)[https://go.dev/doc/faq#methodsonvaluesorpointers] recommends that method receivers should be consistent. If some of the methods of the type must have pointer receivers, the rest should too, so the method set is consistent regardless of how the type is used. This is because value and pointer receivers have different method sets.
package main
type foo struct {
a int
}
func (f foo) a() {}
func (f *foo) b() {
f.a = 10
}
package main
type foo struct {
a int
}
func (f *foo) a() {}
func (f *foo) b() {
f.a = 10
}