coracle icon indicating copy to clipboard operation
coracle copied to clipboard

Can't Add Relay URI with Port Definition

Open henrixd7 opened this issue 1 year ago • 3 comments

When I try to use ws://dev.local:7777 as a relay, I receive the following error: "Please provide a valid relay URL."

This error is triggered by the isShareableRelayUrl function in node_modules/@welshman/util/build/Relay.mjs:

export const isShareableRelayUrl = (url) => {
    var _a;
    return Boolean(typeof url === 'string' &&
        // Is it actually a websocket url and has a dot
        url.match(/^wss:\/\/.+\..+/) &&
        // Sometimes bugs cause multiple relays to get concatenated
        ((_a = url.match(/:\/\//g)) === null || _a === void 0 ? void 0 : _a.length) === 1 &&
        // It shouldn't have any whitespace, url-encoded or otherwise
        !url.match(/\s|%/) &&
        // Don't match stuff with a port number
        !url.slice(6).match(/:\d+/) &&
        // Don't match stuff with a numeric tld
        !url.slice(6).match(/\.\d+\b/) &&
        // Don't match raw ip addresses
        !url.slice(6).match(/\d+\.\d+\.\d+\.\d+/) &&
        // Skip nostr.wine's virtual relays
        !url.slice(6).match(/\/npub/));
};

The relevant part is:

// Don't match stuff with a port number
!url.slice(6).match(/:\d+/) &&

This doesn't seem right. ws://dev.local:7777 is a valid relay URI and should be allowed.

My intention is to use a local cache relay as read-only and other relays as write-only to achieve the fastest possible experience with my locally running client.

henrixd7 avatar May 29 '24 03:05 henrixd7

This is on my radar, I'm just not sure yet how to handle it, since you don't want to hit other people's local urls.

staab avatar Jun 10 '24 17:06 staab

It would be nice to support https://github.com/CodyTseng/nostr-relay-tray

staab avatar Jun 18 '24 16:06 staab

I have the same issue. Running nostr-rs-relay locally and can't connect to it with Coracle.

Silberengel avatar Sep 30 '24 06:09 Silberengel

Please fix this ;-D

rabble avatar Oct 19 '24 03:10 rabble

Fixed in 4651a158

staab avatar Jan 06 '25 21:01 staab