-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
15 changed files
with
399 additions
and
111 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
package iptec | ||
|
||
import "github.com/aredoff/iptec/dnslient" | ||
|
||
type dnsclientMixinInterface interface { | ||
dnsclientInitialization() | ||
} | ||
|
||
type DnsClient struct { | ||
Dns *dnslient.Dns | ||
} | ||
|
||
func (m *DnsClient) dnsclientInitialization() { | ||
m.Dns = dnslient.New() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
package dnslient | ||
|
||
import ( | ||
"context" | ||
"net" | ||
"time" | ||
) | ||
|
||
func New() *Dns { | ||
return &Dns{ | ||
timeout: 4 * time.Second, | ||
} | ||
} | ||
|
||
type Dns struct { | ||
client net.Resolver | ||
timeout time.Duration | ||
} | ||
|
||
func (c *Dns) A(host string) (records []string, err error) { | ||
ctx, cancel := context.WithTimeout(context.Background(), c.timeout) | ||
defer cancel() | ||
records, err = c.client.LookupHost(ctx, host) | ||
return | ||
} | ||
|
||
func (c *Dns) TXT(host string) (records []string, err error) { | ||
ctx, cancel := context.WithTimeout(context.Background(), c.timeout) | ||
defer cancel() | ||
records, err = c.client.LookupTXT(ctx, host) | ||
return | ||
} | ||
|
||
func (c *Dns) CNAME(host string) (records string, err error) { | ||
ctx, cancel := context.WithTimeout(context.Background(), c.timeout) | ||
defer cancel() | ||
records, err = c.client.LookupCNAME(ctx, host) | ||
return | ||
} | ||
|
||
func (c *Dns) MX(host string) ([]string, error) { | ||
ctx, cancel := context.WithTimeout(context.Background(), c.timeout) | ||
defer cancel() | ||
mxs, err := c.client.LookupMX(ctx, host) | ||
if err != nil { | ||
return nil, err | ||
} | ||
records := make([]string, 0, len(mxs)) | ||
for _, v := range mxs { | ||
records = append(records, v.Host) | ||
} | ||
return records, nil | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.