mirror of
https://github.com/AsamK/signal-cli
synced 2025-08-29 02:20:39 +00:00
Update libsignal-service
This commit is contained in:
parent
804949ddea
commit
9b56aa6259
6 changed files with 30 additions and 57 deletions
|
@ -19,7 +19,7 @@ repositories {
|
|||
}
|
||||
|
||||
dependencies {
|
||||
compile 'com.github.turasa:signal-service-java:2.5.11_unofficial_1'
|
||||
compile 'com.github.turasa:signal-service-java:2.5.17_unofficial_1'
|
||||
compile 'org.bouncycastle:bcprov-jdk15on:1.55'
|
||||
compile 'net.sourceforge.argparse4j:argparse4j:0.7.0'
|
||||
compile 'org.freedesktop.dbus:dbus-java:2.7.0'
|
||||
|
|
BIN
gradle/wrapper/gradle-wrapper.jar
vendored
BIN
gradle/wrapper/gradle-wrapper.jar
vendored
Binary file not shown.
4
gradle/wrapper/gradle-wrapper.properties
vendored
4
gradle/wrapper/gradle-wrapper.properties
vendored
|
@ -1,6 +1,6 @@
|
|||
#Sat May 20 11:26:11 CEST 2017
|
||||
#Thu Aug 17 20:18:16 CEST 2017
|
||||
distributionBase=GRADLE_USER_HOME
|
||||
distributionPath=wrapper/dists
|
||||
zipStoreBase=GRADLE_USER_HOME
|
||||
zipStorePath=wrapper/dists
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-3.5-bin.zip
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-4.0.2-bin.zip
|
||||
|
|
|
@ -1012,14 +1012,11 @@ public class Main {
|
|||
}
|
||||
if (syncMessage.getVerified().isPresent()) {
|
||||
System.out.println("Received sync message with verified identities:");
|
||||
final List<VerifiedMessage> verifiedList = syncMessage.getVerified().get();
|
||||
for (VerifiedMessage v : verifiedList) {
|
||||
System.out.println(" - " + v.getDestination() + ": " + v.getVerified());
|
||||
String safetyNumber = formatSafetyNumber(m.computeSafetyNumber(v.getDestination(), v.getIdentityKey()));
|
||||
final VerifiedMessage verifiedMessage = syncMessage.getVerified().get();
|
||||
System.out.println(" - " + verifiedMessage.getDestination() + ": " + verifiedMessage.getVerified());
|
||||
String safetyNumber = formatSafetyNumber(m.computeSafetyNumber(verifiedMessage.getDestination(), verifiedMessage.getIdentityKey()));
|
||||
System.out.println(" " + safetyNumber);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
|
|
|
@ -368,7 +368,7 @@ class Manager implements Signal {
|
|||
}
|
||||
|
||||
public void updateAccountAttributes() throws IOException {
|
||||
accountManager.setAccountAttributes(signalingKey, signalProtocolStore.getLocalRegistrationId(), false, false, true);
|
||||
accountManager.setAccountAttributes(signalingKey, signalProtocolStore.getLocalRegistrationId(), true);
|
||||
}
|
||||
|
||||
public void unregister() throws IOException {
|
||||
|
@ -481,24 +481,6 @@ class Manager implements Signal {
|
|||
return records;
|
||||
}
|
||||
|
||||
private PreKeyRecord getOrGenerateLastResortPreKey() {
|
||||
if (signalProtocolStore.containsPreKey(Medium.MAX_VALUE)) {
|
||||
try {
|
||||
return signalProtocolStore.loadPreKey(Medium.MAX_VALUE);
|
||||
} catch (InvalidKeyIdException e) {
|
||||
signalProtocolStore.removePreKey(Medium.MAX_VALUE);
|
||||
}
|
||||
}
|
||||
|
||||
ECKeyPair keyPair = Curve.generateKeyPair();
|
||||
PreKeyRecord record = new PreKeyRecord(Medium.MAX_VALUE, keyPair);
|
||||
|
||||
signalProtocolStore.storePreKey(Medium.MAX_VALUE, record);
|
||||
save();
|
||||
|
||||
return record;
|
||||
}
|
||||
|
||||
private SignedPreKeyRecord generateSignedPreKey(IdentityKeyPair identityKeyPair) {
|
||||
try {
|
||||
ECKeyPair keyPair = Curve.generateKeyPair();
|
||||
|
@ -518,7 +500,7 @@ class Manager implements Signal {
|
|||
public void verifyAccount(String verificationCode) throws IOException {
|
||||
verificationCode = verificationCode.replace("-", "");
|
||||
signalingKey = Util.getSecret(52);
|
||||
accountManager.verifyAccountWithCode(verificationCode, signalingKey, signalProtocolStore.getLocalRegistrationId(), false, false, true);
|
||||
accountManager.verifyAccountWithCode(verificationCode, signalingKey, signalProtocolStore.getLocalRegistrationId(), true);
|
||||
|
||||
//accountManager.setGcmId(Optional.of(GoogleCloudMessaging.getInstance(this).register(REGISTRATION_ID)));
|
||||
registered = true;
|
||||
|
@ -529,10 +511,9 @@ class Manager implements Signal {
|
|||
|
||||
private void refreshPreKeys() throws IOException {
|
||||
List<PreKeyRecord> oneTimePreKeys = generatePreKeys();
|
||||
PreKeyRecord lastResortKey = getOrGenerateLastResortPreKey();
|
||||
SignedPreKeyRecord signedPreKeyRecord = generateSignedPreKey(signalProtocolStore.getIdentityKeyPair());
|
||||
|
||||
accountManager.setPreKeys(signalProtocolStore.getIdentityKeyPair().getPublicKey(), lastResortKey, signedPreKeyRecord, oneTimePreKeys);
|
||||
accountManager.setPreKeys(signalProtocolStore.getIdentityKeyPair().getPublicKey(), signedPreKeyRecord, oneTimePreKeys);
|
||||
}
|
||||
|
||||
|
||||
|
@ -1203,7 +1184,6 @@ class Manager implements Signal {
|
|||
if (rm.isContactsRequest()) {
|
||||
try {
|
||||
sendContacts();
|
||||
sendVerifiedMessage();
|
||||
} catch (UntrustedIdentityException | IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
@ -1298,10 +1278,8 @@ class Manager implements Signal {
|
|||
}
|
||||
}
|
||||
if (syncMessage.getVerified().isPresent()) {
|
||||
final List<VerifiedMessage> verifiedList = syncMessage.getVerified().get();
|
||||
for (VerifiedMessage v : verifiedList) {
|
||||
signalProtocolStore.saveIdentity(v.getDestination(), v.getIdentityKey(), TrustLevel.fromVerifiedState(v.getVerified()));
|
||||
}
|
||||
final VerifiedMessage verifiedMessage = syncMessage.getVerified().get();
|
||||
signalProtocolStore.saveIdentity(verifiedMessage.getDestination(), verifiedMessage.getIdentityKey(), TrustLevel.fromVerifiedState(verifiedMessage.getVerified()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1513,8 +1491,21 @@ class Manager implements Signal {
|
|||
try (OutputStream fos = new FileOutputStream(contactsFile)) {
|
||||
DeviceContactsOutputStream out = new DeviceContactsOutputStream(fos);
|
||||
for (ContactInfo record : contactStore.getContacts()) {
|
||||
VerifiedMessage verifiedMessage = null;
|
||||
if (getIdentities().containsKey(record.number)) {
|
||||
JsonIdentityKeyStore.Identity currentIdentity = null;
|
||||
for (JsonIdentityKeyStore.Identity id : getIdentities().get(record.number)) {
|
||||
if (currentIdentity == null || id.getDateAdded().after(currentIdentity.getDateAdded())) {
|
||||
currentIdentity = id;
|
||||
}
|
||||
}
|
||||
if (currentIdentity != null) {
|
||||
verifiedMessage = new VerifiedMessage(record.number, currentIdentity.getIdentityKey(), currentIdentity.getTrustLevel().toVerifiedState(), currentIdentity.getDateAdded().getTime());
|
||||
}
|
||||
}
|
||||
|
||||
out.write(new DeviceContact(record.number, Optional.fromNullable(record.name),
|
||||
createContactAvatarAttachment(record.number), Optional.fromNullable(record.color)));
|
||||
createContactAvatarAttachment(record.number), Optional.fromNullable(record.color), Optional.fromNullable(verifiedMessage)));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1538,23 +1529,8 @@ class Manager implements Signal {
|
|||
}
|
||||
}
|
||||
|
||||
private void sendVerifiedMessage() throws IOException, UntrustedIdentityException {
|
||||
List<VerifiedMessage> verifiedMessages = new LinkedList<>();
|
||||
for (Map.Entry<String, List<JsonIdentityKeyStore.Identity>> x : getIdentities().entrySet()) {
|
||||
final String name = x.getKey();
|
||||
for (JsonIdentityKeyStore.Identity id : x.getValue()) {
|
||||
if (id.getTrustLevel() == TrustLevel.TRUSTED_UNVERIFIED) {
|
||||
continue;
|
||||
}
|
||||
VerifiedMessage verifiedMessage = new VerifiedMessage(name, id.getIdentityKey(), id.getTrustLevel().toVerifiedState());
|
||||
verifiedMessages.add(verifiedMessage);
|
||||
}
|
||||
}
|
||||
sendSyncMessage(SignalServiceSyncMessage.forVerified(verifiedMessages));
|
||||
}
|
||||
|
||||
private void sendVerifiedMessage(String destination, IdentityKey identityKey, TrustLevel trustLevel) throws IOException, UntrustedIdentityException {
|
||||
VerifiedMessage verifiedMessage = new VerifiedMessage(destination, identityKey, trustLevel.toVerifiedState());
|
||||
VerifiedMessage verifiedMessage = new VerifiedMessage(destination, identityKey, trustLevel.toVerifiedState(), System.currentTimeMillis());
|
||||
sendSyncMessage(SignalServiceSyncMessage.forVerified(verifiedMessage));
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue