Skip to content

Commit

Permalink
Reverted last commits
Browse files Browse the repository at this point in the history
* updating to signal-cli v 0.10.0 is more work than anticipated; changes
  will be reverted here and development continues on dedicated feature
  branch.
  • Loading branch information
Bernhard B committed Dec 14, 2021
1 parent 0f0a2f0 commit 0d0b061
Show file tree
Hide file tree
Showing 5 changed files with 51 additions and 26 deletions.
45 changes: 35 additions & 10 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,20 +1,32 @@
ARG SIGNAL_CLI_VERSION=0.10.0
ARG LIBSIGNAL_CLIENT_VERSION=0.11.0
ARG SIGNAL_CLI_VERSION=0.9.2
ARG ZKGROUP_VERSION=0.8.2
ARG LIBSIGNAL_CLIENT_VERSION=0.9.7

ARG SWAG_VERSION=1.6.7
ARG GRAALVM_JAVA_VERSION=17
ARG GRAALVM_JAVA_VERSION=11
ARG GRAALVM_VERSION=21.3.0

FROM golang:1.17-bullseye AS buildcontainer

ARG SIGNAL_CLI_VERSION
ARG ZKGROUP_VERSION
ARG LIBSIGNAL_CLIENT_VERSION
ARG SWAG_VERSION
ARG GRAALVM_JAVA_VERSION
ARG GRAALVM_VERSION

COPY ext/libraries/zkgroup/v${ZKGROUP_VERSION} /tmp/zkgroup-libraries
COPY ext/libraries/libsignal-client/v${LIBSIGNAL_CLIENT_VERSION} /tmp/libsignal-client-libraries

# use architecture specific libzkgroup.so
RUN arch="$(uname -m)"; \
case "$arch" in \
aarch64) echo "[DEBUG] Using arm64 zkgroup" && cp /tmp/zkgroup-libraries/arm64/libzkgroup.so /tmp/libzkgroup.so ;; \
armv7l) echo "[DEBUG] Using armv7 zkgroup" && cp /tmp/zkgroup-libraries/armv7/libzkgroup.so /tmp/libzkgroup.so ;; \
x86_64) echo "[DEBUG] Using x86-64 zkgroup" && cp /tmp/zkgroup-libraries/x86-64/libzkgroup.so /tmp/libzkgroup.so ;; \
*) echo "Unknown architecture" && exit 1 ;; \
esac;

# use architecture specific libsignal_jni.so
RUN arch="$(uname -m)"; \
case "$arch" in \
Expand All @@ -25,7 +37,7 @@ RUN arch="$(uname -m)"; \
esac;

