Skip to content

Commit 4678b6f

Browse files
authored
update dhp function based on risk-involved bank account scenario
1. nhp agent exposes http service to support external access. 2. nhp agent supports to register trusted applicatiiotn and exposes functions with http endpoint. 3. support remote attestation of hygon CSV 4. NHP server as light-weight storage supports to download and upload file 5. dhp quick start Co-authored-by: wenhulove333@163.com <Zhang Wenhu>
1 parent ecd2470 commit 4678b6f

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

68 files changed

+3780
-192
lines changed

Makefile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,8 @@ agentd:
8484
@echo "$(COLOUR_BLUE)[OpenNHP] Building nhp-agent... $(END_COLOUR)"
8585
cd endpoints && \
8686
go build -trimpath -ldflags ${LD_FLAGS} -v -o ../release/nhp-agent/nhp-agentd ./agent/main/main.go && \
87-
cp ./agent/main/etc/*.toml ../release/nhp-agent/etc/
87+
cp ./agent/main/etc/*.toml ../release/nhp-agent/etc/ && \
88+
cp -rf ./agent/main/etc/certs ../release/nhp-agent/etc/
8889

8990
acd:
9091
@echo "$(COLOUR_BLUE)[OpenNHP] Building nhp-ac... $(END_COLOUR)"

docker/Dockerfile.ac

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,12 @@ WORKDIR /nhp-server
44
COPY . .
55

66
RUN echo "Building for architecture: ${TARGETARCH}"
7-
##
7+
##
88
ENV GOPROXY=https://goproxy.cn,direct
99

1010
RUN cd /nhp-server && make init acd test
1111

12-
FROM ubuntu:20.04 AS runtime
12+
FROM ubuntu:22.04 AS runtime
1313
ENV DEBIAN_FRONTEND=noninteractive
1414
RUN apt-get update && \
1515
apt-get install -y wget \
@@ -21,7 +21,7 @@ RUN apt-get update && \
2121
git \
2222
curl \
2323
telnet \
24-
&& rm -rf /var/lib/apt/lists/*
24+
&& rm -rf /var/lib/apt/lists/*
2525

2626
# Traefik version
2727
ARG TRAEFIK_VERSION=v2.10.4
@@ -35,8 +35,8 @@ RUN tar -zxvf traefik.tar.gz && \
3535
mv traefik /opt/traefik/ && \
3636
chmod +x /opt/traefik/traefik && \
3737
rm -rf /tmp/*
38-
39-
COPY --from=builder /nhp-server/release/nhp-ac /nhp-ac
38+
39+
COPY --from=builder /nhp-server/release/nhp-ac /nhp-ac
4040
COPY --from=builder /nhp-server/docker/iptables_defaults_ubuntu.sh /iptables_defaults_ubuntu.sh
4141
COPY --from=builder /nhp-server/docker/iptables_defaults_x86.sh /iptables_defaults_x86.sh
4242
RUN if [ "$(uname -m)" = "x86_64" ]; then \

docker/Dockerfile.agent

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ WORKDIR /workdir
55
COPY . .
66

77
RUN echo "Building for architecture: ${TARGETARCH}"
8-
##
8+
##
99
ENV GOPROXY=https://goproxy.cn,direct
1010

1111
RUN cd /workdir && cat Makefile && make init agentd test
@@ -23,7 +23,7 @@ RUN apt-get update && \
2323
curl \
2424
inetutils-ping \
2525
telnet \
26-
&& rm -rf /var/lib/apt/lists/*
26+
&& rm -rf /var/lib/apt/lists/*
2727
RUN groupadd -r nginx && \
2828
useradd -r -g nginx -s /bin/bash -d /home/nginx -m nginx
2929

docker/Dockerfile.app

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM --platform=$BUILDPLATFORM ubuntu:20.04 AS builder
1+
FROM --platform=$BUILDPLATFORM ubuntu:22.04 AS builder
22

33
# Get target platform architecture
44
ARG TARGETARCH
@@ -57,13 +57,13 @@ WORKDIR /app
5757

5858
# Copy the source code
5959
COPY ./web-app .
60-
##
60+
##
6161
ENV GOPROXY=https://goproxy.cn,direct
6262
# Build the application
6363
RUN CGO_ENABLED=0 GOOS=linux go mod tidy && go build -o app
6464

6565
# Stage 2: Create a minimal runtime image
66-
FROM ubuntu:20.04
66+
FROM ubuntu:22.04
6767
RUN apt-get update && \
6868
apt-get install -y --no-install-recommends \
6969
build-essential \

docker/Dockerfile.base

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM --platform=$BUILDPLATFORM ubuntu:20.04 AS builder
1+
FROM --platform=$BUILDPLATFORM ubuntu:22.04 AS builder
22

33
# Get target platform architecture
44
ARG TARGETARCH
@@ -15,6 +15,7 @@ RUN apt-get update && \
1515
tcpdump \
1616
ipset \
1717
git \
18+
vim \
1819
&& rm -rf /var/lib/apt/lists/*
1920

2021
# Set Go version

docker/Dockerfile.db

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
FROM opennhp-base:latest AS builder
2+
3+
WORKDIR /workdir
4+
5+
COPY . .
6+
7+
RUN echo "Building for architecture: ${TARGETARCH}"
8+
##
9+
ENV GOPROXY=https://goproxy.cn,direct
10+
11+
RUN cd /workdir && cat Makefile && make init db test
12+
13+
ENV DEBIAN_FRONTEND=noninteractive
14+
RUN apt-get update && \
15+
apt-get install -y wget \
16+
ca-certificates \
17+
tcpdump \
18+
curl \
19+
&& rm -rf /var/lib/apt/lists/*
20+
21+
RUN mv /workdir/release/nhp-db /nhp-db
22+
USER root
23+
24+
CMD ["tail", "-f", "/dev/null"]

docker/Dockerfile.server

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,12 @@ WORKDIR /nhp-server
55
COPY . .
66

77
RUN echo "Building for architecture: ${TARGETARCH}"
8-
##
8+
##
99
ENV GOPROXY=https://goproxy.cn,direct
1010

1111
RUN cd /nhp-server && make init serverd plugins test
1212

13-
FROM ubuntu:20.04 AS runtime
13+
FROM ubuntu:22.04 AS runtime
1414

1515
ENV DEBIAN_FRONTEND=noninteractive
1616
RUN apt-get update && \
@@ -23,9 +23,10 @@ RUN apt-get update && \
2323
git \
2424
curl \
2525
telnet \
26-
&& rm -rf /var/lib/apt/lists/*
26+
vim \
27+
&& rm -rf /var/lib/apt/lists/*
2728

28-
COPY --from=builder /nhp-server/release/nhp-server /nhp-server
29+
COPY --from=builder /nhp-server/release/nhp-server /nhp-server
2930

3031
ENTRYPOINT ["/bin/sh", "-c"]
3132
CMD ["nginx & /nhp-server/nhp-serverd run"]

docker/docker-compose.dhp.yaml

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
networks:
2+
network_default:
3+
ipam:
4+
driver: default
5+
config:
6+
- subnet: '177.7.0.0/16'
7+
8+
volumes:
9+
postgres_data:
10+
11+
services:
12+
nhp-server:
13+
image: opennhp-server
14+
build:
15+
context: ..
16+
dockerfile: ./docker/Dockerfile.server
17+
container_name: nhp-server
18+
restart: always
19+
networks:
20+
network_default:
21+
ipv4_address: 177.7.0.9
22+
volumes:
23+
- ./nhp-server/etc/:/nhp-server/etc/:rw
24+
- ./nhp-server/logs/:/nhp-server/logs/:rw
25+
- ./nhp-server/templates/:/nhp-server/templates/:rw
26+
- ./nhp-server/plugins/example/etc/:/nhp-server/plugins/example/etc/:rw
27+
28+
nhp-db:
29+
image: opennhp-db
30+
container_name: nhp-db
31+
build:
32+
context: ..
33+
dockerfile: ./docker/Dockerfile.db
34+
volumes:
35+
- ./nhp-db/etc/:/nhp-db/etc/
36+
- ./nhp-db/logs/:/nhp-db/logs/
37+
- ./nhp-db/demo/:/nhp-db/demo/
38+
restart: always
39+
cap_add:
40+
- NET_ADMIN
41+
depends_on:
42+
- nhp-server
43+
networks:
44+
network_default:
45+
ipv4_address: 177.7.0.12
46+
47+
nhp-agent:
48+
image: opennhp-agent:latest
49+
build:
50+
context: ..
51+
dockerfile: ./docker/Dockerfile.agent
52+
container_name: nhp-agent
53+
restart: always
54+
#command: []
55+
ports:
56+
- "8443:443"
57+
networks:
58+
network_default:
59+
ipv4_address: 177.7.0.8
60+
depends_on:
61+
- nhp-server
62+
- nhp-db
63+
volumes:
64+
- ./nhp-agent/etc:/nhp-agent/etc:rw
65+
- ./nhp-agent/logs:/nhp-agent/logs:rw

docker/nhp-ac/etc/config.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ DefaultCipherScheme = 0
1212
UserId = "agent-0"
1313
OrganizationId = "opennhp.cn"
1414
LogLevel = 4
15-
DHPExeCMD = "..\\nhp-de\\nhp-de.exe"
1615
# UserData: a customized user entry for flexibility.
1716
# Its key-value pairs will be send to server along with knock message.
1817
[UserData]
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
-----BEGIN CERTIFICATE-----
2+
MIIDKzCCAhMCFCl+W8SPu1590nfwXgANK1STySQ0MA0GCSqGSIb3DQEBCwUAMFIx
3+
CzAJBgNVBAYTAkNOMRMwEQYDVQQIDApaaGFuZ0ppYW5nMQswCQYDVQQHDAJIWjEL
4+
MAkGA1UECgwCWFMxFDASBgNVBAMMC3Rlc3RAeHMuY29tMB4XDTI1MDcxNTA4MDEx
5+
NVoXDTI2MDcxNTA4MDExNVowUjELMAkGA1UEBhMCQ04xEzARBgNVBAgMClpoYW5n
6+
SmlhbmcxCzAJBgNVBAcMAkhaMQswCQYDVQQKDAJYUzEUMBIGA1UEAwwLdGVzdEB4
7+
cy5jb20wggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQD4O/9vxs1dGFKJ
8+
L+IjwrRIOJDHuoEzTtJQ7fsyAoow9siv+qvIXDJ42+ReJiehDcvtpPosyyScD6rx
9+
ihWH2I+9su29iz7qyE2aeEwDWOkrNcMGfInhCDmT9BvfveKIgh2CJeh5MwJ5zqnL
10+
QAs8t+2OHlBwxCfTzPe4CGsGX0Ry0324ysqkybHVG3k7BCEpk4oebvbWw1Wemq5d
11+
1yHFbwJFcAuPSaM/Jqi1QO1breQu7azFBHq3PexReKxeshgOqrYR3vFE2XpYLR5/
12+
d45S5eK5Vk1fT0F/UoFCM9P8HrOhir1Di0pKNbhp1etTz3wHsWBo62wliP+2D/Cy
13+
7ux3TC3pAgMBAAEwDQYJKoZIhvcNAQELBQADggEBALWM3eqlFuQzkzF1NIwnCxQ0
14+
RZmXhTtsDnqCwgdTzUT7NyXMiLcDQTQusJAi87L+yc5DMaRqPcr+gCHes8YJQ9Cc
15+
FtqAi15TUiyIdKqt82A6vS5Mr5yHcI3EO4WtAArTj9UUdX4X5unig9KHLb1AyQFk
16+
PJoalnmWy+vnxMBhGemo8ousLZrDOWpPRylW/wnafjvGMxNAF03b32MvtggKKT9m
17+
S0XgmHi7eo/FGYCwKSrgsfAWfitZ/izv4KVw9T4g8m7rSoleTo/0lWKbt1K2U2YR
18+
FoeYltvDOVfgmf1MPlGvyn5llwW4Z1PyR3/mReELJEh79O01KwLc+nJ1oAsbJ8g=
19+
-----END CERTIFICATE-----

0 commit comments

Comments
 (0)