-
Notifications
You must be signed in to change notification settings - Fork 118
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
58aafc0
commit 465559a
Showing
10 changed files
with
162 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
import { useRuntimeConfig } from '#imports'; | ||
import { db } from '@u22n/database'; | ||
import { eq } from '@u22n/database/orm'; | ||
import { domains } from '@u22n/database/schema'; | ||
import { | ||
eventHandler, | ||
getQuery, | ||
getRouterParam, | ||
send, | ||
setResponseStatus | ||
} from 'h3'; | ||
|
||
export default eventHandler(async (event) => { | ||
const secret = getRouterParam(event, 'secret'); | ||
if (useRuntimeConfig().platform.secret !== secret) { | ||
setResponseStatus(event, 401); | ||
return send(event, 'Unauthorized'); | ||
} | ||
|
||
const domain = getQuery(event).domain; | ||
if (!domain || typeof domain !== 'string') { | ||
setResponseStatus(event, 400); | ||
return send(event, 'Bad Request'); | ||
} | ||
|
||
if (!domain.startsWith('mta-sts.')) { | ||
setResponseStatus(event, 400); | ||
return send(event, 'Bad Request'); | ||
} | ||
|
||
const rootDomain = domain.replace(/^mta-sts\./, ''); | ||
const domainResponse = await db.query.domains.findFirst({ | ||
where: eq(domains.domain, rootDomain) | ||
}); | ||
|
||
if (!domainResponse) { | ||
setResponseStatus(event, 403); | ||
return send(event, 'Forbidden'); | ||
} | ||
|
||
setResponseStatus(event, 200); | ||
return send(event, 'Ok'); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
{ | ||
on_demand_tls { | ||
ask {env.PLATFORM_URL}/caddy-check/{env.PLATFORM_SECRET} | ||
} | ||
} | ||
|
||
https:// { | ||
tls { | ||
on_demand | ||
} | ||
root * ./files | ||
file_server | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
version: STSv1 | ||
mode: enforce | ||
mx: *.e.uninbox.com | ||
max_age: 86400 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters