Giter Club home page Giter Club logo

libhosty's People

Contributors

areyoulazy avatar

Stargazers

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

Watchers

 avatar  avatar

libhosty's Issues

Issue: Action Test fails

Describe the bug
go test -v ./... fails

To Reproduce
Steps to reproduce the behavior:

  1. Go in Actions
  2. Rerun the build

Expected behavior
Test should pass

Issue: Handle hosts file limitations

Describe the bug
We should take care about hosts file limitations as described in https://documents.uow.edu.au/~blane/netapp/ontap/nag/networking/concept/c_oc_netw_maintaining_host_file_limits.html

Particular attention to points

  • 1: Maximum line size is 256.
  • 3: Maximum domain name length is 256.
  • 4: Maximum search domains limit is 6. The total number of characters for all search domains cannot exceed 256.

To Reproduce
Steps to reproduce the behavior:
If you add more than 6 hostnames to a line, other hostnames are not recognized by the system

Expected behavior
The 7th hostname should automatically create a new line

Issue: Panic on line deletion

Describe the bug
As mentioned here there's a panic on line deletion.
Panic occurs if there's no newline at the end of the file and you try to delete line by hostname.

To Reproduce
Steps to reproduce the behavior:

  1. Delete last empty line from hosts file by hand
  2. Use hosty to delete a line by hostname
  3. Panic

Expected behavior
As per deletion-by-ip, deletion should occur even without empty lines at the end of the file

Error adding same hostname if it is the last in the previous entry

Let's say I've an entry like:
1.1.1.1 my.dns

If I add an entry like
2.2.2.2 my.dns

the library goes in out-of-bound trying to remove the hostname from the previous entry
This goes well if the 1st entry has more than 1 hostname, like
1.1.1.1 my.dns my.second.dns

Line is not parsed if added with tabs instead of spaces

If I manually add a new line to the hosts file in this format:
[ip.ad.dre.ss]\t\t[hostname]\t\t[#comment]
The line is parsed as Comment and not ADDRESS
If the same line is added with the format
[ip.ad.dre.ss]\s\s\s\s\s\s\s\s[hostname]\s\s\s\s\s\s\s\s[#comment]
The line is correctly parsed as ADDRESS

Issue: new lines with extra character

Describe the bug
Lines added by this library has an extra \t character you can see in hosty output as described here: areYouLazy/hosty#2

To Reproduce
Steps to reproduce the behavior:

  1. Add a line with this library (or use hosty
  2. Add a new line by hand
  3. Print lines to CLI to show the extra \t character

Expected behavior
New lines should not add extra characters, also considering we can't have lines with infinite length

Add Remove Actions by Elements

Is your feature request related to a problem? Please describe.

Support Remove by various elements

Describe the solution you'd like

    hostsFile.RemoveByIP
    hostsFile.RemoveByAddress
    hostsFile.RemoveByHostname

Issue: Invalid raw after comment/uncomment

Describe the bug

After a Comment/Uncomment action the raw version of the line is outdated

To Reproduce

Steps to reproduce the behavior:

  1. Load file
  2. Comment/uncomment a row
  3. Save file to disk
  4. check line.Raw and compare with the actual file

Expected behavior

line.Raw should output the correct representation of the line

Issue: Handle multiple lines

Describe the bug

Since there's no limitations in how many rows with the same IP or FQDN can be in the file, Add/Comment/Uncomment functions should not be limited to the first match

To Reproduce

    hostsFile.GetHostsFileLineByIP // returns 1 entry even if there are more lines with the same IP

Expected behavior

There should be a way to get all the lines with the same IP/FQDN

Support for query with regexp

Is your feature request related to a problem? Please describe.

It would be useful to be able to query by regexp (aka wildcard domains)

Describe the solution you'd like

    // hostsFile.GetHostsFileLinesByHostnameAsRegexp("*.mydomain.ltd")
    hostsFile.GetHostsFileLinesByHostnameAsRegexp(reg string) []*libhosty.HostsFileLine {}

Issue: Honor glibc HOSTALIASES env

Describe the bug

We should honor the env variable defined by glibc as described here

To Reproduce

  1. export the env HOSTALIASES with a custom hosts file
  2. the library will pick up the default /etc/hosts file

Expected behavior

The library should pick up the file defined in the HOSTALIASES variable

Add support for bulk actions

Is your feature request related to a problem? Please describe.

Bulk action is defined as a query with more parameters of the same type

Describe the solution you'd like

    hostsFile.BulkGetHostsFileLinesByIPs(ip1, ip2, ip3)
    hostsFile.BulkGetHostsFileLinesByAddresses(address1, address2, address3)
    hostsFile.BulkGetHostsFileLinesByHostnames(hostname1, hostname2, hostname3)

Add Support for Bulk Actions

Is your feature request related to a problem? Please describe.

Add support for bulk actions on multiple lines

Describe the solution you'd like

    hostsFile.BulkCommentByIP
    hostsFile.BulkCommentByAddress
    hostsFile.BulkCommentByHostname

    hostsFile.BulkUncommentByIP
    hostsFile.BulkUncommentByAddress
    hostsFile.BulkUncommentByHostname

    hostsFile.BulkRemoveByIP
    hostsFile.BulkRemoveByAddress
    hostsFile.BulkRemoveByHostname

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.