Skip to content

Commit cba6d1d

Browse files
authored
Allow more European countries in free mode (#636)
1 parent 3feed48 commit cba6d1d

4 files changed

Lines changed: 18 additions & 9 deletions

File tree

freebuff/web/src/app/home-client.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ const faqs = [
3131
{
3232
question: 'Which countries is Freebuff available in?',
3333
answer:
34-
'Freebuff is currently available in:\n\nUnited States, Canada, United Kingdom, Australia, New Zealand, Norway, Sweden, Netherlands, Denmark, Germany, Finland, Belgium, Luxembourg, Liechtenstein, Switzerland, Austria, Singapore, Malta, Israel, Ireland, and Iceland.',
34+
'Freebuff is currently available in:\n\nUnited States, Canada, United Kingdom, Australia, New Zealand, Norway, Sweden, Netherlands, Denmark, Germany, France, Italy, Spain, Portugal, Finland, Belgium, Luxembourg, Liechtenstein, Switzerland, Austria, Singapore, Malta, Israel, Ireland, and Iceland.',
3535
},
3636
{
3737
question: 'Are you training on my data?',

web/src/app/api/v1/freebuff/session/__tests__/session.test.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -230,15 +230,15 @@ describe('POST /api/v1/freebuff/session', () => {
230230
test('returns country_blocked without joining the queue for disallowed country', async () => {
231231
const sessionDeps = makeSessionDeps()
232232
const resp = await postFreebuffSession(
233-
makeReq('ok', { cfCountry: 'FR' }),
233+
makeReq('ok', { cfCountry: 'JP' }),
234234
makeDeps(sessionDeps, 'u1'),
235235
)
236236
// 403 (not 200) so older CLIs that don't know `country_blocked` fall into
237237
// their error-retry backoff instead of tight-polling.
238238
expect(resp.status).toBe(403)
239239
const body = await resp.json()
240240
expect(body.status).toBe('country_blocked')
241-
expect(body.countryCode).toBe('FR')
241+
expect(body.countryCode).toBe('JP')
242242
expect(body.countryBlockReason).toBe('country_not_allowed')
243243
expect(sessionDeps.rows.size).toBe(0)
244244
})
@@ -326,13 +326,13 @@ describe('GET /api/v1/freebuff/session', () => {
326326
test('returns country_blocked for disallowed country on GET', async () => {
327327
const sessionDeps = makeSessionDeps()
328328
const resp = await getFreebuffSession(
329-
makeReq('ok', { cfCountry: 'FR' }),
329+
makeReq('ok', { cfCountry: 'JP' }),
330330
makeDeps(sessionDeps, 'u1'),
331331
)
332332
expect(resp.status).toBe(403)
333333
const body = await resp.json()
334334
expect(body.status).toBe('country_blocked')
335-
expect(body.countryCode).toBe('FR')
335+
expect(body.countryCode).toBe('JP')
336336
expect(body.countryBlockReason).toBe('country_not_allowed')
337337
})
338338

@@ -358,7 +358,7 @@ describe('GET /api/v1/freebuff/session', () => {
358358
})
359359
let countryChecks = 0
360360
const resp = await getFreebuffSession(
361-
makeReq('ok', { cfCountry: 'FR' }),
361+
makeReq('ok', { cfCountry: 'JP' }),
362362
makeDeps(sessionDeps, 'u1', {
363363
getCountryAccess: async (req) => {
364364
countryChecks++

web/src/server/__tests__/free-mode-country.test.ts

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,11 @@ describe('free mode country access', () => {
2929
['SG', 'SG'],
3030
['MT', 'MT'],
3131
['IL', 'IL'],
32+
['FR', 'FR'],
33+
['BE', 'BE'],
34+
['IT', 'IT'],
35+
['ES', 'ES'],
36+
['PT', 'PT'],
3237
])('allows allowlisted Cloudflare country %s', async (header, expected) => {
3338
const access = await getFreeModeCountryAccess(
3439
makeReq({
@@ -44,11 +49,11 @@ describe('free mode country access', () => {
4449

4550
test('blocks countries outside the allowlist', async () => {
4651
const access = await getFreeModeCountryAccess(
47-
makeReq({ 'cf-ipcountry': 'FR' }),
52+
makeReq({ 'cf-ipcountry': 'JP' }),
4853
noAnonymousNetwork,
4954
)
5055
expect(access.allowed).toBe(false)
51-
expect(access.countryCode).toBe('FR')
56+
expect(access.countryCode).toBe('JP')
5257
expect(access.blockReason).toBe('country_not_allowed')
5358
})
5459

@@ -295,7 +300,7 @@ describe('free mode country access', () => {
295300

296301
test('allowLocalhost does not bypass when cf-ipcountry is set', async () => {
297302
const access = await getFreeModeCountryAccess(
298-
makeReq({ 'cf-ipcountry': 'FR' }),
303+
makeReq({ 'cf-ipcountry': 'JP' }),
299304
{
300305
ipinfoToken: 'test-token',
301306
allowLocalhost: true,

web/src/server/free-mode-country.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,10 @@ export const FREE_MODE_ALLOWED_COUNTRIES = new Set([
1919
'NL',
2020
'DK',
2121
'DE',
22+
'FR',
23+
'IT',
24+
'ES',
25+
'PT',
2226
'FI',
2327
'BE',
2428
'LU',

0 commit comments

Comments
 (0)