Compare commits

..

No commits in common. "cdb0816bc36b52bc1603f8c6e155586039e9605e" and "0e3dc04af8636a908389ba27b13673ae5ff4cc28" have entirely different histories.

10 changed files with 11 additions and 90 deletions

View file

@ -338,7 +338,6 @@ func (p *proberClient) reportResult(node monero.Node, tookTime float64) error {
if !node.IsTor {
if hostIps, err := net.LookupIP(node.Hostname); err == nil {
node.IPv6Only = ip.IsIPv6Only(hostIps)
node.IPAddresses = ip.SliceToString(hostIps)
}
}

View file

@ -21,7 +21,6 @@ declare global {
is_tor: boolean;
is_available: boolean;
nettype: string;
ip_addresses: string;
}
interface ApiResponse {

View file

@ -16,8 +16,6 @@
export let hostname;
export let port;
export let ipv6_only;
/** @type {string} */
export let ip_addresses;
/**
* @param {string} onionAddr
@ -37,7 +35,7 @@
{#if is_tor}
<button
class="max-w-40 truncate text-orange-800 dark:text-orange-300"
class="max-w-32 truncate text-orange-800 dark:text-orange-300"
on:click={() => modalAlert(hostname, port)}
>
👁 {hostname}
@ -45,12 +43,7 @@
<span class="text-gray-700 dark:text-gray-400">(TOR)</span>
{:else}
{formatHostname(hostname)}:<span class="text-indigo-800 dark:text-indigo-400">{port}</span><br />
<div class="max-w-40 text-ellipsis overflow-x-auto md:overflow-hidden hover:overflow-visible">
<span class="whitespace-break-spaces text-gray-700 dark:text-gray-400"
>{ip_addresses.replace(/,/g, ' ')}</span
>
{#if ipv6_only}
<span class="text-rose-800 dark:text-rose-400">(IPv6 only)</span>
{/if}
</div>
{/if}

View file

@ -211,12 +211,12 @@
<tr>
<td
><HostPortCell
ip_addresses={row.ip_addresses}
is_tor={row.is_tor}
hostname={row.hostname}
port={row.port}
ipv6_only={row.ipv6_only}
/>
<a class="anchor" href="/remote-nodes/logs/?node_id={row.id}">[Logs]</a>
</td>
<td><NetTypeCell nettype={row.nettype} height={row.height} /></td>
<td><ProtocolCell protocol={row.protocol} cors={row.cors} /></td>
@ -241,13 +241,7 @@
majority_fee={majorityFee[row.nettype]}
/>
</td>
<td
><UptimeCell uptime={row.uptime} /><br />
<a
class="anchor !text-purple-800 dark:!text-purple-400"
href="/remote-nodes/logs/?node_id={row.id}">[Logs]</a
>
</td>
<td><UptimeCell uptime={row.uptime} /></td>
<td>
{format(row.last_checked * 1000, 'PP HH:mm')}<br />
{formatDistance(row.last_checked * 1000, new Date(), { addSuffix: true })}

View file

@ -75,7 +75,7 @@
</tr>
<tr>
<td class="font-bold">Public IP</td>
<td>{nodeInfo?.ip_addresses.replace(/,/g, ', ')}</td>
<td>{nodeInfo?.ip}</td>
</tr>
<tr>
<td class="font-bold">Net Type</td>

View file

@ -261,14 +261,11 @@ func v3(db *DB) error {
slog.Debug("[DB] Migrating database schema version 3")
// table: tbl_node
// TODO: Remove IF NOT EXISTS SQL statement below after merging to main
// branch. The statement only to accomodate commit 518d4b4 so future main
// branch keep on schema version 3.
slog.Debug("[DB] Adding additional columns to tbl_node")
slog.Debug("[DB] Adding ipv6_only column to tbl_node")
_, err := db.Exec(`
ALTER TABLE tbl_node
ADD COLUMN IF NOT EXISTS ipv6_only TINYINT(1) UNSIGNED NOT NULL DEFAULT '0' AFTER cors_capable,
ADD COLUMN ip_addresses TEXT NOT NULL DEFAULT '' AFTER cors_capable;`)
ADD ipv6_only TINYINT(1) UNSIGNED NOT NULL DEFAULT '0'
AFTER cors_capable;`)
if err != nil {
return err
}

View file

@ -3,7 +3,6 @@ package ip
import (
"net"
"strings"
)
// IsIPv6Only returns true if all given IPs are IPv6
@ -15,14 +14,3 @@ func IsIPv6Only(ips []net.IP) bool {
}
return true
}
// SliceToString converts []net.IP to a string separated by comma.
// If the separator is empty, it defaults to ",".
func SliceToString(ips []net.IP) string {
r := make([]string, len(ips))
for i, j := range ips {
r[i] = j.String()
}
return strings.Join(r, ",")
}

View file

@ -44,43 +44,3 @@ func TestIsIPv6Only(t *testing.T) {
})
}
}
// Single test: go test ./internal/ip -bench TestSliceToString -benchmem -run=^$ -v
func TestSliceToString(t *testing.T) {
tests := []struct {
name string
ips []net.IP
want string
}{
{
name: "IPv4",
ips: []net.IP{
net.ParseIP("1.1.1.1"),
},
want: "1.1.1.1",
},
{
name: "IPv6",
ips: []net.IP{
net.ParseIP("2606:4700::6810:85e5"),
},
want: "2606:4700::6810:85e5",
},
{
name: "IPv6 and IPv4",
ips: []net.IP{
net.ParseIP("1.1.1.1"),
net.ParseIP("2606:4700::6810:85e5"),
},
want: "1.1.1.1,2606:4700::6810:85e5",
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
if got := SliceToString(tt.ips); got != tt.want {
t.Errorf("SliceToString() = %v, want %v", got, tt.want)
}
})
}
}

View file

@ -55,7 +55,6 @@ type Node struct {
LastCheckStatus types.JSONText `json:"last_check_statuses" db:"last_check_status"`
CORSCapable bool `json:"cors" db:"cors_capable"`
IPv6Only bool `json:"ipv6_only" db:"ipv6_only"`
IPAddresses string `json:"ip_addresses" db:"ip_addresses"`
}
// Get node from database by id
@ -199,7 +198,6 @@ func (r *moneroRepo) Add(protocol string, hostname string, port uint) error {
}
ipAddr := ""
ips := ""
ipv6_only := false
if !is_tor {
@ -219,7 +217,6 @@ func (r *moneroRepo) Add(protocol string, hostname string, port uint) error {
}
ipAddr = hostIp.String()
ips = ip.SliceToString(hostIps)
}
row, err := r.db.Query(`
@ -254,7 +251,6 @@ func (r *moneroRepo) Add(protocol string, hostname string, port uint) error {
date_entered,
last_checked,
last_check_status,
ip_addresses,
ipv6_only
) VALUES (
?,
@ -268,7 +264,6 @@ func (r *moneroRepo) Add(protocol string, hostname string, port uint) error {
?,
?,
?,
?,
?
)`,
protocol,
@ -282,7 +277,6 @@ func (r *moneroRepo) Add(protocol string, hostname string, port uint) error {
time.Now().Unix(),
0,
string(statusDb),
ips,
ipv6_only)
if err != nil {
return err

View file

@ -309,7 +309,6 @@ func (r *moneroRepo) ProcessJob(report ProbeReport, proberId int64) error {
last_checked = ?,
last_check_status = ?,
cors_capable = ?,
ip_addresses = ?,
ipv6_only = ?
WHERE
id = ?`
@ -332,7 +331,6 @@ func (r *moneroRepo) ProcessJob(report ProbeReport, proberId int64) error {
now.Unix(),
statuses,
report.Node.CORSCapable,
report.Node.IPAddresses,
report.Node.IPv6Only,
report.Node.ID)
if err != nil {
@ -346,11 +344,10 @@ func (r *moneroRepo) ProcessJob(report ProbeReport, proberId int64) error {
uptime = ?,
last_checked = ?,
last_check_status = ?,
ip_addresses = ?,
ipv6_only = ?
WHERE
id = ?`
if _, err := r.db.Exec(u, 0, report.Node.Uptime, now.Unix(), statuses, report.Node.IPAddresses, report.Node.IPv6Only, report.Node.ID); err != nil {
if _, err := r.db.Exec(u, 0, report.Node.Uptime, now.Unix(), statuses, report.Node.IPv6Only, report.Node.ID); err != nil {
slog.Warn(err.Error())
}
}