nostr-zap 0.2.1 → 0.2.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 8adf3c935487b6598f64c224fe196c8cf2b2e7c120dd9ef1c478b15570e2e6a3
4
- data.tar.gz: 107fb7009537702c271f4205443286ba136090a1a6d14ac6e01826d654c43731
3
+ metadata.gz: f8822568c7b644cdd59d59c9e8ca86cad64002f6839c65a278ab208689cff6ba
4
+ data.tar.gz: 9c600769d979d211d16064f5299d596da576731a61dc30af51e31a4c4b9a27bd
5
5
  SHA512:
6
- metadata.gz: 6b7e8aad4a7824cdc850d73c6099b3e80723c3873d4f9930c1bc79ee4c8554693d1be28fbb768e7cff7f2939368270688fa2a75dd28953094c7a63a33e551ecb
7
- data.tar.gz: 3f9c7119b791b8ec79c7a39e9d7e79b30576af5bb1c8f9e121099658a363fb29a44e612fe0e33d130579b08a130927b80fa339aefb0332d064bff46e78e4005b
6
+ metadata.gz: 9699d2b77f3078359c31493036a8fc939cbe1b0dc946eea0c1b70cc006e643ce562c06ba6e19d855f9c117e4f53e90c3b1ec367f7861b6090d7f9f9e0d8febca
7
+ data.tar.gz: 1606d53ff76301a4fc936fc59ae716b4db9ef090761b96206f108340630bdf4b1c9318007d3fcce62709110ccfa2721ff401e920194f9ff21d0dbcf5a5bb47a0
data/README.md CHANGED
@@ -131,6 +131,9 @@ error = NostrZap::RelayUrlValidator.validate("ws://localhost")
131
131
 
132
132
  error = NostrZap::RelayUrlValidator.validate("wss://192.168.1.1")
133
133
  # => "Relay URL points to a private/reserved address: wss://192.168.1.1"
134
+
135
+ error = NostrZap::RelayUrlValidator.validate("wss://relay.nostr.bg")
136
+ # => nil (hostnames that do not currently resolve are accepted)
134
137
  ```
135
138
 
136
139
  Blocked IP ranges: `127.0.0.0/8`, `10.0.0.0/8`, `172.16.0.0/12`, `192.168.0.0/16`, `169.254.0.0/16`, `0.0.0.0/8`, `::1`, `fc00::/7`, `fe80::/10`.
@@ -27,7 +27,7 @@ module NostrZap
27
27
  IPAddr.new('0.0.0.0/8'),
28
28
  IPAddr.new('::1/128'),
29
29
  IPAddr.new('fc00::/7'),
30
- IPAddr.new('fe80::/10'),
30
+ IPAddr.new('fe80::/10')
31
31
  ].freeze
32
32
 
33
33
  def self.validate(url)
@@ -46,7 +46,7 @@ module NostrZap
46
46
  "Invalid relay URL: #{@url}"
47
47
  end
48
48
 
49
- private
49
+ private
50
50
 
51
51
  def validate_scheme(uri)
52
52
  return if uri.scheme == 'wss'
@@ -67,12 +67,25 @@ module NostrZap
67
67
  end
68
68
 
69
69
  def private_host?(host)
70
+ ip = parse_ip_literal(host)
71
+ return private_ip?(ip) if ip
72
+
70
73
  addresses = Resolv.getaddresses(host)
71
- return true if addresses.empty?
74
+ return false if addresses.empty?
72
75
 
73
- addresses.any? { |addr| PRIVATE_IP_RANGES.any? { |range| range.include?(addr) } }
76
+ addresses.any? { |addr| private_ip?(addr) }
74
77
  rescue Resolv::ResolvError
75
- true
78
+ false
79
+ end
80
+
81
+ def parse_ip_literal(host)
82
+ IPAddr.new(host)
83
+ rescue IPAddr::InvalidAddressError
84
+ nil
85
+ end
86
+
87
+ def private_ip?(ip)
88
+ PRIVATE_IP_RANGES.any? { |range| range.include?(ip) }
76
89
  end
77
90
  end
78
91
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module NostrZap
4
- VERSION = '0.2.1'
4
+ VERSION = '0.2.2'
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: nostr-zap
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
4
+ version: 0.2.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Alexander Zykov
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2026-02-07 00:00:00.000000000 Z
11
+ date: 2026-02-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bip-schnorr
@@ -68,7 +68,7 @@ metadata:
68
68
  source_code_uri: https://github.com/sashazykov/nostr-zap
69
69
  changelog_uri: https://github.com/sashazykov/nostr-zap/blob/main/CHANGELOG.md
70
70
  rubygems_mfa_required: 'true'
71
- post_install_message:
71
+ post_install_message:
72
72
  rdoc_options: []
73
73
  require_paths:
74
74
  - lib
@@ -83,8 +83,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
83
83
  - !ruby/object:Gem::Version
84
84
  version: '0'
85
85
  requirements: []
86
- rubygems_version: 3.1.6
87
- signing_key:
86
+ rubygems_version: 3.0.3.1
87
+ signing_key:
88
88
  specification_version: 4
89
89
  summary: NIP-57 Zaps for NOSTR — validate zap requests, build zap receipts, publish
90
90
  to relays