Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

net: should expand IP address 1.1 to 1.0.0.1 #36822

Open
jamieson99 opened this issue Jan 28, 2020 · 9 comments
Open

net: should expand IP address 1.1 to 1.0.0.1 #36822

jamieson99 opened this issue Jan 28, 2020 · 9 comments
Milestone

Comments

@jamieson99
Copy link

@jamieson99 jamieson99 commented Jan 28, 2020

nameserver 1.1 in /etc/resolv.conf not parsed

What did you do?

go get github.com/kevinburke/twilio-go

What did you see instead?

go get github.com/kevinburke/twilio-go: module github.com/kevinburke/twilio-go:
Get https://proxy.golang.org/github.com/kevinburke/twilio-go/@v/list:
dial tcp: lookup proxy.golang.org on [::1]:53: dial tcp [::1]:53:
connect: connection refused

Workaround

Change 1.1 to 1.0.0.1 or 1.1.1.1 in /etc/resolv.conf

# /etc/resolv.conf
nameserver 1.1
@davecheney
Copy link
Contributor

@davecheney davecheney commented Jan 28, 2020

Looking at http://man7.org/linux/man-pages/man5/resolv.conf.5.html, name server is defined to be an IPV4 or IPV6 address, nameserver 1.1 appears to be neither so I don't see how it could be used as a DNS server.

Why did you expect that Go would be able to use 1.1 as a nameserver?

@jamieson99
Copy link
Author

@jamieson99 jamieson99 commented Jan 28, 2020

1.1 should expand to 1.0.0.1

Examples:

Try putting nameserver 1.1 into resolv.conf and then ping something; your resolver should properly use that resolver.

Or, just ping 1.1 or traceroute 1.1, or ping 127.1. On Linux (but apparently not Mac), you can even ping 0 (which expands to 0.0.0.0)

CloudFlare's public nameservers are documented at: https://1.1/ (which should be a working link in your browser)

dig google.com @1.1
....
;; ANSWER SECTION:
google.com.     120 IN  A   172.217.6.142
....
;; SERVER: 1.0.0.1#53(1.0.0.1)

The expansion rules are covered here (part of POSIX / IEEE 1003.1).

http://man7.org/linux/man-pages/man3/inet_addr.3.html

#! /usr/bin/env python

import socket
print(socket.gethostbyname('1.1'))
# '1.0.0.1'

It appears that net does not properly expand and parse IPv4 in this format, so that might be the underlying cause here.

@ianlancetaylor
Copy link
Contributor

@ianlancetaylor ianlancetaylor commented Jan 28, 2020

This is part of POSIX (IEEE 1003.1).

Do you have a citation for that? I didn't think that IEEE 1003.1 talked about networking at all. Thanks.

@ianlancetaylor ianlancetaylor changed the title /etc/resolv.conf not interpreted properly net: should treat IP address 1.1 as 1.0.0.1 Jan 28, 2020
@ianlancetaylor ianlancetaylor added this to the Go1.15 milestone Jan 28, 2020
@jamieson99
Copy link
Author

@jamieson99 jamieson99 commented Jan 28, 2020

package main

import (
    "fmt"
    "net"
    "os"
)

func main() {
    ip := net.ParseIP("1.1")
    if ip.To4() == nil {
        fmt.Printf("IPv4 expansion is not working.")
        os.Exit(1)
    }
}
@rhedile
Copy link

@rhedile rhedile commented Jan 28, 2020

@ianlancetaylor
Copy link
Contributor

@ianlancetaylor ianlancetaylor commented Jan 28, 2020

Thanks for the pointer.

@davecheney
Copy link
Contributor

@davecheney davecheney commented Jan 28, 2020

Indeed, TIL!

@opennota
Copy link

@opennota opennota commented Jan 29, 2020

http://1089054054/

@davecheney
Copy link
Contributor

@davecheney davecheney commented Jan 29, 2020

Well, that's just about all the internet I can handle today. Good evening

@jamieson99 jamieson99 changed the title net: should treat IP address 1.1 as 1.0.0.1 net: should expand IP address 1.1 to 1.0.0.1 Jan 30, 2020
@odeke-em odeke-em modified the milestones: Go1.15, Go1.16 May 25, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
6 participants
You can’t perform that action at this time.