Compare commits
6 Commits
d5e46e186e
...
master
Author | SHA1 | Date | |
---|---|---|---|
|
f4edb07629 | ||
|
9b9d222546 | ||
|
86d7823aae | ||
|
019652ca67 | ||
|
6d97d437a2 | ||
|
2af30101cc |
47
Dockerfile
Normal file
47
Dockerfile
Normal file
@@ -0,0 +1,47 @@
|
|||||||
|
FROM rust:1.77-bullseye AS builder
|
||||||
|
|
||||||
|
ADD sources.list /etc/apt/
|
||||||
|
RUN apt-get update && apt-get install -y \
|
||||||
|
libc6-dev \
|
||||||
|
libclang-dev \
|
||||||
|
pkg-config \
|
||||||
|
libssl-dev
|
||||||
|
ADD crates.conf /root/.cargo/config
|
||||||
|
RUN USER=root cargo new --bin license_service
|
||||||
|
ADD ./cert_lib /cert_lib
|
||||||
|
WORKDIR /license_service
|
||||||
|
COPY ./license_server/Cargo.toml ./Cargo.toml
|
||||||
|
|
||||||
|
RUN cargo build --release && rm src/*.rs target/release/deps/license_server*
|
||||||
|
|
||||||
|
ADD ./license_server/src ./src
|
||||||
|
|
||||||
|
RUN cargo build --release
|
||||||
|
|
||||||
|
FROM debian:bullseye-slim AS deployer
|
||||||
|
|
||||||
|
ADD sources.list /etc/apt/
|
||||||
|
|
||||||
|
RUN apt-get update && \
|
||||||
|
apt-get install -y ca-certificates tzdata && \
|
||||||
|
rm -rf /var/lib/apt/lists/*
|
||||||
|
|
||||||
|
EXPOSE 8080
|
||||||
|
|
||||||
|
ENV TZ=Asia/Shanghai \
|
||||||
|
APP_USER=license_usr
|
||||||
|
|
||||||
|
RUN groupadd service && \
|
||||||
|
useradd -g service $APP_USER && \
|
||||||
|
mkdir -p /license_service
|
||||||
|
|
||||||
|
COPY --from=builder /license_service/target/release/license_server /license_service/license_server
|
||||||
|
|
||||||
|
RUN chown -R $APP_USER:service /license_service
|
||||||
|
|
||||||
|
USER $APP_USER
|
||||||
|
WORKDIR /license_service
|
||||||
|
|
||||||
|
VOLUME ["/license_service/license.key", "/license_service/license.pem", "/license_service/netfilter.zip", "/license_service/products.json"]
|
||||||
|
|
||||||
|
CMD ["./license_server"]
|
14
crates.conf
Normal file
14
crates.conf
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
[source.crates-io]
|
||||||
|
# To use sparse index, change 'rsproxy' to 'rsproxy-sparse'
|
||||||
|
replace-with = 'rsproxy-sparse'
|
||||||
|
|
||||||
|
[source.rsproxy]
|
||||||
|
registry = "https://rsproxy.cn/crates.io-index"
|
||||||
|
[source.rsproxy-sparse]
|
||||||
|
registry = "sparse+https://rsproxy.cn/index/"
|
||||||
|
|
||||||
|
[registries.rsproxy]
|
||||||
|
index = "https://rsproxy.cn/crates.io-index"
|
||||||
|
|
||||||
|
[net]
|
||||||
|
git-fetch-with-cli = true
|
File diff suppressed because one or more lines are too long
@@ -1,4 +1,3 @@
|
|||||||
#![feature(diagnostic_namespace)]
|
|
||||||
#![allow(dead_code)]
|
#![allow(dead_code)]
|
||||||
|
|
||||||
use tracing::{error, info};
|
use tracing::{error, info};
|
||||||
|
@@ -7,6 +7,7 @@ use tokio::{fs::File, io::AsyncReadExt};
|
|||||||
pub struct Product {
|
pub struct Product {
|
||||||
pub id: String,
|
pub id: String,
|
||||||
pub name: String,
|
pub name: String,
|
||||||
|
pub couple: Vec<String>,
|
||||||
}
|
}
|
||||||
|
|
||||||
static PRODUCTS: OnceLock<Vec<Product>> = OnceLock::new();
|
static PRODUCTS: OnceLock<Vec<Product>> = OnceLock::new();
|
||||||
|
@@ -9,9 +9,9 @@ export function LicenseCode() {
|
|||||||
const licenseCode = useLicenseCodeStore((state) => state.licenceCode);
|
const licenseCode = useLicenseCodeStore((state) => state.licenceCode);
|
||||||
const copyLicenseCode = async () => {
|
const copyLicenseCode = async () => {
|
||||||
if (not(isEmpty(licenseCode))) {
|
if (not(isEmpty(licenseCode))) {
|
||||||
await navigator.clipboard.writeText(licenseCode);
|
await navigator.clipboard.writeText(licenseCode ?? "");
|
||||||
notifications.show({
|
notifications.show({
|
||||||
title: "授权码已复制",
|
message: "授权码已复制",
|
||||||
color: "green",
|
color: "green",
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@@ -80,7 +80,7 @@ async function generateLicense(form: LicenseInfoForm, selectedProducts: string[]
|
|||||||
const validDays = now.add(validYears, "year").diff(now, "day");
|
const validDays = now.add(validYears, "year").diff(now, "day");
|
||||||
if (isEmpty(selectedProducts)) {
|
if (isEmpty(selectedProducts)) {
|
||||||
notifications.show({
|
notifications.show({
|
||||||
title: "至少需要选择一个产品",
|
message: "至少需要选择一个产品",
|
||||||
color: "red",
|
color: "red",
|
||||||
});
|
});
|
||||||
return "";
|
return "";
|
||||||
|
@@ -14,3 +14,6 @@
|
|||||||
overflow-y: auto;
|
overflow-y: auto;
|
||||||
min-height: 0;
|
min-height: 0;
|
||||||
}
|
}
|
||||||
|
.product-item {
|
||||||
|
cursor: pointer;
|
||||||
|
}
|
||||||
|
@@ -91,7 +91,13 @@ function ProductItem(props: ProductItemProps) {
|
|||||||
}, [props.id, selected, append, remove]);
|
}, [props.id, selected, append, remove]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Box px="sm" py="xs" bg={selected ? "green" : "gray"} onClick={handleSelectAction}>
|
<Box
|
||||||
|
px="sm"
|
||||||
|
py="xs"
|
||||||
|
bg={selected ? "green" : "gray"}
|
||||||
|
className={classes["product-item"]}
|
||||||
|
onClick={handleSelectAction}
|
||||||
|
>
|
||||||
<Text size="xs" c={selected ? "white" : "gray"}>
|
<Text size="xs" c={selected ? "white" : "gray"}>
|
||||||
{props.name}
|
{props.name}
|
||||||
</Text>
|
</Text>
|
||||||
|
@@ -1,9 +1,10 @@
|
|||||||
import { concat, pluck, uniq } from "ramda";
|
import { concat, find, pluck, propEq, uniq } from "ramda";
|
||||||
import { create } from "zustand";
|
import { create } from "zustand";
|
||||||
|
|
||||||
interface Product {
|
interface Product {
|
||||||
id: string;
|
id: string;
|
||||||
name: string;
|
name: string;
|
||||||
|
couple: string[];
|
||||||
}
|
}
|
||||||
|
|
||||||
interface ProductsStore {
|
interface ProductsStore {
|
||||||
@@ -18,8 +19,12 @@ interface ProductsStore {
|
|||||||
export const useProductsStore = create<ProductsStore>((set, get) => ({
|
export const useProductsStore = create<ProductsStore>((set, get) => ({
|
||||||
products: [],
|
products: [],
|
||||||
selectedProducts: [],
|
selectedProducts: [],
|
||||||
append: (code: string) =>
|
append: (code: string) => {
|
||||||
set((state) => ({ selectedProducts: [...state.selectedProducts, code] })),
|
const selectedProduct: Product | undefined = find(propEq(code, "id"), get().products);
|
||||||
|
set((state) => ({
|
||||||
|
selectedProducts: uniq([...state.selectedProducts, code, ...(selectedProduct?.couple ?? [])]),
|
||||||
|
}));
|
||||||
|
},
|
||||||
remove: (code: string) =>
|
remove: (code: string) =>
|
||||||
set((state) => ({ selectedProducts: state.selectedProducts.filter((item) => item !== code) })),
|
set((state) => ({ selectedProducts: state.selectedProducts.filter((item) => item !== code) })),
|
||||||
unselectAll: () => set({ selectedProducts: [] }),
|
unselectAll: () => set({ selectedProducts: [] }),
|
||||||
|
@@ -4,5 +4,11 @@ export const theme = createTheme({
|
|||||||
focusRing: "never",
|
focusRing: "never",
|
||||||
fontSmoothing: true,
|
fontSmoothing: true,
|
||||||
defaultRadius: "xs",
|
defaultRadius: "xs",
|
||||||
lineHeights: "xs",
|
lineHeights: {
|
||||||
|
xs: "1.2",
|
||||||
|
sm: "1.25",
|
||||||
|
md: "1.35",
|
||||||
|
lg: "1.4",
|
||||||
|
xl: "1.5",
|
||||||
|
},
|
||||||
});
|
});
|
||||||
|
@@ -1,21 +1,5 @@
|
|||||||
import cx, { ClassDictionary } from "clsx";
|
import cx, { ClassDictionary } from "clsx";
|
||||||
import { defaultTo, isEmpty, isNil, prop } from "ramda";
|
import { isEmpty, isNil, prop } from "ramda";
|
||||||
import { ChangeHandler } from "react-hook-form";
|
|
||||||
|
|
||||||
export function convertFormEvent(
|
|
||||||
name: string,
|
|
||||||
event: InputEvent,
|
|
||||||
property: string = "value",
|
|
||||||
defaultValue?: unknown = null
|
|
||||||
): Parameters<ChangeHandler> {
|
|
||||||
return {
|
|
||||||
target: {
|
|
||||||
name,
|
|
||||||
value: defaultTo(defaultValue)(prop(property, event.currentTarget)),
|
|
||||||
},
|
|
||||||
type: event.type,
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
export function composite(classesDefination: ClassDictionary, ...classes: string[]) {
|
export function composite(classesDefination: ClassDictionary, ...classes: string[]) {
|
||||||
/** @type {import("clsx").ClassArray} */
|
/** @type {import("clsx").ClassArray} */
|
||||||
|
15
sources.list
Normal file
15
sources.list
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
deb http://mirrors.163.com/debian/ bullseye main non-free contrib
|
||||||
|
|
||||||
|
deb http://mirrors.163.com/debian/ bullseye-updates main non-free contrib
|
||||||
|
|
||||||
|
deb http://mirrors.163.com/debian/ bullseye-backports main non-free contrib
|
||||||
|
|
||||||
|
deb-src http://mirrors.163.com/debian/ bullseye main non-free contrib
|
||||||
|
|
||||||
|
deb-src http://mirrors.163.com/debian/ bullseye-updates main non-free contrib
|
||||||
|
|
||||||
|
deb-src http://mirrors.163.com/debian/ bullseye-backports main non-free contrib
|
||||||
|
|
||||||
|
#deb http://mirrors.163.com/debian-security/ bullseye/updates main non-free contrib
|
||||||
|
|
||||||
|
#deb-src http://mirrors.163.com/debian-security/ bullseye/updates main non-free contrib
|
Reference in New Issue
Block a user