mirror of
https://github.com/moonlight-stream/moonlight-android.git
synced 2025-07-20 19:42:45 +00:00
Speed up initial discovery by generating a new keypair while discovering machines.
This commit is contained in:
parent
94a26fb831
commit
a3106bffca
@ -6,6 +6,7 @@ import java.net.InetAddress;
|
|||||||
import java.net.UnknownHostException;
|
import java.net.UnknownHostException;
|
||||||
|
|
||||||
import com.limelight.binding.PlatformBinding;
|
import com.limelight.binding.PlatformBinding;
|
||||||
|
import com.limelight.binding.crypto.AndroidCryptoProvider;
|
||||||
import com.limelight.computers.ComputerManagerListener;
|
import com.limelight.computers.ComputerManagerListener;
|
||||||
import com.limelight.computers.ComputerManagerService;
|
import com.limelight.computers.ComputerManagerService;
|
||||||
import com.limelight.nvstream.http.ComputerDetails;
|
import com.limelight.nvstream.http.ComputerDetails;
|
||||||
@ -59,6 +60,9 @@ public class PcView extends Activity {
|
|||||||
|
|
||||||
// Start updates
|
// Start updates
|
||||||
startComputerUpdates();
|
startComputerUpdates();
|
||||||
|
|
||||||
|
// Force a keypair to be generated early to avoid discovery delays
|
||||||
|
new AndroidCryptoProvider(PcView.this).getClientCertificate();
|
||||||
}
|
}
|
||||||
}.start();
|
}.start();
|
||||||
}
|
}
|
||||||
|
@ -51,6 +51,8 @@ public class AndroidCryptoProvider implements LimelightCryptoProvider {
|
|||||||
private RSAPrivateKey key;
|
private RSAPrivateKey key;
|
||||||
private byte[] pemCertBytes;
|
private byte[] pemCertBytes;
|
||||||
|
|
||||||
|
private static Object globalCryptoLock = new Object();
|
||||||
|
|
||||||
static {
|
static {
|
||||||
// Install the Bouncy Castle provider
|
// Install the Bouncy Castle provider
|
||||||
Security.addProvider(new BouncyCastleProvider());
|
Security.addProvider(new BouncyCastleProvider());
|
||||||
@ -208,7 +210,7 @@ public class AndroidCryptoProvider implements LimelightCryptoProvider {
|
|||||||
public X509Certificate getClientCertificate() {
|
public X509Certificate getClientCertificate() {
|
||||||
// Use a lock here to ensure only one guy will be generating or loading
|
// Use a lock here to ensure only one guy will be generating or loading
|
||||||
// the certificate and key at a time
|
// the certificate and key at a time
|
||||||
synchronized (this) {
|
synchronized (globalCryptoLock) {
|
||||||
// Return a loaded cert if we have one
|
// Return a loaded cert if we have one
|
||||||
if (cert != null) {
|
if (cert != null) {
|
||||||
return cert;
|
return cert;
|
||||||
@ -235,7 +237,7 @@ public class AndroidCryptoProvider implements LimelightCryptoProvider {
|
|||||||
public RSAPrivateKey getClientPrivateKey() {
|
public RSAPrivateKey getClientPrivateKey() {
|
||||||
// Use a lock here to ensure only one guy will be generating or loading
|
// Use a lock here to ensure only one guy will be generating or loading
|
||||||
// the certificate and key at a time
|
// the certificate and key at a time
|
||||||
synchronized (this) {
|
synchronized (globalCryptoLock) {
|
||||||
// Return a loaded key if we have one
|
// Return a loaded key if we have one
|
||||||
if (key != null) {
|
if (key != null) {
|
||||||
return key;
|
return key;
|
||||||
@ -260,7 +262,7 @@ public class AndroidCryptoProvider implements LimelightCryptoProvider {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public byte[] getPemEncodedClientCertificate() {
|
public byte[] getPemEncodedClientCertificate() {
|
||||||
synchronized (this) {
|
synchronized (globalCryptoLock) {
|
||||||
// Call our helper function to do the cert loading/generation for us
|
// Call our helper function to do the cert loading/generation for us
|
||||||
getClientCertificate();
|
getClientCertificate();
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user