Skip to content

Commit

Permalink
more informative field names
Browse files Browse the repository at this point in the history
  • Loading branch information
jreisinger committed Jun 7, 2024
1 parent 6c9cb48 commit ceeaaf8
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion checkip.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
package checkip

import (
"encoding/json"
"net"
)

Expand All @@ -20,14 +21,27 @@ func (t Type) String() string {
return [...]string{"Info", "Sec", "InfoSec"}[t]
}

func (t Type) MarshalJSON() ([]byte, error) {
var s string
switch t {
case TypeInfo:
s = "info"
case TypeSec:
s = "security"
case TypeInfoSec:
s = "infoAndSecurity"
}
return json.Marshal(s)
}

// Check provides generic and/or security information about an IP address.
type Check func(ipaddr net.IP) (Result, error)

// Result is the information provided by a Check.
type Result struct {
Name string `json:"name"` // check name, max 15 chars
Type Type `json:"type"` // check type
Malicious bool `json:"malicious"` // provided by TypeSec check type
Malicious bool `json:"malicious"` // provided by TypeSec and TypeInfoSec check type
Info Info `json:"info"`
}

Expand Down

0 comments on commit ceeaaf8

Please sign in to comment.