Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
D
dyndnsd-client
Manage
Activity
Members
Labels
Plan
Issues
1
Issue boards
Milestones
Iterations
Requirements
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
open-source
dyndnsd-client
Commits
7a79b514
Commit
7a79b514
authored
7 years ago
by
Erick Hitter
Browse files
Options
Downloads
Patches
Plain Diff
Ensure IPs are valid
parent
553a60f0
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
dyndnsd-client.go
+20
-6
20 additions, 6 deletions
dyndnsd-client.go
with
20 additions
and
6 deletions
dyndnsd-client.go
+
20
−
6
View file @
7a79b514
...
...
@@ -6,6 +6,7 @@ import (
"github.com/joshbetz/config"
"io/ioutil"
"log"
"net"
"net/http"
"net/url"
"os"
...
...
@@ -55,9 +56,15 @@ func main() {
// IPv4 is required
if
ipv4
,
err
:=
getUrl
(
ipv4Endpoint
);
err
==
nil
{
query
:=
endpoint
.
Query
()
query
.
Set
(
"myip"
,
ipv4
)
endpoint
.
RawQuery
=
query
.
Encode
()
if
ipv4Valid
:=
net
.
ParseIP
(
ipv4
);
ipv4Valid
==
nil
{
logger
.
Println
(
"Invalid IPv4 address"
)
logger
.
Printf
(
"%s"
,
err
)
return
}
else
{
query
:=
endpoint
.
Query
()
query
.
Set
(
"myip"
,
ipv4Valid
.
String
())
endpoint
.
RawQuery
=
query
.
Encode
()
}
}
else
{
logger
.
Println
(
"Couldn't retrieve IPv4 address"
)
logger
.
Printf
(
"%s"
,
err
)
...
...
@@ -66,9 +73,16 @@ func main() {
// IPv6 is optional
if
ipv6
,
err
:=
getUrl
(
ipv6Endpoint
);
err
==
nil
{
query
:=
endpoint
.
Query
()
query
.
Set
(
"myip6"
,
ipv6
)
endpoint
.
RawQuery
=
query
.
Encode
()
if
ipv6Valid
:=
net
.
ParseIP
(
ipv6
);
ipv6Valid
==
nil
{
logger
.
Println
(
"Invalid IPv6 address"
)
logger
.
Printf
(
"%s"
,
err
)
}
else
{
// TODO: parse to /64, use ::1.
query
:=
endpoint
.
Query
()
query
.
Set
(
"myip6"
,
ipv6
)
endpoint
.
RawQuery
=
query
.
Encode
()
}
}
else
{
logger
.
Println
(
"Couldn't retrieve IPv6 address"
)
logger
.
Printf
(
"%s"
,
err
)
...
...
This diff is collapsed.
Click to expand it.
Erick Hitter
@ethitter
mentioned in issue
#3 (closed)
·
7 years ago
mentioned in issue
#3 (closed)
mentioned in issue #3
Toggle commit list
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment