Browse Source

Merge pull request #346 from oxen-io/performance

Improve Onion Request Path Loading Efficiency
pull/349/head
Niels Andriesse 2 years ago committed by GitHub
parent
commit
3183b0ef9a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 32
      Session.xcodeproj/project.pbxproj
  2. 296323
      Session/Meta/CSV/GeoLite2-Country-Blocks-IPv4.csv
  3. 253
      Session/Meta/CSV/GeoLite2-Country-Locations-English.csv
  4. BIN
      Session/Meta/Countries/GeoLite2-Country-Blocks-IPv4
  5. BIN
      Session/Meta/Countries/GeoLite2-Country-Locations-English
  6. 21
      Session/Utilities/IP2Country.swift

32
Session.xcodeproj/project.pbxproj

@ -305,6 +305,8 @@
B8D64FCB25BA78A90029CFC0 /* SignalUtilitiesKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = C33FD9AB255A548A00E217F9 /* SignalUtilitiesKit.framework */; };
B8FF8DAE25C0D00F004D1F22 /* SessionMessagingKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = C3C2A6F025539DE700C340D1 /* SessionMessagingKit.framework */; };
B8FF8DAF25C0D00F004D1F22 /* SessionUtilitiesKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = C3C2A679255388CC00C340D1 /* SessionUtilitiesKit.framework */; };
B8FF8E6225C10DA5004D1F22 /* GeoLite2-Country-Blocks-IPv4 in Resources */ = {isa = PBXBuildFile; fileRef = B8FF8E6125C10DA5004D1F22 /* GeoLite2-Country-Blocks-IPv4 */; };
B8FF8E7425C10FC3004D1F22 /* GeoLite2-Country-Locations-English in Resources */ = {isa = PBXBuildFile; fileRef = B8FF8E7325C10FC3004D1F22 /* GeoLite2-Country-Locations-English */; };
B90418E6183E9DD40038554A /* DateUtil.m in Sources */ = {isa = PBXBuildFile; fileRef = B90418E5183E9DD40038554A /* DateUtil.m */; };
B9EB5ABD1884C002007CBB57 /* MessageUI.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = B9EB5ABC1884C002007CBB57 /* MessageUI.framework */; };
C300A5B22554AF9800555489 /* VisibleMessage+Profile.swift in Sources */ = {isa = PBXBuildFile; fileRef = C300A5B12554AF9800555489 /* VisibleMessage+Profile.swift */; };
@ -543,8 +545,6 @@
C3548F0624456447009433A8 /* PNModeVC.swift in Sources */ = {isa = PBXBuildFile; fileRef = C3548F0524456447009433A8 /* PNModeVC.swift */; };
C3548F0824456AB6009433A8 /* UIView+Wrapping.swift in Sources */ = {isa = PBXBuildFile; fileRef = C3548F0724456AB6009433A8 /* UIView+Wrapping.swift */; };
C354E75A23FE2A7600CE22E3 /* BaseVC.swift in Sources */ = {isa = PBXBuildFile; fileRef = C354E75923FE2A7600CE22E3 /* BaseVC.swift */; };
C35E8AA82485C85800ACB629 /* GeoLite2-Country-Locations-English.csv in Resources */ = {isa = PBXBuildFile; fileRef = C35E8AA52485C85400ACB629 /* GeoLite2-Country-Locations-English.csv */; };
C35E8AA92485C85800ACB629 /* GeoLite2-Country-Blocks-IPv4.csv in Resources */ = {isa = PBXBuildFile; fileRef = C35E8AA62485C85600ACB629 /* GeoLite2-Country-Blocks-IPv4.csv */; };
C35E8AAE2485E51D00ACB629 /* IP2Country.swift in Sources */ = {isa = PBXBuildFile; fileRef = C35E8AAD2485E51D00ACB629 /* IP2Country.swift */; };
C3645350252449260045C478 /* VoiceMessageView.swift in Sources */ = {isa = PBXBuildFile; fileRef = C364534F252449260045C478 /* VoiceMessageView.swift */; };
C364535C252467900045C478 /* AudioUtilities.swift in Sources */ = {isa = PBXBuildFile; fileRef = C364535B252467900045C478 /* AudioUtilities.swift */; };
@ -1356,6 +1356,8 @@
B8D8F19225661BF80092EF10 /* Storage+Messaging.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "Storage+Messaging.swift"; sourceTree = "<group>"; };
B8D8F1BC25661C6F0092EF10 /* Storage+OnionRequests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "Storage+OnionRequests.swift"; sourceTree = "<group>"; };
B8D8F1EF256621180092EF10 /* MessageSender+Convenience.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; name = "MessageSender+Convenience.swift"; path = "../../SignalUtilitiesKit/Messaging/Sending & Receiving/MessageSender+Convenience.swift"; sourceTree = "<group>"; };
B8FF8E6125C10DA5004D1F22 /* GeoLite2-Country-Blocks-IPv4 */ = {isa = PBXFileReference; lastKnownFileType = file.bplist; name = "GeoLite2-Country-Blocks-IPv4"; path = "Countries/GeoLite2-Country-Blocks-IPv4"; sourceTree = "<group>"; };
B8FF8E7325C10FC3004D1F22 /* GeoLite2-Country-Locations-English */ = {isa = PBXFileReference; lastKnownFileType = file.bplist; name = "GeoLite2-Country-Locations-English"; path = "Countries/GeoLite2-Country-Locations-English"; sourceTree = "<group>"; };
B90418E4183E9DD40038554A /* DateUtil.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DateUtil.h; sourceTree = "<group>"; };
B90418E5183E9DD40038554A /* DateUtil.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = DateUtil.m; sourceTree = "<group>"; };
B9EB5ABC1884C002007CBB57 /* MessageUI.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = MessageUI.framework; path = System/Library/Frameworks/MessageUI.framework; sourceTree = SDKROOT; };
@ -1596,8 +1598,6 @@
C3548F0724456AB6009433A8 /* UIView+Wrapping.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "UIView+Wrapping.swift"; sourceTree = "<group>"; };
C354E75923FE2A7600CE22E3 /* BaseVC.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BaseVC.swift; sourceTree = "<group>"; };
C35E8AA22485C72300ACB629 /* SwiftCSV.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = SwiftCSV.framework; path = ThirdParty/Carthage/Build/iOS/SwiftCSV.framework; sourceTree = "<group>"; };
C35E8AA52485C85400ACB629 /* GeoLite2-Country-Locations-English.csv */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = "GeoLite2-Country-Locations-English.csv"; sourceTree = "<group>"; };
C35E8AA62485C85600ACB629 /* GeoLite2-Country-Blocks-IPv4.csv */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = "GeoLite2-Country-Blocks-IPv4.csv"; sourceTree = "<group>"; };
C35E8AAD2485E51D00ACB629 /* IP2Country.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = IP2Country.swift; sourceTree = "<group>"; };
C364534F252449260045C478 /* VoiceMessageView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = VoiceMessageView.swift; sourceTree = "<group>"; };
C364535B252467900045C478 /* AudioUtilities.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AudioUtilities.swift; sourceTree = "<group>"; };
@ -2388,6 +2388,15 @@
path = Shared;
sourceTree = "<group>";
};
B8FF8E6025C10D8B004D1F22 /* Countries */ = {
isa = PBXGroup;
children = (
B8FF8E6125C10DA5004D1F22 /* GeoLite2-Country-Blocks-IPv4 */,
B8FF8E7325C10FC3004D1F22 /* GeoLite2-Country-Locations-English */,
);
name = Countries;
sourceTree = "<group>";
};
C300A5BB2554AFFB00555489 /* Messages */ = {
isa = PBXGroup;
children = (
@ -2756,15 +2765,6 @@
path = Jobs;
sourceTree = "<group>";
};
C35E8AA42485C83B00ACB629 /* CSV */ = {
isa = PBXGroup;
children = (
C35E8AA62485C85600ACB629 /* GeoLite2-Country-Blocks-IPv4.csv */,
C35E8AA52485C85400ACB629 /* GeoLite2-Country-Locations-English.csv */,
);
path = CSV;
sourceTree = "<group>";
};
C360968D25AD16B4008B62B2 /* Onboarding */ = {
isa = PBXGroup;
children = (
@ -3561,7 +3561,7 @@
76EB03C218170B33006006FC /* AppDelegate.h */,
76EB03C318170B33006006FC /* AppDelegate.m */,
34D99CE3217509C1000AFB39 /* AppEnvironment.swift */,
C35E8AA42485C83B00ACB629 /* CSV */,
B8FF8E6025C10D8B004D1F22 /* Countries */,
34330A581E7875FB00DF2FB9 /* Fonts */,
B633C4FD1A1D190B0059AC12 /* Images */,
B66DBF4919D5BBC8006EA940 /* Images.xcassets */,
@ -4319,7 +4319,6 @@
34330A5E1E787BD800DF2FB9 /* ElegantIcons.ttf in Resources */,
AD83FF451A73426500B5C81A /* audio_pause_button@2x.png in Resources */,
45A2F005204473A3002E978A /* NewMessage.aifc in Resources */,
C35E8AA92485C85800ACB629 /* GeoLite2-Country-Blocks-IPv4.csv in Resources */,
45B74A882044AAB600CD42F8 /* aurora.aifc in Resources */,
45B74A742044AAB600CD42F8 /* aurora-quiet.aifc in Resources */,
45B74A852044AAB600CD42F8 /* bamboo.aifc in Resources */,
@ -4333,12 +4332,12 @@
4503F1BF20470A5B00CEE724 /* classic.aifc in Resources */,
4503F1BE20470A5B00CEE724 /* classic-quiet.aifc in Resources */,
45B74A7E2044AAB600CD42F8 /* complete.aifc in Resources */,
B8FF8E7425C10FC3004D1F22 /* GeoLite2-Country-Locations-English in Resources */,
B8CCF6352396005F0091D419 /* SpaceMono-Regular.ttf in Resources */,
45B74A872044AAB600CD42F8 /* complete-quiet.aifc in Resources */,
45B74A772044AAB600CD42F8 /* hello.aifc in Resources */,
4C61819F219E1796009BD6B5 /* typing-animation-dark.gif in Resources */,
45B74A7C2044AAB600CD42F8 /* hello-quiet.aifc in Resources */,
C35E8AA82485C85800ACB629 /* GeoLite2-Country-Locations-English.csv in Resources */,
45B74A792044AAB600CD42F8 /* input.aifc in Resources */,
C3CA3ABE255CDB0D00F4C6D4 /* portuguese.txt in Resources */,
45B74A8C2044AAB600CD42F8 /* input-quiet.aifc in Resources */,
@ -4351,6 +4350,7 @@
45B74A822044AAB600CD42F8 /* pulse.aifc in Resources */,
C3CA3AC8255CDB2900F4C6D4 /* spanish.txt in Resources */,
34B6A90B218BA1D1007C4606 /* typing-animation.gif in Resources */,
B8FF8E6225C10DA5004D1F22 /* GeoLite2-Country-Blocks-IPv4 in Resources */,
45B74A802044AAB600CD42F8 /* pulse-quiet.aifc in Resources */,
45B74A8B2044AAB600CD42F8 /* synth.aifc in Resources */,
45B74A752044AAB600CD42F8 /* synth-quiet.aifc in Resources */,

296323
Session/Meta/CSV/GeoLite2-Country-Blocks-IPv4.csv

File diff suppressed because it is too large Load Diff

253
Session/Meta/CSV/GeoLite2-Country-Locations-English.csv

@ -1,253 +0,0 @@
geoname_id,locale_code,continent_code,continent_name,country_iso_code,country_name,is_in_european_union
49518,en,AF,Africa,RW,Rwanda,0
51537,en,AF,Africa,SO,Somalia,0
69543,en,AS,Asia,YE,Yemen,0
99237,en,AS,Asia,IQ,Iraq,0
102358,en,AS,Asia,SA,"Saudi Arabia",0
130758,en,AS,Asia,IR,Iran,0
146669,en,EU,Europe,CY,Cyprus,1
149590,en,AF,Africa,TZ,Tanzania,0
163843,en,AS,Asia,SY,Syria,0
174982,en,AS,Asia,AM,Armenia,0
192950,en,AF,Africa,KE,Kenya,0
203312,en,AF,Africa,CD,"DR Congo",0
223816,en,AF,Africa,DJ,Djibouti,0
226074,en,AF,Africa,UG,Uganda,0
239880,en,AF,Africa,CF,"Central African Republic",0
241170,en,AF,Africa,SC,Seychelles,0
248816,en,AS,Asia,JO,"Hashemite Kingdom of Jordan",0
272103,en,AS,Asia,LB,Lebanon,0
285570,en,AS,Asia,KW,Kuwait,0
286963,en,AS,Asia,OM,Oman,0
289688,en,AS,Asia,QA,Qatar,0
290291,en,AS,Asia,BH,Bahrain,0
290557,en,AS,Asia,AE,"United Arab Emirates",0
294640,en,AS,Asia,IL,Israel,0
298795,en,AS,Asia,TR,Turkey,0
337996,en,AF,Africa,ET,Ethiopia,0
338010,en,AF,Africa,ER,Eritrea,0
357994,en,AF,Africa,EG,Egypt,0
366755,en,AF,Africa,SD,Sudan,0
390903,en,EU,Europe,GR,Greece,1
433561,en,AF,Africa,BI,Burundi,0
453733,en,EU,Europe,EE,Estonia,1
458258,en,EU,Europe,LV,Latvia,1
587116,en,AS,Asia,AZ,Azerbaijan,0
597427,en,EU,Europe,LT,"Republic of Lithuania",1
607072,en,EU,Europe,SJ,"Svalbard and Jan Mayen",0
614540,en,AS,Asia,GE,Georgia,0
617790,en,EU,Europe,MD,"Republic of Moldova",0
630336,en,EU,Europe,BY,Belarus,0
660013,en,EU,Europe,FI,Finland,1
661882,en,EU,Europe,AX,"Åland",1
690791,en,EU,Europe,UA,Ukraine,0
718075,en,EU,Europe,MK,"North Macedonia",0
719819,en,EU,Europe,HU,Hungary,1
732800,en,EU,Europe,BG,Bulgaria,1
783754,en,EU,Europe,AL,Albania,0
798544,en,EU,Europe,PL,Poland,1
798549,en,EU,Europe,RO,Romania,1
831053,en,EU,Europe,XK,Kosovo,0
878675,en,AF,Africa,ZW,Zimbabwe,0
895949,en,AF,Africa,ZM,Zambia,0
921929,en,AF,Africa,KM,Comoros,0
927384,en,AF,Africa,MW,Malawi,0
932692,en,AF,Africa,LS,Lesotho,0
933860,en,AF,Africa,BW,Botswana,0
934292,en,AF,Africa,MU,Mauritius,0
934841,en,AF,Africa,SZ,Eswatini,0
935317,en,AF,Africa,RE,Réunion,1
953987,en,AF,Africa,ZA,"South Africa",0
1024031,en,AF,Africa,YT,Mayotte,1
1036973,en,AF,Africa,MZ,Mozambique,0
1062947,en,AF,Africa,MG,Madagascar,0
1149361,en,AS,Asia,AF,Afghanistan,0
1168579,en,AS,Asia,PK,Pakistan,0
1210997,en,AS,Asia,BD,Bangladesh,0
1218197,en,AS,Asia,TM,Turkmenistan,0
1220409,en,AS,Asia,TJ,Tajikistan,0
1227603,en,AS,Asia,LK,"Sri Lanka",0
1252634,en,AS,Asia,BT,Bhutan,0
1269750,en,AS,Asia,IN,India,0
1282028,en,AS,Asia,MV,Maldives,0
1282588,en,AS,Asia,IO,"British Indian Ocean Territory",0
1282988,en,AS,Asia,NP,Nepal,0
1327865,en,AS,Asia,MM,Myanmar,0
1512440,en,AS,Asia,UZ,Uzbekistan,0
1522867,en,AS,Asia,KZ,Kazakhstan,0
1527747,en,AS,Asia,KG,Kyrgyzstan,0
1546748,en,AN,Antarctica,TF,"French Southern Territories",0
1547314,en,AN,Antarctica,HM,"Heard Island and McDonald Islands",0
1547376,en,AS,Asia,CC,"Cocos [Keeling] Islands",0
1559582,en,OC,Oceania,PW,Palau,0
1562822,en,AS,Asia,VN,Vietnam,0
1605651,en,AS,Asia,TH,Thailand,0
1643084,en,AS,Asia,ID,Indonesia,0
1655842,en,AS,Asia,LA,Laos,0
1668284,en,AS,Asia,TW,Taiwan,0
1694008,en,AS,Asia,PH,Philippines,0
1733045,en,AS,Asia,MY,Malaysia,0
1814991,en,AS,Asia,CN,China,0
1819730,en,AS,Asia,HK,"Hong Kong",0
1820814,en,AS,Asia,BN,Brunei,0
1821275,en,AS,Asia,MO,Macao,0
1831722,en,AS,Asia,KH,Cambodia,0
1835841,en,AS,Asia,KR,"South Korea",0
1861060,en,AS,Asia,JP,Japan,0
1873107,en,AS,Asia,KP,"North Korea",0
1880251,en,AS,Asia,SG,Singapore,0
1899402,en,OC,Oceania,CK,"Cook Islands",0
1966436,en,OC,Oceania,TL,"East Timor",0
2017370,en,EU,Europe,RU,Russia,0
2029969,en,AS,Asia,MN,Mongolia,0
2077456,en,OC,Oceania,AU,Australia,0
2078138,en,OC,Oceania,CX,"Christmas Island",0
2080185,en,OC,Oceania,MH,"Marshall Islands",0
2081918,en,OC,Oceania,FM,"Federated States of Micronesia",0
2088628,en,OC,Oceania,PG,"Papua New Guinea",0
2103350,en,OC,Oceania,SB,"Solomon Islands",0
2110297,en,OC,Oceania,TV,Tuvalu,0
2110425,en,OC,Oceania,NR,Nauru,0
2134431,en,OC,Oceania,VU,Vanuatu,0
2139685,en,OC,Oceania,NC,"New Caledonia",0
2155115,en,OC,Oceania,NF,"Norfolk Island",0
2186224,en,OC,Oceania,NZ,"New Zealand",0
2205218,en,OC,Oceania,FJ,Fiji,0
2215636,en,AF,Africa,LY,Libya,0
2233387,en,AF,Africa,CM,Cameroon,0
2245662,en,AF,Africa,SN,Senegal,0
2260494,en,AF,Africa,CG,"Congo Republic",0
2264397,en,EU,Europe,PT,Portugal,1
2275384,en,AF,Africa,LR,Liberia,0
2287781,en,AF,Africa,CI,"Ivory Coast",0
2300660,en,AF,Africa,GH,Ghana,0
2309096,en,AF,Africa,GQ,"Equatorial Guinea",0
2328926,en,AF,Africa,NG,Nigeria,0
2361809,en,AF,Africa,BF,"Burkina Faso",0
2363686,en,AF,Africa,TG,Togo,0
2372248,en,AF,Africa,GW,Guinea-Bissau,0
2378080,en,AF,Africa,MR,Mauritania,0
2395170,en,AF,Africa,BJ,Benin,0
2400553,en,AF,Africa,GA,Gabon,0
2403846,en,AF,Africa,SL,"Sierra Leone",0
2410758,en,AF,Africa,ST,"São Tomé and Príncipe",0
2411586,en,EU,Europe,GI,Gibraltar,1
2413451,en,AF,Africa,GM,Gambia,0
2420477,en,AF,Africa,GN,Guinea,0
2434508,en,AF,Africa,TD,Chad,0
2440476,en,AF,Africa,NE,Niger,0
2453866,en,AF,Africa,ML,Mali,0
2461445,en,AF,Africa,EH,"Western Sahara",0
2464461,en,AF,Africa,TN,Tunisia,0
2510769,en,EU,Europe,ES,Spain,1
2542007,en,AF,Africa,MA,Morocco,0
2562770,en,EU,Europe,MT,Malta,1
2589581,en,AF,Africa,DZ,Algeria,0
2622320,en,EU,Europe,FO,"Faroe Islands",0
2623032,en,EU,Europe,DK,Denmark,1
2629691,en,EU,Europe,IS,Iceland,0
2635167,en,EU,Europe,GB,"United Kingdom",1
2658434,en,EU,Europe,CH,Switzerland,0
2661886,en,EU,Europe,SE,Sweden,1
2750405,en,EU,Europe,NL,Netherlands,1
2782113,en,EU,Europe,AT,Austria,1
2802361,en,EU,Europe,BE,Belgium,1
2921044,en,EU,Europe,DE,Germany,1
2960313,en,EU,Europe,LU,Luxembourg,1
2963597,en,EU,Europe,IE,Ireland,1
2993457,en,EU,Europe,MC,Monaco,0
3017382,en,EU,Europe,FR,France,1
3041565,en,EU,Europe,AD,Andorra,0
3042058,en,EU,Europe,LI,Liechtenstein,0
3042142,en,EU,Europe,JE,Jersey,0
3042225,en,EU,Europe,IM,"Isle of Man",0
3042362,en,EU,Europe,GG,Guernsey,0
3057568,en,EU,Europe,SK,Slovakia,1
3077311,en,EU,Europe,CZ,Czechia,1
3144096,en,EU,Europe,NO,Norway,0
3164670,en,EU,Europe,VA,"Vatican City",0
3168068,en,EU,Europe,SM,"San Marino",0
3175395,en,EU,Europe,IT,Italy,1
3190538,en,EU,Europe,SI,Slovenia,1
3194884,en,EU,Europe,ME,Montenegro,0
3202326,en,EU,Europe,HR,Croatia,1
3277605,en,EU,Europe,BA,"Bosnia and Herzegovina",0
3351879,en,AF,Africa,AO,Angola,0
3355338,en,AF,Africa,NA,Namibia,0
3370751,en,AF,Africa,SH,"Saint Helena",0
3371123,en,AN,Antarctica,BV,"Bouvet Island",0
3374084,en,NA,"North America",BB,Barbados,0
3374766,en,AF,Africa,CV,"Cabo Verde",0
3378535,en,SA,"South America",GY,Guyana,0
3381670,en,SA,"South America",GF,"French Guiana",1
3382998,en,SA,"South America",SR,Suriname,0
3424932,en,NA,"North America",PM,"Saint Pierre and Miquelon",0
3425505,en,NA,"North America",GL,Greenland,0
3437598,en,SA,"South America",PY,Paraguay,0
3439705,en,SA,"South America",UY,Uruguay,0
3469034,en,SA,"South America",BR,Brazil,0
3474414,en,SA,"South America",FK,"Falkland Islands",0
3474415,en,AN,Antarctica,GS,"South Georgia and the South Sandwich Islands",0
3489940,en,NA,"North America",JM,Jamaica,0
3508796,en,NA,"North America",DO,"Dominican Republic",0
3562981,en,NA,"North America",CU,Cuba,0
3570311,en,NA,"North America",MQ,Martinique,1
3572887,en,NA,"North America",BS,Bahamas,0
3573345,en,NA,"North America",BM,Bermuda,0
3573511,en,NA,"North America",AI,Anguilla,0
3573591,en,NA,"North America",TT,"Trinidad and Tobago",0
3575174,en,NA,"North America",KN,"St Kitts and Nevis",0
3575830,en,NA,"North America",DM,Dominica,0
3576396,en,NA,"North America",AG,"Antigua and Barbuda",0
3576468,en,NA,"North America",LC,"Saint Lucia",0
3576916,en,NA,"North America",TC,"Turks and Caicos Islands",0
3577279,en,NA,"North America",AW,Aruba,0
3577718,en,NA,"North America",VG,"British Virgin Islands",0
3577815,en,NA,"North America",VC,"Saint Vincent and the Grenadines",0
3578097,en,NA,"North America",MS,Montserrat,0
3578421,en,NA,"North America",MF,"Saint Martin",1
3578476,en,NA,"North America",BL,"Saint Barthélemy",0
3579143,en,NA,"North America",GP,Guadeloupe,1
3580239,en,NA,"North America",GD,Grenada,0
3580718,en,NA,"North America",KY,"Cayman Islands",0
3582678,en,NA,"North America",BZ,Belize,0
3585968,en,NA,"North America",SV,"El Salvador",0
3595528,en,NA,"North America",GT,Guatemala,0
3608932,en,NA,"North America",HN,Honduras,0
3617476,en,NA,"North America",NI,Nicaragua,0
3624060,en,NA,"North America",CR,"Costa Rica",0
3625428,en,SA,"South America",VE,Venezuela,0
3658394,en,SA,"South America",EC,Ecuador,0
3686110,en,SA,"South America",CO,Colombia,0
3703430,en,NA,"North America",PA,Panama,0
3723988,en,NA,"North America",HT,Haiti,0
3865483,en,SA,"South America",AR,Argentina,0
3895114,en,SA,"South America",CL,Chile,0
3923057,en,SA,"South America",BO,Bolivia,0
3932488,en,SA,"South America",PE,Peru,0
3996063,en,NA,"North America",MX,Mexico,0
4030656,en,OC,Oceania,PF,"French Polynesia",0
4030699,en,OC,Oceania,PN,"Pitcairn Islands",0
4030945,en,OC,Oceania,KI,Kiribati,0
4031074,en,OC,Oceania,TK,Tokelau,0
4032283,en,OC,Oceania,TO,Tonga,0
4034749,en,OC,Oceania,WF,"Wallis and Futuna",0
4034894,en,OC,Oceania,WS,Samoa,0
4036232,en,OC,Oceania,NU,Niue,0
4041468,en,OC,Oceania,MP,"Northern Mariana Islands",0
4043988,en,OC,Oceania,GU,Guam,0
4566966,en,NA,"North America",PR,"Puerto Rico",0
4796775,en,NA,"North America",VI,"U.S. Virgin Islands",0
5854968,en,OC,Oceania,UM,"U.S. Minor Outlying Islands",0
5880801,en,OC,Oceania,AS,"American Samoa",0
6251999,en,NA,"North America",CA,Canada,0
6252001,en,NA,"North America",US,"United States",0
6254930,en,AS,Asia,PS,Palestine,0
6255147,en,AS,Asia,,,0
6255148,en,EU,Europe,,,0
6290252,en,EU,Europe,RS,Serbia,0
6697173,en,AN,Antarctica,AQ,Antarctica,0
7609695,en,NA,"North America",SX,"Sint Maarten",0
7626836,en,NA,"North America",CW,Curaçao,0
7626844,en,NA,"North America",BQ,"Bonaire, Sint Eustatius, and Saba",0
7909807,en,AF,Africa,SS,"South Sudan",0
1 geoname_id locale_code continent_code continent_name country_iso_code country_name is_in_european_union
2 49518 en AF Africa RW Rwanda 0
3 51537 en AF Africa SO Somalia 0
4 69543 en AS Asia YE Yemen 0
5 99237 en AS Asia IQ Iraq 0
6 102358 en AS Asia SA Saudi Arabia 0
7 130758 en AS Asia IR Iran 0
8 146669 en EU Europe CY Cyprus 1
9 149590 en AF Africa TZ Tanzania 0
10 163843 en AS Asia SY Syria 0
11 174982 en AS Asia AM Armenia 0
12 192950 en AF Africa KE Kenya 0
13 203312 en AF Africa CD DR Congo 0
14 223816 en AF Africa DJ Djibouti 0
15 226074 en AF Africa UG Uganda 0
16 239880 en AF Africa CF Central African Republic 0
17 241170 en AF Africa SC Seychelles 0
18 248816 en AS Asia JO Hashemite Kingdom of Jordan 0
19 272103 en AS Asia LB Lebanon 0
20 285570 en AS Asia KW Kuwait 0
21 286963 en AS Asia OM Oman 0
22 289688 en AS Asia QA Qatar 0
23 290291 en AS Asia BH Bahrain 0
24 290557 en AS Asia AE United Arab Emirates 0
25 294640 en AS Asia IL Israel 0
26 298795 en AS Asia TR Turkey 0
27 337996 en AF Africa ET Ethiopia 0
28 338010 en AF Africa ER Eritrea 0
29 357994 en AF Africa EG Egypt 0
30 366755 en AF Africa SD Sudan 0
31 390903 en EU Europe GR Greece 1
32 433561 en AF Africa BI Burundi 0
33 453733 en EU Europe EE Estonia 1
34 458258 en EU Europe LV Latvia 1
35 587116 en AS Asia AZ Azerbaijan 0
36 597427 en EU Europe LT Republic of Lithuania 1
37 607072 en EU Europe SJ Svalbard and Jan Mayen 0
38 614540 en AS Asia GE Georgia 0
39 617790 en EU Europe MD Republic of Moldova 0
40 630336 en EU Europe BY Belarus 0
41 660013 en EU Europe FI Finland 1
42 661882 en EU Europe AX Åland 1
43 690791 en EU Europe UA Ukraine 0
44 718075 en EU Europe MK North Macedonia 0
45 719819 en EU Europe HU Hungary 1
46 732800 en EU Europe BG Bulgaria 1
47 783754 en EU Europe AL Albania 0
48 798544 en EU Europe PL Poland 1
49 798549 en EU Europe RO Romania 1
50 831053 en EU Europe XK Kosovo 0
51 878675 en AF Africa ZW Zimbabwe 0
52 895949 en AF Africa ZM Zambia 0
53 921929 en AF Africa KM Comoros 0
54 927384 en AF Africa MW Malawi 0
55 932692 en AF Africa LS Lesotho 0
56 933860 en AF Africa BW Botswana 0
57 934292 en AF Africa MU Mauritius 0
58 934841 en AF Africa SZ Eswatini 0
59 935317 en AF Africa RE Réunion 1
60 953987 en AF Africa ZA South Africa 0
61 1024031 en AF Africa YT Mayotte 1
62 1036973 en AF Africa MZ Mozambique 0
63 1062947 en AF Africa MG Madagascar 0
64 1149361 en AS Asia AF Afghanistan 0
65 1168579 en AS Asia PK Pakistan 0
66 1210997 en AS Asia BD Bangladesh 0
67 1218197 en AS Asia TM Turkmenistan 0
68 1220409 en AS Asia TJ Tajikistan 0
69 1227603 en AS Asia LK Sri Lanka 0
70 1252634 en AS Asia BT Bhutan 0
71 1269750 en AS Asia IN India 0
72 1282028 en AS Asia MV Maldives 0
73 1282588 en AS Asia IO British Indian Ocean Territory 0
74 1282988 en AS Asia NP Nepal 0
75 1327865 en AS Asia MM Myanmar 0
76 1512440 en AS Asia UZ Uzbekistan 0
77 1522867 en AS Asia KZ Kazakhstan 0
78 1527747 en AS Asia KG Kyrgyzstan 0
79 1546748 en AN Antarctica TF French Southern Territories 0
80 1547314 en AN Antarctica HM Heard Island and McDonald Islands 0
81 1547376 en AS Asia CC Cocos [Keeling] Islands 0
82 1559582 en OC Oceania PW Palau 0
83 1562822 en AS Asia VN Vietnam 0
84 1605651 en AS Asia TH Thailand 0
85 1643084 en AS Asia ID Indonesia 0
86 1655842 en AS Asia LA Laos 0
87 1668284 en AS Asia TW Taiwan 0
88 1694008 en AS Asia PH Philippines 0
89 1733045 en AS Asia MY Malaysia 0
90 1814991 en AS Asia CN China 0
91 1819730 en AS Asia HK Hong Kong 0
92 1820814 en AS Asia BN Brunei 0
93 1821275 en AS Asia MO Macao 0
94 1831722 en AS Asia KH Cambodia 0
95 1835841 en AS Asia KR South Korea 0
96 1861060 en AS Asia JP Japan 0
97 1873107 en AS Asia KP North Korea 0
98 1880251 en AS Asia SG Singapore 0
99 1899402 en OC Oceania CK Cook Islands 0
100 1966436 en OC Oceania TL East Timor 0
101 2017370 en EU Europe RU Russia 0
102 2029969 en AS Asia MN Mongolia 0
103 2077456 en OC Oceania AU Australia 0
104 2078138 en OC Oceania CX Christmas Island 0
105 2080185 en OC Oceania MH Marshall Islands 0
106 2081918 en OC Oceania FM Federated States of Micronesia 0
107 2088628 en OC Oceania PG Papua New Guinea 0
108 2103350 en OC Oceania SB Solomon Islands 0
109 2110297 en OC Oceania TV Tuvalu 0
110 2110425 en OC Oceania NR Nauru 0
111 2134431 en OC Oceania VU Vanuatu 0
112 2139685 en OC Oceania NC New Caledonia 0
113 2155115 en OC Oceania NF Norfolk Island 0
114 2186224 en OC Oceania NZ New Zealand 0
115 2205218 en OC Oceania FJ Fiji 0
116 2215636 en AF Africa LY Libya 0
117 2233387 en AF Africa CM Cameroon 0
118 2245662 en AF Africa SN Senegal 0
119 2260494 en AF Africa CG Congo Republic 0
120 2264397 en EU Europe PT Portugal 1
121 2275384 en AF Africa LR Liberia 0
122 2287781 en AF Africa CI Ivory Coast 0
123 2300660 en AF Africa GH Ghana 0
124 2309096 en AF Africa GQ Equatorial Guinea 0
125 2328926 en AF Africa NG Nigeria 0
126 2361809 en AF Africa BF Burkina Faso 0
127 2363686 en AF Africa TG Togo 0
128 2372248 en AF Africa GW Guinea-Bissau 0
129 2378080 en AF Africa MR Mauritania 0
130 2395170 en AF Africa BJ Benin 0
131 2400553 en AF Africa GA Gabon 0
132 2403846 en AF Africa SL Sierra Leone 0
133 2410758 en AF Africa ST São Tomé and Príncipe 0
134 2411586 en EU Europe GI Gibraltar 1
135 2413451 en AF Africa GM Gambia 0
136 2420477 en AF Africa GN Guinea 0
137 2434508 en AF Africa TD Chad 0
138 2440476 en AF Africa NE Niger 0
139 2453866 en AF Africa ML Mali 0
140 2461445 en AF Africa EH Western Sahara 0
141 2464461 en AF Africa TN Tunisia 0
142 2510769 en EU Europe ES Spain 1
143 2542007 en AF Africa MA Morocco 0
144 2562770 en EU Europe MT Malta 1
145 2589581 en AF Africa DZ Algeria 0
146 2622320 en EU Europe FO Faroe Islands 0
147 2623032 en EU Europe DK Denmark 1
148 2629691 en EU Europe IS Iceland 0
149 2635167 en EU Europe GB United Kingdom 1
150 2658434 en EU Europe CH Switzerland 0
151 2661886 en EU Europe SE Sweden 1
152 2750405 en EU Europe NL Netherlands 1
153 2782113 en EU Europe AT Austria 1
154 2802361 en EU Europe BE Belgium 1
155 2921044 en EU Europe DE Germany 1
156 2960313 en EU Europe LU Luxembourg 1
157 2963597 en EU Europe IE Ireland 1
158 2993457 en EU Europe MC Monaco 0
159 3017382 en EU Europe FR France 1
160 3041565 en EU Europe AD Andorra 0
161 3042058 en EU Europe LI Liechtenstein 0
162 3042142 en EU Europe JE Jersey 0
163 3042225 en EU Europe IM Isle of Man 0
164 3042362 en EU Europe GG Guernsey 0
165 3057568 en EU Europe SK Slovakia 1
166 3077311 en EU Europe CZ Czechia 1
167 3144096 en EU Europe NO Norway 0
168 3164670 en EU Europe VA Vatican City 0
169 3168068 en EU Europe SM San Marino 0
170 3175395 en EU Europe IT Italy 1
171 3190538 en EU Europe SI Slovenia 1
172 3194884 en EU Europe ME Montenegro 0
173 3202326 en EU Europe HR Croatia 1
174 3277605 en EU Europe BA Bosnia and Herzegovina 0
175 3351879 en AF Africa AO Angola 0
176 3355338 en AF Africa NA Namibia 0
177 3370751 en AF Africa SH Saint Helena 0
178 3371123 en AN Antarctica BV Bouvet Island 0
179 3374084 en NA North America BB Barbados 0
180 3374766 en AF Africa CV Cabo Verde 0
181 3378535 en SA South America GY Guyana 0
182 3381670 en SA South America GF French Guiana 1
183 3382998 en SA South America SR Suriname 0
184 3424932 en NA North America PM Saint Pierre and Miquelon 0
185 3425505 en NA North America GL Greenland 0
186 3437598 en SA South America PY Paraguay 0
187 3439705 en SA South America UY Uruguay 0
188 3469034 en SA South America BR Brazil 0
189 3474414 en SA South America FK Falkland Islands 0
190 3474415 en AN Antarctica GS South Georgia and the South Sandwich Islands 0
191 3489940 en NA North America JM Jamaica 0
192 3508796 en NA North America DO Dominican Republic 0
193 3562981 en NA North America CU Cuba 0
194 3570311 en NA North America MQ Martinique 1
195 3572887 en NA North America BS Bahamas 0
196 3573345 en NA North America BM Bermuda 0
197 3573511 en NA North America AI Anguilla 0
198 3573591 en NA North America TT Trinidad and Tobago 0
199 3575174 en NA North America KN St Kitts and Nevis 0
200 3575830 en NA North America DM Dominica 0
201 3576396 en NA North America AG Antigua and Barbuda 0
202 3576468 en NA North America LC Saint Lucia 0
203 3576916 en NA North America TC Turks and Caicos Islands 0
204 3577279 en NA North America AW Aruba 0
205 3577718 en NA North America VG British Virgin Islands 0
206 3577815 en NA North America VC Saint Vincent and the Grenadines 0
207 3578097 en NA North America MS Montserrat 0
208 3578421 en NA North America MF Saint Martin 1
209 3578476 en NA North America BL Saint Barthélemy 0
210 3579143 en NA North America GP Guadeloupe 1
211 3580239 en NA North America GD Grenada 0
212 3580718 en NA North America KY Cayman Islands 0
213 3582678 en NA North America BZ Belize 0
214 3585968 en NA North America SV El Salvador 0
215 3595528 en NA North America GT Guatemala 0
216 3608932 en NA North America HN Honduras 0
217 3617476 en NA North America NI Nicaragua 0
218 3624060 en NA North America CR Costa Rica 0
219 3625428 en SA South America VE Venezuela 0
220 3658394 en SA South America EC Ecuador 0
221 3686110 en SA South America CO Colombia 0
222 3703430 en NA North America PA Panama 0
223 3723988 en NA North America HT Haiti 0
224 3865483 en SA South America AR Argentina 0
225 3895114 en SA South America CL Chile 0
226 3923057 en SA South America BO Bolivia 0
227 3932488 en SA South America PE Peru 0
228 3996063 en NA North America MX Mexico 0
229 4030656 en OC Oceania PF French Polynesia 0
230 4030699 en OC Oceania PN Pitcairn Islands 0
231 4030945 en OC Oceania KI Kiribati 0
232 4031074 en OC Oceania TK Tokelau 0
233 4032283 en OC Oceania TO Tonga 0
234 4034749 en OC Oceania WF Wallis and Futuna 0
235 4034894 en OC Oceania WS Samoa 0
236 4036232 en OC Oceania NU Niue 0
237 4041468 en OC Oceania MP Northern Mariana Islands 0
238 4043988 en OC Oceania GU Guam 0
239 4566966 en NA North America PR Puerto Rico 0
240 4796775 en NA North America VI U.S. Virgin Islands 0
241 5854968 en OC Oceania UM U.S. Minor Outlying Islands 0
242 5880801 en OC Oceania AS American Samoa 0
243 6251999 en NA North America CA Canada 0
244 6252001 en NA North America US United States 0
245 6254930 en AS Asia PS Palestine 0
246 6255147 en AS Asia 0
247 6255148 en EU Europe 0
248 6290252 en EU Europe RS Serbia 0
249 6697173 en AN Antarctica AQ Antarctica 0
250 7609695 en NA North America SX Sint Maarten 0
251 7626836 en NA North America CW Curaçao 0
252 7626844 en NA North America BQ Bonaire, Sint Eustatius, and Saba 0
253 7909807 en AF Africa SS South Sudan 0

BIN
Session/Meta/Countries/GeoLite2-Country-Blocks-IPv4

Binary file not shown.

BIN
Session/Meta/Countries/GeoLite2-Country-Locations-English

Binary file not shown.

21
Session/Utilities/IP2Country.swift

@ -2,8 +2,17 @@
final class IP2Country {
var countryNamesCache: [String:String] = [:]
private lazy var ipv4Table = try! CSV(name: "GeoLite2-Country-Blocks-IPv4", extension: "csv", bundle: .main, delimiter: ",", encoding: .utf8, loadColumns: true)!
private lazy var countryNamesTable = try! CSV(name: "GeoLite2-Country-Locations-English", extension: "csv", bundle: .main, delimiter: ",", encoding: .utf8, loadColumns: true)!
private lazy var ipv4Table: [String:[String]] = {
let url = Bundle.main.url(forResource: "GeoLite2-Country-Blocks-IPv4", withExtension: nil)!
let data = try! Data(contentsOf: url)
return try! NSKeyedUnarchiver.unarchiveTopLevelObjectWithData(data) as! [String:[String]]
}()
private lazy var countryNamesTable: [String:[String]] = {
let url = Bundle.main.url(forResource: "GeoLite2-Country-Locations-English", withExtension: nil)!
let data = try! Data(contentsOf: url)
return try! NSKeyedUnarchiver.unarchiveTopLevelObjectWithData(data) as! [String:[String]]
}()
private static let workQueue = DispatchQueue(label: "IP2Country.workQueue", qos: .utility) // It's important that this is a serial queue
@ -25,10 +34,10 @@ final class IP2Country {
var truncatedIP = ip
func getCountryInternal() -> String {
if let country = countryNamesCache[ip] { return country }
if let ipv4TableIndex = ipv4Table.namedColumns["network"]!.firstIndex(where: { $0.starts(with: truncatedIP) }) {
let countryID = ipv4Table.namedColumns["registered_country_geoname_id"]![ipv4TableIndex]
if let countryNamesTableIndex = countryNamesTable.namedColumns["geoname_id"]!.firstIndex(of: countryID) {
let country = countryNamesTable.namedColumns["country_name"]![countryNamesTableIndex]
if let ipv4TableIndex = ipv4Table["network"]!.firstIndex(where: { $0.starts(with: truncatedIP) }) {
let countryID = ipv4Table["registered_country_geoname_id"]![ipv4TableIndex]
if let countryNamesTableIndex = countryNamesTable["geoname_id"]!.firstIndex(of: countryID) {
let country = countryNamesTable["country_name"]![countryNamesTableIndex]
countryNamesCache[ip] = country
return country
}

Loading…
Cancel
Save