@samitouri / QOSami-HFS / commits / 4a34c902

fix: (beta) country was not logged if geo had no restrictions

Massimo Melina committed Jan 10, 2024 at 17:18 UTC 4a34c90231c6f08ab89aa7839adb11685178c9e6
1 file changed +2 -2
src/geo.ts
+2 -2
@@ -17,12 +17,12 @@ setInterval(checkFiles, DAY) // keep updated at run-time
17 export const ip2country = _.memoize((ip: string) => ip2location.getCountryShortAsync(ip).then(v => v === '-' ? '' : v, () => ''))
18
19 export const geoFilter: Middleware = async (ctx, next) => {
20 - if (!ctx.state.skipFilters && enabled.get() && allow.get() !== null && !isLocalHost(ctx)) {
20 + if (enabled.get() && !isLocalHost(ctx)) {
21 const { connection } = ctx.state
22 const country = connection.country ??= await ip2country(ctx.ip)
23 if (country)
24 updateConnection(connection, { country })
25 - if (allow.get() !== null)
25 + if (!ctx.state.skipFilters && allow.get() !== null)
26 if (country ? list.get().includes(country) !== allow.get() : !allowUnknown.get())
27 return disconnect(ctx)
28 }