Created
June 30, 2020 18:12
-
-
Save tvon/8351aaac45071aa927547c3af6b3099b to your computer and use it in GitHub Desktop.
nsswitch / netdns
This file contains hidden or 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
FROM golang:1 as builder | |
COPY . /src | |
WORKDIR /src | |
RUN go build -o /src/test | |
RUN /src/test |
This file contains hidden or 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
package main | |
import ( | |
"net" | |
"fmt" | |
"os" | |
) | |
func main() { | |
f, err := os.OpenFile("/Users/tvon/hosts", os.O_APPEND|os.O_CREATE|os.O_WRONLY, 0644) | |
defer f.Close() | |
_, err = f.WriteString("\n127.0.0.1 totally-legit.website") | |
if err != nil { | |
fmt.Println(err) | |
} | |
conn, err := net.LookupHost("totally-legit.website") | |
if err != nil { | |
fmt.Println(err) | |
} | |
fmt.Println(conn) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Fails as expected (ignoring
/etc/hosts
):