sebastianhaberey / nsd

Flutter Network Service Discovery (NSD) Plugin
61 stars 30 forks source link

Service name validation #29

Closed kllaas closed 1 year ago

kllaas commented 1 year ago

Description

Hello!

In my company we use _company_project._tcp , I decided to remove the native implementation of NSD in our Android/IOS projects and replace it with your library. I was surprised when I found that I can't use it because it can't validate our service name with this regular expression "r'^[a-zA-Z0-9-]{1,15}.( tcp |udp)'". I haven't seen any application blocking discovery of this service. Could you fix this please?

Scenario

Use the plugin in my own application via Flutter dependency

Platform

Android

sebastianhaberey commented 1 year ago

This is due to the specification (RFC 6335):

Valid service names are hereby normatively defined as follows:

  • MUST be at least 1 character and no more than 15 characters long
  • MUST contain only US-ASCII [ANSI.X3.4-1986] letters 'A' - 'Z' and 'a' - 'z', digits '0' - '9', and hyphens ('-', ASCII 0x2D or decimal 45)
  • MUST contain at least one letter ('A' - 'Z' or 'a' - 'z')
  • MUST NOT begin or end with a hyphen
  • hyphens MUST NOT be adjacent to other hyphens
officialdoniald commented 1 year ago

I need this feature too (at discovery and registration). :D If it is possible, please add this to package. Thanks.

sebastianhaberey commented 1 year ago

Well sure, if it helps you guys, I'll have a look a this coming weekend and see if I can find a solution 🙂

sebastianhaberey commented 1 year ago

I've added an option to disable the service type validation:

disableServiceTypeValidation(true);

Please try version 2.3.0 and see if this will work for you.

officialdoniald commented 1 year ago

Thanks Sebastian, it works fine :D