Skip to content

Commit 6731a21

Browse files
committed
fix(hostd): address configuration hostname no port
1 parent 7c3f4b1 commit 6731a21

File tree

4 files changed

+17
-4
lines changed

4 files changed

+17
-4
lines changed

.changeset/sharp-ears-tell.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'hostd': minor
3+
---
4+
5+
The address configuration setting now expects only the hostname without a port. Closes https://github.com/SiaFoundation/hostd/issues/536

apps/hostd-e2e/src/fixtures/configResetAllSettings.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ export const configResetAllSettings = step(
1818

1919
// host
2020
await setSwitchByLabel(page, 'acceptingContracts', false)
21-
await fillTextInputByName(page, 'netAddress', 'foobar.com:9880')
21+
await fillTextInputByName(page, 'netAddress', 'foobar.com')
2222
await fillTextInputByName(page, 'maxContractDuration', '6')
2323

2424
// pricing

apps/hostd-e2e/src/specs/config.spec.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ test('basic field change and save behaviour', async ({ page }) => {
2828

2929
// Test that values can be updated.
3030
await setSwitchByLabel(page, 'acceptingContracts', true)
31-
await fillTextInputByName(page, 'netAddress', 'foobar.com:7777')
31+
await fillTextInputByName(page, 'netAddress', 'foobar1.com')
3232
await fillTextInputByName(page, 'maxContractDuration', '7')
3333
await fillSelectInputByName(page, 'pinnedCurrency', 'AUD')
3434
await fillTextInputByName(page, 'pinnedThreshold', '7')
@@ -48,7 +48,7 @@ test('basic field change and save behaviour', async ({ page }) => {
4848
// await expect(
4949
// page.getByText('Address has changed, make sure to re-announce the host.')
5050
// ).toBeVisible()
51-
await expectTextInputByName(page, 'netAddress', 'foobar.com:7777')
51+
await expectTextInputByName(page, 'netAddress', 'foobar1.com')
5252
await expectTextInputByName(page, 'maxContractDuration', '7')
5353
await fillSelectInputByName(page, 'pinnedCurrency', 'USD')
5454
await expectTextInputByName(page, 'pinnedThreshold', '7')

apps/hostd/contexts/config/fields.tsx

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import {
1010
} from './types'
1111
import { calculateMaxCollateral } from './transform'
1212
import { currencyOptions } from '@siafoundation/react-core'
13+
import { Maybe } from '@siafoundation/types'
1314

1415
type Categories = 'host' | 'pricing' | 'DNS' | 'bandwidth' | 'RHP3'
1516

@@ -46,9 +47,16 @@ export function getFields({
4647
category: 'host',
4748
title: 'Address',
4849
description: <>The network address of the host.</>,
49-
placeholder: 'my.host.com:9982',
50+
placeholder: 'my.host.com',
5051
validation: {
5152
required: 'required',
53+
validate: {
54+
noProtocol: (value: Maybe<string>) =>
55+
!/^https?:\/\//.test(value || '') ||
56+
'must not start with http:// or https://',
57+
noPort: (value: Maybe<string>) =>
58+
!/:\d+$/.test(value || '') || 'must not include port',
59+
},
5260
},
5361
},
5462
maxContractDuration: {

0 commit comments

Comments
 (0)