mirror of https://github.com/mpolden/echoip
Include both IPv4 and IPv6 links
This commit is contained in:
parent
2b340fc2ec
commit
4cfccfdcaf
|
@ -141,19 +141,12 @@ func (a *API) DefaultHandler(w http.ResponseWriter, r *http.Request) *appError {
|
||||||
return internalServerError(err)
|
return internalServerError(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
IsV6 := true
|
|
||||||
ip := net.ParseIP(r.Header.Get(IP_HEADER))
|
|
||||||
if ip.To4() != nil {
|
|
||||||
IsV6 = false
|
|
||||||
}
|
|
||||||
|
|
||||||
var data = struct {
|
var data = struct {
|
||||||
IP string
|
IP string
|
||||||
IsV6 bool
|
|
||||||
JSON string
|
JSON string
|
||||||
Header http.Header
|
Header http.Header
|
||||||
Cmd
|
Cmd
|
||||||
}{ip.String(), IsV6, string(b), r.Header, cmd}
|
}{r.Header.Get(IP_HEADER), string(b), r.Header, cmd}
|
||||||
|
|
||||||
if err := t.Execute(w, &data); err != nil {
|
if err := t.Execute(w, &data); err != nil {
|
||||||
return internalServerError(err)
|
return internalServerError(err)
|
||||||
|
|
|
@ -28,6 +28,9 @@
|
||||||
margin-top: 10px;
|
margin-top: 10px;
|
||||||
text-align: center;
|
text-align: center;
|
||||||
}
|
}
|
||||||
|
#footer a {
|
||||||
|
margin: 0 10px;
|
||||||
|
}
|
||||||
.ip {
|
.ip {
|
||||||
border: 1px solid #cbcbcb;
|
border: 1px solid #cbcbcb;
|
||||||
background: #f2f2f2;
|
background: #f2f2f2;
|
||||||
|
@ -71,9 +74,8 @@
|
||||||
</table>
|
</table>
|
||||||
</div>
|
</div>
|
||||||
<div id="footer">
|
<div id="footer">
|
||||||
{{ if .IsV6 }}
|
|
||||||
<a href="http://v4.ifconfig.co">IPv4 page</a>
|
<a href="http://v4.ifconfig.co">IPv4 page</a>
|
||||||
{{end}}
|
<a href="http://v6.ifconfig.co">IPv6 page</a>
|
||||||
</div>
|
</div>
|
||||||
<a href="https://github.com/martinp/ifconfigd"><img style="position: absolute; top: 0; right: 0; border: 0;" src="https://s3.amazonaws.com/github/ribbons/forkme_right_red_aa0000.png" alt="Fork me on GitHub"></a>
|
<a href="https://github.com/martinp/ifconfigd"><img style="position: absolute; top: 0; right: 0; border: 0;" src="https://s3.amazonaws.com/github/ribbons/forkme_right_red_aa0000.png" alt="Fork me on GitHub"></a>
|
||||||
</body>
|
</body>
|
||||||
|
|
Loading…
Reference in New Issue