admin/internet: "check" domain button merged into "verify"
Massimo Melina committed
May 8, 2024 at 15:32 UTC
a2879fd1c8dd7d159359890ee9f3560dc442d72c
1 file changed
+13
-17
admin/src/InternetPage.ts
+13
-17
@@ -23,7 +23,7 @@ const COUNTRIES = ALL.filter(x => WITH_IP.includes(x.code))
23
24
const PORT_FORWARD_URL = 'https://portforward.com/'
25
const HIGHER_PORT = 1080
26
-const MSG_ISP = `It is possible that your Internet Provider won't let you get incoming connections. Ask them if they sell "public IP" as an extra service.`
26
+const MSG_ISP = `It's possible that don't have a public IP, so that HFS won't be reachable on the Internet. Ask your Internet Provider if they sell "public IP" as an extra service.`
27
28
export default function InternetPage() {
29
const [checkResult, setCheckResult] = useState<boolean | undefined>()
@@ -243,26 +243,16 @@ export default function InternetPage() {
243
244
function baseUrlBox() {
245
const url = config.data?.base_url
246
- const hostname = url && new URL(url).hostname
247
- const domain = !isIP(hostname) && hostname
246
return config.element || h(TitleCard, { icon: Public, title: "Address" },
247
h(Flex, { flexWrap: 'wrap' },
248
"Main address: ",
249
url ? h('tt', {}, url) : "automatic, not configured",
252
- h(Flex, {}, // keep buttons together when wrapping
253
- h(Btn, {
254
- size: 'small',
255
- variant: 'outlined',
256
- 'aria-label': "Change address",
257
- onClick: () => void changeBaseUrl().then(config.reload)
258
- }, "Change"),
259
- domain && h(Btn, {
260
- size: 'small',
261
- variant: 'outlined',
262
- onClick: () => apiCall('check_domain', { domain })
263
- .then(() => alertDialog("Domain seems ok", 'success'))
264
- }, "Check"),
265
- ),
250
+ h(Btn, {
251
+ size: 'small',
252
+ variant: 'outlined',
253
+ 'aria-label': "Change address",
254
+ onClick: () => void changeBaseUrl().then(config.reload)
255
+ }, "Change"),
256
),
257
h(ConfigForm<{ roots: any, force_address: boolean }>, {
258
saveOnChange: true,
@@ -334,6 +324,12 @@ export default function InternetPage() {
324
setChecking(true)
325
try {
326
const url = config.data?.base_url
327
+ {
328
+ const hostname = url && new URL(url).hostname
329
+ const domain = !isIP(hostname) && hostname
330
+ if (domain && false === await apiCall('check_domain', { domain }).catch(e =>
331
+ confirmDialog(String(e), { confirmText: "Continue anyway" }) )) return
332
+ }
333
const urlResult = url && await apiCall('self_check', { url }).catch(() =>
334
alertDialog(md(`Sorry, we couldn't verify your configured address ${url} 😰\nstill, we are going to test your IP address 🤞`), 'warning'))
335
if (urlResult?.success) {