diff --git a/.changeset/sharp-ears-tell.md b/.changeset/sharp-ears-tell.md new file mode 100644 index 000000000..426b29132 --- /dev/null +++ b/.changeset/sharp-ears-tell.md @@ -0,0 +1,5 @@ +--- +'hostd': minor +--- + +The address configuration setting now expects only the hostname without a port. Closes https://github.com/SiaFoundation/hostd/issues/536 diff --git a/apps/hostd-e2e/src/fixtures/configResetAllSettings.ts b/apps/hostd-e2e/src/fixtures/configResetAllSettings.ts index 37ac09460..2b1f8ddb6 100644 --- a/apps/hostd-e2e/src/fixtures/configResetAllSettings.ts +++ b/apps/hostd-e2e/src/fixtures/configResetAllSettings.ts @@ -18,7 +18,7 @@ export const configResetAllSettings = step( // host await setSwitchByLabel(page, 'acceptingContracts', false) - await fillTextInputByName(page, 'netAddress', 'foobar.com:9880') + await fillTextInputByName(page, 'netAddress', 'foobar.com') await fillTextInputByName(page, 'maxContractDuration', '6') // pricing diff --git a/apps/hostd-e2e/src/specs/config.spec.ts b/apps/hostd-e2e/src/specs/config.spec.ts index 0e48f37d8..0b9d536b8 100644 --- a/apps/hostd-e2e/src/specs/config.spec.ts +++ b/apps/hostd-e2e/src/specs/config.spec.ts @@ -28,7 +28,7 @@ test('basic field change and save behaviour', async ({ page }) => { // Test that values can be updated. await setSwitchByLabel(page, 'acceptingContracts', true) - await fillTextInputByName(page, 'netAddress', 'foobar.com:7777') + await fillTextInputByName(page, 'netAddress', 'foobar.com') await fillTextInputByName(page, 'maxContractDuration', '7') await fillSelectInputByName(page, 'pinnedCurrency', 'AUD') await fillTextInputByName(page, 'pinnedThreshold', '7') @@ -48,7 +48,7 @@ test('basic field change and save behaviour', async ({ page }) => { // await expect( // page.getByText('Address has changed, make sure to re-announce the host.') // ).toBeVisible() - await expectTextInputByName(page, 'netAddress', 'foobar.com:7777') + await expectTextInputByName(page, 'netAddress', 'foobar.com') await expectTextInputByName(page, 'maxContractDuration', '7') await fillSelectInputByName(page, 'pinnedCurrency', 'USD') await expectTextInputByName(page, 'pinnedThreshold', '7') diff --git a/apps/hostd/contexts/config/fields.tsx b/apps/hostd/contexts/config/fields.tsx index b18f219e3..74fd53090 100644 --- a/apps/hostd/contexts/config/fields.tsx +++ b/apps/hostd/contexts/config/fields.tsx @@ -10,6 +10,7 @@ import { } from './types' import { calculateMaxCollateral } from './transform' import { currencyOptions } from '@siafoundation/react-core' +import { Maybe } from '@siafoundation/types' type Categories = 'host' | 'pricing' | 'DNS' | 'bandwidth' | 'RHP3' @@ -46,9 +47,16 @@ export function getFields({ category: 'host', title: 'Address', description: <>The network address of the host., - placeholder: 'my.host.com:9982', + placeholder: 'my.host.com', validation: { required: 'required', + validate: { + noProtocol: (value: Maybe) => + !/^https?:\/\//.test(value || '') || + 'must not start with http:// or https://', + noPort: (value: Maybe) => + !/:\d+$/.test(value || '') || 'must not include port', + }, }, }, maxContractDuration: {