RUN apt-get update \
&& apt-get install -y --no-install-recommends wget openjdk-17-jre software-properties-common git locales zip file build-essential libz-dev zlib1g-dev \
&& apt-get install -y --no-install-recommends wget default-jre software-properties-common git locales zip file build-essential libz-dev zlib1g-dev \
&& rm -rf /var/lib/apt/lists/*

RUN sed -i -e 's/# en_US.UTF-8 UTF-8/en_US.UTF-8 UTF-8/' /etc/locale.gen && \
Expand All @@ -34,10 +46,6 @@ RUN sed -i -e 's/# en_US.UTF-8 UTF-8/en_US.UTF-8 UTF-8/' /etc/locale.gen && \

ENV PATH="/root/.cargo/bin:${PATH}"

ENV JAVA_OPTS="-Djdk.lang.Process.launchMechanism=vfork"

RUN bash -c '([[ ! -d $JAVA_SECURITY_DIR ]] && ln -s $JAVA_HOME/lib $JAVA_HOME/conf) || (echo "Found java conf dir, package has been fixed, remove this hack"; exit -1)'

ENV LANG en_US.UTF-8

RUN cd /tmp/ \
Expand All @@ -52,8 +60,9 @@ RUN cd /tmp/ \
&& git clone https://github.com/AsamK/signal-cli.git signal-cli-${SIGNAL_CLI_VERSION} \
&& cd signal-cli-${SIGNAL_CLI_VERSION} \
&& git checkout v${SIGNAL_CLI_VERSION} \
&& cp /tmp/libzkgroup.so ./lib/src/main/resources/libzkgroup.so \
&& cp /tmp/libsignal_jni.so ./lib/src/main/resources/libsignal_jni.so \
&& ./gradlew build --stacktrace \
&& ./gradlew build \
&& ./gradlew installDist \
&& ./gradlew distTar

Expand Down Expand Up @@ -83,6 +92,22 @@ RUN if [ "$(uname -m)" = "aarch64" ] || [ "$(uname -m)" = "x86_64" ]; then \
echo "Unknown architecture"; \
fi;

# replace zkgroup

RUN ls /tmp/signal-cli-${SIGNAL_CLI_VERSION}/build/install/signal-cli/lib/zkgroup-java-${ZKGROUP_VERSION}.jar || (echo "\n\nzkgroup jar file with version ${ZKGROUP_VERSION} not found. Maybe the version needs to be bumped in the signal-cli-rest-api Dockerfile?\n\n" && echo "Available version: \n" && ls /tmp/signal-cli-${SIGNAL_CLI_VERSION}/build/install/signal-cli/lib/zkgroup-java-* && echo "\n\n" && exit 1)

RUN cd /tmp/ \
&& zip -u /tmp/signal-cli-${SIGNAL_CLI_VERSION}/build/install/signal-cli/lib/zkgroup-java-${ZKGROUP_VERSION}.jar libzkgroup.so

RUN cd /tmp/signal-cli-${SIGNAL_CLI_VERSION}/build/distributions/ \
&& mkdir -p signal-cli-${SIGNAL_CLI_VERSION}/lib/ \
&& cp /tmp/signal-cli-${SIGNAL_CLI_VERSION}/build/install/signal-cli/lib/zkgroup-java-${ZKGROUP_VERSION}.jar signal-cli-${SIGNAL_CLI_VERSION}/lib/ \
# update zip
&& zip -u /tmp/signal-cli-${SIGNAL_CLI_VERSION}/build/distributions/signal-cli-${SIGNAL_CLI_VERSION}.zip signal-cli-${SIGNAL_CLI_VERSION}/lib/zkgroup-java-${ZKGROUP_VERSION}.jar \
# update tar
&& tar --delete -vPf /tmp/signal-cli-${SIGNAL_CLI_VERSION}/build/distributions/signal-cli-${SIGNAL_CLI_VERSION}.tar signal-cli-${SIGNAL_CLI_VERSION}/lib/zkgroup-java-${ZKGROUP_VERSION}.jar \
&& tar --owner='' --group='' -rvPf /tmp/signal-cli-${SIGNAL_CLI_VERSION}/build/distributions/signal-cli-${SIGNAL_CLI_VERSION}.tar signal-cli-${SIGNAL_CLI_VERSION}/lib/zkgroup-java-${ZKGROUP_VERSION}.jar

# replace libsignal-client

RUN ls /tmp/signal-cli-${SIGNAL_CLI_VERSION}/build/install/signal-cli/lib/signal-client-java-${LIBSIGNAL_CLIENT_VERSION}.jar || (echo "\n\nsignal-client jar file with version ${LIBSIGNAL_CLIENT_VERSION} not found. Maybe the version needs to be bumped in the signal-cli-rest-api Dockerfile?\n\n" && echo "Available version: \n" && ls /tmp/signal-cli-${SIGNAL_CLI_VERSION}/build/install/signal-cli/lib/signal-client-java-* && echo "\n\n" && exit 1)
Expand Down Expand Up @@ -116,7 +141,7 @@ RUN cd /tmp/signal-cli-rest-api-src/scripts && go build -o jsonrpc2-helper


# Start a fresh container for release container
FROM eclipse-temurin:17-focal
FROM eclipse-temurin:11-jre-focal

ENV GIN_MODE=release

Expand Down
Binary file not shown.
Binary file not shown.
Binary file not shown.
32 changes: 16 additions & 16 deletions src/client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -430,7 +430,7 @@ func (s *SignalClient) send(number string, message string,
return nil, err
}
} else {
cmd := []string{"--config", s.signalCliConfig, "-a", number, "send"}
cmd := []string{"--config", s.signalCliConfig, "-u", number, "send"}
if !isGroup {
cmd = append(cmd, recipients...)
} else {
Expand Down Expand Up @@ -471,7 +471,7 @@ func (s *SignalClient) RegisterNumber(number string, useVoice bool, captcha stri
if s.signalCliMode == JsonRpc {
return errors.New(endpointNotSupportedInJsonRpcMode)
}
command := []string{"--config", s.signalCliConfig, "-a", number, "register"}
command := []string{"--config", s.signalCliConfig, "-u", number, "register"}

if useVoice {
command = append(command, "--voice")
Expand All @@ -490,7 +490,7 @@ func (s *SignalClient) VerifyRegisteredNumber(number string, token string, pin s
return errors.New(endpointNotSupportedInJsonRpcMode)
}

cmd := []string{"--config", s.signalCliConfig, "-a", number, "verify", token}
cmd := []string{"--config", s.signalCliConfig, "-u", number, "verify", token}
if pin != "" {
cmd = append(cmd, "--pin")
cmd = append(cmd, pin)
Expand Down Expand Up @@ -572,7 +572,7 @@ func (s *SignalClient) Receive(number string, timeout int64) (string, error) {
}
return string(msg.Params), nil
} else {
command := []string{"--config", s.signalCliConfig, "--output", "json", "-a", number, "receive", "-t", strconv.FormatInt(timeout, 10)}
command := []string{"--config", s.signalCliConfig, "--output", "json", "-u", number, "receive", "-t", strconv.FormatInt(timeout, 10)}

out, err := runSignalCli(true, command, "", s.signalCliMode)
if err != nil {
Expand Down Expand Up @@ -624,7 +624,7 @@ func (s *SignalClient) CreateGroup(number string, name string, members []string,
}
internalGroupId = resp.GroupId
} else {
cmd := []string{"--config", s.signalCliConfig, "-a", number, "updateGroup", "-n", name, "-m"}
cmd := []string{"--config", s.signalCliConfig, "-u", number, "updateGroup", "-n", name, "-m"}
cmd = append(cmd, members...)

if addMembersPermission != DefaultGroupPermission {
Expand Down Expand Up @@ -674,7 +674,7 @@ func (s *SignalClient) GetGroups(number string) ([]GroupEntry, error) {
return groupEntries, err
}
} else {
rawData, err = runSignalCli(true, []string{"--config", s.signalCliConfig, "--output", "json", "-a", number, "listGroups", "-d"}, "", s.signalCliMode)
rawData, err = runSignalCli(true, []string{"--config", s.signalCliConfig, "--output", "json", "-u", number, "listGroups", "-d"}, "", s.signalCliMode)
if err != nil {
return groupEntries, err
}
Expand Down Expand Up @@ -736,7 +736,7 @@ func (s *SignalClient) GetGroup(number string, groupId string) (*GroupEntry, err
}

func (s *SignalClient) DeleteGroup(number string, groupId string) error {
_, err := runSignalCli(true, []string{"--config", s.signalCliConfig, "-a", number, "quitGroup", "-g", string(groupId)}, "", s.signalCliMode)
_, err := runSignalCli(true, []string{"--config", s.signalCliConfig, "-u", number, "quitGroup", "-g", string(groupId)}, "", s.signalCliMode)
return err
}

Expand Down Expand Up @@ -871,7 +871,7 @@ func (s *SignalClient) UpdateProfile(number string, profileName string, base64Av
}
_, err = jsonRpc2Client.getRaw("updateProfile", request)
} else {
cmd := []string{"--config", s.signalCliConfig, "-a", number, "updateProfile", "--name", profileName}
cmd := []string{"--config", s.signalCliConfig, "-u", number, "updateProfile", "--name", profileName}
if base64Avatar == "" {
cmd = append(cmd, "--remove-avatar")
} else {
Expand Down Expand Up @@ -909,7 +909,7 @@ func (s *SignalClient) ListIdentities(number string) (*[]IdentityEntry, error) {
identityEntries = append(identityEntries, identityEntry)
}
} else {
rawData, err := runSignalCli(true, []string{"--config", s.signalCliConfig, "-a", number, "listIdentities"}, "", s.signalCliMode)
rawData, err := runSignalCli(true, []string{"--config", s.signalCliConfig, "-u", number, "listIdentities"}, "", s.signalCliMode)
if err != nil {
return nil, err
}
Expand Down Expand Up @@ -946,7 +946,7 @@ func (s *SignalClient) TrustIdentity(number string, numberToTrust string, verifi
}
_, err = jsonRpc2Client.getRaw("trust", request)
} else {
cmd := []string{"--config", s.signalCliConfig, "-a", number, "trust", numberToTrust, "--verified-safety-number", verifiedSafetyNumber}
cmd := []string{"--config", s.signalCliConfig, "-u", number, "trust", numberToTrust, "--verified-safety-number", verifiedSafetyNumber}
_, err = runSignalCli(true, cmd, "", s.signalCliMode)
}
return err
Expand All @@ -965,7 +965,7 @@ func (s *SignalClient) BlockGroup(number string, groupId string) error {
}
_, err = jsonRpc2Client.getRaw("block", request)
} else {
_, err = runSignalCli(true, []string{"--config", s.signalCliConfig, "-a", number, "block", "-g", groupId}, "", s.signalCliMode)
_, err = runSignalCli(true, []string{"--config", s.signalCliConfig, "-u", number, "block", "-g", groupId}, "", s.signalCliMode)
}
return err
}
Expand All @@ -983,7 +983,7 @@ func (s *SignalClient) JoinGroup(number string, groupId string) error {
}
_, err = jsonRpc2Client.getRaw("updateGroup", request)
} else {
_, err = runSignalCli(true, []string{"--config", s.signalCliConfig, "-a", number, "updateGroup", "-g", groupId}, "", s.signalCliMode)
_, err = runSignalCli(true, []string{"--config", s.signalCliConfig, "-u", number, "updateGroup", "-g", groupId}, "", s.signalCliMode)
}
return err
}
Expand All @@ -1001,7 +1001,7 @@ func (s *SignalClient) QuitGroup(number string, groupId string) error {
}
_, err = jsonRpc2Client.getRaw("quitGroup", request)
} else {
_, err = runSignalCli(true, []string{"--config", s.signalCliConfig, "-a", number, "quitGroup", "-g", groupId}, "", s.signalCliMode)
_, err = runSignalCli(true, []string{"--config", s.signalCliConfig, "-u", number, "quitGroup", "-g", groupId}, "", s.signalCliMode)
}
return err
}
Expand Down Expand Up @@ -1053,7 +1053,7 @@ func (s *SignalClient) SendReaction(number string, recipient string, emoji strin

cmd := []string{
"--config", s.signalCliConfig,
"-a", number,
"-u", number,
"sendReaction",
}
if !isGroup {
Expand Down Expand Up @@ -1099,7 +1099,7 @@ func (s *SignalClient) SendStartTyping(number string, recipient string) error {
}
_, err = jsonRpc2Client.getRaw("sendTyping", request)
} else {
cmd := []string{"--config", s.signalCliConfig, "-a", number, "sendTyping"}
cmd := []string{"--config", s.signalCliConfig, "-u", number, "sendTyping"}
if !isGroup {
cmd = append(cmd, recp)
} else {
Expand Down Expand Up @@ -1142,7 +1142,7 @@ func (s *SignalClient) SendStopTyping(number string, recipient string) error {
}
_, err = jsonRpc2Client.getRaw("sendTyping", request)
} else {
cmd := []string{"--config", s.signalCliConfig, "-a", number, "sendTyping", "--stop"}
cmd := []string{"--config", s.signalCliConfig, "-u", number, "sendTyping", "--stop"}
if !isGroup {
cmd = append(cmd, recp)
} else {
Expand Down

0 comments on commit 0d0b061

Please sign in to comment.