diff --git a/internal/handler/views/add_node.templ b/internal/handler/views/add_node.templ index 65ec85f..f845fda 100644 --- a/internal/handler/views/add_node.templ +++ b/internal/handler/views/add_node.templ @@ -23,7 +23,7 @@ templ AddNode() {
diff --git a/internal/handler/views/add_node_templ.go b/internal/handler/views/add_node_templ.go index 9c8b2b0..4361a4a 100644 --- a/internal/handler/views/add_node_templ.go +++ b/internal/handler/views/add_node_templ.go @@ -37,7 +37,7 @@ func AddNode() templ.Component { if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } - _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("

Add Monero Node

You can use this page to add known remote node to the system so my bots can monitor it.


Important Note

  • As an administrator of this instance, I have full rights to delete, and blacklist any submitted node with or without providing any reason.
  • I2P nodes monitoring is beta and currently only support b32 address.

Enter your Monero node information below:

Existing remote nodes can be found in /remote-nodes page.

") + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("

Add Monero Node

You can use this page to add known remote node to the system so my bots can monitor it.


Important Note

  • As an administrator of this instance, I have full rights to delete, and blacklist any submitted node with or without providing any reason.
  • I2P nodes monitoring is beta.

Enter your Monero node information below:

Existing remote nodes can be found in /remote-nodes page.

") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } diff --git a/internal/monero/monero.go b/internal/monero/monero.go index bbe9b66..2675c65 100644 --- a/internal/monero/monero.go +++ b/internal/monero/monero.go @@ -319,13 +319,24 @@ func validTorHostname(hostname string) bool { return regexp.MustCompile(`^([a-z0-9-]+\.)*[a-z2-7]{56}\.onion$`).MatchString(hostname) } -// validI2PHostname checks if a given hostname is a valid p32 I2P address +// validI2PHostname checks if a given hostname is a valid b32 or naming service +// I2P address // -// Old b32 addresses are always {52 chars}.b32.i2p and new ones are {56+ chars}.b32.i2p. -// See: https://geti2p.net/spec/b32encrypted -// TODO: Validate new format and allow naming service hostnames +// Old b32 addresses are always {52 chars}.b32.i2p and new ones are +// {56+ chars}.b32.i2p. Since I don't know if there is a length limit of new +// b32 addresses, this function allows up to 63 characters. +// +// For naming service, I2P addresses are up to 67 characters, including the +// '.i2p' part. Please note that this naming service validation only validates +// simple length and allowed characters. Advanced validation such as +// internationalized domain name (IDN) is not implemented. +// +// Ref: https://geti2p.net/spec/b32encrypted and https://geti2p.net/en/docs/naming func validI2PHostname(hostname string) bool { - return regexp.MustCompile(`^[a-z2-7]{52,}\.b32\.i2p$`).MatchString(hostname) + // To minimize abuse, I set minimum length of submitted i2p naming service + // address to 5 characters. If someone have an address of 4 characters or + // less, let them open an issue or create a pull request. + return regexp.MustCompile(`^([a-z2-7]{52,63}\.b32|[a-z0-9-]{5,63})\.i2p$`).MatchString(hostname) } func (r *moneroRepo) Delete(id uint) error { diff --git a/internal/monero/monero_test.go b/internal/monero/monero_test.go index 09c8163..421a2b0 100644 --- a/internal/monero/monero_test.go +++ b/internal/monero/monero_test.go @@ -179,7 +179,6 @@ func Benchmark_validTorHostname(b *testing.B) { // Single test: // go test -race ./internal/monero -run=TestValidI2PHostname -v -// TODO: Validate new format and allow naming service hostnames func TestValidI2PHostname(t *testing.T) { tests := []struct { name string @@ -201,6 +200,11 @@ func TestValidI2PHostname(t *testing.T) { host: "abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrst123456.b32.i2p", wantValid: false, }, + { + name: "Valid naming service i2p host", + host: "i2p-projekt.i2p", + wantValid: true, + }, { name: "clearnet domain", host: "test.com",