Fwknop2 icon indicating copy to clipboard operation
Fwknop2 copied to clipboard

Can't set IP resolver URL if it contains a path

Open RyanDwyer opened this issue 5 years ago • 1 comments

  1. Tap the 3 dots in the main menu and go to Configure.
  2. Enter a URL containing a path (eg. https://example.com/ip).
  3. Click Save Settings.

You'll get an error "URL must be in the form of http://whatismyip.akamai.com or https://api.ipify.org".

There are two issues here:

  1. The error message text is incorrect. Fwknop2 does support custom URLs. I suggest changing the text to be something like "Please enter a valid URL".
  2. Validation fails if the URL contains a path component.

Here's the relevant code: https://github.com/jp-bennett/Fwknop2/blob/c15b66dc7b7f1c43f1cd917f3001eabcaf7dddd7/app/src/main/java/biz/incomsystems/fwknop2/GeneralConfigActivity.java#L55

The string being passed to the DomainValidator is just everything to the right of ://. It likely needs to be split again on / so it only gives the hostname to the DomainValidator. Actually, it should also check for a custom port by splitting on a colon if it exists. Come to think of it, perhaps this DomainValidator should be dropped in favour of a general URL validation library.

RyanDwyer avatar Apr 15 '19 07:04 RyanDwyer

Yeah, Valid points. I'll get this fixed up.

jp-bennett avatar Apr 17 '19 21:04 jp-bennett