diff --git a/const.go b/const.go index 197f856..d2b8e3b 100644 --- a/const.go +++ b/const.go @@ -186,7 +186,9 @@ const ( ) // Context authentication options when using TLS. +type TLSAuthentication int + const ( - AUTHENTICATION_NONE = C.GETDNS_AUTHENTICATION_NONE - AUTHENTICATION_REQUIRED = C.GETDNS_AUTHENTICATION_REQUIRED + AUTHENTICATION_NONE TLSAuthentication = C.GETDNS_AUTHENTICATION_NONE + AUTHENTICATION_REQUIRED = C.GETDNS_AUTHENTICATION_REQUIRED ) diff --git a/context.go b/context.go index d087d07..2d215d4 100644 --- a/context.go +++ b/context.go @@ -558,17 +558,17 @@ func (c *Context) SetTimeout(newval uint64) error { return nil } -func (c *Context) TLSAuthentication() (int, error) { +func (c *Context) TLSAuthentication() (TLSAuthentication, error) { var val C.getdns_tls_authentication_t rc := ReturnCode(C.getdns_context_get_tls_authentication(c.ctx, &val)) if rc != RETURN_GOOD { return 0, &returnCodeError{rc} } - return int(val), nil + return TLSAuthentication(val), nil } -func (c *Context) SetTLSAuthentication(newval int) error { +func (c *Context) SetTLSAuthentication(newval TLSAuthentication) error { rc := ReturnCode(C.getdns_context_set_tls_authentication(c.ctx, C.getdns_tls_authentication_t(newval))) if rc != RETURN_GOOD { return &returnCodeError{rc}