Fixed issue with matching wild card

This commit is contained in:
2026-07-10 00:13:40 -04:00
parent 655aeb47a2
commit 56c2fb1a5c
6 changed files with 62 additions and 2 deletions
+17
View File
@@ -313,6 +313,23 @@ curl -H "auth-token: your-token-here" \
- `200` `{"message": "example.com deleted", ...}`
- `404` `{"name": "HostNotFound", "message": "Host does not exists"}`
### Clear Host Cache
**DELETE** `/api/host/cache`
Remove all cached wildcard-subdomain host lookups. Cache entries are created on
demand when a wildcard host serves a subdomain; clearing them forces the next
request for each subdomain to be resolved fresh through the lookup tree.
```bash
curl -H "auth-token: your-token-here" \
-X DELETE \
https://proxy-host.com/api/host/cache
```
**Responses:**
- `200` `{"message": "Cleared 3 cached hosts.", "count": 3}`
### Renew Wildcard Certificate
**PUT** `/api/host/:host/renew`
+8 -1
View File
@@ -276,7 +276,7 @@ class Host extends Table{
let out = await super.remove(...args);
await Host.buildLookUpObj();
await this.bustCache(this.host);
await deleteCert(this.host);
await deleteCert(this.domain);
return out;
} catch(error){
@@ -345,8 +345,12 @@ class Host extends Table{
// Hold the last passed long wild card.
let last_resort = {};
// Hold the parent element
let parent = undefined;
// Walk over each fragment of the host, from right to left
for(let fragment of host.split('.').reverse()){
parent = place;
// If a long wild card is found on this level, hold on to it
if(place['**']) last_resort = place['**'];
@@ -366,6 +370,9 @@ class Host extends Table{
// After the tree has been traversed, see if we have leaf node to return.
if(place && place['#record']) return place['#record'];
// If the parent has a wild, its the wildcard we want.
if(parent && parent['*']['#record']) return parent['*']['#record'];
}
static async lookUpReady(){
+7
View File
@@ -35,6 +35,12 @@ app.host = (function(app){
});
}
function clearCache(callack){
app.api.delete('host/cache', function(error, data){
callack(error, data);
});
}
return {
getCert,
list: list,
@@ -42,5 +48,6 @@ app.host = (function(app){
add: add,
edit: edit,
remove: remove,
clearCache: clearCache,
}
})(app);
+1 -1
View File
@@ -415,7 +415,7 @@ function formAJAX(btn){
var method = ($form.attr('method') || 'post').toLowerCase();
if($form.validate && !$form.validate()){
app.util.actionMessage('Please fix the form errors.', $form, 'danger')
app.util.actionMessage('Please fix the form errors.', $form, 'danger');
return false;
}
+13
View File
@@ -52,6 +52,19 @@ router.get('/lookupobj', async function(req, res, next){
}
});
router.delete('/cache', async function(req, res, next){
try{
let count = await Model.clearCache();
return res.json({
message: `Cleared ${count} cached host${count === 1 ? '' : 's'}.`,
count,
});
}catch(error){
return next(error);
}
});
router.get('/:item', async function(req, res, next){
try{
+16
View File
@@ -148,6 +148,18 @@
}
}
function hostClearCache(btn){
let $btn = $(btn);
$btn.prop('disabled', true);
app.host.clearCache(function(error, data){
$btn.prop('disabled', false);
if(error){
return app.util.actionMessage(error.message || error, $.scope.hosts.$this, 'danger');
}
app.util.actionMessage(data.message, $.scope.hosts.$this, 'success');
});
}
async function hostMatchWildcard(host){
try{
let res = await app.api.get(`host/lookup/${host}`);
@@ -446,6 +458,10 @@
Proxy List
</span>
<span class="float-end">
<button type="button" class="btn btn-sm btn-outline-secondary me-2" onclick="hostClearCache(this)" title="Clear cached wildcard subdomain lookups">
<i class="fa-solid fa-broom"></i>
Clear Cache
</button>
<i class="fa-solid fa-circle-minus"></i>
</span>
</div>