updated dip
This commit is contained in:
parent
f77f3f95a9
commit
f595597fc0
@ -3,11 +3,11 @@ package main
|
||||
import (
|
||||
"flag"
|
||||
"fmt"
|
||||
"log"
|
||||
"net"
|
||||
"net/http"
|
||||
"os"
|
||||
"strings"
|
||||
"log"
|
||||
|
||||
"github.com/labstack/echo/v4"
|
||||
"github.com/likexian/whois-go"
|
||||
@ -39,10 +39,7 @@ func (ip *IP) GetIPInfo(c echo.Context) (err error) {
|
||||
func Dip(c echo.Context) (err error) {
|
||||
var ip IP
|
||||
|
||||
err = ip.GetIPInfo(c)
|
||||
if err != nil {
|
||||
return c.Render(http.StatusInternalServerError, "error.html", err)
|
||||
}
|
||||
ip.GetIPInfo(c)
|
||||
|
||||
if strings.Contains(c.Request().Header.Get(echo.HeaderAccept), echo.MIMETextHTML) {
|
||||
return c.Render(http.StatusOK, "index.html", ip)
|
||||
@ -70,7 +67,7 @@ func (ip *IP) CheckIPAddress() (err error) {
|
||||
func (ip *IP) GetHostname() (err error) {
|
||||
revip, err := net.LookupAddr(ip.IP)
|
||||
if err != nil {
|
||||
return fmt.Errorf(fmt.Sprintf("Supplied address \"%s\" doesn't have a valid reverse DNS entry", ip.IP))
|
||||
return err
|
||||
}
|
||||
ip.Hostname = revip[0]
|
||||
return
|
||||
|
@ -1,9 +1,9 @@
|
||||
<html>
|
||||
<head>
|
||||
<title>Public IP Address</title>
|
||||
{{ template "head.html" .}}
|
||||
</head>
|
||||
<body>
|
||||
<h1>Error</h1>
|
||||
<p>{{ . }} isn't a IP address</p>
|
||||
<p>{{ . }}</p>
|
||||
</body>
|
||||
</html>
|
||||
|
@ -1,5 +1,6 @@
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<link rel="stylesheet" href="css/uikit.min.css" />
|
||||
<script src="js/uikit.min.js"></script>
|
||||
<script src="js/uikit-icons.min.js"></script>
|
||||
<title>Public IP Address</title>
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<link rel="stylesheet" href="css/uikit.min.css" />
|
||||
<script src="js/uikit.min.js"></script>
|
||||
<script src="js/uikit-icons.min.js"></script>
|
@ -1,6 +1,5 @@
|
||||
<html>
|
||||
<head>
|
||||
<title>Public IP Address</title>
|
||||
{{ template "head.html" .}}
|
||||
</head>
|
||||
<body>
|
||||
|
Loading…
Reference in New Issue
Block a user