Переглянути джерело

prevent raw tcp on port 80 or 443

Milo Schwartz 5 місяців тому
батько
коміт
a7c99b016c

+ 8 - 8
server/routers/resource/createResource.ts

@@ -133,24 +133,24 @@ export async function createResource(
                     )
                 );
 
-            if (existingResource.length > 0) {
+            if (proxyPort === 443 || proxyPort === 80) {
                 return next(
                     createHttpError(
-                        HttpCode.CONFLICT,
-                        "Resource with that protocol and port already exists"
+                        HttpCode.BAD_REQUEST,
+                        "Port 80 and 443 are reserved for https resources"
                     )
                 );
             }
-        } else {
-            if (proxyPort === 443 || proxyPort === 80) {
+
+            if (existingResource.length > 0) {
                 return next(
                     createHttpError(
-                        HttpCode.BAD_REQUEST,
-                        "Port 80 and 443 are reserved for https resources"
+                        HttpCode.CONFLICT,
+                        "Resource with that protocol and port already exists"
                     )
                 );
             }
-
+        } else {
             // make sure the full domain is unique
             const existingResource = await db
                 .select()

+ 1 - 1
src/app/[orgId]/settings/resources/[resourceId]/connectivity/page.tsx

@@ -132,7 +132,7 @@ export default function ReverseProxyTargets(props: {
         defaultValues: {
             ip: "",
             method: resource.http ? "http" : null,
-            port: resource.http ? 80 : resource.proxyPort || 1234
+            port: ""
             // protocol: "TCP",
         }
     });