mirror of https://github.com/0xERR0R/blocky.git
update go-enum to v0.4.0
This commit is contained in:
parent
56712ff1be
commit
476dd7d0eb
2
Makefile
2
Makefile
|
@ -27,7 +27,7 @@ serve_docs: ## serves online docs
|
|||
mkdocs serve
|
||||
|
||||
build: ## Build binary
|
||||
go install github.com/abice/go-enum@v0.3.8
|
||||
go install github.com/abice/go-enum@v0.4.0
|
||||
go generate ./...
|
||||
go build -v -ldflags="-w -s -X github.com/0xERR0R/blocky/util.Version=${VERSION} -X github.com/0xERR0R/blocky/util.BuildTime=${BUILD_TIME}" -o $(BIN_OUT_DIR)/$(BINARY_NAME)$(BINARY_SUFFIX)
|
||||
|
||||
|
|
|
@ -47,11 +47,11 @@ func NetProtocolNames() []string {
|
|||
}
|
||||
|
||||
var _NetProtocolMap = map[NetProtocol]string{
|
||||
0: _NetProtocolName[0:3],
|
||||
1: _NetProtocolName[3:6],
|
||||
2: _NetProtocolName[6:13],
|
||||
3: _NetProtocolName[13:20],
|
||||
4: _NetProtocolName[20:25],
|
||||
NetProtocolUdp: _NetProtocolName[0:3],
|
||||
NetProtocolTcp: _NetProtocolName[3:6],
|
||||
NetProtocolTcpUdp: _NetProtocolName[6:13],
|
||||
NetProtocolTcpTls: _NetProtocolName[13:20],
|
||||
NetProtocolHttps: _NetProtocolName[20:25],
|
||||
}
|
||||
|
||||
// String implements the Stringer interface.
|
||||
|
@ -63,14 +63,14 @@ func (x NetProtocol) String() string {
|
|||
}
|
||||
|
||||
var _NetProtocolValue = map[string]NetProtocol{
|
||||
_NetProtocolName[0:3]: 0,
|
||||
_NetProtocolName[3:6]: 1,
|
||||
_NetProtocolName[6:13]: 2,
|
||||
_NetProtocolName[13:20]: 3,
|
||||
_NetProtocolName[20:25]: 4,
|
||||
_NetProtocolName[0:3]: NetProtocolUdp,
|
||||
_NetProtocolName[3:6]: NetProtocolTcp,
|
||||
_NetProtocolName[6:13]: NetProtocolTcpUdp,
|
||||
_NetProtocolName[13:20]: NetProtocolTcpTls,
|
||||
_NetProtocolName[20:25]: NetProtocolHttps,
|
||||
}
|
||||
|
||||
// ParseNetProtocol attempts to convert a string to a NetProtocol
|
||||
// ParseNetProtocol attempts to convert a string to a NetProtocol.
|
||||
func ParseNetProtocol(name string) (NetProtocol, error) {
|
||||
if x, ok := _NetProtocolValue[name]; ok {
|
||||
return x, nil
|
||||
|
@ -78,12 +78,12 @@ func ParseNetProtocol(name string) (NetProtocol, error) {
|
|||
return NetProtocol(0), fmt.Errorf("%s is not a valid NetProtocol, try [%s]", name, strings.Join(_NetProtocolNames, ", "))
|
||||
}
|
||||
|
||||
// MarshalText implements the text marshaller method
|
||||
// MarshalText implements the text marshaller method.
|
||||
func (x NetProtocol) MarshalText() ([]byte, error) {
|
||||
return []byte(x.String()), nil
|
||||
}
|
||||
|
||||
// UnmarshalText implements the text unmarshaller method
|
||||
// UnmarshalText implements the text unmarshaller method.
|
||||
func (x *NetProtocol) UnmarshalText(text []byte) error {
|
||||
name := string(text)
|
||||
tmp, err := ParseNetProtocol(name)
|
||||
|
@ -134,12 +134,12 @@ func QueryLogTypeNames() []string {
|
|||
}
|
||||
|
||||
var _QueryLogTypeMap = map[QueryLogType]string{
|
||||
0: _QueryLogTypeName[0:7],
|
||||
1: _QueryLogTypeName[7:11],
|
||||
2: _QueryLogTypeName[11:16],
|
||||
3: _QueryLogTypeName[16:26],
|
||||
4: _QueryLogTypeName[26:29],
|
||||
5: _QueryLogTypeName[29:39],
|
||||
QueryLogTypeConsole: _QueryLogTypeName[0:7],
|
||||
QueryLogTypeNone: _QueryLogTypeName[7:11],
|
||||
QueryLogTypeMysql: _QueryLogTypeName[11:16],
|
||||
QueryLogTypePostgresql: _QueryLogTypeName[16:26],
|
||||
QueryLogTypeCsv: _QueryLogTypeName[26:29],
|
||||
QueryLogTypeCsvClient: _QueryLogTypeName[29:39],
|
||||
}
|
||||
|
||||
// String implements the Stringer interface.
|
||||
|
@ -151,15 +151,15 @@ func (x QueryLogType) String() string {
|
|||
}
|
||||
|
||||
var _QueryLogTypeValue = map[string]QueryLogType{
|
||||
_QueryLogTypeName[0:7]: 0,
|
||||
_QueryLogTypeName[7:11]: 1,
|
||||
_QueryLogTypeName[11:16]: 2,
|
||||
_QueryLogTypeName[16:26]: 3,
|
||||
_QueryLogTypeName[26:29]: 4,
|
||||
_QueryLogTypeName[29:39]: 5,
|
||||
_QueryLogTypeName[0:7]: QueryLogTypeConsole,
|
||||
_QueryLogTypeName[7:11]: QueryLogTypeNone,
|
||||
_QueryLogTypeName[11:16]: QueryLogTypeMysql,
|
||||
_QueryLogTypeName[16:26]: QueryLogTypePostgresql,
|
||||
_QueryLogTypeName[26:29]: QueryLogTypeCsv,
|
||||
_QueryLogTypeName[29:39]: QueryLogTypeCsvClient,
|
||||
}
|
||||
|
||||
// ParseQueryLogType attempts to convert a string to a QueryLogType
|
||||
// ParseQueryLogType attempts to convert a string to a QueryLogType.
|
||||
func ParseQueryLogType(name string) (QueryLogType, error) {
|
||||
if x, ok := _QueryLogTypeValue[name]; ok {
|
||||
return x, nil
|
||||
|
@ -167,12 +167,12 @@ func ParseQueryLogType(name string) (QueryLogType, error) {
|
|||
return QueryLogType(0), fmt.Errorf("%s is not a valid QueryLogType, try [%s]", name, strings.Join(_QueryLogTypeNames, ", "))
|
||||
}
|
||||
|
||||
// MarshalText implements the text marshaller method
|
||||
// MarshalText implements the text marshaller method.
|
||||
func (x QueryLogType) MarshalText() ([]byte, error) {
|
||||
return []byte(x.String()), nil
|
||||
}
|
||||
|
||||
// UnmarshalText implements the text unmarshaller method
|
||||
// UnmarshalText implements the text unmarshaller method.
|
||||
func (x *QueryLogType) UnmarshalText(text []byte) error {
|
||||
name := string(text)
|
||||
tmp, err := ParseQueryLogType(name)
|
||||
|
|
|
@ -35,8 +35,8 @@ func ListCacheTypeNames() []string {
|
|||
}
|
||||
|
||||
var _ListCacheTypeMap = map[ListCacheType]string{
|
||||
0: _ListCacheTypeName[0:9],
|
||||
1: _ListCacheTypeName[9:18],
|
||||
ListCacheTypeBlacklist: _ListCacheTypeName[0:9],
|
||||
ListCacheTypeWhitelist: _ListCacheTypeName[9:18],
|
||||
}
|
||||
|
||||
// String implements the Stringer interface.
|
||||
|
@ -48,11 +48,11 @@ func (x ListCacheType) String() string {
|
|||
}
|
||||
|
||||
var _ListCacheTypeValue = map[string]ListCacheType{
|
||||
_ListCacheTypeName[0:9]: 0,
|
||||
_ListCacheTypeName[9:18]: 1,
|
||||
_ListCacheTypeName[0:9]: ListCacheTypeBlacklist,
|
||||
_ListCacheTypeName[9:18]: ListCacheTypeWhitelist,
|
||||
}
|
||||
|
||||
// ParseListCacheType attempts to convert a string to a ListCacheType
|
||||
// ParseListCacheType attempts to convert a string to a ListCacheType.
|
||||
func ParseListCacheType(name string) (ListCacheType, error) {
|
||||
if x, ok := _ListCacheTypeValue[name]; ok {
|
||||
return x, nil
|
||||
|
@ -60,12 +60,12 @@ func ParseListCacheType(name string) (ListCacheType, error) {
|
|||
return ListCacheType(0), fmt.Errorf("%s is not a valid ListCacheType, try [%s]", name, strings.Join(_ListCacheTypeNames, ", "))
|
||||
}
|
||||
|
||||
// MarshalText implements the text marshaller method
|
||||
// MarshalText implements the text marshaller method.
|
||||
func (x ListCacheType) MarshalText() ([]byte, error) {
|
||||
return []byte(x.String()), nil
|
||||
}
|
||||
|
||||
// UnmarshalText implements the text unmarshaller method
|
||||
// UnmarshalText implements the text unmarshaller method.
|
||||
func (x *ListCacheType) UnmarshalText(text []byte) error {
|
||||
name := string(text)
|
||||
tmp, err := ParseListCacheType(name)
|
||||
|
|
|
@ -35,8 +35,8 @@ func FormatTypeNames() []string {
|
|||
}
|
||||
|
||||
var _FormatTypeMap = map[FormatType]string{
|
||||
0: _FormatTypeName[0:4],
|
||||
1: _FormatTypeName[4:8],
|
||||
FormatTypeText: _FormatTypeName[0:4],
|
||||
FormatTypeJson: _FormatTypeName[4:8],
|
||||
}
|
||||
|
||||
// String implements the Stringer interface.
|
||||
|
@ -48,11 +48,11 @@ func (x FormatType) String() string {
|
|||
}
|
||||
|
||||
var _FormatTypeValue = map[string]FormatType{
|
||||
_FormatTypeName[0:4]: 0,
|
||||
_FormatTypeName[4:8]: 1,
|
||||
_FormatTypeName[0:4]: FormatTypeText,
|
||||
_FormatTypeName[4:8]: FormatTypeJson,
|
||||
}
|
||||
|
||||
// ParseFormatType attempts to convert a string to a FormatType
|
||||
// ParseFormatType attempts to convert a string to a FormatType.
|
||||
func ParseFormatType(name string) (FormatType, error) {
|
||||
if x, ok := _FormatTypeValue[name]; ok {
|
||||
return x, nil
|
||||
|
@ -60,12 +60,12 @@ func ParseFormatType(name string) (FormatType, error) {
|
|||
return FormatType(0), fmt.Errorf("%s is not a valid FormatType, try [%s]", name, strings.Join(_FormatTypeNames, ", "))
|
||||
}
|
||||
|
||||
// MarshalText implements the text marshaller method
|
||||
// MarshalText implements the text marshaller method.
|
||||
func (x FormatType) MarshalText() ([]byte, error) {
|
||||
return []byte(x.String()), nil
|
||||
}
|
||||
|
||||
// UnmarshalText implements the text unmarshaller method
|
||||
// UnmarshalText implements the text unmarshaller method.
|
||||
func (x *FormatType) UnmarshalText(text []byte) error {
|
||||
name := string(text)
|
||||
tmp, err := ParseFormatType(name)
|
||||
|
@ -110,12 +110,12 @@ func LevelNames() []string {
|
|||
}
|
||||
|
||||
var _LevelMap = map[Level]string{
|
||||
0: _LevelName[0:4],
|
||||
1: _LevelName[4:9],
|
||||
2: _LevelName[9:14],
|
||||
3: _LevelName[14:18],
|
||||
4: _LevelName[18:23],
|
||||
5: _LevelName[23:28],
|
||||
LevelInfo: _LevelName[0:4],
|
||||
LevelTrace: _LevelName[4:9],
|
||||
LevelDebug: _LevelName[9:14],
|
||||
LevelWarn: _LevelName[14:18],
|
||||
LevelError: _LevelName[18:23],
|
||||
LevelFatal: _LevelName[23:28],
|
||||
}
|
||||
|
||||
// String implements the Stringer interface.
|
||||
|
@ -127,15 +127,15 @@ func (x Level) String() string {
|
|||
}
|
||||
|
||||
var _LevelValue = map[string]Level{
|
||||
_LevelName[0:4]: 0,
|
||||
_LevelName[4:9]: 1,
|
||||
_LevelName[9:14]: 2,
|
||||
_LevelName[14:18]: 3,
|
||||
_LevelName[18:23]: 4,
|
||||
_LevelName[23:28]: 5,
|
||||
_LevelName[0:4]: LevelInfo,
|
||||
_LevelName[4:9]: LevelTrace,
|
||||
_LevelName[9:14]: LevelDebug,
|
||||
_LevelName[14:18]: LevelWarn,
|
||||
_LevelName[18:23]: LevelError,
|
||||
_LevelName[23:28]: LevelFatal,
|
||||
}
|
||||
|
||||
// ParseLevel attempts to convert a string to a Level
|
||||
// ParseLevel attempts to convert a string to a Level.
|
||||
func ParseLevel(name string) (Level, error) {
|
||||
if x, ok := _LevelValue[name]; ok {
|
||||
return x, nil
|
||||
|
@ -143,12 +143,12 @@ func ParseLevel(name string) (Level, error) {
|
|||
return Level(0), fmt.Errorf("%s is not a valid Level, try [%s]", name, strings.Join(_LevelNames, ", "))
|
||||
}
|
||||
|
||||
// MarshalText implements the text marshaller method
|
||||
// MarshalText implements the text marshaller method.
|
||||
func (x Level) MarshalText() ([]byte, error) {
|
||||
return []byte(x.String()), nil
|
||||
}
|
||||
|
||||
// UnmarshalText implements the text unmarshaller method
|
||||
// UnmarshalText implements the text unmarshaller method.
|
||||
func (x *Level) UnmarshalText(text []byte) error {
|
||||
name := string(text)
|
||||
tmp, err := ParseLevel(name)
|
||||
|
|
|
@ -35,8 +35,8 @@ func RequestProtocolNames() []string {
|
|||
}
|
||||
|
||||
var _RequestProtocolMap = map[RequestProtocol]string{
|
||||
0: _RequestProtocolName[0:3],
|
||||
1: _RequestProtocolName[3:6],
|
||||
RequestProtocolTCP: _RequestProtocolName[0:3],
|
||||
RequestProtocolUDP: _RequestProtocolName[3:6],
|
||||
}
|
||||
|
||||
// String implements the Stringer interface.
|
||||
|
@ -48,11 +48,11 @@ func (x RequestProtocol) String() string {
|
|||
}
|
||||
|
||||
var _RequestProtocolValue = map[string]RequestProtocol{
|
||||
_RequestProtocolName[0:3]: 0,
|
||||
_RequestProtocolName[3:6]: 1,
|
||||
_RequestProtocolName[0:3]: RequestProtocolTCP,
|
||||
_RequestProtocolName[3:6]: RequestProtocolUDP,
|
||||
}
|
||||
|
||||
// ParseRequestProtocol attempts to convert a string to a RequestProtocol
|
||||
// ParseRequestProtocol attempts to convert a string to a RequestProtocol.
|
||||
func ParseRequestProtocol(name string) (RequestProtocol, error) {
|
||||
if x, ok := _RequestProtocolValue[name]; ok {
|
||||
return x, nil
|
||||
|
@ -60,12 +60,12 @@ func ParseRequestProtocol(name string) (RequestProtocol, error) {
|
|||
return RequestProtocol(0), fmt.Errorf("%s is not a valid RequestProtocol, try [%s]", name, strings.Join(_RequestProtocolNames, ", "))
|
||||
}
|
||||
|
||||
// MarshalText implements the text marshaller method
|
||||
// MarshalText implements the text marshaller method.
|
||||
func (x RequestProtocol) MarshalText() ([]byte, error) {
|
||||
return []byte(x.String()), nil
|
||||
}
|
||||
|
||||
// UnmarshalText implements the text unmarshaller method
|
||||
// UnmarshalText implements the text unmarshaller method.
|
||||
func (x *RequestProtocol) UnmarshalText(text []byte) error {
|
||||
name := string(text)
|
||||
tmp, err := ParseRequestProtocol(name)
|
||||
|
@ -116,12 +116,12 @@ func ResponseTypeNames() []string {
|
|||
}
|
||||
|
||||
var _ResponseTypeMap = map[ResponseType]string{
|
||||
0: _ResponseTypeName[0:8],
|
||||
1: _ResponseTypeName[8:14],
|
||||
2: _ResponseTypeName[14:21],
|
||||
3: _ResponseTypeName[21:32],
|
||||
4: _ResponseTypeName[32:41],
|
||||
5: _ResponseTypeName[41:50],
|
||||
ResponseTypeRESOLVED: _ResponseTypeName[0:8],
|
||||
ResponseTypeCACHED: _ResponseTypeName[8:14],
|
||||
ResponseTypeBLOCKED: _ResponseTypeName[14:21],
|
||||
ResponseTypeCONDITIONAL: _ResponseTypeName[21:32],
|
||||
ResponseTypeCUSTOMDNS: _ResponseTypeName[32:41],
|
||||
ResponseTypeHOSTSFILE: _ResponseTypeName[41:50],
|
||||
}
|
||||
|
||||
// String implements the Stringer interface.
|
||||
|
@ -133,15 +133,15 @@ func (x ResponseType) String() string {
|
|||
}
|
||||
|
||||
var _ResponseTypeValue = map[string]ResponseType{
|
||||
_ResponseTypeName[0:8]: 0,
|
||||
_ResponseTypeName[8:14]: 1,
|
||||
_ResponseTypeName[14:21]: 2,
|
||||
_ResponseTypeName[21:32]: 3,
|
||||
_ResponseTypeName[32:41]: 4,
|
||||
_ResponseTypeName[41:50]: 5,
|
||||
_ResponseTypeName[0:8]: ResponseTypeRESOLVED,
|
||||
_ResponseTypeName[8:14]: ResponseTypeCACHED,
|
||||
_ResponseTypeName[14:21]: ResponseTypeBLOCKED,
|
||||
_ResponseTypeName[21:32]: ResponseTypeCONDITIONAL,
|
||||
_ResponseTypeName[32:41]: ResponseTypeCUSTOMDNS,
|
||||
_ResponseTypeName[41:50]: ResponseTypeHOSTSFILE,
|
||||
}
|
||||
|
||||
// ParseResponseType attempts to convert a string to a ResponseType
|
||||
// ParseResponseType attempts to convert a string to a ResponseType.
|
||||
func ParseResponseType(name string) (ResponseType, error) {
|
||||
if x, ok := _ResponseTypeValue[name]; ok {
|
||||
return x, nil
|
||||
|
@ -149,12 +149,12 @@ func ParseResponseType(name string) (ResponseType, error) {
|
|||
return ResponseType(0), fmt.Errorf("%s is not a valid ResponseType, try [%s]", name, strings.Join(_ResponseTypeNames, ", "))
|
||||
}
|
||||
|
||||
// MarshalText implements the text marshaller method
|
||||
// MarshalText implements the text marshaller method.
|
||||
func (x ResponseType) MarshalText() ([]byte, error) {
|
||||
return []byte(x.String()), nil
|
||||
}
|
||||
|
||||
// UnmarshalText implements the text unmarshaller method
|
||||
// UnmarshalText implements the text unmarshaller method.
|
||||
func (x *ResponseType) UnmarshalText(text []byte) error {
|
||||
name := string(text)
|
||||
tmp, err := ParseResponseType(name)
|
||||
|
|
Loading…
Reference in New Issue