mirror of
https://github.com/signalapp/Signal-Server.git
synced 2026-11-30 10:06:50 +00:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
c6810d7460 | ||
|
|
4c1e7e7c2f | ||
|
|
931081752a | ||
|
|
424e98e67e | ||
|
|
7cfa93f5f8 | ||
|
|
fd8e8d1475 | ||
|
|
7ed5eb22ec |
No files matched your search
+38
-51
@@ -1,32 +1,16 @@
|
||||
twilio:
|
||||
accountId:
|
||||
twilio: # Twilio SMS gateway configuration
|
||||
accountId:
|
||||
accountToken:
|
||||
number:
|
||||
localDomain: # The domain Twilio can call back to.
|
||||
international: # Boolean specifying Twilio for international delivery
|
||||
|
||||
# Optional. If specified, Nexmo will be used for non-US SMS and
|
||||
# voice verification if twilio.international is false. Otherwise,
|
||||
# Nexmo, if specified, Nexmo will only be used as a fallback
|
||||
# for failed Twilio deliveries.
|
||||
nexmo:
|
||||
apiKey:
|
||||
apiSecret:
|
||||
number:
|
||||
push: # GCM/APN push server configuration
|
||||
host:
|
||||
port:
|
||||
username:
|
||||
password:
|
||||
|
||||
gcm:
|
||||
senderId:
|
||||
apiKey:
|
||||
|
||||
# Optional. Only if iOS clients are supported.
|
||||
apn:
|
||||
# In PEM format.
|
||||
certificate:
|
||||
|
||||
# In PEM format.
|
||||
key:
|
||||
|
||||
s3:
|
||||
s3: # AWS S3 configuration
|
||||
accessKey:
|
||||
accessSecret:
|
||||
|
||||
@@ -35,13 +19,37 @@ s3:
|
||||
# correct permissions.
|
||||
attachmentsBucket:
|
||||
|
||||
memcache:
|
||||
servers:
|
||||
user:
|
||||
password:
|
||||
directory: # Redis server configuration for TS directory
|
||||
url:
|
||||
|
||||
redis:
|
||||
url:
|
||||
cache: # Redis server configuration for general purpose caching
|
||||
url:
|
||||
|
||||
websocket:
|
||||
enabled: true
|
||||
|
||||
messageStore: # Postgres database configuration for message store
|
||||
driverClass: org.postgresql.Driver
|
||||
user:
|
||||
password:
|
||||
url:
|
||||
|
||||
database: # Postgres database configuration for account store
|
||||
# the name of your JDBC driver
|
||||
driverClass: org.postgresql.Driver
|
||||
|
||||
# the username
|
||||
user:
|
||||
|
||||
# the password
|
||||
password:
|
||||
|
||||
# the JDBC URL
|
||||
url: jdbc:postgresql://somehost:somport/somedb
|
||||
|
||||
# any properties specific to your JDBC driver:
|
||||
properties:
|
||||
charSet: UTF-8
|
||||
|
||||
federation:
|
||||
name:
|
||||
@@ -52,24 +60,3 @@ federation:
|
||||
authenticationToken: foo
|
||||
certificate: in pem format
|
||||
|
||||
# Optional address of graphite server to report metrics
|
||||
graphite:
|
||||
host:
|
||||
port:
|
||||
|
||||
database:
|
||||
# the name of your JDBC driver
|
||||
driverClass: org.postgresql.Driver
|
||||
|
||||
# the username
|
||||
user:
|
||||
|
||||
# the password
|
||||
password:
|
||||
|
||||
# the JDBC URL
|
||||
url: jdbc:postgresql://somehost:somport/somedb
|
||||
|
||||
# any properties specific to your JDBC driver:
|
||||
properties:
|
||||
charSet: UTF-8
|
||||
@@ -9,7 +9,7 @@
|
||||
|
||||
<groupId>org.whispersystems.textsecure</groupId>
|
||||
<artifactId>TextSecureServer</artifactId>
|
||||
<version>0.46</version>
|
||||
<version>0.49</version>
|
||||
|
||||
<properties>
|
||||
<dropwizard.version>0.7.1</dropwizard.version>
|
||||
|
||||
@@ -102,7 +102,7 @@ public class MessageController {
|
||||
@Valid IncomingMessageList messages)
|
||||
throws IOException, RateLimitExceededException
|
||||
{
|
||||
rateLimiters.getMessagesLimiter().validate(source.getNumber());
|
||||
rateLimiters.getMessagesLimiter().validate(source.getNumber() + "__" + destinationName);
|
||||
|
||||
try {
|
||||
boolean isSyncMessage = source.getNumber().equals(destinationName);
|
||||
|
||||
@@ -25,6 +25,7 @@ import org.whispersystems.websocket.messages.WebSocketResponseMessage;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
import javax.ws.rs.WebApplicationException;
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
|
||||
@@ -136,8 +137,10 @@ public class WebSocketConnection implements DispatchChannel {
|
||||
receiptSender.sendReceipt(account, message.getSource(), message.getTimestamp(),
|
||||
message.hasRelay() ? Optional.of(message.getRelay()) :
|
||||
Optional.<String>absent());
|
||||
} catch (IOException | NoSuchUserException | TransientPushFailureException | NotPushRegisteredException e) {
|
||||
} catch (IOException | NoSuchUserException | TransientPushFailureException | NotPushRegisteredException e) {
|
||||
logger.warn("sendDeliveryReceiptFor", e);
|
||||
} catch (WebApplicationException e) {
|
||||
logger.warn("Bad federated response for receipt: " + e.getResponse().getStatus());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+86
-13
@@ -157,14 +157,94 @@ public class WebSocketConnectionTest {
|
||||
futures.get(0).setException(new IOException());
|
||||
futures.get(2).setException(new IOException());
|
||||
|
||||
// List<OutgoingMessageSignal> pending = new LinkedList<OutgoingMessageSignal>() {{
|
||||
// add(createMessage("sender1", 1111, false, "first"));
|
||||
// add(createMessage("sender2", 3333, false, "third"));
|
||||
// }};
|
||||
|
||||
verify(storedMessages, times(1)).delete(eq(account.getNumber()), eq(2L));
|
||||
verify(receiptSender, times(1)).sendReceipt(eq(account), eq("sender1"), eq(2222L), eq(Optional.<String>absent()));
|
||||
|
||||
// verify(pushSender, times(1)).sendMessage(eq(sender1), eq(sender1device), any(OutgoingMessageSignal.class));
|
||||
connection.onDispatchUnsubscribed(websocketAddress.serialize());
|
||||
verify(client).close(anyInt(), anyString());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testOnlineSend() throws Exception {
|
||||
MessagesManager storedMessages = mock(MessagesManager.class);
|
||||
OutgoingMessageSignal firstMessage = OutgoingMessageSignal.newBuilder()
|
||||
.setMessage(ByteString.copyFrom("first".getBytes()))
|
||||
.setSource("sender1")
|
||||
.setTimestamp(System.currentTimeMillis())
|
||||
.setSourceDevice(1)
|
||||
.setType(OutgoingMessageSignal.Type.CIPHERTEXT_VALUE)
|
||||
.build();
|
||||
|
||||
OutgoingMessageSignal secondMessage = OutgoingMessageSignal.newBuilder()
|
||||
.setMessage(ByteString.copyFrom("second".getBytes()))
|
||||
.setSource("sender2")
|
||||
.setTimestamp(System.currentTimeMillis())
|
||||
.setSourceDevice(2)
|
||||
.setType(OutgoingMessageSignal.Type.CIPHERTEXT_VALUE)
|
||||
.build();
|
||||
|
||||
List<OutgoingMessageEntity> pendingMessages = new LinkedList<>();
|
||||
|
||||
when(device.getId()).thenReturn(2L);
|
||||
when(device.getSignalingKey()).thenReturn(Base64.encodeBytes(new byte[52]));
|
||||
|
||||
when(account.getAuthenticatedDevice()).thenReturn(Optional.of(device));
|
||||
when(account.getNumber()).thenReturn("+14152222222");
|
||||
|
||||
final Device sender1device = mock(Device.class);
|
||||
|
||||
Set<Device> sender1devices = new HashSet<Device>() {{
|
||||
add(sender1device);
|
||||
}};
|
||||
|
||||
Account sender1 = mock(Account.class);
|
||||
when(sender1.getDevices()).thenReturn(sender1devices);
|
||||
|
||||
when(accountsManager.get("sender1")).thenReturn(Optional.of(sender1));
|
||||
when(accountsManager.get("sender2")).thenReturn(Optional.<Account>absent());
|
||||
|
||||
when(storedMessages.getMessagesForDevice(account.getNumber(), device.getId()))
|
||||
.thenReturn(pendingMessages);
|
||||
|
||||
final List<SettableFuture<WebSocketResponseMessage>> futures = new LinkedList<>();
|
||||
final WebSocketClient client = mock(WebSocketClient.class);
|
||||
|
||||
when(client.sendRequest(eq("PUT"), eq("/api/v1/message"), any(Optional.class)))
|
||||
.thenAnswer(new Answer<SettableFuture<WebSocketResponseMessage>>() {
|
||||
@Override
|
||||
public SettableFuture<WebSocketResponseMessage> answer(InvocationOnMock invocationOnMock) throws Throwable {
|
||||
SettableFuture<WebSocketResponseMessage> future = SettableFuture.create();
|
||||
futures.add(future);
|
||||
return future;
|
||||
}
|
||||
});
|
||||
|
||||
WebsocketAddress websocketAddress = new WebsocketAddress(account.getNumber(), device.getId());
|
||||
WebSocketConnection connection = new WebSocketConnection(pushSender, receiptSender, storedMessages,
|
||||
account, device, client);
|
||||
|
||||
connection.onDispatchSubscribed(websocketAddress.serialize());
|
||||
connection.onDispatchMessage(websocketAddress.serialize(), PubSubProtos.PubSubMessage.newBuilder()
|
||||
.setType(PubSubProtos.PubSubMessage.Type.DELIVER)
|
||||
.setContent(ByteString.copyFrom(firstMessage.toByteArray()))
|
||||
.build().toByteArray());
|
||||
|
||||
connection.onDispatchMessage(websocketAddress.serialize(), PubSubProtos.PubSubMessage.newBuilder()
|
||||
.setType(PubSubProtos.PubSubMessage.Type.DELIVER)
|
||||
.setContent(ByteString.copyFrom(secondMessage.toByteArray()))
|
||||
.build().toByteArray());
|
||||
|
||||
verify(client, times(2)).sendRequest(eq("PUT"), eq("/api/v1/message"), any(Optional.class));
|
||||
|
||||
assertEquals(futures.size(), 2);
|
||||
|
||||
WebSocketResponseMessage response = mock(WebSocketResponseMessage.class);
|
||||
when(response.getStatus()).thenReturn(200);
|
||||
futures.get(1).set(response);
|
||||
futures.get(0).setException(new IOException());
|
||||
|
||||
verify(receiptSender, times(1)).sendReceipt(eq(account), eq("sender2"), eq(secondMessage.getTimestamp()), eq(Optional.<String>absent()));
|
||||
verify(pushSender, times(1)).sendMessage(eq(account), eq(device), any(OutgoingMessageSignal.class));
|
||||
|
||||
connection.onDispatchUnsubscribed(websocketAddress.serialize());
|
||||
verify(client).close(anyInt(), anyString());
|
||||
@@ -173,13 +253,6 @@ public class WebSocketConnectionTest {
|
||||
private OutgoingMessageEntity createMessage(long id, String sender, long timestamp, boolean receipt, String content) {
|
||||
return new OutgoingMessageEntity(id, receipt ? OutgoingMessageSignal.Type.RECEIPT_VALUE : OutgoingMessageSignal.Type.CIPHERTEXT_VALUE,
|
||||
null, timestamp, sender, 1, content.getBytes());
|
||||
// return OutgoingMessageSignal.newBuilder()
|
||||
// .setSource(sender)
|
||||
// .setSourceDevice(1)
|
||||
// .setType(receipt ? OutgoingMessageSignal.Type.RECEIPT_VALUE : OutgoingMessageSignal.Type.CIPHERTEXT_VALUE)
|
||||
// .setTimestamp(timestamp)
|
||||
// .setMessage(ByteString.copyFrom(content.getBytes()))
|
||||
// .build();
|
||||
}
|
||||
|
||||
}
|
||||
Reference in new issue
Block a user