Giter Club home page Giter Club logo

udger-dotnet's Introduction

Udger golang (format V3)

this package reads in memory all the database from udger and lets you lookup user agents's metadatas.

install

go get github.com/udger/udger

Documentation

For detailed documentation and basic usage examples, please see the package documentation at https://godoc.org/github.com/udger/udger

Automatic updates download

For autoupdate data use Udger data updater (https://udger.com/support/documentation/?doc=62)

old v2 format

If you still use the previous format of the db (v2), please see the branch old_format_v2

udger-dotnet's People

Contributors

mallat avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

udger-dotnet's Issues

Threadsafe, fast and clean fork - What to do?

I have rewritten large parts of the UdgerParser from the dev_v3 branch to make it threadsafe, faster and cleanup the code. It passes all the tests, and from my own testing is much faster than the previous version.

Compared to the previous implementation it caches most of the database in memory, except IP locations and IPv6 data center mainly because the IP location lookup table is huge. It adds a flag to do Data Center parsing (DataCenterParserEnabled) so that you enable data center parsing at the same time as IP location can be disabled (so you can run it fully in memory without disk reads and still parse IPv4 data centers).

We have been running it in production for a while, and it seems to be working well.

Currently its a fork available here: https://github.com/nordicfactory/udger-dotnet
I would be happy to make a PR if you think its appropriate.

Info useragent

Hi,
I've tried your app. I don't understand how it finds details about user agent. Examples in the Console test don't show any details and if I run the code step-by-step the app jump always a part when you check browser details.

I think generated regex is wrong.

Error when User Agent contains apostrophes

When a User Agent contains an apostrophe ('), the Udger client fails with the exception:

System.Data.SQLite.SQLiteException (0x80004005): SQL logic error or missing database
unrecognized token: ":"
DataReader.cs(62,0): at Udger.Parser.DataReader.selectQuery(String query)
UdgerParser.cs(106,0): at Udger.Parser.UdgerParser.parseUA(String _userAgent)
UdgerParser.cs(73,0): at Udger.Parser.UdgerParser.parse()
Program.cs(46,0): at ConsoleTest.Program.Main(String[] args)

This is because query parameters are being added to the sql query by concatenation.
SqliteParameters should be used instead. Here are some of the reasons why: http://stackoverflow.com/a/20017707/390819

Clarify license of this and other udger projects for contribution

I have made a rewrite of udger-dotnet into .Net Core and with some other cleanup and improvements. Doing this I used code from udger-dotnet, udger-dotnet v3 branch and also udger-java.

Can you clarify what licenses these are under? Seems like Java is using BSD: https://udger.com/legal/java_parser but the .NET code is very unclear to me (LGPL, also BSD?).

I hope to contribute my rewrite, but first I need to know what kind of license it becomes.

Any plan to move to dotnetcore/standard?

I am starting a new project in dotnet core, I would need a compatible version.
If nothing is planned/started on your side, I will probably start a fork (or total new version) to make it work.

Waiting any feedback before developing stuff for nothing ;).

Some queries could be cached for efficiency

There are three queries in UdgerParser.cs that have no filters. This means that the same data (and all data) is selected from the DB every single time a detection is being made:

//client
DataTable clientRegex = dt.selectQuery(@"SELECT class_id,client_id,regstring,name,name_code,homepage,icon,icon_big,engine,vendor,vendor_code,vendor_homepage,uptodate_current_version,client_classification,client_classification_code
                      FROM udger_client_regex
                      JOIN udger_client_list ON udger_client_list.id = udger_client_regex.client_id
                      JOIN udger_client_class ON udger_client_class.id = udger_client_list.class_id
                      ORDER BY sequence ASC")
DataTable osRegex = dt.selectQuery(@"SELECT os_id,regstring,family,family_code,name,name_code,homepage,icon,icon_big,vendor,vendor_code,vendor_homepage
                      FROM udger_os_regex
                      JOIN udger_os_list ON udger_os_list.id = udger_os_regex.os_id
                      ORDER BY sequence ASC")
DataTable device = dt.selectQuery(@"SELECT deviceclass_id,regstring,name,name_code,icon,icon_big
                      FROM udger_deviceclass_regex
                      JOIN udger_deviceclass_list ON udger_deviceclass_list.id=udger_deviceclass_regex.deviceclass_id
                      ORDER BY sequence ASC")

Using the test database, these queries bring 141, 165 and 42 records respectively.

Given the fact that the DB is essentially read-only from the perspective of the Udger Client and that the same data is retrieved every time, I think that these records could be cached to avoid 3 DB roudtrips on every detection.

Sql santize error

With a user-agent such as

Mozilla/5.0 (Linux; Android 4.4.4; eZee' Tab10010-S Build/KTU84Q) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/33.0.0.0 Safari/537.36

We get an exception :

Unhandled Exception: System.Data.SQLite.SQLiteException: SQL logic error or missing database
near "Tab10010": syntax error
   at Udger.Parser.DataReader.selectQuery(String query)
   at Udger.Parser.UdgerParser.parseUA(String _userAgent)
   at Udger.Parser.UdgerParser.parse()

Looks like the user agent string is not sanitized when creating the query for sqlite and the single quote after eZee' causes the problem.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.