Skip to content

Commit

Permalink
Add type for TLS authentications.
Browse files Browse the repository at this point in the history
  • Loading branch information
Jim Hague committed Jul 22, 2016
1 parent daf125a commit 99a402e
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
6 changes: 4 additions & 2 deletions const.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
)
6 changes: 3 additions & 3 deletions context.go
Original file line number Diff line number Diff line change
Expand Up @@ -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}
Expand Down

0 comments on commit 99a402e

Please sign in to comment.