Skip to content

Commit

Permalink
1.0
Browse files Browse the repository at this point in the history
Client:
- allow passing single exe to simplify wrappers
- don't fetch unnecessary data

Server:
- verify signatures in background, don't make the client wait
- don't read unused entries/signatures
  • Loading branch information
poison committed Oct 21, 2018
2 parents 6d5b7dd + e39592a commit 436294a
Show file tree
Hide file tree
Showing 35 changed files with 1,368 additions and 521 deletions.
20 changes: 11 additions & 9 deletions arch/PKGBUILD
Original file line number Diff line number Diff line change
@@ -1,35 +1,37 @@
_pkgname=dxvk-cache-pool
pkgname=("dxvk-cache-server-git" "dxvk-cache-client-git")
# Maintainer: rc.poison <rc dot poison at gmail dot com>

pkgbase=dxvk-cache-pool
pkgname=("dxvk-cache-client-git" "dxvk-cache-server-git")
pkgver=r149.0291c01
pkgrel=1
pkgdesc='Client/server to share DXVK pipeline caches.'
pkgdesc='Client/server to share DXVK pipeline caches for smoother wine gaming.'
arch=('any')
url='https://github.com/rcpoison/dxvk-cache-pool'
license=('Apache')
license=('Apache 2')
depends=('java-runtime>=8')
makedepends=('git' 'maven' 'java-environment>=8')
source=('git+https://github.com/rcpoison/dxvk-cache-pool.git')
sha1sums=('SKIP')

pkgver() {
cd "$_pkgname"
printf "r%s.%s" "$(git rev-list --count HEAD)" "$(git rev-parse --short HEAD)"
cd "$pkgbase"
git describe --long --tags | sed 's/\([^-]*-g\)/r\1/;s/-/./g'
}


build() {
cd "$_pkgname"
cd "$pkgbase"
./build.sh
}

package_dxvk-cache-server-git() {
cd "$_pkgname"
cd "$pkgbase"
install -Dm755 dxvk-cache-server -t "$pkgdir"/usr/bin
install -Dm644 dxvk-cache-server.service -t "$pkgdir"/usr/lib/systemd/system/
}

package_dxvk-cache-client-git() {
cd "$_pkgname"
cd "$pkgbase"
install -Dm755 dxvk-cache-client -t "$pkgdir"/usr/bin
install -Dm755 dxvk-cache-pool.sh -t "$pkgdir"/etc/profile.d
}

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,15 @@
import com.ignorelist.kassandra.dxvk.cache.pool.common.crypto.IdentityWithVerification;
import com.ignorelist.kassandra.dxvk.cache.pool.common.crypto.PublicKey;
import com.ignorelist.kassandra.dxvk.cache.pool.common.crypto.PublicKeyInfo;
import com.ignorelist.kassandra.dxvk.cache.pool.common.crypto.SignatureCount;
import com.ignorelist.kassandra.dxvk.cache.pool.common.model.PredicateStateCacheEntrySigned;
import com.ignorelist.kassandra.dxvk.cache.pool.common.model.StateCache;
import com.ignorelist.kassandra.dxvk.cache.pool.common.model.StateCacheEntry;
import com.ignorelist.kassandra.dxvk.cache.pool.common.model.StateCacheEntryInfo;
import com.ignorelist.kassandra.dxvk.cache.pool.common.model.StateCacheEntrySigned;
import com.ignorelist.kassandra.dxvk.cache.pool.common.model.StateCacheInfo;
import com.ignorelist.kassandra.dxvk.cache.pool.common.model.StateCacheInfoSignees;
import com.ignorelist.kassandra.dxvk.cache.pool.common.model.StateCacheMeta;
import com.ignorelist.kassandra.dxvk.cache.pool.common.model.StateCacheSigned;
import java.io.IOException;
import java.util.Set;
Expand Down Expand Up @@ -51,6 +54,8 @@ public class CachePoolRestClient extends AbstractRestClient implements CacheStor
};
private static final GenericType<Set<PublicKeyInfo>> TYPE_PUBLIC_KEY_INFO_SET=new GenericType<Set<PublicKeyInfo>>() {
};
private static final GenericType<Set<SignatureCount>> TYPE_SIGNATURE_COUNT_SET=new GenericType<Set<SignatureCount>>() {
};

