Skip to content

Commit

Permalink
Allow unverified SSL connection
Browse files Browse the repository at this point in the history
  • Loading branch information
nickw444 committed Apr 8, 2018
1 parent 04e4db9 commit 0b9f4d0
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 9 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ Cloudflare DynDNS Updater
Flags:
--help Show context-sensitive help (also try --help-long and --help-man).
--ip-address=IP-ADDRESS Skip resolving external IP and use provided IP
--no-verify Don't verify ssl certificates
--cf-email=CF-EMAIL Cloudflare Email
--cf-api-key=CF-API-KEY Cloudflare API key
--cf-zone-id=CF-ZONE-ID Cloudflare Zone ID
Expand Down
10 changes: 2 additions & 8 deletions ip.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,21 +23,15 @@ func (f *FakeIPService) GetExternalIP() (net.IP, error) {
}

type IpifyIPService struct {
httpClient *http.Client
}

func NewIpifyIPService() *IpifyIPService {
return &IpifyIPService{
httpClient: &http.Client{},
}
HttpClient *http.Client
}

type IpifyAPIResponse struct {
IP string
}

func (i *IpifyIPService) GetExternalIP() (net.IP, error) {
r, err := i.httpClient.Get("https://api.ipify.org?format=json")
r, err := i.HttpClient.Get("https://api.ipify.org?format=json")
if err != nil {
return nil, err
}
Expand Down
10 changes: 9 additions & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ import (

"github.com/Sirupsen/logrus"
"gopkg.in/alecthomas/kingpin.v2"
"net/http"
"crypto/tls"
)

var log = logrus.New()
Expand All @@ -15,6 +17,7 @@ func main() {
app = kingpin.New("cf-ddns", "Cloudflare DynDNS Updater")

ipAddress = app.Flag("ip-address", "Skip resolving external IP and use provided IP").String()
noVerify = app.Flag("no-verify", "Don't verify ssl certificates").Bool()

cfEmail = app.Flag("cf-email", "Cloudflare Email").Required().String()
cfApiKey = app.Flag("cf-api-key", "Cloudflare API key").Required().String()
Expand All @@ -33,7 +36,12 @@ func main() {
fakeIp: net.ParseIP(*ipAddress),
}
} else {
ip = NewIpifyIPService()
httpClient := &http.Client{
Transport: &http.Transport{
TLSClientConfig: &tls.Config{InsecureSkipVerify: *noVerify},
},
}
ip = &IpifyIPService{HttpClient: httpClient}
}

if dns, err = NewCFDNSUpdater(*cfZoneId, *cfApiKey, *cfEmail, log.WithField("component", "cf-dns-updater")); err != nil {
Expand Down

0 comments on commit 0b9f4d0

Please sign in to comment.