Skip to content

Commit

Permalink
fix: make sure the A record for the app domain has a TTL.
Browse files Browse the repository at this point in the history
  • Loading branch information
zicklag committed Nov 5, 2024
1 parent 4f1d873 commit e12ad17
Showing 1 changed file with 17 additions and 4 deletions.
21 changes: 17 additions & 4 deletions src/lib/dns/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -120,10 +120,23 @@ export async function startDnsServer() {
});

// Add an A record that will direct web traffic to the app
const staticRecords = new DefaultStore();
const appDomain = pubenv.PUBLIC_DOMAIN.split(':')[0];
staticRecords.set(appDomain, 'A', APP_IPS);
s.use(staticRecords.handler);
s.use(async (req, res, next) => {
if (res.finished) return next();
const question = req.packet.questions[0];

if (question.name == pubenv.PUBLIC_DOMAIN.split(':')[0] && question.type == 'A') {
res.answer(
APP_IPS.map((ip) => ({
name: question.name,
type: 'A',
data: ip,
ttl: DNS_TTL
}))
);
}

next();
});

// Reject queries that are not valid domain names
s.use(async (req, res, next) => {
Expand Down

0 comments on commit e12ad17

Please sign in to comment.