Add protocol, ip and port fields

This commit is contained in:
perp 2024-07-25 16:25:41 +01:00
parent 9e7f881026
commit db120280f1
2 changed files with 20 additions and 4 deletions

View File

@ -47,7 +47,7 @@ func main() {
count += 1
// Print information
fmt.Printf("%sIP%s: %s%s\n", green, reset, blue, socks5.Query)
fmt.Printf("%sIP%s: %s%s\n", green, reset, blue, socks5.IP)
fmt.Printf("%sISP%s: %s%s\n", blue, reset, green, socks5.Isp)
fmt.Printf("%sCountry%s: %s%s\n", green, reset, blue, socks5.Country)
fmt.Printf("%sCity%s: %s%s\n", blue, reset, green, socks5.City)

View File

@ -5,6 +5,8 @@ import (
"fmt"
"io"
"net/http"
"strconv"
"strings"
"time"
)
@ -13,7 +15,10 @@ var endpoint = "http://ip-api.com/json?fields=66842623"
// Lookup represents a proxy lookup
type Lookup struct {
Full string `json:"full"`
Protocol string `json:"protocol"`
IP string `json:"ip"`
Port int `json:"port"`
Status string `json:"status"`
Continent string `json:"continent"`
ContinentCode string `json:"continentCode"`
@ -99,8 +104,19 @@ func (c *Channels) Verify(proxy string, timeout time.Duration) {
return
}
// Set full proxy
lookup.Full = proxy
// Replace & split IP
ip := strings.Split(strings.ReplaceAll(proxy, "//", ""), ":")
// Convert port
port, err := strconv.Atoi(ip[2])
if err != nil {
port = 0
}
// Set values
lookup.Protocol = scheme
lookup.IP = ip[1]
lookup.Port = port
// Check scheme
switch scheme {