Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cta more container api #217

Merged
merged 2 commits into from
Sep 6, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 15 additions & 4 deletions packages/compose-tunnel-agent/src/api-server/containers/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,11 @@
import logs from './logs'
import { inspectFilteredContainer } from './filter'

const containerIdActionSchema = z.object({
containerId: z.string(),
action: z.union([z.literal('stop'), z.literal('start'), z.literal('restart')]),
})

export const containers: FastifyPluginAsync<{
docker: Dockerode
dockerFilter: DockerFilterClient
Expand All @@ -20,10 +25,16 @@
schema: {
params: containerIdSchema,
},
}, async ({ params: { containerId } }, res) => {
const container = await inspectFilteredContainer(dockerFilter, containerId)
void res.send(container)
})
}, async ({ params: { containerId } }) => await inspectFilteredContainer(dockerFilter, containerId))

app.post<{
Params: z.infer<typeof containerIdActionSchema>
}>('/:containerId/:action', {
schema: {
params: containerIdActionSchema,
},
preValidation: async ({ params: { containerId } }) => await inspectFilteredContainer(dockerFilter, containerId),
}, async ({ params: { containerId, action } }) => await docker.getContainer(containerId)[action]())
Dismissed Show dismissed Hide dismissed

await app.register(fastifyWebsocket)
await app.register(exec, { docker, dockerFilter })
Expand Down
2 changes: 1 addition & 1 deletion tunnel-server/src/proxy/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ export const proxy = ({

req.url = path ?? '/'

if (activeTunnel.access === 'private') {
if (activeTunnel.access === 'private' && req.method !== 'OPTIONS') {
return {
req: await validatePrivateTunnelRequest(req, activeTunnel, session(activeTunnel.publicKeyThumbprint)),
activeTunnel,
Expand Down
Loading