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