{"id":31783455,"url":"https://github.com/aspriddell/libloc-sharp","last_synced_at":"2025-10-10T10:26:48.842Z","repository":{"id":170059988,"uuid":"646157043","full_name":"aspriddell/libloc-sharp","owner":"aspriddell","description":"A managed version of IPFire's libloc library","archived":false,"fork":false,"pushed_at":"2024-09-27T11:04:46.000Z","size":138,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-09-20T17:35:19.549Z","etag":null,"topics":["geoip","geoip-lookup","geolocation","geolocation-database","hacktoberfest","ipfire","libloc"],"latest_commit_sha":null,"homepage":"","language":"C#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"lgpl-2.1","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/aspriddell.png","metadata":{"files":{"readme":"readme.md","changelog":null,"contributing":null,"funding":null,"license":"license.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null}},"created_at":"2023-05-27T13:20:53.000Z","updated_at":"2024-09-27T10:59:36.000Z","dependencies_parsed_at":null,"dependency_job_id":"ca4180f3-a46c-485e-b282-b2b5a924ac27","html_url":"https://github.com/aspriddell/libloc-sharp","commit_stats":{"total_commits":48,"total_committers":1,"mean_commits":48.0,"dds":0.0,"last_synced_commit":"f0a5d267efae0c850eb9df3aaa26b4952a26877c"},"previous_names":["aspriddell/libloc-sharp"],"tags_count":10,"template":false,"template_full_name":null,"purl":"pkg:github/aspriddell/libloc-sharp","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aspriddell%2Flibloc-sharp","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aspriddell%2Flibloc-sharp/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aspriddell%2Flibloc-sharp/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aspriddell%2Flibloc-sharp/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/aspriddell","download_url":"https://codeload.github.com/aspriddell/libloc-sharp/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aspriddell%2Flibloc-sharp/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":279003548,"owners_count":26083595,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-10-10T02:00:06.843Z","response_time":62,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["geoip","geoip-lookup","geolocation","geolocation-database","hacktoberfest","ipfire","libloc"],"created_at":"2025-10-10T10:26:47.819Z","updated_at":"2025-10-10T10:26:48.835Z","avatar_url":"https://github.com/aspriddell.png","language":"C#","readme":"# libloc-sharp\n[![DragonFruit Discord](https://img.shields.io/discord/482528405292843018?label=Discord)](https://discord.gg/VA26u5Z)\n![GitHub Latest Release)](https://img.shields.io/github/v/release/aspriddell/libloc-sharp?logo=github)\n\nA version of IPFire's libloc library rewritten for .NET\n\n## Overview\nThis is a rewritten version of libloc (an IP address database used by IPFire firewall software to screen network traffic)\nalong with an additional library, `libloc.Access`, that enables the database to be loaded as a hosted service, enabling automatic database updates and access control.\n\nThe core libloc project has been written to require a single 3rd party library (IPNetwork) and has most of the expected read functionality.\n\n### Usage (libloc)\n[![Latest Nuget](https://img.shields.io/nuget/v/libloc?label=libloc\u0026logo=nuget)](https://nuget.org/packages/libloc)\n\nThe libloc `DatabaseLoader.LoadFromFile(string path)` returns an `ILocationDatabase` if the database was successfully loaded in. Accessing different features of the database can then be done through this instance:\n\n- `ILocationDatabase.AS` provides a database of Autonomous Systems, where the entire collection can be accessed, or a specific entry can be loaded by ASN\n- `ILocationDatabase.Networks` provides all networks that own a block of IP addresses which can be accessed by index or enumerated over\n- `ILocationDatabase.Countries` provides a list of all countries and their continents. These can be accessed by country code, index or enumerated over\n- `ILocationDatabase.ResolveAddress(IPAddress address)` performs a network tree traversal to locate the network a specific address belongs to, along with the ASN of the owner, the start and end addresses and the prefix length.\nThese values are stored and processed as IPv6, so an IPv4 address will need mapping back from v6 if desired.\n- `ILocationDatabase.GetEnumerator(AddressFamily family)` provides an enumerator that can be used to get all networks, and their corresponding address blocks.\n\n```csharp\nvar database = DatabaseLoader.LoadFromFile(\"C:\\location.db\");\n\n// locate 1.1.1.1\nvar networkInfo = database.ResolveAddress(IPAddress.Parse(\"1.1.1.1\"));\n\n// load AS info\nvar asInfo = database.AS[networkInfo.ASN];\n```\n\n### Usage (libloc.Access)\n[![Latest Nuget (libloc.Access)](https://img.shields.io/nuget/v/libloc.Access?label=libloc.Access\u0026logo=nuget)](https://nuget.org/packages/libloc.Access)\n\nThere are a few things to note when using `libloc.Access`:\n\n- A `DragonFruit.Data.ApiClient` must be registered in the dependency container - see [here](https://github.com/dragonfruitnetwork/dragonfruit-common/wiki/%5BApiClient%5D-Getting-Started) for more information\n- `IConfiguration` is used to load service preferences in (under the `LocationDb` section)\n- `ILogger` is injected into the database accessor for logging and diagnosing the database update process\n\nTo use the database accessor, use `builder.Services.AddLocationDb()` in the startup code (after the client has been registered) and access the database using the `ILocationDbAccessor` interface:\n\n```csharp\nbuilder.Serivces.AddSingleton\u003cApiClient\u003cApiSystemTextJsonSerializer\u003e\u003e();\n\n// add databases\nbuilder.Services.AddLocationDb();\nbuilder.Services.AddDbContext\u003cDummyDatabase\u003e(c =\u003e c.UseNpgsql(\"Host=localhost\"));\n\n// after building the host, you can access the database via dependency injection\nvar locationDb = services.GetRequiredService\u003cILocationDbAccessor\u003e();\nvar network = await locationDb.PerformAsync(db =\u003e db.ResolveNetwork(IPAddress.Parse(\"1.1.1.1\")));\n```\n\n### License\nThe project is licensed under LGPL-2.1, the same as the original library.\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faspriddell%2Flibloc-sharp","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Faspriddell%2Flibloc-sharp","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faspriddell%2Flibloc-sharp/lists"}