mirror of
https://github.com/ReaJason/MemShellParty.git
synced 2026-09-21 22:50:42 +08:00
refactor: rename
1. 将枚举 Server 改为字符串常量,使得 memshell 和 probeshell 都能共用 2. 移除 memshell 模块直接内置在 generator 中 3. 通用类从 memshell 移动至 javaweb 下,命名修改,增加辨识度
This commit is contained in:
+1
-1
@@ -1,5 +1,5 @@
|
||||
{
|
||||
"$schema": "https://biomejs.dev/schemas/2.1.3/schema.json",
|
||||
"$schema": "https://biomejs.dev/schemas/2.1.4/schema.json",
|
||||
"vcs": {
|
||||
"enabled": false,
|
||||
"clientKind": "git",
|
||||
|
||||
Binary file not shown.
+4
-4
@@ -14,10 +14,10 @@
|
||||
"lint:fix": "bunx @biomejs/biome check ./ --write"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@biomejs/biome": "2.1.3",
|
||||
"@biomejs/biome": "2.1.4",
|
||||
"@react-router/dev": "^7.8.0",
|
||||
"@types/node": "^24.2.1",
|
||||
"@types/react": "^19.1.9",
|
||||
"@types/react": "^19.1.10",
|
||||
"@types/react-copy-to-clipboard": "^5.0.7",
|
||||
"@types/react-dom": "^19.1.7",
|
||||
"@types/react-syntax-highlighter": "^15.5.13",
|
||||
@@ -25,7 +25,7 @@
|
||||
"rimraf": "^6.0.1",
|
||||
"tailwindcss": "^4.1.11",
|
||||
"typescript": "^5.9.2",
|
||||
"vite": "^7.1.1",
|
||||
"vite": "^7.1.2",
|
||||
"vite-bundle-visualizer": "^1.2.1"
|
||||
},
|
||||
"dependencies": {
|
||||
@@ -36,7 +36,7 @@
|
||||
"clsx": "^2.1.1",
|
||||
"framer-motion": "^12.23.12",
|
||||
"i18next": "^25.3.4",
|
||||
"lucide-react": "^0.537.0",
|
||||
"lucide-react": "^0.539.0",
|
||||
"motion": "^12.23.12",
|
||||
"radix-ui": "^1.4.2",
|
||||
"react": "^19.1.1",
|
||||
|
||||
@@ -1,41 +1,41 @@
|
||||
import {
|
||||
ArrowUpRightIcon,
|
||||
AxeIcon,
|
||||
CommandIcon,
|
||||
NetworkIcon,
|
||||
ServerIcon,
|
||||
ShieldOffIcon,
|
||||
SwordIcon,
|
||||
WaypointsIcon,
|
||||
ZapIcon,
|
||||
ArrowUpRightIcon,
|
||||
AxeIcon,
|
||||
CommandIcon,
|
||||
NetworkIcon,
|
||||
ServerIcon,
|
||||
ShieldOffIcon,
|
||||
SwordIcon,
|
||||
WaypointsIcon,
|
||||
ZapIcon,
|
||||
} from "lucide-react";
|
||||
import { type JSX, useCallback, useEffect, useId, useState } from "react";
|
||||
import { FormProvider, type UseFormReturn } from "react-hook-form";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { AntSwordTabContent } from "@/components/memshell/tabs/antsword-tab";
|
||||
import { BehinderTabContent } from "@/components/memshell/tabs/behinder-tab";
|
||||
import { CommandTabContent } from "@/components/memshell/tabs/command-tab";
|
||||
import {type JSX, useCallback, useEffect, useId, useState} from "react";
|
||||
import {FormProvider, type UseFormReturn} from "react-hook-form";
|
||||
import {useTranslation} from "react-i18next";
|
||||
import {AntSwordTabContent} from "@/components/memshell/tabs/antsword-tab";
|
||||
import {BehinderTabContent} from "@/components/memshell/tabs/behinder-tab";
|
||||
import {CommandTabContent} from "@/components/memshell/tabs/command-tab";
|
||||
import CustomTabContent from "@/components/memshell/tabs/custom-tab";
|
||||
import { GodzillaTabContent } from "@/components/memshell/tabs/godzilla-tab";
|
||||
import { NeoRegTabContent } from "@/components/memshell/tabs/neoreg-tab";
|
||||
import { Suo5TabContent } from "@/components/memshell/tabs/suo5-tab";
|
||||
import { Card, CardContent, CardHeader, CardTitle } from "@/components/ui/card.tsx";
|
||||
import {GodzillaTabContent} from "@/components/memshell/tabs/godzilla-tab";
|
||||
import {NeoRegTabContent} from "@/components/memshell/tabs/neoreg-tab";
|
||||
import {Suo5TabContent} from "@/components/memshell/tabs/suo5-tab";
|
||||
import {Card, CardContent, CardHeader, CardTitle} from "@/components/ui/card.tsx";
|
||||
import {
|
||||
FormControl,
|
||||
FormDescription,
|
||||
FormField,
|
||||
FormFieldItem,
|
||||
FormFieldLabel,
|
||||
FormItem,
|
||||
FormLabel,
|
||||
FormMessage,
|
||||
FormControl,
|
||||
FormDescription,
|
||||
FormField,
|
||||
FormFieldItem,
|
||||
FormFieldLabel,
|
||||
FormItem,
|
||||
FormLabel,
|
||||
FormMessage,
|
||||
} from "@/components/ui/form.tsx";
|
||||
import { Label } from "@/components/ui/label.tsx";
|
||||
import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from "@/components/ui/select.tsx";
|
||||
import { Switch } from "@/components/ui/switch.tsx";
|
||||
import { Tabs, TabsList, TabsTrigger } from "@/components/ui/tabs";
|
||||
import type { ShellFormSchema } from "@/types/schema.ts";
|
||||
import { type MainConfig, type ServerConfig, ShellToolType } from "@/types/shell.ts";
|
||||
import {Label} from "@/components/ui/label.tsx";
|
||||
import {Select, SelectContent, SelectItem, SelectTrigger, SelectValue} from "@/components/ui/select.tsx";
|
||||
import {Switch} from "@/components/ui/switch.tsx";
|
||||
import {Tabs, TabsList, TabsTrigger} from "@/components/ui/tabs";
|
||||
import {type MainConfig, type ServerConfig, ShellToolType} from "@/types/memshell";
|
||||
import type {MemShellFormSchema} from "@/types/schema.ts";
|
||||
|
||||
const shellToolIcons: Record<ShellToolType, JSX.Element> = {
|
||||
[ShellToolType.Behinder]: <ShieldOffIcon className="h-4 w-4" />,
|
||||
@@ -60,7 +60,7 @@ export default function MainConfigCard({
|
||||
servers,
|
||||
}: Readonly<{
|
||||
mainConfig: MainConfig | undefined;
|
||||
form: UseFormReturn<ShellFormSchema>;
|
||||
form: UseFormReturn<MemShellFormSchema>;
|
||||
servers?: ServerConfig;
|
||||
}>) {
|
||||
const [shellToolMap, setShellToolMap] = useState<{
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
import { PackageIcon } from "lucide-react";
|
||||
import { useEffect, useState } from "react";
|
||||
import { FormProvider, type UseFormReturn } from "react-hook-form";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { Card, CardContent, CardHeader, CardTitle } from "@/components/ui/card.tsx";
|
||||
import { FormControl, FormField, FormItem, FormLabel } from "@/components/ui/form.tsx";
|
||||
import { RadioGroup, RadioGroupItem } from "@/components/ui/radio-group.tsx";
|
||||
import type { ShellFormSchema } from "@/types/schema.ts";
|
||||
import type { PackerConfig } from "@/types/shell.ts";
|
||||
import {PackageIcon} from "lucide-react";
|
||||
import {useEffect, useState} from "react";
|
||||
import {FormProvider, type UseFormReturn} from "react-hook-form";
|
||||
import {useTranslation} from "react-i18next";
|
||||
import {Card, CardContent, CardHeader, CardTitle} from "@/components/ui/card.tsx";
|
||||
import {FormControl, FormField, FormItem, FormLabel} from "@/components/ui/form.tsx";
|
||||
import {RadioGroup, RadioGroupItem} from "@/components/ui/radio-group.tsx";
|
||||
import type {PackerConfig} from "@/types/memshell";
|
||||
import type {MemShellFormSchema} from "@/types/schema.ts";
|
||||
|
||||
type Option = {
|
||||
name: string;
|
||||
@@ -18,7 +18,7 @@ export default function PackageConfigCard({
|
||||
form,
|
||||
}: Readonly<{
|
||||
packerConfig: PackerConfig | undefined;
|
||||
form: UseFormReturn<ShellFormSchema>;
|
||||
form: UseFormReturn<MemShellFormSchema>;
|
||||
}>) {
|
||||
const [options, setOptions] = useState<Array<Option>>([]);
|
||||
|
||||
|
||||
@@ -1,16 +1,16 @@
|
||||
import { ScrollTextIcon } from "lucide-react";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { Button } from "@/components/ui/button";
|
||||
import { Card, CardContent, CardHeader, CardTitle } from "@/components/ui/card";
|
||||
import { Separator } from "@/components/ui/separator";
|
||||
import { downloadBytes, formatBytes } from "@/lib/utils";
|
||||
import type { GenerateResult } from "@/types/shell";
|
||||
import {ScrollTextIcon} from "lucide-react";
|
||||
import {useTranslation} from "react-i18next";
|
||||
import {Button} from "@/components/ui/button";
|
||||
import {Card, CardContent, CardHeader, CardTitle} from "@/components/ui/card";
|
||||
import {Separator} from "@/components/ui/separator";
|
||||
import {downloadBytes, formatBytes} from "@/lib/utils";
|
||||
import type {MemShellResult} from "@/types/memshell";
|
||||
|
||||
export function AgentResult({
|
||||
packMethod,
|
||||
packResult,
|
||||
generateResult,
|
||||
}: Readonly<{ packMethod: string; packResult: string; generateResult?: GenerateResult }>) {
|
||||
}: Readonly<{ packMethod: string; packResult: string; generateResult?: MemShellResult }>) {
|
||||
const { t } = useTranslation();
|
||||
const isPureAgent = packMethod === "AgentJar";
|
||||
return (
|
||||
|
||||
@@ -1,22 +1,22 @@
|
||||
import { FileTextIcon } from "lucide-react";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { Card, CardContent, CardHeader, CardTitle } from "@/components/ui/card";
|
||||
import { Separator } from "@/components/ui/separator";
|
||||
import { shouldHidden } from "@/lib/utils";
|
||||
import {FileTextIcon} from "lucide-react";
|
||||
import {useTranslation} from "react-i18next";
|
||||
import {Card, CardContent, CardHeader, CardTitle} from "@/components/ui/card";
|
||||
import {Separator} from "@/components/ui/separator";
|
||||
import {shouldHidden} from "@/lib/utils";
|
||||
import {
|
||||
type AntSwordShellToolConfig,
|
||||
type BehinderShellToolConfig,
|
||||
type CommandShellToolConfig,
|
||||
type GenerateResult,
|
||||
type GodzillaShellToolConfig,
|
||||
type NeoreGeorgShellToolConfig,
|
||||
ShellToolType,
|
||||
type Suo5ShellToolConfig,
|
||||
} from "@/types/shell";
|
||||
import { CopyableField } from "../../copyable-field";
|
||||
import { FeedbackAlert } from "./feedback-alert";
|
||||
type AntSwordShellToolConfig,
|
||||
type BehinderShellToolConfig,
|
||||
type CommandShellToolConfig,
|
||||
type GodzillaShellToolConfig,
|
||||
type MemShellResult,
|
||||
type NeoreGeorgShellToolConfig,
|
||||
ShellToolType,
|
||||
type Suo5ShellToolConfig,
|
||||
} from "@/types/memshell";
|
||||
import {CopyableField} from "../../copyable-field";
|
||||
import {FeedbackAlert} from "./feedback-alert";
|
||||
|
||||
export function BasicInfo({ generateResult }: Readonly<{ generateResult?: GenerateResult }>) {
|
||||
export function BasicInfo({ generateResult }: Readonly<{ generateResult?: MemShellResult }>) {
|
||||
const { t } = useTranslation();
|
||||
return (
|
||||
<Card>
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { Button } from "@/components/ui/button";
|
||||
import { downloadBytes } from "@/lib/utils";
|
||||
import type { GenerateResult } from "@/types/shell";
|
||||
import {useTranslation} from "react-i18next";
|
||||
import {Button} from "@/components/ui/button";
|
||||
import {downloadBytes} from "@/lib/utils";
|
||||
import type {MemShellResult} from "@/types/memshell";
|
||||
|
||||
export function JarResult({
|
||||
packResult,
|
||||
generateResult,
|
||||
}: Readonly<{ packResult: string; generateResult?: GenerateResult }>) {
|
||||
}: Readonly<{ packResult: string; generateResult?: MemShellResult }>) {
|
||||
const { t } = useTranslation();
|
||||
return (
|
||||
<div className="flex items-center justify-center">
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
import { useTranslation } from "react-i18next";
|
||||
import {useTranslation} from "react-i18next";
|
||||
import CodeViewer from "@/components/code-viewer";
|
||||
import type { GenerateResult } from "@/types/shell";
|
||||
import { AgentResult } from "./agent";
|
||||
import { JarResult } from "./jar-result";
|
||||
import { MultiPackResult } from "./multi-packer";
|
||||
import type {MemShellResult} from "@/types/memshell";
|
||||
import {AgentResult} from "./agent";
|
||||
import {JarResult} from "./jar-result";
|
||||
import {MultiPackResult} from "./multi-packer";
|
||||
|
||||
export function ResultComponent({
|
||||
packResult,
|
||||
@@ -14,7 +14,7 @@ export function ResultComponent({
|
||||
packResult: string | undefined;
|
||||
allPackResults: Map<string, string> | undefined;
|
||||
packMethod: string;
|
||||
generateResult?: GenerateResult;
|
||||
generateResult?: MemShellResult;
|
||||
}>) {
|
||||
const showCode = packMethod === "JSP";
|
||||
const isAgent = packMethod.startsWith("Agent");
|
||||
|
||||
@@ -1,15 +1,15 @@
|
||||
import { DownloadIcon } from "lucide-react";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { toast } from "sonner";
|
||||
import {DownloadIcon} from "lucide-react";
|
||||
import {useTranslation} from "react-i18next";
|
||||
import {toast} from "sonner";
|
||||
|
||||
import { QuickUsage } from "@/components/memshell/quick-usage";
|
||||
import { Button } from "@/components/ui/button.tsx";
|
||||
import { Tabs, TabsContent, TabsList, TabsTrigger } from "@/components/ui/tabs.tsx";
|
||||
import { downloadBytes } from "@/lib/utils.ts";
|
||||
import type { GenerateResult } from "@/types/shell.ts";
|
||||
import {QuickUsage} from "@/components/memshell/quick-usage";
|
||||
import {Button} from "@/components/ui/button.tsx";
|
||||
import {Tabs, TabsContent, TabsList, TabsTrigger} from "@/components/ui/tabs.tsx";
|
||||
import {downloadBytes} from "@/lib/utils.ts";
|
||||
import type {MemShellResult} from "@/types/memshell";
|
||||
import CodeViewer from "../code-viewer";
|
||||
import { BasicInfo } from "./results/basic-info";
|
||||
import { ResultComponent } from "./results/result-component";
|
||||
import {BasicInfo} from "./results/basic-info";
|
||||
import {ResultComponent} from "./results/result-component";
|
||||
|
||||
export default function ShellResult({
|
||||
packResult,
|
||||
@@ -20,7 +20,7 @@ export default function ShellResult({
|
||||
packResult: string | undefined;
|
||||
allPackResults: Map<string, string> | undefined;
|
||||
packMethod: string;
|
||||
generateResult?: GenerateResult;
|
||||
generateResult?: MemShellResult;
|
||||
}>) {
|
||||
const { t } = useTranslation();
|
||||
if (!generateResult) {
|
||||
|
||||
@@ -1,18 +1,18 @@
|
||||
import { FormProvider, type UseFormReturn } from "react-hook-form";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { Card, CardContent } from "@/components/ui/card";
|
||||
import { FormControl, FormField, FormFieldItem, FormFieldLabel } from "@/components/ui/form";
|
||||
import { Input } from "@/components/ui/input";
|
||||
import { TabsContent } from "@/components/ui/tabs";
|
||||
import type { ShellFormSchema } from "@/types/schema";
|
||||
import { OptionalClassFormField } from "./classname-field";
|
||||
import { ShellTypeFormField } from "./shelltype-field";
|
||||
import { UrlPatternFormField } from "./urlpattern-field";
|
||||
import {FormProvider, type UseFormReturn} from "react-hook-form";
|
||||
import {useTranslation} from "react-i18next";
|
||||
import {Card, CardContent} from "@/components/ui/card";
|
||||
import {FormControl, FormField, FormFieldItem, FormFieldLabel} from "@/components/ui/form";
|
||||
import {Input} from "@/components/ui/input";
|
||||
import {TabsContent} from "@/components/ui/tabs";
|
||||
import type {MemShellFormSchema} from "@/types/schema";
|
||||
import {OptionalClassFormField} from "./classname-field";
|
||||
import {ShellTypeFormField} from "./shelltype-field";
|
||||
import {UrlPatternFormField} from "./urlpattern-field";
|
||||
|
||||
export function AntSwordTabContent({
|
||||
form,
|
||||
shellTypes,
|
||||
}: Readonly<{ form: UseFormReturn<ShellFormSchema>; shellTypes: Array<string> }>) {
|
||||
}: Readonly<{ form: UseFormReturn<MemShellFormSchema>; shellTypes: Array<string> }>) {
|
||||
const { t } = useTranslation();
|
||||
return (
|
||||
<FormProvider {...form}>
|
||||
|
||||
@@ -1,18 +1,18 @@
|
||||
import { FormProvider, type UseFormReturn } from "react-hook-form";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { Card, CardContent } from "@/components/ui/card";
|
||||
import { FormField, FormFieldItem, FormFieldLabel } from "@/components/ui/form";
|
||||
import { Input } from "@/components/ui/input";
|
||||
import { TabsContent } from "@/components/ui/tabs";
|
||||
import type { ShellFormSchema } from "@/types/schema";
|
||||
import { OptionalClassFormField } from "./classname-field";
|
||||
import { ShellTypeFormField } from "./shelltype-field";
|
||||
import { UrlPatternFormField } from "./urlpattern-field";
|
||||
import {FormProvider, type UseFormReturn} from "react-hook-form";
|
||||
import {useTranslation} from "react-i18next";
|
||||
import {Card, CardContent} from "@/components/ui/card";
|
||||
import {FormField, FormFieldItem, FormFieldLabel} from "@/components/ui/form";
|
||||
import {Input} from "@/components/ui/input";
|
||||
import {TabsContent} from "@/components/ui/tabs";
|
||||
import type {MemShellFormSchema} from "@/types/schema";
|
||||
import {OptionalClassFormField} from "./classname-field";
|
||||
import {ShellTypeFormField} from "./shelltype-field";
|
||||
import {UrlPatternFormField} from "./urlpattern-field";
|
||||
|
||||
export function BehinderTabContent({
|
||||
form,
|
||||
shellTypes,
|
||||
}: Readonly<{ form: UseFormReturn<ShellFormSchema>; shellTypes: Array<string> }>) {
|
||||
}: Readonly<{ form: UseFormReturn<MemShellFormSchema>; shellTypes: Array<string> }>) {
|
||||
const { t } = useTranslation();
|
||||
return (
|
||||
<FormProvider {...form}>
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
import { ChevronDown, ChevronUp, Settings } from "lucide-react";
|
||||
import { Fragment, useId, useState } from "react";
|
||||
import { FormProvider, type UseFormReturn } from "react-hook-form";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { Button } from "@/components/ui/button";
|
||||
import { FormField, FormFieldItem, FormFieldLabel } from "@/components/ui/form.tsx";
|
||||
import { Input } from "@/components/ui/input.tsx";
|
||||
import type { ShellFormSchema } from "@/types/schema.ts";
|
||||
import {ChevronDown, ChevronUp, Settings} from "lucide-react";
|
||||
import {Fragment, useId, useState} from "react";
|
||||
import {FormProvider, type UseFormReturn} from "react-hook-form";
|
||||
import {useTranslation} from "react-i18next";
|
||||
import {Button} from "@/components/ui/button";
|
||||
import {FormField, FormFieldItem, FormFieldLabel} from "@/components/ui/form.tsx";
|
||||
import {Input} from "@/components/ui/input.tsx";
|
||||
import type {MemShellFormSchema} from "@/types/schema.ts";
|
||||
|
||||
export function OptionalClassFormField({ form }: Readonly<{ form: UseFormReturn<ShellFormSchema> }>) {
|
||||
export function OptionalClassFormField({ form }: Readonly<{ form: UseFormReturn<MemShellFormSchema> }>) {
|
||||
const { t } = useTranslation();
|
||||
const [showAdvanced, setShowAdvanced] = useState(false);
|
||||
const shellClassNameId = useId();
|
||||
|
||||
@@ -1,21 +1,21 @@
|
||||
import { useQuery } from "@tanstack/react-query";
|
||||
import { FormProvider, type UseFormReturn } from "react-hook-form";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { Card, CardContent } from "@/components/ui/card";
|
||||
import { FormControl, FormField, FormFieldItem, FormFieldLabel } from "@/components/ui/form";
|
||||
import { Input } from "@/components/ui/input";
|
||||
import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from "@/components/ui/select";
|
||||
import { TabsContent } from "@/components/ui/tabs";
|
||||
import { env } from "@/config";
|
||||
import type { ShellFormSchema } from "@/types/schema";
|
||||
import { OptionalClassFormField } from "./classname-field";
|
||||
import { ShellTypeFormField } from "./shelltype-field";
|
||||
import { UrlPatternFormField } from "./urlpattern-field";
|
||||
import {useQuery} from "@tanstack/react-query";
|
||||
import {FormProvider, type UseFormReturn} from "react-hook-form";
|
||||
import {useTranslation} from "react-i18next";
|
||||
import {Card, CardContent} from "@/components/ui/card";
|
||||
import {FormControl, FormField, FormFieldItem, FormFieldLabel} from "@/components/ui/form";
|
||||
import {Input} from "@/components/ui/input";
|
||||
import {Select, SelectContent, SelectItem, SelectTrigger, SelectValue} from "@/components/ui/select";
|
||||
import {TabsContent} from "@/components/ui/tabs";
|
||||
import {env} from "@/config";
|
||||
import type {MemShellFormSchema} from "@/types/schema";
|
||||
import {OptionalClassFormField} from "./classname-field";
|
||||
import {ShellTypeFormField} from "./shelltype-field";
|
||||
import {UrlPatternFormField} from "./urlpattern-field";
|
||||
|
||||
export function CommandTabContent({
|
||||
form,
|
||||
shellTypes,
|
||||
}: Readonly<{ form: UseFormReturn<ShellFormSchema>; shellTypes: Array<string> }>) {
|
||||
}: Readonly<{ form: UseFormReturn<MemShellFormSchema>; shellTypes: Array<string> }>) {
|
||||
const { t } = useTranslation();
|
||||
const { data } = useQuery<{ encryptors: Array<string>; implementationClasses: Array<string> }>({
|
||||
queryKey: ["commandConfigs"],
|
||||
|
||||
@@ -1,22 +1,22 @@
|
||||
import { t } from "i18next";
|
||||
import { useId, useState } from "react";
|
||||
import { FormProvider, type UseFormReturn } from "react-hook-form";
|
||||
import { Card, CardContent } from "@/components/ui/card";
|
||||
import { FormControl, FormField, FormFieldItem, FormFieldLabel, FormMessage } from "@/components/ui/form";
|
||||
import { Input } from "@/components/ui/input";
|
||||
import { Label } from "@/components/ui/label";
|
||||
import { RadioGroup, RadioGroupItem } from "@/components/ui/radio-group";
|
||||
import { TabsContent } from "@/components/ui/tabs";
|
||||
import { Textarea } from "@/components/ui/textarea";
|
||||
import type { ShellFormSchema } from "@/types/schema";
|
||||
import { OptionalClassFormField } from "./classname-field";
|
||||
import { ShellTypeFormField } from "./shelltype-field";
|
||||
import { UrlPatternFormField } from "./urlpattern-field";
|
||||
import {t} from "i18next";
|
||||
import {useId, useState} from "react";
|
||||
import {FormProvider, type UseFormReturn} from "react-hook-form";
|
||||
import {Card, CardContent} from "@/components/ui/card";
|
||||
import {FormControl, FormField, FormFieldItem, FormFieldLabel, FormMessage} from "@/components/ui/form";
|
||||
import {Input} from "@/components/ui/input";
|
||||
import {Label} from "@/components/ui/label";
|
||||
import {RadioGroup, RadioGroupItem} from "@/components/ui/radio-group";
|
||||
import {TabsContent} from "@/components/ui/tabs";
|
||||
import {Textarea} from "@/components/ui/textarea";
|
||||
import type {MemShellFormSchema} from "@/types/schema";
|
||||
import {OptionalClassFormField} from "./classname-field";
|
||||
import {ShellTypeFormField} from "./shelltype-field";
|
||||
import {UrlPatternFormField} from "./urlpattern-field";
|
||||
|
||||
export default function CustomTabContent({
|
||||
form,
|
||||
shellTypes,
|
||||
}: Readonly<{ form: UseFormReturn<ShellFormSchema>; shellTypes: Array<string> }>) {
|
||||
}: Readonly<{ form: UseFormReturn<MemShellFormSchema>; shellTypes: Array<string> }>) {
|
||||
const [isFile, setIsFile] = useState(false);
|
||||
const optionOneId = useId();
|
||||
const optionTwoId = useId();
|
||||
|
||||
@@ -1,18 +1,18 @@
|
||||
import { FormProvider, type UseFormReturn } from "react-hook-form";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { Card, CardContent } from "@/components/ui/card";
|
||||
import { FormField, FormFieldItem, FormFieldLabel } from "@/components/ui/form";
|
||||
import { Input } from "@/components/ui/input";
|
||||
import { TabsContent } from "@/components/ui/tabs";
|
||||
import type { ShellFormSchema } from "@/types/schema";
|
||||
import { OptionalClassFormField } from "./classname-field";
|
||||
import { ShellTypeFormField } from "./shelltype-field";
|
||||
import { UrlPatternFormField } from "./urlpattern-field";
|
||||
import {FormProvider, type UseFormReturn} from "react-hook-form";
|
||||
import {useTranslation} from "react-i18next";
|
||||
import {Card, CardContent} from "@/components/ui/card";
|
||||
import {FormField, FormFieldItem, FormFieldLabel} from "@/components/ui/form";
|
||||
import {Input} from "@/components/ui/input";
|
||||
import {TabsContent} from "@/components/ui/tabs";
|
||||
import type {MemShellFormSchema} from "@/types/schema";
|
||||
import {OptionalClassFormField} from "./classname-field";
|
||||
import {ShellTypeFormField} from "./shelltype-field";
|
||||
import {UrlPatternFormField} from "./urlpattern-field";
|
||||
|
||||
export function GodzillaTabContent({
|
||||
form,
|
||||
shellTypes,
|
||||
}: Readonly<{ form: UseFormReturn<ShellFormSchema>; shellTypes: Array<string> }>) {
|
||||
}: Readonly<{ form: UseFormReturn<MemShellFormSchema>; shellTypes: Array<string> }>) {
|
||||
const { t } = useTranslation();
|
||||
return (
|
||||
<FormProvider {...form}>
|
||||
|
||||
@@ -1,18 +1,18 @@
|
||||
import { FormProvider, type UseFormReturn } from "react-hook-form";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { Card, CardContent } from "@/components/ui/card";
|
||||
import { FormField, FormFieldItem, FormFieldLabel } from "@/components/ui/form";
|
||||
import { Input } from "@/components/ui/input";
|
||||
import { TabsContent } from "@/components/ui/tabs";
|
||||
import type { ShellFormSchema } from "@/types/schema";
|
||||
import { OptionalClassFormField } from "./classname-field";
|
||||
import { ShellTypeFormField } from "./shelltype-field";
|
||||
import { UrlPatternFormField } from "./urlpattern-field";
|
||||
import {FormProvider, type UseFormReturn} from "react-hook-form";
|
||||
import {useTranslation} from "react-i18next";
|
||||
import {Card, CardContent} from "@/components/ui/card";
|
||||
import {FormField, FormFieldItem, FormFieldLabel} from "@/components/ui/form";
|
||||
import {Input} from "@/components/ui/input";
|
||||
import {TabsContent} from "@/components/ui/tabs";
|
||||
import type {MemShellFormSchema} from "@/types/schema";
|
||||
import {OptionalClassFormField} from "./classname-field";
|
||||
import {ShellTypeFormField} from "./shelltype-field";
|
||||
import {UrlPatternFormField} from "./urlpattern-field";
|
||||
|
||||
export function NeoRegTabContent({
|
||||
form,
|
||||
shellTypes,
|
||||
}: Readonly<{ form: UseFormReturn<ShellFormSchema>; shellTypes: Array<string> }>) {
|
||||
}: Readonly<{ form: UseFormReturn<MemShellFormSchema>; shellTypes: Array<string> }>) {
|
||||
const { t } = useTranslation();
|
||||
return (
|
||||
<FormProvider {...form}>
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
import { FormProvider, type UseFormReturn } from "react-hook-form";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { FormControl, FormField, FormFieldItem, FormFieldLabel } from "@/components/ui/form.tsx";
|
||||
import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from "@/components/ui/select.tsx";
|
||||
import type { ShellFormSchema } from "@/types/schema.ts";
|
||||
import {FormProvider, type UseFormReturn} from "react-hook-form";
|
||||
import {useTranslation} from "react-i18next";
|
||||
import {FormControl, FormField, FormFieldItem, FormFieldLabel} from "@/components/ui/form.tsx";
|
||||
import {Select, SelectContent, SelectItem, SelectTrigger, SelectValue} from "@/components/ui/select.tsx";
|
||||
import type {MemShellFormSchema} from "@/types/schema.ts";
|
||||
|
||||
export function ShellTypeFormField({
|
||||
form,
|
||||
shellTypes,
|
||||
}: Readonly<{ form: UseFormReturn<ShellFormSchema>; shellTypes: Array<string> }>) {
|
||||
}: Readonly<{ form: UseFormReturn<MemShellFormSchema>; shellTypes: Array<string> }>) {
|
||||
const { t } = useTranslation();
|
||||
return (
|
||||
<FormProvider {...form}>
|
||||
|
||||
@@ -1,18 +1,18 @@
|
||||
import { FormProvider, type UseFormReturn } from "react-hook-form";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { Card, CardContent } from "@/components/ui/card";
|
||||
import { FormField, FormFieldItem, FormFieldLabel } from "@/components/ui/form";
|
||||
import { Input } from "@/components/ui/input";
|
||||
import { TabsContent } from "@/components/ui/tabs";
|
||||
import type { ShellFormSchema } from "@/types/schema";
|
||||
import { OptionalClassFormField } from "./classname-field";
|
||||
import { ShellTypeFormField } from "./shelltype-field";
|
||||
import { UrlPatternFormField } from "./urlpattern-field";
|
||||
import {FormProvider, type UseFormReturn} from "react-hook-form";
|
||||
import {useTranslation} from "react-i18next";
|
||||
import {Card, CardContent} from "@/components/ui/card";
|
||||
import {FormField, FormFieldItem, FormFieldLabel} from "@/components/ui/form";
|
||||
import {Input} from "@/components/ui/input";
|
||||
import {TabsContent} from "@/components/ui/tabs";
|
||||
import type {MemShellFormSchema} from "@/types/schema";
|
||||
import {OptionalClassFormField} from "./classname-field";
|
||||
import {ShellTypeFormField} from "./shelltype-field";
|
||||
import {UrlPatternFormField} from "./urlpattern-field";
|
||||
|
||||
export function Suo5TabContent({
|
||||
form,
|
||||
shellTypes,
|
||||
}: Readonly<{ form: UseFormReturn<ShellFormSchema>; shellTypes: Array<string> }>) {
|
||||
}: Readonly<{ form: UseFormReturn<MemShellFormSchema>; shellTypes: Array<string> }>) {
|
||||
const { t } = useTranslation();
|
||||
return (
|
||||
<FormProvider {...form}>
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
import { FormProvider, type UseFormReturn } from "react-hook-form";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { FormField, FormFieldItem, FormFieldLabel, FormMessage } from "@/components/ui/form.tsx";
|
||||
import { Input } from "@/components/ui/input.tsx";
|
||||
import { shouldHidden } from "@/lib/utils";
|
||||
import type { ShellFormSchema } from "@/types/schema.ts";
|
||||
import {FormProvider, type UseFormReturn} from "react-hook-form";
|
||||
import {useTranslation} from "react-i18next";
|
||||
import {FormField, FormFieldItem, FormFieldLabel, FormMessage} from "@/components/ui/form.tsx";
|
||||
import {Input} from "@/components/ui/input.tsx";
|
||||
import {shouldHidden} from "@/lib/utils";
|
||||
import type {MemShellFormSchema} from "@/types/schema.ts";
|
||||
|
||||
export function UrlPatternFormField({ form }: Readonly<{ form: UseFormReturn<ShellFormSchema> }>) {
|
||||
export function UrlPatternFormField({ form }: Readonly<{ form: UseFormReturn<MemShellFormSchema> }>) {
|
||||
const { t } = useTranslation();
|
||||
const shellType = form.watch("shellType");
|
||||
return (
|
||||
|
||||
+3
-3
@@ -3,9 +3,9 @@ import { useTranslation } from "react-i18next";
|
||||
import { CopyableField } from "@/components/copyable-field";
|
||||
import { FeedbackAlert } from "@/components/memshell/results/feedback-alert";
|
||||
import { Card, CardContent, CardHeader, CardTitle } from "@/components/ui/card";
|
||||
import type { ProbeGenerateResult } from "@/types/probe";
|
||||
import type { ProbeShellResult } from "@/types/probeshell";
|
||||
|
||||
export function BasicInfo({ generateResult }: Readonly<{ generateResult?: ProbeGenerateResult }>) {
|
||||
export function BasicInfo({ generateResult }: Readonly<{ generateResult?: ProbeShellResult }>) {
|
||||
const { t } = useTranslation();
|
||||
return (
|
||||
<Card>
|
||||
@@ -19,7 +19,7 @@ export function BasicInfo({ generateResult }: Readonly<{ generateResult?: ProbeG
|
||||
</CardTitle>
|
||||
</CardHeader>
|
||||
<CardContent>
|
||||
<div className="grid grid-cols-1 md:grid-cols-2 gap-2">
|
||||
<div className="grid grid-cols-1 gap-2">
|
||||
<CopyableField
|
||||
label={t("mainConfig.shellClassName")}
|
||||
value={generateResult?.shellClassName}
|
||||
+3
-3
@@ -16,8 +16,8 @@ import { Input } from "@/components/ui/input";
|
||||
import { Label } from "@/components/ui/label";
|
||||
import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from "@/components/ui/select";
|
||||
import { Switch } from "@/components/ui/switch";
|
||||
import type { ProbeFormSchema } from "@/types/schema";
|
||||
import type { ServerConfig } from "@/types/shell";
|
||||
import type { ServerConfig } from "@/types/memshell";
|
||||
import type { ProbeShellFormSchema } from "@/types/schema";
|
||||
import { Separator } from "../ui/separator";
|
||||
|
||||
// 常量提取到组件外部
|
||||
@@ -59,7 +59,7 @@ const DEFAULT_FORM_VALUES = {
|
||||
} as const;
|
||||
|
||||
interface MainConfigCardProps {
|
||||
readonly form: UseFormReturn<ProbeFormSchema>;
|
||||
readonly form: UseFormReturn<ProbeShellFormSchema>;
|
||||
readonly servers?: ServerConfig;
|
||||
}
|
||||
|
||||
+3
-3
@@ -5,8 +5,8 @@ import { useTranslation } from "react-i18next";
|
||||
import { Card, CardContent, CardHeader, CardTitle } from "@/components/ui/card.tsx";
|
||||
import { FormControl, FormField, FormItem, FormLabel } from "@/components/ui/form.tsx";
|
||||
import { RadioGroup, RadioGroupItem } from "@/components/ui/radio-group.tsx";
|
||||
import type { ProbeFormSchema } from "@/types/schema";
|
||||
import type { PackerConfig } from "@/types/shell.ts";
|
||||
import type { PackerConfig } from "@/types/memshell";
|
||||
import type { ProbeShellFormSchema } from "@/types/schema";
|
||||
|
||||
type Option = {
|
||||
name: string;
|
||||
@@ -18,7 +18,7 @@ export default function PackageConfigCard({
|
||||
form,
|
||||
}: Readonly<{
|
||||
packerConfig: PackerConfig | undefined;
|
||||
form: UseFormReturn<ProbeFormSchema>;
|
||||
form: UseFormReturn<ProbeShellFormSchema>;
|
||||
}>) {
|
||||
const [options, setOptions] = useState<Array<Option>>([]);
|
||||
const { t } = useTranslation();
|
||||
+3
-3
@@ -1,7 +1,7 @@
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { QuickUsage } from "@/components/probe/quick-usage";
|
||||
import { QuickUsage } from "@/components/probeshell/quick-usage";
|
||||
import { Tabs, TabsContent, TabsList, TabsTrigger } from "@/components/ui/tabs.tsx";
|
||||
import type { ProbeGenerateResult } from "@/types/probe";
|
||||
import type { ProbeShellResult } from "@/types/probeshell";
|
||||
import CodeViewer from "../code-viewer";
|
||||
import { MultiPackResult } from "../memshell/results/multi-packer";
|
||||
import { BasicInfo } from "./basic-info";
|
||||
@@ -15,7 +15,7 @@ export default function ShellResult({
|
||||
packResult: string | undefined;
|
||||
allPackResults: Map<string, string> | undefined;
|
||||
packMethod: string;
|
||||
generateResult?: ProbeGenerateResult;
|
||||
generateResult?: ProbeShellResult;
|
||||
}>) {
|
||||
const { t } = useTranslation();
|
||||
if (!generateResult) {
|
||||
@@ -8,8 +8,8 @@ export const siteConfig = {
|
||||
label: "MemShellGenerator",
|
||||
},
|
||||
{
|
||||
href: "/probe",
|
||||
label: "ProbeGenerator",
|
||||
href: "/probeshell",
|
||||
label: "ProbeShellGenerator",
|
||||
},
|
||||
],
|
||||
};
|
||||
|
||||
+10
-10
@@ -11,16 +11,16 @@ import ShellResult from "@/components/memshell/shell-result";
|
||||
import {Button} from "@/components/ui/button";
|
||||
import {Form} from "@/components/ui/form.tsx";
|
||||
import {env} from "@/config.ts";
|
||||
import {type ShellFormSchema, shellFormSchema, useYupValidationResolver} from "@/types/schema.ts";
|
||||
import {
|
||||
type APIErrorResponse,
|
||||
type GenerateResponse,
|
||||
type GenerateResult,
|
||||
type MainConfig,
|
||||
type MemShellGenerateResponse,
|
||||
type MemShellResult,
|
||||
type PackerConfig,
|
||||
type ServerConfig,
|
||||
ShellToolType,
|
||||
} from "@/types/shell.ts";
|
||||
} from "@/types/memshell";
|
||||
import {type MemShellFormSchema, memShellFormSchema, useYupValidationResolver} from "@/types/schema.ts";
|
||||
import {transformToPostData} from "@/utils/transformer.ts";
|
||||
|
||||
export default function MemShellPage() {
|
||||
@@ -52,7 +52,7 @@ export default function MemShellPage() {
|
||||
|
||||
const { t } = useTranslation();
|
||||
const form = useForm({
|
||||
resolver: useYupValidationResolver(shellFormSchema, t),
|
||||
resolver: useYupValidationResolver(memShellFormSchema, t),
|
||||
defaultValues: {
|
||||
server: urlParams.server ?? "Tomcat",
|
||||
serverVersion: urlParams.serverVersion ?? "unknown",
|
||||
@@ -79,15 +79,15 @@ export default function MemShellPage() {
|
||||
|
||||
const [packResult, setPackResult] = useState<string | undefined>();
|
||||
const [allPackResults, setAllPackResults] = useState<Map<string, string> | undefined>();
|
||||
const [generateResult, setGenerateResult] = useState<GenerateResult>();
|
||||
const [generateResult, setGenerateResult] = useState<MemShellResult>();
|
||||
const [packMethod, setPackMethod] = useState<string>("");
|
||||
const [isActionPending, startTransition] = useTransition();
|
||||
|
||||
const onSubmit = async (data: ShellFormSchema) => {
|
||||
const onSubmit = async (data: MemShellFormSchema) => {
|
||||
startTransition(async () => {
|
||||
try {
|
||||
const postData = transformToPostData(data);
|
||||
const response = await fetch(`${env.API_URL}/generate`, {
|
||||
const response = await fetch(`${env.API_URL}/memshell/generate`, {
|
||||
method: "POST",
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
@@ -101,8 +101,8 @@ export default function MemShellPage() {
|
||||
return;
|
||||
}
|
||||
|
||||
const result = (await response.json()) as GenerateResponse;
|
||||
setGenerateResult(result.generateResult);
|
||||
const result = (await response.json()) as MemShellGenerateResponse;
|
||||
setGenerateResult(result.memShellResult);
|
||||
setPackResult(result.packResult);
|
||||
setAllPackResults(result.allPackResults);
|
||||
setPackMethod(data.packingMethod);
|
||||
|
||||
@@ -4,20 +4,20 @@ import { useState, useTransition } from "react";
|
||||
import { useForm } from "react-hook-form";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { toast } from "sonner";
|
||||
import MainConfigCard from "@/components/probe/main-config-card";
|
||||
import PackageConfigCard from "@/components/probe/package-config-card";
|
||||
import ShellResult from "@/components/probe/shell-result";
|
||||
import MainConfigCard from "@/components/probeshell/main-config-card";
|
||||
import PackageConfigCard from "@/components/probeshell/package-config-card";
|
||||
import ShellResult from "@/components/probeshell/shell-result";
|
||||
import { Button } from "@/components/ui/button";
|
||||
import {
|
||||
Form,
|
||||
} from "@/components/ui/form";
|
||||
import { env } from "@/config";
|
||||
import type { ProbeGenerateResponse, ProbeGenerateResult } from "@/types/probe";
|
||||
import { type ProbeFormSchema, probeFormSchema, useYupValidationProbeResolver } from "@/types/schema";
|
||||
import type { APIErrorResponse, PackerConfig, ServerConfig } from "@/types/shell";
|
||||
import type { APIErrorResponse, PackerConfig, ServerConfig } from "@/types/memshell";
|
||||
import type { ProbeShellGenerateResponse, ProbeShellResult } from "@/types/probeshell";
|
||||
import { type ProbeShellFormSchema, probeShellFormSchema, useYupValidationProbeResolver } from "@/types/schema";
|
||||
import { transformToProbePostData } from "@/utils/transformer";
|
||||
|
||||
export default function ProbeGenerator() {
|
||||
export default function ProbeShellGenerator() {
|
||||
const { data: serverConfig } = useQuery<ServerConfig>({
|
||||
queryKey: ["serverConfig"],
|
||||
queryFn: async () => {
|
||||
@@ -36,8 +36,8 @@ export default function ProbeGenerator() {
|
||||
|
||||
const { t } = useTranslation();
|
||||
|
||||
const form = useForm<ProbeFormSchema>({
|
||||
resolver: useYupValidationProbeResolver(probeFormSchema, t),
|
||||
const form = useForm<ProbeShellFormSchema>({
|
||||
resolver: useYupValidationProbeResolver(probeShellFormSchema, t),
|
||||
defaultValues: {
|
||||
probeMethod: "Sleep",
|
||||
probeContent: "Server",
|
||||
@@ -52,11 +52,11 @@ export default function ProbeGenerator() {
|
||||
|
||||
const [packResult, setPackResult] = useState<string | undefined>();
|
||||
const [allPackResults, setAllPackResults] = useState<Map<string, string> | undefined>();
|
||||
const [generateResult, setGenerateResult] = useState<ProbeGenerateResult>();
|
||||
const [generateResult, setGenerateResult] = useState<ProbeShellResult>();
|
||||
const [packMethod, setPackMethod] = useState<string>("");
|
||||
const [isActionPending, startTransition] = useTransition();
|
||||
|
||||
const onSubmit = async (data: ProbeFormSchema) => {
|
||||
const onSubmit = async (data: ProbeShellFormSchema) => {
|
||||
startTransition(async () => {
|
||||
try {
|
||||
const postData = transformToProbePostData(data);
|
||||
@@ -74,8 +74,8 @@ export default function ProbeGenerator() {
|
||||
return;
|
||||
}
|
||||
|
||||
const result = (await response.json()) as ProbeGenerateResponse;
|
||||
setGenerateResult(result.probeResult);
|
||||
const result = (await response.json()) as ProbeShellGenerateResponse;
|
||||
setGenerateResult(result.probeShellResult);
|
||||
setPackResult(result.packResult);
|
||||
setAllPackResults(result.allPackResults);
|
||||
setPackMethod(data.packingMethod);
|
||||
+7
-7
@@ -1,14 +1,14 @@
|
||||
import {createHashRouter} from "react-router-dom";
|
||||
import RootLayout from "@/components/layouts/root-layout";
|
||||
import {env} from "@/config";
|
||||
import LandingPage from "@/pages/landing";
|
||||
import MemShellPage from "@/pages/memshell";
|
||||
import type {ShellFormSchema} from "@/types/schema";
|
||||
import LandingPage from "./pages/landing";
|
||||
import ProbePage from "./pages/probe";
|
||||
import ProbeShellPage from "@/pages/probeshell";
|
||||
import type {MemShellFormSchema} from "@/types/schema";
|
||||
|
||||
// Function to parse URL parameters into form default values
|
||||
const parseUrlParams = (searchParams: URLSearchParams): Partial<ShellFormSchema> => {
|
||||
const result: Partial<ShellFormSchema> = {};
|
||||
const parseUrlParams = (searchParams: URLSearchParams): Partial<MemShellFormSchema> => {
|
||||
const result: Partial<MemShellFormSchema> = {};
|
||||
|
||||
// Helper function to parse boolean values
|
||||
const parseBoolean = (value: string | null): boolean | undefined => {
|
||||
@@ -72,8 +72,8 @@ export const router = createHashRouter(
|
||||
},
|
||||
},
|
||||
{
|
||||
path: "probe",
|
||||
element: <ProbePage />,
|
||||
path: "probeshell",
|
||||
element: <ProbeShellPage />,
|
||||
},
|
||||
],
|
||||
},
|
||||
|
||||
@@ -87,8 +87,8 @@ export interface MainConfig {
|
||||
|
||||
export type PackerConfig = Array<string>;
|
||||
|
||||
export interface GenerateResponse {
|
||||
generateResult: GenerateResult;
|
||||
export interface MemShellGenerateResponse {
|
||||
memShellResult: MemShellResult;
|
||||
packResult?: string;
|
||||
allPackResults?: Map<string, string>;
|
||||
}
|
||||
@@ -97,7 +97,7 @@ export interface APIErrorResponse {
|
||||
error: string;
|
||||
}
|
||||
|
||||
export interface GenerateResult {
|
||||
export interface MemShellResult {
|
||||
shellClassName: string;
|
||||
shellSize: number;
|
||||
shellBytesBase64Str: string;
|
||||
@@ -51,13 +51,13 @@ export interface PayloadFormValues {
|
||||
packingMethod: string;
|
||||
}
|
||||
|
||||
export interface ProbeGenerateResponse {
|
||||
probeResult: ProbeGenerateResult;
|
||||
export interface ProbeShellGenerateResponse {
|
||||
probeShellResult: ProbeShellResult;
|
||||
packResult?: string;
|
||||
allPackResults?: Map<string, string>;
|
||||
}
|
||||
|
||||
export interface ProbeGenerateResult {
|
||||
export interface ProbeShellResult {
|
||||
shellClassName: string;
|
||||
shellSize: number;
|
||||
shellBytesBase64Str: string;
|
||||
+28
-29
@@ -1,10 +1,10 @@
|
||||
import type { TFunction } from "i18next";
|
||||
import { useCallback } from "react";
|
||||
import type { FieldErrors } from "react-hook-form";
|
||||
import type {TFunction} from "i18next";
|
||||
import {useCallback} from "react";
|
||||
import type {FieldErrors} from "react-hook-form";
|
||||
import * as yup from "yup";
|
||||
import { ShellToolType } from "./shell";
|
||||
import {ShellToolType} from "./memshell";
|
||||
|
||||
export const shellFormSchema = yup.object({
|
||||
export const memShellFormSchema = yup.object({
|
||||
server: yup.string().required().min(1),
|
||||
serverVersion: yup.string().required().min(1),
|
||||
targetJdkVersion: yup.string().optional(),
|
||||
@@ -30,8 +30,8 @@ export const shellFormSchema = yup.object({
|
||||
});
|
||||
|
||||
interface ValidationResult {
|
||||
values: ShellFormSchema;
|
||||
errors: FieldErrors<ShellFormSchema>;
|
||||
values: MemShellFormSchema;
|
||||
errors: FieldErrors<MemShellFormSchema>;
|
||||
}
|
||||
|
||||
const urlPatternIsNeeded = (shellType: string) => {
|
||||
@@ -52,15 +52,15 @@ const isInvalidUrl = (urlPattern: string | undefined) =>
|
||||
|
||||
export const useYupValidationResolver = (validationSchema: yup.ObjectSchema<any>, t: TFunction) =>
|
||||
useCallback(
|
||||
async (data: ShellFormSchema): Promise<ValidationResult> => {
|
||||
async (data: MemShellFormSchema): Promise<ValidationResult> => {
|
||||
try {
|
||||
const values = (await validationSchema.validate(data, {
|
||||
abortEarly: false,
|
||||
})) as ShellFormSchema;
|
||||
})) as MemShellFormSchema;
|
||||
|
||||
const urlPattern: keyof ShellFormSchema = "urlPattern";
|
||||
const shellClassBase64: keyof ShellFormSchema = "shellClassBase64";
|
||||
const serverVersion: keyof ShellFormSchema = "serverVersion";
|
||||
const urlPattern: keyof MemShellFormSchema = "urlPattern";
|
||||
const shellClassBase64: keyof MemShellFormSchema = "shellClassBase64";
|
||||
const serverVersion: keyof MemShellFormSchema = "serverVersion";
|
||||
const errors = {} as any;
|
||||
|
||||
if (urlPatternIsNeeded(values?.shellType) && isInvalidUrl(values?.urlPattern)) {
|
||||
@@ -89,22 +89,22 @@ export const useYupValidationResolver = (validationSchema: yup.ObjectSchema<any>
|
||||
} catch (errors) {
|
||||
if (errors instanceof yup.ValidationError) {
|
||||
return {
|
||||
values: {} as ShellFormSchema,
|
||||
values: {} as MemShellFormSchema,
|
||||
errors: errors.inner.reduce(
|
||||
(allErrors, currentError) => {
|
||||
allErrors[currentError.path as keyof ShellFormSchema] = {
|
||||
allErrors[currentError.path as keyof MemShellFormSchema] = {
|
||||
type: currentError.type ?? "validation",
|
||||
message: currentError.message,
|
||||
};
|
||||
return allErrors;
|
||||
},
|
||||
{} as FieldErrors<ShellFormSchema>,
|
||||
{} as FieldErrors<MemShellFormSchema>,
|
||||
),
|
||||
};
|
||||
}
|
||||
|
||||
return {
|
||||
values: {} as ShellFormSchema,
|
||||
values: {} as MemShellFormSchema,
|
||||
errors: {
|
||||
server: {
|
||||
type: "unknown",
|
||||
@@ -117,11 +117,11 @@ export const useYupValidationResolver = (validationSchema: yup.ObjectSchema<any>
|
||||
[validationSchema, t],
|
||||
);
|
||||
|
||||
export type ShellFormSchema = yup.InferType<typeof shellFormSchema>;
|
||||
export type MemShellFormSchema = yup.InferType<typeof memShellFormSchema>;
|
||||
|
||||
export type ProbeFormSchema = yup.InferType<typeof probeFormSchema>;
|
||||
export type ProbeShellFormSchema = yup.InferType<typeof probeShellFormSchema>;
|
||||
|
||||
export const probeFormSchema = yup.object().shape({
|
||||
export const probeShellFormSchema = yup.object().shape({
|
||||
probeMethod: yup.string().required(),
|
||||
probeContent: yup.string().required(),
|
||||
shellClassName: yup.string().optional(),
|
||||
@@ -139,19 +139,19 @@ export const probeFormSchema = yup.object().shape({
|
||||
});
|
||||
|
||||
interface ProbeValidationResult {
|
||||
values: ProbeFormSchema;
|
||||
errors: FieldErrors<ProbeFormSchema>;
|
||||
values: ProbeShellFormSchema;
|
||||
errors: FieldErrors<ProbeShellFormSchema>;
|
||||
}
|
||||
|
||||
export const useYupValidationProbeResolver = (validationSchema: yup.ObjectSchema<any>, t: TFunction) =>
|
||||
useCallback(
|
||||
async (data: ProbeFormSchema): Promise<ProbeValidationResult> => {
|
||||
async (data: ProbeShellFormSchema): Promise<ProbeValidationResult> => {
|
||||
try {
|
||||
const values = (await validationSchema.validate(data, {
|
||||
abortEarly: false,
|
||||
})) as ProbeFormSchema;
|
||||
})) as ProbeShellFormSchema;
|
||||
|
||||
const host: keyof ProbeFormSchema = "host";
|
||||
const host: keyof ProbeShellFormSchema = "host";
|
||||
const errors = {} as any;
|
||||
|
||||
if (values.probeMethod === "DNSLog" && !values.host) {
|
||||
@@ -165,26 +165,25 @@ export const useYupValidationProbeResolver = (validationSchema: yup.ObjectSchema
|
||||
errors,
|
||||
};
|
||||
} catch (errors) {
|
||||
console.log(errors)
|
||||
if (errors instanceof yup.ValidationError) {
|
||||
return {
|
||||
values: {} as ProbeFormSchema,
|
||||
values: {} as ProbeShellFormSchema,
|
||||
errors: errors.inner.reduce(
|
||||
(allErrors, currentError) => {
|
||||
allErrors[currentError.path as keyof ProbeFormSchema] = {
|
||||
allErrors[currentError.path as keyof ProbeShellFormSchema] = {
|
||||
type: currentError.type ?? "validation",
|
||||
message: currentError.message,
|
||||
};
|
||||
console.log(allErrors)
|
||||
return allErrors;
|
||||
},
|
||||
{} as FieldErrors<ProbeFormSchema>,
|
||||
{} as FieldErrors<ProbeShellFormSchema>,
|
||||
),
|
||||
};
|
||||
}
|
||||
|
||||
return {
|
||||
values: {} as ProbeFormSchema,
|
||||
values: {} as ProbeShellFormSchema,
|
||||
errors: {
|
||||
server: {
|
||||
type: "unknown",
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
import type {ProbeConfig, ProbeContentConfig} from "@/types/probe";
|
||||
import type {ProbeFormSchema, ShellFormSchema} from "@/types/schema.ts";
|
||||
import type {InjectorConfig, ShellConfig, ShellToolConfig} from "@/types/shell.ts";
|
||||
import type {InjectorConfig, ShellConfig, ShellToolConfig} from "@/types/memshell";
|
||||
import type {ProbeConfig, ProbeContentConfig} from "@/types/probeshell";
|
||||
import type {MemShellFormSchema, ProbeShellFormSchema} from "@/types/schema.ts";
|
||||
|
||||
export function transformToPostData(formValue: ShellFormSchema) {
|
||||
export function transformToPostData(formValue: MemShellFormSchema) {
|
||||
const shellConfig: ShellConfig = {
|
||||
server: formValue.server,
|
||||
serverVersion: formValue.serverVersion,
|
||||
@@ -39,7 +39,7 @@ export function transformToPostData(formValue: ShellFormSchema) {
|
||||
};
|
||||
}
|
||||
|
||||
export function transformToProbePostData(formValue: ProbeFormSchema) {
|
||||
export function transformToProbePostData(formValue: ProbeShellFormSchema) {
|
||||
const probeConfig: ProbeConfig = {
|
||||
probeMethod: formValue.probeMethod,
|
||||
probeContent: formValue.probeContent,
|
||||
@@ -69,7 +69,7 @@ export function transformToProbePostData(formValue: ProbeFormSchema) {
|
||||
* @param values The form values
|
||||
* @returns A URL string with query parameters
|
||||
*/
|
||||
export function generateShareableUrl(values: ShellFormSchema): string {
|
||||
export function generateShareableUrl(values: MemShellFormSchema): string {
|
||||
const params = new URLSearchParams();
|
||||
|
||||
// Helper function to add parameters only if they have non-default values
|
||||
|
||||
Reference in New Issue
Block a user