Skip to content
Snippets Groups Projects
Commit 3e6b991c authored by akwizgran's avatar akwizgran
Browse files

Don't use vanilla bridges when non-default obfs4 are recommended.

parent aaf2001e
No related branches found
No related tags found
1 merge request!17Update bridges, refactor bridge configuration
Pipeline #16191 passed
......@@ -28,22 +28,27 @@ public interface CircumventionProvider {
/**
* Countries where default obfs4 bridges should be used.
*/
String[] COUNTRIES_DEFAULT_BRIDGES = {"BY"};
String[] COUNTRIES_DEFAULT_OBFS4 = {"BY"};
/**
* Countries where non-default obfs4 and vanilla bridges should be used.
* Countries where non-default obfs4 bridges should be used.
*/
String[] COUNTRIES_NON_DEFAULT_BRIDGES = {"BY", "CN", "EG", "HK", "IR", "RU"};
String[] COUNTRIES_NON_DEFAULT_OBFS4 = {"BY", "CN", "EG", "HK", "IR", "RU"};
/**
* Countries where vanilla bridges should be used.
*/
String[] COUNTRIES_VANILLA = {"BY"};
/**
* Countries where meek bridges should be used.
*/
String[] COUNTRIES_MEEK_BRIDGES = {"TM"};
String[] COUNTRIES_MEEK = {"TM"};
/**
* Countries where snowflake bridges should be used.
*/
String[] COUNTRIES_SNOWFLAKE_BRIDGES = {"BY", "CN", "EG", "HK", "IR", "RU", "TM"};
String[] COUNTRIES_SNOWFLAKE = {"BY", "CN", "EG", "HK", "IR", "RU", "TM"};
/**
* Returns the types of bridge connection that are suitable for the given country, or
......
......@@ -27,14 +27,13 @@ class CircumventionProviderImpl implements CircumventionProvider {
private static final String DEFAULT_COUNTRY_CODE = "ZZ";
private static final Set<String> DEFAULT_BRIDGES =
new HashSet<>(asList(COUNTRIES_DEFAULT_BRIDGES));
private static final Set<String> NON_DEFAULT_BRIDGES =
new HashSet<>(asList(COUNTRIES_NON_DEFAULT_BRIDGES));
private static final Set<String> MEEK_BRIDGES =
new HashSet<>(asList(COUNTRIES_MEEK_BRIDGES));
private static final Set<String> SNOWFLAKE_BRIDGES =
new HashSet<>(asList(COUNTRIES_SNOWFLAKE_BRIDGES));
private static final Set<String> USE_DEFAULT_OBFS4 =
new HashSet<>(asList(COUNTRIES_DEFAULT_OBFS4));
private static final Set<String> USE_NON_DEFAULT_OBFS4 =
new HashSet<>(asList(COUNTRIES_NON_DEFAULT_OBFS4));
private static final Set<String> USE_VANILLA = new HashSet<>(asList(COUNTRIES_VANILLA));
private static final Set<String> USE_MEEK = new HashSet<>(asList(COUNTRIES_MEEK));
private static final Set<String> USE_SNOWFLAKE = new HashSet<>(asList(COUNTRIES_SNOWFLAKE));
@Inject
CircumventionProviderImpl() {
......@@ -43,15 +42,11 @@ class CircumventionProviderImpl implements CircumventionProvider {
@Override
public List<BridgeType> getSuitableBridgeTypes(String countryCode) {
List<BridgeType> types = new ArrayList<>();
if (DEFAULT_BRIDGES.contains(countryCode)) {
types.add(DEFAULT_OBFS4);
}
if (NON_DEFAULT_BRIDGES.contains(countryCode)) {
types.add(NON_DEFAULT_OBFS4);
types.add(VANILLA);
}
if (MEEK_BRIDGES.contains(countryCode)) types.add(MEEK);
if (SNOWFLAKE_BRIDGES.contains(countryCode)) types.add(SNOWFLAKE);
if (USE_DEFAULT_OBFS4.contains(countryCode)) types.add(DEFAULT_OBFS4);
if (USE_NON_DEFAULT_OBFS4.contains(countryCode)) types.add(NON_DEFAULT_OBFS4);
if (USE_VANILLA.contains(countryCode)) types.add(VANILLA);
if (USE_MEEK.contains(countryCode)) types.add(MEEK);
if (USE_SNOWFLAKE.contains(countryCode)) types.add(SNOWFLAKE);
// If we don't have any recommendations for this country then use the defaults
if (types.isEmpty()) {
types.add(DEFAULT_OBFS4);
......
......@@ -8,10 +8,11 @@ import static org.briarproject.onionwrapper.CircumventionProvider.BridgeType.MEE
import static org.briarproject.onionwrapper.CircumventionProvider.BridgeType.NON_DEFAULT_OBFS4;
import static org.briarproject.onionwrapper.CircumventionProvider.BridgeType.SNOWFLAKE;
import static org.briarproject.onionwrapper.CircumventionProvider.BridgeType.VANILLA;
import static org.briarproject.onionwrapper.CircumventionProvider.COUNTRIES_DEFAULT_BRIDGES;
import static org.briarproject.onionwrapper.CircumventionProvider.COUNTRIES_MEEK_BRIDGES;
import static org.briarproject.onionwrapper.CircumventionProvider.COUNTRIES_NON_DEFAULT_BRIDGES;
import static org.briarproject.onionwrapper.CircumventionProvider.COUNTRIES_SNOWFLAKE_BRIDGES;
import static org.briarproject.onionwrapper.CircumventionProvider.COUNTRIES_DEFAULT_OBFS4;
import static org.briarproject.onionwrapper.CircumventionProvider.COUNTRIES_MEEK;
import static org.briarproject.onionwrapper.CircumventionProvider.COUNTRIES_NON_DEFAULT_OBFS4;
import static org.briarproject.onionwrapper.CircumventionProvider.COUNTRIES_SNOWFLAKE;
import static org.briarproject.onionwrapper.CircumventionProvider.COUNTRIES_VANILLA;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
......@@ -22,17 +23,19 @@ public class CircumventionProviderImplTest extends BaseTest {
@Test
public void testGetSuitableBridgeTypes() {
for (String countryCode : COUNTRIES_DEFAULT_BRIDGES) {
for (String countryCode : COUNTRIES_DEFAULT_OBFS4) {
testBridgesAreSuitableAndExist(DEFAULT_OBFS4, countryCode);
}
for (String countryCode : COUNTRIES_NON_DEFAULT_BRIDGES) {
for (String countryCode : COUNTRIES_NON_DEFAULT_OBFS4) {
testBridgesAreSuitableAndExist(NON_DEFAULT_OBFS4, countryCode);
}
for (String countryCode : COUNTRIES_VANILLA) {
testBridgesAreSuitableAndExist(VANILLA, countryCode);
}
for (String countryCode : COUNTRIES_MEEK_BRIDGES) {
for (String countryCode : COUNTRIES_MEEK) {
testBridgesAreSuitableAndExist(MEEK, countryCode);
}
for (String countryCode : COUNTRIES_SNOWFLAKE_BRIDGES) {
for (String countryCode : COUNTRIES_SNOWFLAKE) {
testBridgesAreSuitableAndExist(SNOWFLAKE, countryCode);
}
// If bridges are enabled manually in a country with no specific bridge recommendations,
......
......@@ -30,10 +30,11 @@ import static org.briarproject.onionwrapper.CircumventionProvider.BridgeType.MEE
import static org.briarproject.onionwrapper.CircumventionProvider.BridgeType.NON_DEFAULT_OBFS4;
import static org.briarproject.onionwrapper.CircumventionProvider.BridgeType.SNOWFLAKE;
import static org.briarproject.onionwrapper.CircumventionProvider.BridgeType.VANILLA;
import static org.briarproject.onionwrapper.CircumventionProvider.COUNTRIES_DEFAULT_BRIDGES;
import static org.briarproject.onionwrapper.CircumventionProvider.COUNTRIES_MEEK_BRIDGES;
import static org.briarproject.onionwrapper.CircumventionProvider.COUNTRIES_NON_DEFAULT_BRIDGES;
import static org.briarproject.onionwrapper.CircumventionProvider.COUNTRIES_SNOWFLAKE_BRIDGES;
import static org.briarproject.onionwrapper.CircumventionProvider.COUNTRIES_DEFAULT_OBFS4;
import static org.briarproject.onionwrapper.CircumventionProvider.COUNTRIES_MEEK;
import static org.briarproject.onionwrapper.CircumventionProvider.COUNTRIES_NON_DEFAULT_OBFS4;
import static org.briarproject.onionwrapper.CircumventionProvider.COUNTRIES_SNOWFLAKE;
import static org.briarproject.onionwrapper.CircumventionProvider.COUNTRIES_VANILLA;
import static org.briarproject.onionwrapper.TestUtils.deleteTestDirectory;
import static org.briarproject.onionwrapper.TestUtils.getArchitectureForTorBinary;
import static org.briarproject.onionwrapper.TestUtils.getTestDirectory;
......@@ -71,27 +72,29 @@ public class BridgeTest extends BaseTest {
if (bridges.add(bridge)) states.add(new Params(bridge, type, stats));
}
}
for (String countryCode : COUNTRIES_DEFAULT_BRIDGES) {
for (String countryCode : COUNTRIES_DEFAULT_OBFS4) {
for (String bridge : provider.getBridges(DEFAULT_OBFS4, countryCode)) {
if (bridges.add(bridge)) states.add(new Params(bridge, DEFAULT_OBFS4, stats));
}
}
for (String countryCode : COUNTRIES_NON_DEFAULT_BRIDGES) {
for (String countryCode : COUNTRIES_NON_DEFAULT_OBFS4) {
for (String bridge : provider.getBridges(NON_DEFAULT_OBFS4, countryCode)) {
if (bridges.add(bridge)) {
states.add(new Params(bridge, NON_DEFAULT_OBFS4, stats));
}
}
}
for (String countryCode : COUNTRIES_VANILLA) {
for (String bridge : provider.getBridges(VANILLA, countryCode)) {
if (bridges.add(bridge)) states.add(new Params(bridge, VANILLA, stats));
}
}
for (String countryCode : COUNTRIES_MEEK_BRIDGES) {
for (String countryCode : COUNTRIES_MEEK) {
for (String bridge : provider.getBridges(MEEK, countryCode)) {
if (bridges.add(bridge)) states.add(new Params(bridge, MEEK, stats));
}
}
for (String countryCode : COUNTRIES_SNOWFLAKE_BRIDGES) {
for (String countryCode : COUNTRIES_SNOWFLAKE) {
for (String bridge : provider.getBridges(SNOWFLAKE, countryCode)) {
if (bridges.add(bridge)) states.add(new Params(bridge, SNOWFLAKE, stats));
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment