Giter Site home page Giter Site logo

threatint / go-net Goto Github PK

View Code? Open in Web Editor NEW
12.0 2.0 1.0 242 KB

Library containing basic validators and helpers for handling IP addresses, IP networks, IP ranges (from - to IP address), domain names, FQDN (fully qualified domain names), and URL (unified resource locators).

License: MIT License

Python 2.27% Go 97.73%
go golang ip ipv4 ipv6 fqdn domain url punycode golang-library

go-net's Introduction

go-net

Introduction

This library contains basic validators and helpers for handling IP addresses, IP networks, IP ranges (from - to IP adress), domain names, FQDN (fully qualified domain names), and URL (unified resource locators).

All methods that work with IP addresses are IPv4 and IPv6 compliant.

Please see the unit tests (xx_test.go) for examples on how to use this library.

Hints

We have received feedback from software developers who were confused about how this library handles specific cases. Examples include but are not limited to:

  • URLs:
    • We consider URLs that do not have a scheme as valid. This is a clear violation of RFC#3986 that says The scheme and path components are required, (...). We are doing this because of several of our own use cases where we had to process large lists of URLs that did not contain a scheme in each end every case. We neither wanted to add a scheme like http:// by default nor simply reject entries. If you, however, need a URL that fully complies to RFC#3986 (e.g. because you want to use it with other libraries), please call NormaliseURLSchema().
  • Domains
    • To get an idea, what a valid domain name looks like, we use the list of TLDs (top-level-domains) from IANA.
  • FQDNs
    • www.site.tld is not a URL but a FQDN (fully qualified domain name), because it neither has a path component nor a schema (http://, https://, etc.).
    • www.site.tld/about is a valid URL.
  • IP addresses and networks
    • 10.0.0.1/32 although presented as a network address is in fact a single IPv4 address (10.0.0.1).
    • 10.0.0.1/24 is not an IPv4 address, but a URL! This is because we do not need a schema (see URLs above), but when the netmask is /24 the last byte must be 0.
    • 10.0.0.0/24 is a valid network address.

If you find any other behaviour that seems odd, please double check with the code of the unit tests. If something still does not make sense, let us know by starting a discussion or by opening an issue here.

License

Release under the MIT License. (see LICENSE)

QA

Codacy Badge

go-net's People

Contributors

atc0005 avatar beyer-stefan avatar

Stargazers

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

Watchers

 avatar  avatar

Forkers

atc0005

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.