public CachePoolRestClient(String baseUrl) {
super(baseUrl);
Expand Down Expand Up @@ -130,6 +135,15 @@ public Set<String> findBaseNames(int version, String subString) {
.get(TYPE_STRING_SET);
}

@Override
public Set<String> getAvilableBaseNames(int version, Set<String> baseNames) {
return getWebTarget()
.path("getAvailableBaseNames")
.path(Integer.toString(version))
.request(MediaType.APPLICATION_JSON)
.post(Entity.json(baseNames), TYPE_STRING_SET);
}

@Override
public StateCacheInfoSignees getCacheDescriptorSignees(int version, String baseName) {
return getWebTarget()
Expand Down Expand Up @@ -228,4 +242,28 @@ public void storeIdentity(IdentityWithVerification identityWithVerification) thr
throw new UnsupportedOperationException("Not supported yet."); //TODO: implement
}

@Override
public Set<SignatureCount> getSignatureCounts(int version, String baseName) {
return getWebTarget()
.path("signatureCounts")
.path(Integer.toString(version))
.path(baseName)
.request(MediaType.APPLICATION_JSON)
.get(TYPE_SIGNATURE_COUNT_SET);
}

@Override
public Set<SignatureCount> getTotalSignatureCounts(int version) {
return getWebTarget()
.path("totalSignatureCounts")
.path(Integer.toString(version))
.request(MediaType.APPLICATION_JSON)
.get(TYPE_SIGNATURE_COUNT_SET);
}

@Override
public Set<StateCacheEntry> getCacheEntries(StateCacheMeta cacheMeta, Set<StateCacheEntryInfo> cacheEntryInfos) {
throw new UnsupportedOperationException("Not supported."); // TODO: I don't think this needs to be exported through REST. Maybe introduce another iface.
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@

import com.ignorelist.kassandra.dxvk.cache.pool.common.model.StateCache;
import com.ignorelist.kassandra.dxvk.cache.pool.common.model.StateCacheEntry;
import com.ignorelist.kassandra.dxvk.cache.pool.common.model.StateCacheEntryInfo;
import com.ignorelist.kassandra.dxvk.cache.pool.common.model.StateCacheInfo;
import com.ignorelist.kassandra.dxvk.cache.pool.common.model.StateCacheMeta;
import java.io.Closeable;
import java.io.IOException;
import java.util.Set;
Expand All @@ -30,4 +32,8 @@ public interface CacheStorage extends Closeable {

Set<StateCacheInfo> getCacheDescriptors(int version, Set<String> baseNames);

Set<StateCacheEntry> getCacheEntries(final StateCacheMeta cacheMeta, final Set<StateCacheEntryInfo> cacheEntryInfos);

Set<String> getAvilableBaseNames(final int version, final Set<String> baseNames);

}
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
*/
package com.ignorelist.kassandra.dxvk.cache.pool.common.api;

import com.ignorelist.kassandra.dxvk.cache.pool.common.crypto.SignatureCount;
import com.ignorelist.kassandra.dxvk.cache.pool.common.model.PredicateStateCacheEntrySigned;
import com.ignorelist.kassandra.dxvk.cache.pool.common.model.StateCacheEntrySigned;
import com.ignorelist.kassandra.dxvk.cache.pool.common.model.StateCacheInfo;
Expand All @@ -31,4 +32,8 @@ public interface CacheStorageSigned {

Set<StateCacheInfoSignees> getCacheDescriptorsSignees(int version, Set<String> baseNames);

Set<SignatureCount> getSignatureCounts(final int version, final String baseName);

Set<SignatureCount> getTotalSignatureCounts(final int version);

}
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,15 @@
import com.ignorelist.kassandra.dxvk.cache.pool.common.crypto.IdentityVerification;
import com.ignorelist.kassandra.dxvk.cache.pool.common.crypto.IdentityWithVerification;
import com.ignorelist.kassandra.dxvk.cache.pool.common.crypto.PublicKeyInfo;
import java.io.Closeable;
import java.io.IOException;
import java.util.Set;

/**
*
* @author poison
*/
public interface IdentityStorage {

public interface IdentityStorage extends Closeable {

Identity getIdentity(final PublicKeyInfo keyInfo);

Expand All @@ -26,5 +26,5 @@ public interface IdentityStorage {
void storeIdentity(IdentityWithVerification identityWithVerification) throws IOException;

Set<PublicKeyInfo> getVerifiedKeyInfos();

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package com.ignorelist.kassandra.dxvk.cache.pool.common.api;

import com.google.common.base.Predicate;
import com.google.common.collect.ImmutableSet;
import com.ignorelist.kassandra.dxvk.cache.pool.common.crypto.PublicKeyInfo;
import com.ignorelist.kassandra.dxvk.cache.pool.common.model.PredicateStateCacheEntrySigned;
import java.util.Set;

/**
*
* @author poison
*/
public class PredicatePublicKeyInfo implements Predicate<PublicKeyInfo> {

private final IdentityStorage identityStorage;
private final ImmutableSet<PublicKeyInfo> acceptedPublicKeys;
private final boolean onlyAcceptVerifiedKeys;

public PredicatePublicKeyInfo(final IdentityStorage identityStorage, final ImmutableSet<PublicKeyInfo> acceptedPublicKeys, final boolean onlyAcceptVerifiedKeys) {
this.identityStorage=identityStorage;
this.acceptedPublicKeys=acceptedPublicKeys;
this.onlyAcceptVerifiedKeys=onlyAcceptVerifiedKeys;
}

@Override
public boolean apply(PublicKeyInfo input) {
boolean accept=true;
if (onlyAcceptVerifiedKeys) {
accept&=null!=identityStorage.getIdentity(input);
}
if (null!=acceptedPublicKeys) {
accept&=acceptedPublicKeys.contains(input);
}
return accept;
}

public static PredicatePublicKeyInfo buildFrom(final IdentityStorage identityStorage, final PredicateStateCacheEntrySigned predicateStateCacheEntrySigned) {
if (null!=predicateStateCacheEntrySigned.getAcceptedPublicKeys()) {
Set<PublicKeyInfo> accepted=predicateStateCacheEntrySigned.getAcceptedPublicKeys().getAcceptedPublicKeys();
if (null!=accepted&&!accepted.isEmpty()) {
return new PredicatePublicKeyInfo(identityStorage, ImmutableSet.copyOf(accepted), predicateStateCacheEntrySigned.isOnlyAcceptVerifiedKeys());
}
}
return new PredicatePublicKeyInfo(identityStorage, null, predicateStateCacheEntrySigned.isOnlyAcceptVerifiedKeys());
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@

import com.google.common.base.Predicate;
import com.google.common.collect.ImmutableSet;
import com.ignorelist.kassandra.dxvk.cache.pool.common.api.IdentityStorage;
import com.ignorelist.kassandra.dxvk.cache.pool.common.crypto.PublicKeyInfo;
import com.ignorelist.kassandra.dxvk.cache.pool.common.crypto.SignaturePublicKeyInfo;
import com.ignorelist.kassandra.dxvk.cache.pool.common.model.PredicateStateCacheEntrySigned;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ public interface SignatureStorage extends IdentityStorage {

Set<SignaturePublicKeyInfo> getSignatures(final StateCacheEntryInfo entryInfo);

Set<SignaturePublicKeyInfo> getSignatures(final StateCacheEntryInfo entryInfo, final Set<PublicKeyInfo> signedBy);

Set<PublicKeyInfo> getSignedBy(final StateCacheEntryInfo entryInfo);

void storePublicKey(final PublicKey publicKey) throws IOException;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package com.ignorelist.kassandra.dxvk.cache.pool.common.crypto;

import com.google.common.collect.ImmutableSet;
import com.google.common.collect.Multiset;
import java.io.Serializable;
import java.util.Comparator;
import java.util.Set;
import javax.xml.bind.annotation.XmlRootElement;

/**
*
* @author poison
*/
@XmlRootElement
public class SignatureCount implements Serializable, Comparable<SignatureCount> {

private static final Comparator<SignatureCount> DEFAULT_COMPARATOR=Comparator
.comparingInt(SignatureCount::getSignatureCount)
.thenComparingInt(SignatureCount::getEntryCount);

private int signatureCount;
private int entryCount;

public SignatureCount() {
}

public SignatureCount(int signature, int count) {
this.signatureCount=signature;
this.entryCount=count;
}

public SignatureCount(Multiset.Entry<Integer> e) {
this(e.getElement(), e.getCount());
}

public int getSignatureCount() {
return signatureCount;
}

public void setSignatureCount(int signatureCount) {
this.signatureCount=signatureCount;
}

public int getEntryCount() {
return entryCount;
}

public void setEntryCount(int entryCount) {
this.entryCount=entryCount;
}

@Override
public int hashCode() {
int hash=3;
hash=71*hash+this.signatureCount;
hash=71*hash+this.entryCount;
return hash;
}

public static Set<SignatureCount> build(Multiset<Integer> stats) {
return stats.entrySet().stream()
.map(SignatureCount::new)
.collect(ImmutableSet.toImmutableSet());
}

@Override
public boolean equals(Object obj) {
if (this==obj) {
return true;
}
if (obj==null) {
return false;
}
if (getClass()!=obj.getClass()) {
return false;
}
final SignatureCount other=(SignatureCount) obj;
if (this.signatureCount!=other.signatureCount) {
return false;
}
if (this.entryCount!=other.entryCount) {
return false;
}
return true;
}

@Override
public int compareTo(SignatureCount o) {
return DEFAULT_COMPARATOR.compare(this, o);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
* @author poison
*/
@XmlRootElement
public class PredicateAcceptedPublicKeys implements Serializable, Predicate<StateCacheEntrySigned> {
public class PredicateAcceptedPublicKeys implements Serializable, Predicate<StateCacheEntrySignees> {

private Set<PublicKeyInfo> acceptedPublicKeys;

Expand All @@ -38,9 +38,10 @@ public void setAcceptedPublicKeys(Set<PublicKeyInfo> acceptedPublicKeys) {
}

@Override
public boolean apply(StateCacheEntrySigned entry) {
public boolean apply(StateCacheEntrySignees entry) {
if (null!=acceptedPublicKeys&&!acceptedPublicKeys.isEmpty()) {
return null!=entry.getSignatures()&&!Collections.disjoint(acceptedPublicKeys, entry.getSignatures());
final Set<PublicKeyInfo> publicKeyInfos=entry.getPublicKeyInfos();
return null!=publicKeyInfos&&!Collections.disjoint(acceptedPublicKeys, publicKeyInfos);
}
return true;
}
Expand Down Expand Up @@ -70,4 +71,9 @@ public boolean equals(Object obj) {
return true;
}

@Override
public String toString() {
return "PredicateAcceptedPublicKeys{"+"acceptedPublicKeys="+acceptedPublicKeys+'}';
}

}
Loading

0 comments on commit 436294a

Please sign in to comment.