first commit
This commit is contained in:
commit
e627916c15
5 files changed
+1034
No files matched your search
@@ -0,0 +1 @@
|
||||
iplookup
|
||||
@@ -0,0 +1,13 @@
|
||||
module iplookup
|
||||
|
||||
go 1.23.0
|
||||
|
||||
require (
|
||||
github.com/oschwald/geoip2-golang v1.11.0
|
||||
golang.org/x/exp v0.0.0-20240823005443-9b4947da3948
|
||||
)
|
||||
|
||||
require (
|
||||
github.com/oschwald/maxminddb-golang v1.13.0 // indirect
|
||||
golang.org/x/sys v0.20.0 // indirect
|
||||
)
|
||||
@@ -0,0 +1,16 @@
|
||||
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
|
||||
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||
github.com/oschwald/geoip2-golang v1.11.0 h1:hNENhCn1Uyzhf9PTmquXENiWS6AlxAEnBII6r8krA3w=
|
||||
github.com/oschwald/geoip2-golang v1.11.0/go.mod h1:P9zG+54KPEFOliZ29i7SeYZ/GM6tfEL+rgSn03hYuUo=
|
||||
github.com/oschwald/maxminddb-golang v1.13.0 h1:R8xBorY71s84yO06NgTmQvqvTvlS/bnYZrrWX1MElnU=
|
||||
github.com/oschwald/maxminddb-golang v1.13.0/go.mod h1:BU0z8BfFVhi1LQaonTwwGQlsHUEu9pWNdMfmq4ztm0o=
|
||||
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
|
||||
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
|
||||
github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg=
|
||||
github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
|
||||
golang.org/x/exp v0.0.0-20240823005443-9b4947da3948 h1:kx6Ds3MlpiUHKj7syVnbp57++8WpuKPcR5yjLBjvLEA=
|
||||
golang.org/x/exp v0.0.0-20240823005443-9b4947da3948/go.mod h1:akd2r19cwCdwSwWeIdzYQGa/EZZyqcOdwWiwj5L5eKQ=
|
||||
golang.org/x/sys v0.20.0 h1:Od9JTbYCk261bKm4M/mw7AklTlFYIa0bIp9BgSm1S8Y=
|
||||
golang.org/x/sys v0.20.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
|
||||
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
|
||||
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
||||
+513
@@ -0,0 +1,513 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"crypto/tls"
|
||||
"flag"
|
||||
"fmt"
|
||||
"html/template"
|
||||
"net"
|
||||
"net/http"
|
||||
"reflect"
|
||||
"strings"
|
||||
|
||||
"github.com/oschwald/geoip2-golang"
|
||||
"golang.org/x/exp/rand"
|
||||
)
|
||||
|
||||
var (
|
||||
port = flag.Int("p", 8080, "Port to listen on")
|
||||
name = flag.String("n", "iplookup.fr", "Name of the application")
|
||||
geocity = flag.String("c", "", "Path to the GeoIP database")
|
||||
geoasn = flag.String("a", "", "Path to the GeoASN database")
|
||||
verbose = flag.Bool("v", false, "Enable verbose logging")
|
||||
|
||||
cli = []string{
|
||||
"curl",
|
||||
"HTTPie",
|
||||
"httpie-go",
|
||||
"Wget",
|
||||
"fetch libfetch",
|
||||
"Go",
|
||||
"Go-http-client",
|
||||
"ddclient",
|
||||
"Mikrotik",
|
||||
"xh",
|
||||
}
|
||||
colors = []string{
|
||||
"#2488bf",
|
||||
"#d84d3d",
|
||||
"#f39700",
|
||||
"#4caf50",
|
||||
}
|
||||
)
|
||||
|
||||
type Ssl struct {
|
||||
San []string
|
||||
Ocsp []string
|
||||
Subject string
|
||||
Issuer string
|
||||
Alpn string
|
||||
Not_before string
|
||||
Not_after string
|
||||
}
|
||||
|
||||
type Geo struct {
|
||||
Country string
|
||||
Ccode string
|
||||
City string
|
||||
Latitude float64
|
||||
Longitude float64
|
||||
Postal string
|
||||
Timezone string
|
||||
}
|
||||
|
||||
type Asn struct {
|
||||
Asn uint
|
||||
Org string
|
||||
}
|
||||
|
||||
type Info struct {
|
||||
Ip string
|
||||
Hostname string
|
||||
Domain bool
|
||||
Port string
|
||||
User_agent string
|
||||
Mime_type string
|
||||
Language string
|
||||
Content_type string
|
||||
Encoding string
|
||||
Method string
|
||||
Cache_control string
|
||||
Referer string
|
||||
X_forwarded_for string
|
||||
X_forwarded_proto string
|
||||
Geo Geo
|
||||
Asn Asn
|
||||
Ssl Ssl
|
||||
}
|
||||
|
||||
type Tmpl struct {
|
||||
Hostname string
|
||||
Color string
|
||||
Title string
|
||||
Info Info
|
||||
}
|
||||
|
||||
func getElem(info Info, elem string) string {
|
||||
elem = strings.ToLower(elem)
|
||||
elem = strings.ReplaceAll(elem, "-", "_")
|
||||
switch elem {
|
||||
case "hostname":
|
||||
return info.Hostname
|
||||
case "host":
|
||||
return info.Hostname
|
||||
case "ip":
|
||||
return info.Ip
|
||||
case "port":
|
||||
return info.Port
|
||||
case "user_agent":
|
||||
return info.User_agent
|
||||
case "ua":
|
||||
return info.User_agent
|
||||
case "useragent":
|
||||
return info.User_agent
|
||||
case "mime_type":
|
||||
return info.Mime_type
|
||||
case "language":
|
||||
return info.Language
|
||||
case "content_type":
|
||||
return info.Content_type
|
||||
case "encoding":
|
||||
return info.Encoding
|
||||
case "method":
|
||||
return info.Method
|
||||
case "cache_control":
|
||||
return info.Cache_control
|
||||
case "referer":
|
||||
return info.Referer
|
||||
case "x_forwarded_for":
|
||||
return info.X_forwarded_for
|
||||
case "x_forwarded_proto":
|
||||
return info.X_forwarded_proto
|
||||
case "country":
|
||||
return info.Geo.Country
|
||||
case "ccode":
|
||||
return info.Geo.Ccode
|
||||
case "cc":
|
||||
return info.Geo.Ccode
|
||||
case "city":
|
||||
return info.Geo.City
|
||||
case "latitude":
|
||||
return fmt.Sprintf("%f", info.Geo.Latitude)
|
||||
case "longitude":
|
||||
return fmt.Sprintf("%f", info.Geo.Longitude)
|
||||
case "postal":
|
||||
return info.Geo.Postal
|
||||
case "timezone":
|
||||
return info.Geo.Timezone
|
||||
case "asn":
|
||||
return fmt.Sprintf("%d", info.Asn.Asn)
|
||||
case "org":
|
||||
return info.Asn.Org
|
||||
case "organisation":
|
||||
return info.Asn.Org
|
||||
case "ssl_san":
|
||||
return strings.Join(info.Ssl.San, ", ")
|
||||
case "ssl_ocsp":
|
||||
return strings.Join(info.Ssl.Ocsp, ", ")
|
||||
case "ssl_subject":
|
||||
return info.Ssl.Subject
|
||||
case "ssl_issuer":
|
||||
return info.Ssl.Issuer
|
||||
case "ssl_alpn":
|
||||
return info.Ssl.Alpn
|
||||
case "ssl_not_after":
|
||||
return info.Ssl.Not_after
|
||||
case "ssl_not_before":
|
||||
return info.Ssl.Not_before
|
||||
case "san":
|
||||
return strings.Join(info.Ssl.San, ", ")
|
||||
case "ocsp":
|
||||
return strings.Join(info.Ssl.Ocsp, ", ")
|
||||
case "subject":
|
||||
return info.Ssl.Subject
|
||||
case "issuer":
|
||||
return info.Ssl.Issuer
|
||||
case "alpn":
|
||||
return info.Ssl.Alpn
|
||||
case "not_after":
|
||||
return info.Ssl.Not_after
|
||||
case "not_before":
|
||||
return info.Ssl.Not_before
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func writeSsl(w http.ResponseWriter, ssl Ssl) {
|
||||
if ssl.San == nil {
|
||||
return
|
||||
}
|
||||
v := reflect.ValueOf(ssl)
|
||||
t := reflect.TypeOf(ssl)
|
||||
for i := 0; i < t.NumField(); i++ {
|
||||
if v.Field(i).Interface() != "" {
|
||||
fmt.Fprintf(w, "%s: %v\n", strings.ToLower(t.Field(i).Name), v.Field(i).Interface())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func writeAsn(w http.ResponseWriter, asn Asn) {
|
||||
if asn.Asn == 0 {
|
||||
return
|
||||
}
|
||||
v := reflect.ValueOf(asn)
|
||||
t := reflect.TypeOf(asn)
|
||||
for i := 0; i < t.NumField(); i++ {
|
||||
if v.Field(i).Interface() != "" {
|
||||
fmt.Fprintf(w, "%s: %v\n", strings.ToLower(t.Field(i).Name), v.Field(i).Interface())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func writeGeo(w http.ResponseWriter, geo Geo) {
|
||||
if geo.Country == "" {
|
||||
return
|
||||
}
|
||||
v := reflect.ValueOf(geo)
|
||||
t := reflect.TypeOf(geo)
|
||||
for i := 0; i < t.NumField(); i++ {
|
||||
if v.Field(i).Interface() != "" {
|
||||
fmt.Fprintf(w, "%s: %v\n", strings.ToLower(t.Field(i).Name), v.Field(i).Interface())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func writeInfo(w http.ResponseWriter, info Info) {
|
||||
w.WriteHeader(http.StatusOK)
|
||||
v := reflect.ValueOf(info)
|
||||
t := reflect.TypeOf(info)
|
||||
for i := 0; i < t.NumField(); i++ {
|
||||
if t.Field(i).Name == "Geo" {
|
||||
writeGeo(w, v.Field(i).Interface().(Geo))
|
||||
} else if t.Field(i).Name == "Asn" {
|
||||
writeAsn(w, v.Field(i).Interface().(Asn))
|
||||
} else if t.Field(i).Name == "Ssl" {
|
||||
writeSsl(w, v.Field(i).Interface().(Ssl))
|
||||
} else if v.Field(i).Interface() != "" {
|
||||
fmt.Fprintf(w, "%s: %v\n", strings.ToLower(t.Field(i).Name), v.Field(i).Interface())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func reqtype(ip string) string {
|
||||
if net.ParseIP(ip) != nil {
|
||||
return "ip"
|
||||
}
|
||||
for i := 0; i < len(ip); i++ {
|
||||
if ip[i] == ':' {
|
||||
return "ip"
|
||||
}
|
||||
if ip[i] < '0' || ip[i] > '9' {
|
||||
if strings.Contains(ip, ".") {
|
||||
return "domain"
|
||||
} else {
|
||||
return "info"
|
||||
}
|
||||
}
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func getSslInfo(domain string, info Info) (Info, error) {
|
||||
lookup, err := net.LookupIP(domain)
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
return info, err
|
||||
}
|
||||
info.Ip = lookup[0].String()
|
||||
|
||||
ssl := Ssl{}
|
||||
conn, err := tls.Dial("tcp", domain+":443", &tls.Config{InsecureSkipVerify: true})
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
return info, err
|
||||
}
|
||||
defer conn.Close()
|
||||
|
||||
ssl.San = conn.ConnectionState().PeerCertificates[0].DNSNames
|
||||
ssl.Subject = conn.ConnectionState().PeerCertificates[0].Subject.String()
|
||||
ssl.Issuer = conn.ConnectionState().PeerCertificates[0].Issuer.String()
|
||||
ssl.Alpn = conn.ConnectionState().NegotiatedProtocol
|
||||
ssl.Ocsp = conn.ConnectionState().PeerCertificates[0].OCSPServer
|
||||
ssl.Not_after = conn.ConnectionState().PeerCertificates[0].NotAfter.String()
|
||||
ssl.Not_before = conn.ConnectionState().PeerCertificates[0].NotBefore.String()
|
||||
info.Ssl = ssl
|
||||
return info, err
|
||||
}
|
||||
|
||||
func getAsn(ip string) Asn {
|
||||
asn := Asn{}
|
||||
ipdb, err := geoip2.Open(*geoasn)
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
return Asn{}
|
||||
}
|
||||
defer ipdb.Close()
|
||||
|
||||
record, err := ipdb.ASN(net.ParseIP(ip))
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
return Asn{}
|
||||
}
|
||||
|
||||
asn.Asn = record.AutonomousSystemNumber
|
||||
asn.Org = record.AutonomousSystemOrganization
|
||||
return asn
|
||||
}
|
||||
|
||||
func getGeo(ip string) Geo {
|
||||
geo := Geo{}
|
||||
ipdb, err := geoip2.Open(*geocity)
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
return Geo{}
|
||||
}
|
||||
defer ipdb.Close()
|
||||
|
||||
record, err := ipdb.City(net.ParseIP(ip))
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
return Geo{}
|
||||
}
|
||||
|
||||
geo.City = record.City.Names["en"]
|
||||
geo.Latitude, geo.Longitude = record.Location.Latitude, record.Location.Longitude
|
||||
geo.Country = record.Country.Names["en"]
|
||||
geo.Ccode = record.Country.IsoCode
|
||||
geo.Postal = record.Postal.Code
|
||||
geo.Timezone = record.Location.TimeZone
|
||||
|
||||
return geo
|
||||
}
|
||||
|
||||
func getIP(info Info, r *http.Request) (Info, error) {
|
||||
var err error
|
||||
if r.Header.Get("X-Forwarded-For") != "" {
|
||||
info.Ip = r.Header.Get("X-Forwarded-For")
|
||||
} else if r.Header.Get("X-Real-IP") != "" {
|
||||
info.Ip = r.Header.Get("X-Real-IP")
|
||||
} else if r.Header.Get("X-Client-IP") != "" {
|
||||
info.Ip = r.Header.Get("X-Client-IP")
|
||||
} else if r.Header.Get("CF-Connecting-IP") != "" {
|
||||
info.Ip = r.Header.Get("CF-Connecting-IP")
|
||||
} else {
|
||||
info.Ip = "82.65.180.141"
|
||||
info.Port = "424242"
|
||||
//info.Ip, info.Port, err = net.SplitHostPort(r.RemoteAddr)
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
return info, err
|
||||
}
|
||||
}
|
||||
return info, nil
|
||||
}
|
||||
|
||||
func getIpInfo(info Info, r *http.Request) (Info, error) {
|
||||
hosts, err := net.LookupAddr(info.Ip)
|
||||
if err != nil {
|
||||
hosts = []string{info.Ip}
|
||||
}
|
||||
info.Hostname = hosts[0]
|
||||
if !info.Domain {
|
||||
info.User_agent = r.UserAgent()
|
||||
info.Mime_type = r.Header.Get("Accept")
|
||||
info.Language = r.Header.Get("Accept-Language")
|
||||
info.Content_type = r.Header.Get("Content-Type")
|
||||
info.Encoding = r.Header.Get("Accept-Encoding")
|
||||
info.Method = r.Method
|
||||
info.Cache_control = r.Header.Get("Cache-Control")
|
||||
info.Referer = r.Header.Get("Referer")
|
||||
info.X_forwarded_for = r.Header.Get("X-Forwarded-For")
|
||||
info.X_forwarded_proto = r.Header.Get("X-Forwarded-Proto")
|
||||
}
|
||||
if *geocity != "" {
|
||||
info.Geo = getGeo(info.Ip)
|
||||
}
|
||||
if *geoasn != "" {
|
||||
info.Asn = getAsn(info.Ip)
|
||||
}
|
||||
return info, nil
|
||||
}
|
||||
|
||||
func handler(w http.ResponseWriter, r *http.Request) {
|
||||
info := Info{}
|
||||
isCli := false
|
||||
var err error
|
||||
|
||||
if *verbose {
|
||||
fmt.Println("Request:", r)
|
||||
}
|
||||
|
||||
if r.URL.Path == "/favicon.ico" {
|
||||
http.Error(w, "Not found", http.StatusNotFound)
|
||||
return
|
||||
}
|
||||
|
||||
if r.Method != "GET" {
|
||||
http.Error(w, "Method not allowed", http.StatusMethodNotAllowed)
|
||||
return
|
||||
}
|
||||
|
||||
for i := 0; i < len(cli); i++ {
|
||||
if strings.Contains(r.UserAgent(), cli[i]) {
|
||||
isCli = true
|
||||
}
|
||||
}
|
||||
|
||||
if r.URL.Path == "/" {
|
||||
info, err = getIP(info, r)
|
||||
if err != nil {
|
||||
http.Error(w, err.Error(), http.StatusInternalServerError)
|
||||
fmt.Println(err)
|
||||
return
|
||||
}
|
||||
if isCli {
|
||||
w.WriteHeader(http.StatusOK)
|
||||
w.Write([]byte(info.Ip + "\n"))
|
||||
return
|
||||
}
|
||||
info, err = getIpInfo(info, r)
|
||||
if err != nil {
|
||||
http.Error(w, err.Error(), http.StatusInternalServerError)
|
||||
fmt.Println(err)
|
||||
}
|
||||
}
|
||||
|
||||
args := strings.Split(r.URL.Path, "/")
|
||||
if len(args) > 1 && args[1] != "" {
|
||||
rtype := reqtype(args[1])
|
||||
if rtype == "" {
|
||||
http.Error(w, "Not found", http.StatusNotFound)
|
||||
return
|
||||
}
|
||||
if rtype == "domain" {
|
||||
info.Domain = true
|
||||
domain := args[1]
|
||||
info, err = getSslInfo(domain, info)
|
||||
if err != nil {
|
||||
http.Error(w, err.Error(), http.StatusInternalServerError)
|
||||
fmt.Println(err)
|
||||
return
|
||||
}
|
||||
} else {
|
||||
info, err = getIP(info, r)
|
||||
if err != nil {
|
||||
http.Error(w, err.Error(), http.StatusInternalServerError)
|
||||
fmt.Println(err)
|
||||
return
|
||||
}
|
||||
}
|
||||
info, err = getIpInfo(info, r)
|
||||
if err != nil {
|
||||
http.Error(w, err.Error(), http.StatusInternalServerError)
|
||||
fmt.Println(err)
|
||||
return
|
||||
}
|
||||
|
||||
if rtype == "info" || (len(args) > 2 && args[2] != "") {
|
||||
if args[len(args)-1] == "all" {
|
||||
writeInfo(w, info)
|
||||
return
|
||||
}
|
||||
if args[len(args)-1] == "geo" {
|
||||
writeGeo(w, info.Geo)
|
||||
return
|
||||
}
|
||||
if args[len(args)-1] == "asn" {
|
||||
writeAsn(w, info.Asn)
|
||||
return
|
||||
}
|
||||
if args[len(args)-1] == "ssl" {
|
||||
writeSsl(w, info.Ssl)
|
||||
return
|
||||
}
|
||||
res := getElem(info, args[len(args)-1])
|
||||
if res == "" {
|
||||
http.Error(w, "Not found", http.StatusNotFound)
|
||||
return
|
||||
}
|
||||
w.WriteHeader(http.StatusOK)
|
||||
fmt.Fprintf(w, "%s\n", res)
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
if isCli {
|
||||
writeInfo(w, info)
|
||||
return
|
||||
}
|
||||
|
||||
tmpl := Tmpl{
|
||||
Title: *name,
|
||||
Color: colors[rand.Intn(len(colors))],
|
||||
Hostname: r.Host,
|
||||
Info: info,
|
||||
}
|
||||
t, err := template.ParseFiles("template.html")
|
||||
if err != nil {
|
||||
http.Error(w, err.Error(), http.StatusInternalServerError)
|
||||
fmt.Println(err)
|
||||
}
|
||||
err = t.Execute(w, tmpl)
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
func main() {
|
||||
flag.Parse()
|
||||
fmt.Println("Listening on port", *port)
|
||||
http.HandleFunc("/", handler)
|
||||
http.ListenAndServe(fmt.Sprintf(":%d", *port), nil)
|
||||
}
|
||||
+491
@@ -0,0 +1,491 @@
|
||||
<!doctype html>
|
||||
|
||||
<head>
|
||||
<style>
|
||||
body {
|
||||
margin: 0;
|
||||
padding-bottom: 40px
|
||||
}
|
||||
|
||||
footer,
|
||||
header,
|
||||
main,
|
||||
nav {
|
||||
display: block
|
||||
}
|
||||
|
||||
@media print {
|
||||
* {
|
||||
color: #000 !important;
|
||||
text-shadow: none !important;
|
||||
background: 0 0 !important;
|
||||
-webkit-box-shadow: none !important;
|
||||
box-shadow: none !important
|
||||
}
|
||||
|
||||
a,
|
||||
a:visited {
|
||||
text-decoration: underline
|
||||
}
|
||||
|
||||
a[href]:after {
|
||||
content: " (" attr(href) ")"
|
||||
}
|
||||
|
||||
p {
|
||||
orphans: 3;
|
||||
widows: 3
|
||||
}
|
||||
}
|
||||
|
||||
* {
|
||||
-webkit-box-sizing: border-box;
|
||||
-moz-box-sizing: border-box;
|
||||
box-sizing: border-box
|
||||
}
|
||||
|
||||
:after,
|
||||
:before {
|
||||
-webkit-box-sizing: border-box;
|
||||
-moz-box-sizing: border-box;
|
||||
box-sizing: border-box
|
||||
}
|
||||
|
||||
body {
|
||||
font-family: monospace;
|
||||
font-size: 1em;
|
||||
line-height: 1.6;
|
||||
color: #a5a5a5;
|
||||
background-color: #121212
|
||||
}
|
||||
|
||||
a {
|
||||
text-decoration: none;
|
||||
color: #fff
|
||||
}
|
||||
|
||||
h1,
|
||||
h4 {
|
||||
font-weight: 500;
|
||||
line-height: 1.1;
|
||||
color: #fff;
|
||||
font-family: monospace
|
||||
}
|
||||
|
||||
h1 {
|
||||
margin-top: 20px;
|
||||
margin-bottom: 20px;
|
||||
font-size: 2em
|
||||
}
|
||||
|
||||
h4 {
|
||||
margin-top: 15px;
|
||||
margin-bottom: 10px;
|
||||
padding-left: 15px;
|
||||
font-size: 18px
|
||||
}
|
||||
|
||||
p {
|
||||
margin: 0 0 10px
|
||||
}
|
||||
|
||||
.text-center {
|
||||
text-align: center
|
||||
}
|
||||
|
||||
ul {
|
||||
margin-top: 0;
|
||||
margin-bottom: 10px
|
||||
}
|
||||
|
||||
.container {
|
||||
padding-right: 15px;
|
||||
padding-left: 15px;
|
||||
margin-right: auto;
|
||||
margin-left: auto
|
||||
}
|
||||
|
||||
@media (min-width:768px) {
|
||||
.container {
|
||||
width: 750px
|
||||
}
|
||||
}
|
||||
|
||||
@media (min-width:992px) {
|
||||
.container {
|
||||
width: 970px
|
||||
}
|
||||
}
|
||||
|
||||
@media (min-width:1200px) {
|
||||
.container {
|
||||
width: 1170px
|
||||
}
|
||||
}
|
||||
|
||||
.col-sm-3,
|
||||
.col-sm-4,
|
||||
.col-sm-5,
|
||||
.col-sm-8,
|
||||
.col-sm-9 {
|
||||
position: relative;
|
||||
min-height: 1px;
|
||||
padding-right: 15px;
|
||||
padding-left: 15px
|
||||
}
|
||||
|
||||
@media (min-width:768px) {
|
||||
|
||||
.col-sm-3,
|
||||
.col-sm-4,
|
||||
.col-sm-5,
|
||||
.col-sm-8,
|
||||
.col-sm-9 {
|
||||
float: left
|
||||
}
|
||||
|
||||
.col-sm-9 {
|
||||
width: 75%
|
||||
}
|
||||
|
||||
.col-sm-8 {
|
||||
width: 60%
|
||||
}
|
||||
|
||||
.col-sm-5 {
|
||||
width: 50%
|
||||
}
|
||||
|
||||
.col-sm-4 {
|
||||
width: 40%
|
||||
}
|
||||
|
||||
.col-sm-3 {
|
||||
width: 25%
|
||||
}
|
||||
}
|
||||
|
||||
.list-group {
|
||||
padding-left: 0;
|
||||
padding-bottom: 15px
|
||||
}
|
||||
|
||||
.list-group-item {
|
||||
position: relative;
|
||||
display: block;
|
||||
padding: 10px 15px;
|
||||
margin-bottom: -1px;
|
||||
background-color: #1e1e1e
|
||||
}
|
||||
|
||||
.panel {
|
||||
margin-bottom: 20px;
|
||||
background-color: #1e1e1e;
|
||||
border-radius: 4px;
|
||||
border-top:2px solid {{.Color}};
|
||||
box-shadow:0 3px 6px rgba(0, 0, 0, .16),
|
||||
0 3px 6px rgba(0, 0, 0, .23);
|
||||
-webkit-box-shadow:0 3px 6px rgba(0, 0, 0, .16),
|
||||
0 3px 6px rgba(0, 0, 0, .23)
|
||||
}
|
||||
|
||||
.panel-heading {
|
||||
padding: 10px 15px;
|
||||
border-top:2px solid {{.Color}};
|
||||
box-shadow:0 3px 6px rgba(0, 0, 0, .16),
|
||||
0 3px 6px rgba(0, 0, 0, .23);
|
||||
-webkit-box-shadow:0 3px 6px rgba(0, 0, 0, .16),
|
||||
0 3px 6px rgba(0, 0, 0, .23)
|
||||
}
|
||||
|
||||
li.list-group-item {
|
||||
overflow: auto;
|
||||
padding-top: 6px;
|
||||
padding-bottom: 6px
|
||||
}
|
||||
|
||||
header.page-header {
|
||||
text-align: center
|
||||
}
|
||||
|
||||
@media(max-width:750px) {
|
||||
div.col-sm-3 {
|
||||
font-weight: 700
|
||||
}
|
||||
}
|
||||
|
||||
footer {
|
||||
position: fixed;
|
||||
height: 40px;
|
||||
width: 100%;
|
||||
text-align: center;
|
||||
left: 0;
|
||||
right: 0;
|
||||
bottom: 0
|
||||
}
|
||||
</style>
|
||||
|
||||
<title>{{ .Title }}</title>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<header class="page-header container">
|
||||
<h1><a href="/">{{ .Title }}</a></h1>
|
||||
</header>
|
||||
<nav class="container"></nav>
|
||||
<main class="container">
|
||||
{{ if not .Info.Domain }}
|
||||
<div class="panel panel-default">
|
||||
<div class="panel-heading">
|
||||
<h4>Connection</h4>
|
||||
</div>
|
||||
<ul class="list-group">
|
||||
{{ if .Info.Ip }}
|
||||
<li class="list-group-item">
|
||||
<div class="col-sm-3">IP Address</div>
|
||||
<div class="col-sm-9">{{ .Info.Ip }}</div>
|
||||
</li>
|
||||
{{ end }}
|
||||
{{ if .Info.Hostname }}
|
||||
<li class="list-group-item">
|
||||
<div class="col-sm-3">Hostname</div>
|
||||
<div class="col-sm-9">{{ .Info.Hostname }}</div>
|
||||
</li>
|
||||
{{ end }}
|
||||
{{ if .Info.Port }}
|
||||
<li class="list-group-item">
|
||||
<div class="col-sm-3">Port</div>
|
||||
<div class="col-sm-9">{{ .Info.Port }}</div>
|
||||
</li>
|
||||
{{ end }}
|
||||
{{ if .Info.User_agent }}
|
||||
<li class="list-group-item">
|
||||
<div class="col-sm-3">User-agent</div>
|
||||
<div class="col-sm-9">{{ .Info.User_agent }}</div>
|
||||
</li>
|
||||
{{ end }}
|
||||
{{ if .Info.Mime_type }}
|
||||
<li class="list-group-item">
|
||||
<div class="col-sm-3">Mime-type</div>
|
||||
<div class="col-sm-9">{{ .Info.Mime_type }}</div>
|
||||
</li>
|
||||
{{ end }}
|
||||
{{ if .Info.Language }}
|
||||
<li class="list-group-item">
|
||||
<div class="col-sm-3">Language</div>
|
||||
<div class="col-sm-9">{{ .Info.Language }}</div>
|
||||
</li>
|
||||
{{ end }}
|
||||
{{ if .Info.Content_type }}
|
||||
<li class="list-group-item">
|
||||
<div class="col-sm-3">Content-type</div>
|
||||
<div class="col-sm-9">{{ .Info.Content_type }}</div>
|
||||
</li>
|
||||
{{ end }}
|
||||
{{ if .Info.Encoding }}
|
||||
<li class="list-group-item">
|
||||
<div class="col-sm-3">Content-encoding</div>
|
||||
<div class="col-sm-9">{{ .Info.Encoding }}</div>
|
||||
</li>
|
||||
{{ end }}
|
||||
{{ if .Info.Method }}
|
||||
<li class="list-group-item">
|
||||
<div class="col-sm-3">Method</div>
|
||||
<div class="col-sm-9">{{ .Info.Method }}</div>
|
||||
</li>
|
||||
{{ end }}
|
||||
{{ if .Info.Cache_control }}
|
||||
<li class="list-group-item">
|
||||
<div class="col-sm-3">Cache-control</div>
|
||||
<div class="col-sm-9">{{ .Info.Cache_control }}</div>
|
||||
</li>
|
||||
{{ end }}
|
||||
{{ if .Info.Referer }}
|
||||
<li class="list-group-item">
|
||||
<div class="col-sm-3">Referer</div>
|
||||
<div class="col-sm-9">{{ .Info.Referer }}</div>
|
||||
</li>
|
||||
{{ end }}
|
||||
{{ if .Info.X_forwarded_for }}
|
||||
<li class="list-group-item">
|
||||
<div class="col-sm-3">X-Forwarded-For</div>
|
||||
<div class="col-sm-9">{{ .Info.X_forwarded_for }}</div>
|
||||
</li>
|
||||
{{ end }}
|
||||
{{ if .Info.X_forwarded_proto }}
|
||||
<li class="list-group-item">
|
||||
<div class="col-sm-3">X-Forwarded-Proto</div>
|
||||
<div class="col-sm-9">{{ .Info.X_forwarded_proto }}</div>
|
||||
</li>
|
||||
{{ end }}
|
||||
</ul>
|
||||
</div>
|
||||
{{ end }}
|
||||
{{ if or .Info.Geo.Country .Info.Asn.Org }}
|
||||
<div class="panel panel-default">
|
||||
<div class="panel-heading">
|
||||
<h4>Lookup</h4>
|
||||
</div>
|
||||
<ul class="list-group">
|
||||
{{ if and .Info.Domain .Info.Ip }}
|
||||
<li class="list-group-item">
|
||||
<div class="col-sm-3">IP address</div>
|
||||
<div class="col-sm-9">{{ .Info.Ip }}</div>
|
||||
</li>
|
||||
{{ end }}
|
||||
{{ if and .Info.Domain .Info.Hostname }}
|
||||
<li class="list-group-item">
|
||||
<div class="col-sm-3">Hostname</div>
|
||||
<div class="col-sm-9">{{ .Info.Hostname }}</div>
|
||||
</li>
|
||||
{{ end }}
|
||||
{{ if .Info.Geo.Country }}
|
||||
<li class="list-group-item">
|
||||
<div class="col-sm-3">Country</div>
|
||||
<div class="col-sm-9">{{ .Info.Geo.Country }}</div>
|
||||
</li>
|
||||
{{ end }}
|
||||
{{ if .Info.Geo.Ccode }}
|
||||
<li class="list-group-item">
|
||||
<div class="col-sm-3">Country code</div>
|
||||
<div class="col-sm-9">{{ .Info.Geo.Ccode }}</div>
|
||||
</li>
|
||||
{{ end }}
|
||||
{{ if .Info.Geo.City }}
|
||||
<li class="list-group-item">
|
||||
<div class="col-sm-3">City</div>
|
||||
<div class="col-sm-9">{{ .Info.Geo.City }}</div>
|
||||
</li>
|
||||
{{ end }}
|
||||
{{ if .Info.Geo.Latitude }}
|
||||
<li class="list-group-item">
|
||||
<div class="col-sm-3">Latitude</div>
|
||||
<div class="col-sm-9">{{ .Info.Geo.Latitude }}</div>
|
||||
</li>
|
||||
{{ end }}
|
||||
{{ if .Info.Geo.Longitude }}
|
||||
<li class="list-group-item">
|
||||
<div class="col-sm-3">Longitude</div>
|
||||
<div class="col-sm-9">{{ .Info.Geo.Longitude }}</div>
|
||||
</li>
|
||||
{{ end }}
|
||||
{{ if .Info.Asn.Asn }}
|
||||
<li class="list-group-item">
|
||||
<div class="col-sm-3">ASN</div>
|
||||
<div class="col-sm-9">{{ .Info.Asn.Asn }}</div>
|
||||
</li>
|
||||
{{ end }}
|
||||
{{ if .Info.Asn.Org }}
|
||||
<li class="list-group-item">
|
||||
<div class="col-sm-3">Organisation</div>
|
||||
<div class="col-sm-9">{{ .Info.Asn.Org }}</div>
|
||||
</li>
|
||||
{{ end }}
|
||||
</ul>
|
||||
</div>
|
||||
{{ end }}
|
||||
{{ if .Info.Ssl.Subject }}
|
||||
<div class="panel panel-default">
|
||||
<div class="panel-heading">
|
||||
<h4>SSL</h4>
|
||||
</div>
|
||||
<ul class="list-group">
|
||||
{{ if .Info.Ssl.Subject }}
|
||||
<li class="list-group-item">
|
||||
<div class="col-sm-3">Subject</div>
|
||||
<div class="col-sm-9">{{ .Info.Ssl.Subject }}</div>
|
||||
</li>
|
||||
{{ end }}
|
||||
{{ if .Info.Ssl.San }}
|
||||
<li class="list-group-item">
|
||||
<div class="col-sm-3">SAN</div>
|
||||
<div class="col-sm-9">{{ range .Info.Ssl.San }}{{ . }} {{ end }}</div>
|
||||
</li>
|
||||
{{ end }}
|
||||
{{ if .Info.Ssl.Issuer }}
|
||||
<li class="list-group-item">
|
||||
<div class="col-sm-3">Issuer</div>
|
||||
<div class="col-sm-9">{{ .Info.Ssl.Issuer }}</div>
|
||||
</li>
|
||||
{{ end }}
|
||||
{{ if .Info.Ssl.Not_before }}
|
||||
<li class="list-group-item">
|
||||
<div class="col-sm-3">Not before</div>
|
||||
<div class="col-sm-9">{{ .Info.Ssl.Not_before }}</div>
|
||||
</li>
|
||||
{{ end }}
|
||||
{{ if .Info.Ssl.Not_after }}
|
||||
<li class="list-group-item">
|
||||
<div class="col-sm-3">Not after</div>
|
||||
<div class="col-sm-9">{{ .Info.Ssl.Not_after }}</div>
|
||||
</li>
|
||||
{{ end }}
|
||||
{{ if .Info.Ssl.Ocsp }}
|
||||
<li class="list-group-item">
|
||||
<div class="col-sm-3">OCSP</div>
|
||||
<div class="col-sm-9">{{ range .Info.Ssl.Ocsp }}{{ . }} {{ end }}</div>
|
||||
</li>
|
||||
{{ end }}
|
||||
{{ if .Info.Ssl.Alpn }}
|
||||
<li class="list-group-item">
|
||||
<div class="col-sm-3">ALPN</div>
|
||||
<div class="col-sm-9">{{ .Info.Ssl.Alpn }}</div>
|
||||
</li>
|
||||
{{ end }}
|
||||
</ul>
|
||||
</div>
|
||||
{{ end }}
|
||||
<details>
|
||||
<summary>Usage examples</summary>
|
||||
<div class="panel panel-default">
|
||||
<div class="panel-heading">
|
||||
<h4>API usage examples</h4>
|
||||
</div>
|
||||
<ul class="list-group">
|
||||
<li class="list-group-item">
|
||||
<div class="col-sm-4">curl {{ .Hostname }}</div>
|
||||
<div class="col-sm-8">{{ .Info.Ip }}</div>
|
||||
</li>
|
||||
{{ if .Info.User_agent }}
|
||||
<li class="list-group-item">
|
||||
<div class="col-sm-4">curl {{ .Hostname }}/user-agent</div>
|
||||
<div class="col-sm-8">{{ .Info.User_agent }}</div>
|
||||
</li>
|
||||
{{ end }}
|
||||
{{ if .Info.Geo.Country }}
|
||||
<li class="list-group-item">
|
||||
<div class="col-sm-4">curl {{ .Hostname }}/country</div>
|
||||
<div class="col-sm-8">{{ .Info.Geo.Country }}</div>
|
||||
</li>
|
||||
{{ end }}
|
||||
{{ if .Info.Asn.Org }}
|
||||
<li class="list-group-item">
|
||||
<div class="col-sm-4">curl {{ .Hostname }}/org</div>
|
||||
<div class="col-sm-8">{{ .Info.Asn.Org }}</div>
|
||||
</li>
|
||||
{{ end }}
|
||||
<li class="list-group-item">
|
||||
<div class="col-sm-4">curl {{ .Hostname }}/all</div>
|
||||
<div class="col-sm-8">{{ .Info }}</div>
|
||||
</li>
|
||||
{{ if .Info.Hostname }}
|
||||
<li class="list-group-item">
|
||||
<div class="col-sm-4">curl {{ .Hostname }}/hostname</div>
|
||||
<div class="col-sm-8">{{ .Info.Hostname }}</div>
|
||||
</li>
|
||||
{{ end }}
|
||||
{{ if .Info.Ssl.Subject }}
|
||||
<li class="list-group-item">
|
||||
<div class="col-sm-4">curl {{ .Hostname }}/ssl</div>
|
||||
<div class="col-sm-8">{{ .Info.Ssl }}</div>
|
||||
</li>
|
||||
{{ end }}
|
||||
</ul>
|
||||
</div>
|
||||
</details>
|
||||
</main>
|
||||
<footer class="container text-center">
|
||||
<p><a target="_blank" href="https://git.rznet.fr/tchivert/iplookup-go">{{ .Title }}</a> - code by <a
|
||||
target="_blank" href="https://tchv.fr/">Tom</a></p>
|
||||
</footer>
|
||||
</body>
|
||||
Reference in new issue
Block a user