mirror of
https://github.com/internetee/epp_proxy.git
synced 2025-08-12 10:49:18 +02:00
Upgraded and created dockerfiles
This commit is contained in:
parent
99b714676b
commit
1f40bbf3fb
18 changed files with 343 additions and 94 deletions
|
@ -1,3 +1,3 @@
|
||||||
erlang 21.3.8
|
erlang 23.3.4.20
|
||||||
ruby 2.6.3
|
ruby 3.2.2
|
||||||
rebar 3.11.0
|
rebar 3.15.2
|
||||||
|
|
70
Dockerfile
70
Dockerfile
|
@ -1,44 +1,48 @@
|
||||||
FROM debian:buster-slim
|
FROM debian:bullseye-slim
|
||||||
|
|
||||||
SHELL ["/bin/bash", "-o", "pipefail", "-c"]
|
SHELL ["/bin/bash", "-o", "pipefail", "-c"]
|
||||||
COPY ./docker/apt/sources.list /etc/apt/
|
COPY ./docker/apt/sources.list /etc/apt/
|
||||||
|
|
||||||
RUN apt-get update && apt-get -t buster install -y -qq wget \
|
# Install all dependencies in a single layer to reduce image size
|
||||||
&& apt-get clean \
|
RUN apt-get update && apt-get install -y -qq \
|
||||||
&& rm -rf /var/lib/apt/lists/*
|
wget \
|
||||||
|
git \
|
||||||
|
build-essential \
|
||||||
RUN apt-get update && apt-get install -y -qq git \
|
libncurses5-dev \
|
||||||
&& apt-get clean \
|
automake \
|
||||||
&& rm -rf /var/lib/apt/lists/*
|
autoconf \
|
||||||
|
curl \
|
||||||
RUN apt-get update && apt-get install -y \
|
ca-certificates \
|
||||||
build-essential=* \
|
libssl-dev \
|
||||||
libncurses5-dev=* \
|
libreadline-dev \
|
||||||
automake=* \
|
libdpkg-perl \
|
||||||
autoconf=* \
|
liberror-perl \
|
||||||
curl=* \
|
libc6 \
|
||||||
ca-certificates=* \
|
|
||||||
libssl-dev=* \
|
|
||||||
libreadline-dev=* \
|
|
||||||
libdpkg-perl=* \
|
|
||||||
liberror-perl=* \
|
|
||||||
libc6=* \
|
|
||||||
libc-dev \
|
libc-dev \
|
||||||
perl=* \
|
perl \
|
||||||
procps=* \
|
procps \
|
||||||
inotify-tools=* \
|
inotify-tools \
|
||||||
libssl1.1=* \
|
libssl1.1 \
|
||||||
perl-base=* \
|
perl-base \
|
||||||
zlib1g-dev \
|
zlib1g-dev \
|
||||||
|
# Additional dependencies for Erlang build
|
||||||
|
libncurses-dev \
|
||||||
|
libsctp-dev \
|
||||||
|
# Documentation tools to prevent build failures
|
||||||
|
xsltproc \
|
||||||
|
libxml2-utils \
|
||||||
|
# Dependencies for Ruby 3.2.2
|
||||||
|
libffi-dev \
|
||||||
|
libyaml-dev \
|
||||||
&& apt-get clean \
|
&& apt-get clean \
|
||||||
&& rm -rf /var/lib/apt/lists/*
|
&& rm -rf /var/lib/apt/lists/*
|
||||||
|
|
||||||
# RUN (groupadd -g 999 asdf || true)
|
# Set environment variables for Erlang build
|
||||||
# RUN (adduser --shell /bin/bash --home /asdf --disabled-password -gid 999 -u 999 asdf || true)
|
ENV KERL_CONFIGURE_OPTIONS="--disable-debug --without-javac --without-wx --without-odbc --disable-hipe --without-jinterface --without-docs"
|
||||||
# ENV PATH="${PATH}:/asdf/.asdf/shims:/asdf/.asdf/bin"
|
ENV KERL_BUILD_DOCS="no"
|
||||||
# USER asdf
|
ENV KERL_DOC_TARGETS=""
|
||||||
# WORKDIR /asdf
|
ENV KERL_INSTALL_HTMLDOCS="no"
|
||||||
|
ENV KERL_INSTALL_MANPAGES="no"
|
||||||
|
|
||||||
RUN git clone https://github.com/asdf-vm/asdf.git --branch v0.6.3 "$HOME"/.asdf && \
|
RUN git clone https://github.com/asdf-vm/asdf.git --branch v0.6.3 "$HOME"/.asdf && \
|
||||||
echo '. $HOME/.asdf/asdf.sh' >> "$HOME"/.bashrc && \
|
echo '. $HOME/.asdf/asdf.sh' >> "$HOME"/.bashrc && \
|
||||||
|
@ -51,7 +55,7 @@ WORKDIR /opt/erlang/epp_proxy
|
||||||
|
|
||||||
COPY .tool-versions ./
|
COPY .tool-versions ./
|
||||||
RUN asdf plugin-add erlang
|
RUN asdf plugin-add erlang
|
||||||
RUN asdf install
|
RUN . $HOME/.asdf/asdf.sh && asdf install
|
||||||
RUN asdf global erlang $(grep erlang .tool-versions | cut -d' ' -f2)
|
RUN asdf global erlang $(grep erlang .tool-versions | cut -d' ' -f2)
|
||||||
RUN asdf plugin-add ruby
|
RUN asdf plugin-add ruby
|
||||||
RUN asdf plugin-add rebar
|
RUN asdf plugin-add rebar
|
||||||
|
|
58
Dockerfile.amd64.legacy
Normal file
58
Dockerfile.amd64.legacy
Normal file
|
@ -0,0 +1,58 @@
|
||||||
|
FROM debian:buster-slim
|
||||||
|
|
||||||
|
SHELL ["/bin/bash", "-o", "pipefail", "-c"]
|
||||||
|
COPY ./docker/apt/sources.list /etc/apt/
|
||||||
|
|
||||||
|
RUN apt-get update && apt-get -t buster install -y -qq wget \
|
||||||
|
&& apt-get clean \
|
||||||
|
&& rm -rf /var/lib/apt/lists/*
|
||||||
|
|
||||||
|
|
||||||
|
RUN apt-get update && apt-get install -y -qq git \
|
||||||
|
&& apt-get clean \
|
||||||
|
&& rm -rf /var/lib/apt/lists/*
|
||||||
|
|
||||||
|
RUN apt-get update && apt-get install -y \
|
||||||
|
build-essential=* \
|
||||||
|
libncurses5-dev=* \
|
||||||
|
automake=* \
|
||||||
|
autoconf=* \
|
||||||
|
curl=* \
|
||||||
|
ca-certificates=* \
|
||||||
|
libssl-dev=* \
|
||||||
|
libreadline-dev=* \
|
||||||
|
libdpkg-perl=* \
|
||||||
|
liberror-perl=* \
|
||||||
|
libc6=* \
|
||||||
|
libc-dev \
|
||||||
|
perl=* \
|
||||||
|
procps=* \
|
||||||
|
inotify-tools=* \
|
||||||
|
libssl1.1=* \
|
||||||
|
perl-base=* \
|
||||||
|
zlib1g-dev \
|
||||||
|
&& apt-get clean \
|
||||||
|
&& rm -rf /var/lib/apt/lists/*
|
||||||
|
|
||||||
|
# RUN (groupadd -g 999 asdf || true)
|
||||||
|
# RUN (adduser --shell /bin/bash --home /asdf --disabled-password -gid 999 -u 999 asdf || true)
|
||||||
|
# ENV PATH="${PATH}:/asdf/.asdf/shims:/asdf/.asdf/bin"
|
||||||
|
# USER asdf
|
||||||
|
# WORKDIR /asdf
|
||||||
|
|
||||||
|
RUN git clone https://github.com/asdf-vm/asdf.git --branch v0.6.3 "$HOME"/.asdf && \
|
||||||
|
echo '. $HOME/.asdf/asdf.sh' >> "$HOME"/.bashrc && \
|
||||||
|
echo '. $HOME/.asdf/asdf.sh' >> "$HOME"/.profile
|
||||||
|
|
||||||
|
ENV PATH="${PATH}:/root/.asdf/shims:/root/.asdf/bin"
|
||||||
|
|
||||||
|
RUN mkdir -p /opt/erlang/epp_proxy
|
||||||
|
WORKDIR /opt/erlang/epp_proxy
|
||||||
|
|
||||||
|
COPY .tool-versions ./
|
||||||
|
RUN asdf plugin-add erlang
|
||||||
|
RUN asdf install
|
||||||
|
RUN asdf global erlang $(grep erlang .tool-versions | cut -d' ' -f2)
|
||||||
|
RUN asdf plugin-add ruby
|
||||||
|
RUN asdf plugin-add rebar
|
||||||
|
RUN asdf install
|
105
Dockerfile.k8s
Normal file
105
Dockerfile.k8s
Normal file
|
@ -0,0 +1,105 @@
|
||||||
|
FROM debian:bullseye-slim AS build
|
||||||
|
|
||||||
|
SHELL ["/bin/bash", "-o", "pipefail", "-c"]
|
||||||
|
COPY ./docker/apt/sources.list /etc/apt/
|
||||||
|
|
||||||
|
# Install build dependencies
|
||||||
|
RUN apt-get update && apt-get install -y -qq \
|
||||||
|
wget \
|
||||||
|
git \
|
||||||
|
build-essential \
|
||||||
|
libncurses5-dev \
|
||||||
|
automake \
|
||||||
|
autoconf \
|
||||||
|
curl \
|
||||||
|
ca-certificates \
|
||||||
|
libssl-dev \
|
||||||
|
libreadline-dev \
|
||||||
|
libdpkg-perl \
|
||||||
|
liberror-perl \
|
||||||
|
libc6 \
|
||||||
|
libc-dev \
|
||||||
|
perl \
|
||||||
|
procps \
|
||||||
|
inotify-tools \
|
||||||
|
libssl1.1 \
|
||||||
|
perl-base \
|
||||||
|
zlib1g-dev \
|
||||||
|
libncurses-dev \
|
||||||
|
libsctp-dev \
|
||||||
|
xsltproc \
|
||||||
|
libxml2-utils \
|
||||||
|
&& apt-get clean \
|
||||||
|
&& rm -rf /var/lib/apt/lists/*
|
||||||
|
|
||||||
|
# Set environment variables for Erlang build
|
||||||
|
ENV KERL_CONFIGURE_OPTIONS="--disable-debug --without-javac --without-wx --without-odbc --disable-hipe --without-jinterface --without-docs"
|
||||||
|
ENV KERL_BUILD_DOCS="no"
|
||||||
|
ENV KERL_DOC_TARGETS=""
|
||||||
|
ENV KERL_INSTALL_HTMLDOCS="no"
|
||||||
|
ENV KERL_INSTALL_MANPAGES="no"
|
||||||
|
|
||||||
|
RUN git clone https://github.com/asdf-vm/asdf.git --branch v0.6.3 "$HOME"/.asdf && \
|
||||||
|
echo '. $HOME/.asdf/asdf.sh' >> "$HOME"/.bashrc && \
|
||||||
|
echo '. $HOME/.asdf/asdf.sh' >> "$HOME"/.profile
|
||||||
|
|
||||||
|
ENV PATH="${PATH}:/root/.asdf/shims:/root/.asdf/bin"
|
||||||
|
|
||||||
|
RUN mkdir -p /opt/erlang/epp_proxy
|
||||||
|
WORKDIR /opt/erlang/epp_proxy
|
||||||
|
|
||||||
|
COPY .tool-versions ./
|
||||||
|
RUN asdf plugin-add erlang
|
||||||
|
RUN ERLANG_VERSION=$(grep erlang .tool-versions | cut -d' ' -f2) && \
|
||||||
|
. $HOME/.asdf/asdf.sh && asdf install erlang $ERLANG_VERSION
|
||||||
|
RUN asdf global erlang $(grep erlang .tool-versions | cut -d' ' -f2)
|
||||||
|
RUN asdf plugin-add rebar
|
||||||
|
RUN REBAR_VERSION=$(grep rebar .tool-versions | cut -d' ' -f2) && \
|
||||||
|
. $HOME/.asdf/asdf.sh && asdf install rebar $REBAR_VERSION
|
||||||
|
RUN asdf global rebar $(grep rebar .tool-versions | cut -d' ' -f2)
|
||||||
|
|
||||||
|
# Copy application files
|
||||||
|
COPY rebar.config rebar.lock ./
|
||||||
|
COPY config ./config
|
||||||
|
COPY apps ./apps
|
||||||
|
|
||||||
|
# Build the release
|
||||||
|
RUN . $HOME/.asdf/asdf.sh && rebar3 as prod release
|
||||||
|
|
||||||
|
# Second stage: runtime image
|
||||||
|
FROM debian:bullseye-slim
|
||||||
|
|
||||||
|
# Install runtime dependencies only
|
||||||
|
RUN apt-get update && apt-get install -y -qq \
|
||||||
|
libssl1.1 \
|
||||||
|
libncurses6 \
|
||||||
|
libsctp1 \
|
||||||
|
procps \
|
||||||
|
&& apt-get clean \
|
||||||
|
&& rm -rf /var/lib/apt/lists/*
|
||||||
|
|
||||||
|
# Create app directory
|
||||||
|
RUN mkdir -p /opt/erlang/epp_proxy
|
||||||
|
WORKDIR /opt/erlang/epp_proxy
|
||||||
|
|
||||||
|
# Copy the release from the build stage
|
||||||
|
COPY --from=build /opt/erlang/epp_proxy/_build/prod/rel/epp_proxy ./
|
||||||
|
|
||||||
|
# Create a non-root user to run the application
|
||||||
|
RUN groupadd -r epp && useradd -r -g epp epp
|
||||||
|
RUN chown -R epp:epp /opt/erlang/epp_proxy
|
||||||
|
USER epp
|
||||||
|
|
||||||
|
# Expose the EPP port
|
||||||
|
EXPOSE 700
|
||||||
|
|
||||||
|
# Set environment variables
|
||||||
|
ENV RELX_REPLACE_OS_VARS=true
|
||||||
|
ENV NODE_NAME=epp_proxy@127.0.0.1
|
||||||
|
|
||||||
|
# Health check
|
||||||
|
# HEALTHCHECK --interval=30s --timeout=5s --start-period=5s --retries=3 \
|
||||||
|
# CMD ps aux | grep "beam" | grep -v grep || exit 1
|
||||||
|
|
||||||
|
# Command to run the application
|
||||||
|
CMD ["./bin/epp_proxy", "foreground"]
|
20
README.md
20
README.md
|
@ -137,7 +137,7 @@ Testing
|
||||||
----
|
----
|
||||||
The application comes with test suite written with common_test. For integration
|
The application comes with test suite written with common_test. For integration
|
||||||
tests, there is a small Roda application located in `apps/epp_proxy/priv/test_backend_app`.
|
tests, there is a small Roda application located in `apps/epp_proxy/priv/test_backend_app`.
|
||||||
It has been written with Ruby 2.6.3.
|
It has been written with Ruby 3.2.2.
|
||||||
|
|
||||||
There is also a number of generated ssl certificates that are used only for testing. Those are
|
There is also a number of generated ssl certificates that are used only for testing. Those are
|
||||||
valid until 2029 and they are located in `apps/epp_proxy/priv/test_ca`. The password for test CA
|
valid until 2029 and they are located in `apps/epp_proxy/priv/test_ca`. The password for test CA
|
||||||
|
@ -151,6 +151,24 @@ $ /bin/bash -l -c "cd apps/epp_proxy/priv/test_backend_app && bundle install"
|
||||||
$ /bin/bash -l -c "cd apps/epp_proxy/priv/test_backend_app && bundle exec rackup --pid pidfile -D"
|
$ /bin/bash -l -c "cd apps/epp_proxy/priv/test_backend_app && bundle exec rackup --pid pidfile -D"
|
||||||
```
|
```
|
||||||
|
|
||||||
|
The easiest way to run tests is using Docker:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# Run all tests
|
||||||
|
docker compose run --rm epp_proxy bash -c "cd /opt/erlang/epp_proxy && rebar3 ct"
|
||||||
|
|
||||||
|
# Run a specific test suite
|
||||||
|
docker compose run --rm epp_proxy bash -c "cd /opt/erlang/epp_proxy && rebar3 ct --suite apps/epp_proxy/test/epp_http_client_SUITE"
|
||||||
|
|
||||||
|
# Start a shell for debugging
|
||||||
|
docker compose run --rm epp_proxy bash -c "cd /opt/erlang/epp_proxy && rebar3 shell"
|
||||||
|
|
||||||
|
# Then in the Erlang shell:
|
||||||
|
application:get_all_env(epp_proxy).
|
||||||
|
# To exit the shell:
|
||||||
|
halt().
|
||||||
|
```
|
||||||
|
|
||||||
After you finish testing, you can stop the process by reading the stored pid:
|
After you finish testing, you can stop the process by reading the stored pid:
|
||||||
|
|
||||||
$ kill `cat apps/epp_proxy/priv/test_backend_app/pidfile`
|
$ kill `cat apps/epp_proxy/priv/test_backend_app/pidfile`
|
||||||
|
|
|
@ -6,3 +6,4 @@ gem "puma"
|
||||||
gem "roda"
|
gem "roda"
|
||||||
gem "rack-unreloader"
|
gem "rack-unreloader"
|
||||||
gem "tilt"
|
gem "tilt"
|
||||||
|
gem "rackup"
|
||||||
|
|
|
@ -1,23 +1,26 @@
|
||||||
GEM
|
GEM
|
||||||
remote: https://rubygems.org/
|
remote: https://rubygems.org/
|
||||||
specs:
|
specs:
|
||||||
nio4r (2.5.2)
|
nio4r (2.7.4)
|
||||||
puma (4.3.5)
|
puma (6.6.0)
|
||||||
nio4r (~> 2.0)
|
nio4r (~> 2.0)
|
||||||
rack (2.2.3)
|
rack (3.1.12)
|
||||||
rack-unreloader (1.7.0)
|
rack-unreloader (2.1.0)
|
||||||
roda (3.21.0)
|
rackup (2.2.1)
|
||||||
|
rack (>= 3)
|
||||||
|
roda (3.90.0)
|
||||||
rack
|
rack
|
||||||
tilt (2.0.9)
|
tilt (2.6.0)
|
||||||
|
|
||||||
PLATFORMS
|
PLATFORMS
|
||||||
ruby
|
aarch64-linux
|
||||||
|
|
||||||
DEPENDENCIES
|
DEPENDENCIES
|
||||||
puma
|
puma
|
||||||
rack-unreloader
|
rack-unreloader
|
||||||
|
rackup
|
||||||
roda
|
roda
|
||||||
tilt
|
tilt
|
||||||
|
|
||||||
BUNDLED WITH
|
BUNDLED WITH
|
||||||
1.17.2
|
2.4.10
|
||||||
|
|
|
@ -33,14 +33,31 @@ start_link(Socket) ->
|
||||||
handle_cast(serve,
|
handle_cast(serve,
|
||||||
State = #state{socket = Socket,
|
State = #state{socket = Socket,
|
||||||
session_id = _SessionId}) ->
|
session_id = _SessionId}) ->
|
||||||
{ok, {PeerIp, _PeerPort}} = ssl:peername(Socket),
|
try
|
||||||
|
% Check if we have a valid socket
|
||||||
|
case ssl:peername(Socket) of
|
||||||
|
{ok, {PeerIp, _PeerPort}} ->
|
||||||
log_opened_connection(PeerIp),
|
log_opened_connection(PeerIp),
|
||||||
|
% Try to perform the handshake
|
||||||
case ssl:handshake(Socket) of
|
case ssl:handshake(Socket) of
|
||||||
{ok, SecureSocket} ->
|
{ok, SecureSocket} ->
|
||||||
NewState = state_from_socket(SecureSocket, State),
|
NewState = state_from_socket(SecureSocket, State),
|
||||||
{noreply, NewState};
|
{noreply, NewState};
|
||||||
{error, Error} ->
|
{error, notsup_on_transport_accept_socket} ->
|
||||||
log_on_invalid_handshake(PeerIp, Error)
|
lager:error("Socket not supported for TLS handshake. This may indicate the socket is not an SSL socket or was improperly initialized."),
|
||||||
|
{stop, normal, State};
|
||||||
|
{error, HandshakeError} ->
|
||||||
|
log_on_invalid_handshake(PeerIp, HandshakeError),
|
||||||
|
{stop, normal, State}
|
||||||
|
end;
|
||||||
|
{error, PeerError} ->
|
||||||
|
lager:error("Invalid socket: cannot get peer information: ~p", [PeerError]),
|
||||||
|
{stop, normal, State}
|
||||||
|
end
|
||||||
|
catch
|
||||||
|
error:CatchError:Stacktrace ->
|
||||||
|
lager:error("Exception during TLS handshake: ~p~nStacktrace: ~p", [CatchError, Stacktrace]),
|
||||||
|
{stop, normal, State}
|
||||||
end;
|
end;
|
||||||
%% Step two: Using the state of the connection, get the hello route
|
%% Step two: Using the state of the connection, get the hello route
|
||||||
%% from http server. Send the response from HTTP server back to EPP
|
%% from http server. Send the response from HTTP server back to EPP
|
||||||
|
@ -171,14 +188,26 @@ log_opened_connection(Ip) ->
|
||||||
|
|
||||||
%% Extract state info from socket. Fail if you must.
|
%% Extract state info from socket. Fail if you must.
|
||||||
state_from_socket(Socket, State) ->
|
state_from_socket(Socket, State) ->
|
||||||
{ok, PeerCert} = ssl:peercert(Socket),
|
|
||||||
{ok, {PeerIp, _PeerPort}} = ssl:peername(Socket),
|
{ok, {PeerIp, _PeerPort}} = ssl:peername(Socket),
|
||||||
{SSL_CLIENT_S_DN_CN, SSL_CLIENT_CERT} =
|
Headers = case ssl:peercert(Socket) of
|
||||||
epp_certs:headers_from_cert(PeerCert),
|
{ok, PeerCert} ->
|
||||||
Headers = [{"SSL-CLIENT-CERT", SSL_CLIENT_CERT},
|
try
|
||||||
|
{SSL_CLIENT_S_DN_CN, SSL_CLIENT_CERT} = epp_certs:headers_from_cert(PeerCert),
|
||||||
|
[{"SSL-CLIENT-CERT", SSL_CLIENT_CERT},
|
||||||
{"SSL-CLIENT-S-DN-CN", SSL_CLIENT_S_DN_CN},
|
{"SSL-CLIENT-S-DN-CN", SSL_CLIENT_S_DN_CN},
|
||||||
{"User-Agent", <<"EPP proxy">>},
|
{"User-Agent", <<"EPP proxy">>},
|
||||||
{"X-Forwarded-for", epp_util:readable_ip(PeerIp)}],
|
{"X-Forwarded-for", epp_util:readable_ip(PeerIp)}]
|
||||||
|
catch
|
||||||
|
_:_ ->
|
||||||
|
lager:warning("Could not extract certificate information from client at IP: ~s", [epp_util:readable_ip(PeerIp)]),
|
||||||
|
[{"User-Agent", <<"EPP proxy">>},
|
||||||
|
{"X-Forwarded-for", epp_util:readable_ip(PeerIp)}]
|
||||||
|
end;
|
||||||
|
{error, _} ->
|
||||||
|
lager:info("No client certificate provided from IP: ~s", [epp_util:readable_ip(PeerIp)]),
|
||||||
|
[{"User-Agent", <<"EPP proxy">>},
|
||||||
|
{"X-Forwarded-for", epp_util:readable_ip(PeerIp)}]
|
||||||
|
end,
|
||||||
NewState = State#state{socket = Socket,
|
NewState = State#state{socket = Socket,
|
||||||
headers = Headers},
|
headers = Headers},
|
||||||
lager:info("Established connection with: [~p]~n",
|
lager:info("Established connection with: [~p]~n",
|
||||||
|
|
|
@ -218,12 +218,18 @@ receive_data(Socket) ->
|
||||||
{ok, Data} ->
|
{ok, Data} ->
|
||||||
EppEnvelope = binary:part(Data, {0, 4}),
|
EppEnvelope = binary:part(Data, {0, 4}),
|
||||||
ReportedLength = binary:decode_unsigned(EppEnvelope, big),
|
ReportedLength = binary:decode_unsigned(EppEnvelope, big),
|
||||||
binary:part(Data, {byte_size(Data), 4 - ReportedLength})
|
% Extract the actual data, skipping the 4-byte length header
|
||||||
|
binary:part(Data, {4, byte_size(Data) - 4})
|
||||||
end.
|
end.
|
||||||
|
|
||||||
match_data(Data, Pattern) ->
|
match_data(Data, Pattern) ->
|
||||||
{ok, MatchPattern} = re:compile(Pattern),
|
{ok, MatchPattern} = re:compile(Pattern),
|
||||||
{match, _Captured} = re:run(Data, MatchPattern).
|
case re:run(Data, MatchPattern) of
|
||||||
|
{match, _Captured} -> {match, _Captured};
|
||||||
|
nomatch ->
|
||||||
|
ct:pal("Expected pattern '~s' not found in data:~n~p", [Pattern, Data]),
|
||||||
|
nomatch
|
||||||
|
end.
|
||||||
|
|
||||||
hello_command() ->
|
hello_command() ->
|
||||||
<<"<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?>",
|
<<"<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?>",
|
||||||
|
|
|
@ -225,12 +225,18 @@ receive_data(Socket) ->
|
||||||
{ok, Data} ->
|
{ok, Data} ->
|
||||||
EppEnvelope = binary:part(Data, {0, 4}),
|
EppEnvelope = binary:part(Data, {0, 4}),
|
||||||
ReportedLength = binary:decode_unsigned(EppEnvelope, big),
|
ReportedLength = binary:decode_unsigned(EppEnvelope, big),
|
||||||
binary:part(Data, {byte_size(Data), 4 - ReportedLength})
|
% Extract the actual data, skipping the 4-byte length header
|
||||||
|
binary:part(Data, {4, byte_size(Data) - 4})
|
||||||
end.
|
end.
|
||||||
|
|
||||||
match_data(Data, Pattern) ->
|
match_data(Data, Pattern) ->
|
||||||
{ok, MatchPattern} = re:compile(Pattern),
|
{ok, MatchPattern} = re:compile(Pattern),
|
||||||
{match, _Captured} = re:run(Data, MatchPattern).
|
case re:run(Data, MatchPattern) of
|
||||||
|
{match, _Captured} -> {match, _Captured};
|
||||||
|
nomatch ->
|
||||||
|
ct:pal("Expected pattern '~s' not found in data:~n~p", [Pattern, Data]),
|
||||||
|
nomatch
|
||||||
|
end.
|
||||||
|
|
||||||
hello_command() ->
|
hello_command() ->
|
||||||
<<"<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?>",
|
<<"<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?>",
|
||||||
|
|
|
@ -7,26 +7,26 @@
|
||||||
{tcp_port, 1700},
|
{tcp_port, 1700},
|
||||||
%% TLS port, specified in RFC to 700, but can be set to anything else
|
%% TLS port, specified in RFC to 700, but can be set to anything else
|
||||||
%% in case that is needed.
|
%% in case that is needed.
|
||||||
{tls_port, 700},
|
{tls_port, "${TLS_PORT}"},
|
||||||
%% When set to true, you can connect to EPP over HTTPS endpoints without
|
%% When set to true, you can connect to EPP over HTTPS endpoints without
|
||||||
%% verifying their TLS certificates.
|
%% verifying their TLS certificates.
|
||||||
{insecure, false},
|
{insecure, false},
|
||||||
%% URL of EPP endpoints. Can be pointed at a web server (Apache/NGINX)
|
%% URL of EPP endpoints. Can be pointed at a web server (Apache/NGINX)
|
||||||
%% Can contain port (https://some-host:3000/epp/session)
|
%% Can contain port (https://some-host:3000/epp/session)
|
||||||
%% Honors the prepended protocol (http / https).
|
%% Honors the prepended protocol (http / https).
|
||||||
{epp_session_url, "https://registry.test/epp/session/"},
|
{epp_session_url, "${EPP_SESSION_URL}"},
|
||||||
{epp_command_url, "https://registry.test/epp/command/"},
|
{epp_command_url, "${EPP_COMMAND_URL}"},
|
||||||
{epp_error_url, "https://registry.test/epp/error/"},
|
{epp_error_url, "${EPP_ERROR_URL}"},
|
||||||
%% Path to root CA that should check the client certificates.
|
%% Path to root CA that should check the client certificates.
|
||||||
{cacertfile_path, "/opt/shared/ca/certs/ca.crt.pem"},
|
{cacertfile_path, "${CACERT_PATH}"},
|
||||||
%% Path to server's certficate file.
|
%% Path to server's certficate file.
|
||||||
{certfile_path, "/opt/shared/ca/certs/cert.pem"},
|
{certfile_path, "${CERT_PATH}"},
|
||||||
|
|
||||||
%% Path to server's key file.
|
%% Path to server's key file.
|
||||||
{keyfile_path, "/opt/shared/ca/certs/key.pem"},
|
{keyfile_path, "${KEY_PATH}"},
|
||||||
|
|
||||||
%% Path to CRL file. When this option is undefined, no CRL check is performed.
|
%% Path to CRL file. When this option is undefined, no CRL check is performed.
|
||||||
{crlfile_path, "/opt/shared/ca/certs/key.pem"}]},
|
{crlfile_path, "${CRL_PATH}"}]},
|
||||||
{lager, [
|
{lager, [
|
||||||
{handlers, [
|
{handlers, [
|
||||||
{lager_console_backend, [{level, debug}]},
|
{lager_console_backend, [{level, debug}]},
|
||||||
|
|
|
@ -4,7 +4,6 @@
|
||||||
{tcp_port, 1180},
|
{tcp_port, 1180},
|
||||||
{tls_port, 1443},
|
{tls_port, 1443},
|
||||||
{insecure, false},
|
{insecure, false},
|
||||||
|
|
||||||
{epp_session_url, "http://localhost:9292/session/"},
|
{epp_session_url, "http://localhost:9292/session/"},
|
||||||
{epp_command_url, "http://localhost:9292/command/"},
|
{epp_command_url, "http://localhost:9292/command/"},
|
||||||
{epp_error_url, "http://localhost:9292/error/"},
|
{epp_error_url, "http://localhost:9292/error/"},
|
||||||
|
@ -12,9 +11,8 @@
|
||||||
{cacertfile_path, "test_ca/certs/ca.crt.pem"},
|
{cacertfile_path, "test_ca/certs/ca.crt.pem"},
|
||||||
{certfile_path, "test_ca/certs/apache.crt"},
|
{certfile_path, "test_ca/certs/apache.crt"},
|
||||||
{keyfile_path, "test_ca/private/apache.key"},
|
{keyfile_path, "test_ca/private/apache.key"},
|
||||||
{crlfile_path, "test_ca/crl/crl.pem"}]},
|
{crlfile_path, "test_ca/crl/crl.pem"}
|
||||||
|
]},
|
||||||
|
|
||||||
{lager, [
|
{lager, [
|
||||||
{handlers, [
|
{handlers, [
|
||||||
{lager_console_backend, [{level, warning}]}
|
{lager_console_backend, [{level, warning}]}
|
||||||
|
|
|
@ -1,2 +1,7 @@
|
||||||
deb http://deb.debian.org/debian/ buster main contrib non-free
|
deb http://deb.debian.org/debian/ bullseye main contrib non-free
|
||||||
deb http://deb.debian.org/debian/ buster-backports main contrib non-free
|
deb http://deb.debian.org/debian-security/ bullseye-security main contrib non-free
|
||||||
|
deb http://deb.debian.org/debian/ bullseye-updates main contrib non-free
|
||||||
|
|
||||||
|
# Legacy
|
||||||
|
# deb http://deb.debian.org/debian/ buster main contrib non-free
|
||||||
|
# deb http://deb.debian.org/debian/ buster-backports main contrib non-free
|
||||||
|
|
|
@ -3,9 +3,13 @@
|
||||||
{deps, [{hackney, "1.15.1"},
|
{deps, [{hackney, "1.15.1"},
|
||||||
{syslog, {git, "https://github.com/Vagabond/erlang-syslog.git", {branch, "master"}}},
|
{syslog, {git, "https://github.com/Vagabond/erlang-syslog.git", {branch, "master"}}},
|
||||||
{lager, "3.7.0"},
|
{lager, "3.7.0"},
|
||||||
{lager_syslog, {git, "https://github.com/erlang-lager/lager_syslog.git"}},
|
{lager_syslog, {git, "https://github.com/erlang-lager/lager_syslog.git", {branch, "master"}}},
|
||||||
{erlsom, "1.5.0"}]}.
|
{erlsom, "1.5.0"}]}.
|
||||||
|
|
||||||
|
{ct_opts, [
|
||||||
|
{sys_config, "./config/test.config"}
|
||||||
|
]}.
|
||||||
|
|
||||||
{relx, [{release, {epp_proxy, "git"},
|
{relx, [{release, {epp_proxy, "git"},
|
||||||
[epp_proxy,
|
[epp_proxy,
|
||||||
lager,
|
lager,
|
||||||
|
@ -56,5 +60,5 @@
|
||||||
}.
|
}.
|
||||||
|
|
||||||
{plugins, [rebar3_auto,
|
{plugins, [rebar3_auto,
|
||||||
{erl_tidy_prv_fmt, ".*", {git, "git://github.com/tsloughter/erl_tidy.git", {branch, "master"}}},
|
{erl_tidy_prv_fmt, ".*", {git, "https://github.com/tsloughter/erl_tidy.git", {branch, "master"}}},
|
||||||
rebar3_appup_plugin]}.
|
rebar3_appup_plugin]}.
|
||||||
|
|
26
rebar.lock
26
rebar.lock
|
@ -1,4 +1,4 @@
|
||||||
{"1.1.0",
|
{"1.2.0",
|
||||||
[{<<"certifi">>,{pkg,<<"certifi">>,<<"2.5.1">>},1},
|
[{<<"certifi">>,{pkg,<<"certifi">>,<<"2.5.1">>},1},
|
||||||
{<<"erlsom">>,{pkg,<<"erlsom">>,<<"1.5.0">>},0},
|
{<<"erlsom">>,{pkg,<<"erlsom">>,<<"1.5.0">>},0},
|
||||||
{<<"goldrush">>,{pkg,<<"goldrush">>,<<"0.1.9">>},1},
|
{<<"goldrush">>,{pkg,<<"goldrush">>,<<"0.1.9">>},1},
|
||||||
|
@ -10,12 +10,12 @@
|
||||||
{ref,"126dd0284fcac9b01613189a82facf8d803411a2"}},
|
{ref,"126dd0284fcac9b01613189a82facf8d803411a2"}},
|
||||||
0},
|
0},
|
||||||
{<<"metrics">>,{pkg,<<"metrics">>,<<"1.0.1">>},1},
|
{<<"metrics">>,{pkg,<<"metrics">>,<<"1.0.1">>},1},
|
||||||
{<<"mimerl">>,{pkg,<<"mimerl">>,<<"1.2.0">>},1},
|
{<<"mimerl">>,{pkg,<<"mimerl">>,<<"1.3.0">>},1},
|
||||||
{<<"parse_trans">>,{pkg,<<"parse_trans">>,<<"3.3.0">>},2},
|
{<<"parse_trans">>,{pkg,<<"parse_trans">>,<<"3.4.2">>},2},
|
||||||
{<<"ssl_verify_fun">>,{pkg,<<"ssl_verify_fun">>,<<"1.1.4">>},1},
|
{<<"ssl_verify_fun">>,{pkg,<<"ssl_verify_fun">>,<<"1.1.4">>},1},
|
||||||
{<<"syslog">>,
|
{<<"syslog">>,
|
||||||
{git,"https://github.com/Vagabond/erlang-syslog.git",
|
{git,"https://github.com/Vagabond/erlang-syslog.git",
|
||||||
{ref,"4a6c6f2c996483e86c1320e9553f91d337bcb6aa"}},
|
{ref,"2c38c70450f80b44711c7c1702171f32f881d4a6"}},
|
||||||
0},
|
0},
|
||||||
{<<"unicode_util_compat">>,{pkg,<<"unicode_util_compat">>,<<"0.4.1">>},2}]}.
|
{<<"unicode_util_compat">>,{pkg,<<"unicode_util_compat">>,<<"0.4.1">>},2}]}.
|
||||||
[
|
[
|
||||||
|
@ -27,8 +27,20 @@
|
||||||
{<<"idna">>, <<"689C46CBCDF3524C44D5F3DDE8001F364CD7608A99556D8FBD8239A5798D4C10">>},
|
{<<"idna">>, <<"689C46CBCDF3524C44D5F3DDE8001F364CD7608A99556D8FBD8239A5798D4C10">>},
|
||||||
{<<"lager">>, <<"563AB17CD32134A3DD17EC3B3622E6D8F827506AA4F8C489158879BED87D980B">>},
|
{<<"lager">>, <<"563AB17CD32134A3DD17EC3B3622E6D8F827506AA4F8C489158879BED87D980B">>},
|
||||||
{<<"metrics">>, <<"25F094DEA2CDA98213CECC3AEFF09E940299D950904393B2A29D191C346A8486">>},
|
{<<"metrics">>, <<"25F094DEA2CDA98213CECC3AEFF09E940299D950904393B2A29D191C346A8486">>},
|
||||||
{<<"mimerl">>, <<"67E2D3F571088D5CFD3E550C383094B47159F3EEE8FFA08E64106CDF5E981BE3">>},
|
{<<"mimerl">>, <<"D0CD9FC04B9061F82490F6581E0128379830E78535E017F7780F37FEA7545726">>},
|
||||||
{<<"parse_trans">>, <<"09765507A3C7590A784615CFD421D101AEC25098D50B89D7AA1D66646BC571C1">>},
|
{<<"parse_trans">>, <<"C352DDC1A0D5E54F9B1654D45F9C432EEF76F9CEA371C55DDFF769EF688FDB74">>},
|
||||||
{<<"ssl_verify_fun">>, <<"F0EAFFF810D2041E93F915EF59899C923F4568F4585904D010387ED74988E77B">>},
|
{<<"ssl_verify_fun">>, <<"F0EAFFF810D2041E93F915EF59899C923F4568F4585904D010387ED74988E77B">>},
|
||||||
{<<"unicode_util_compat">>, <<"D869E4C68901DD9531385BB0C8C40444EBF624E60B6962D95952775CAC5E90CD">>}]}
|
{<<"unicode_util_compat">>, <<"D869E4C68901DD9531385BB0C8C40444EBF624E60B6962D95952775CAC5E90CD">>}]},
|
||||||
|
{pkg_hash_ext,[
|
||||||
|
{<<"certifi">>, <<"805ABD97539CAF89EC6D4732C91E62BA9DA0CDA51AC462380BBD28EE697A8C42">>},
|
||||||
|
{<<"erlsom">>, <<"55A9DBF9CFA77FCFC108BD8E2C4F9F784DEA228A8F4B06EA10B684944946955A">>},
|
||||||
|
{<<"goldrush">>, <<"99CB4128CFFCB3227581E5D4D803D5413FA643F4EB96523F77D9E6937D994CEB">>},
|
||||||
|
{<<"hackney">>, <<"C2790C9F0F7205F4A362512192DEE8179097394400E745E4D20BAB7226A8EAAD">>},
|
||||||
|
{<<"idna">>, <<"4BDD305EB64E18B0273864920695CB18D7A2021F31A11B9C5FBCD9A253F936E2">>},
|
||||||
|
{<<"lager">>, <<"97DC7E1C9E7289C3167F417E71FFE1DF28218537967E076800ECEDB1C28C9E48">>},
|
||||||
|
{<<"metrics">>, <<"69B09ADDDC4F74A40716AE54D140F93BEB0FB8978D8636EADED0C31B6F099F16">>},
|
||||||
|
{<<"mimerl">>, <<"A1E15A50D1887217DE95F0B9B0793E32853F7C258A5CD227650889B38839FE9D">>},
|
||||||
|
{<<"parse_trans">>, <<"4C25347DE3B7C35732D32E69AB43D1CEEE0BEAE3F3B3ADE1B59CBD3DD224D9CA">>},
|
||||||
|
{<<"ssl_verify_fun">>, <<"603561DC0FD62F4F2EA9B890F4E20E1A0D388746D6E20557CAFB1B16950DE88C">>},
|
||||||
|
{<<"unicode_util_compat">>, <<"1D1848C40487CDB0B30E8ED975E34E025860C02E419CB615D255849F3427439D">>}]}
|
||||||
].
|
].
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue