areyoulazy / libhosty Goto Github PK
View Code? Open in Web Editor NEWA pure golang library to manage /etc/hosts files
License: Apache License 2.0
A pure golang library to manage /etc/hosts files
License: Apache License 2.0
Describe the bug
go test -v ./... fails
To Reproduce
Steps to reproduce the behavior:
Expected behavior
Test should pass
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
Describe the bug
We should honor the env variable defined by glibc as described here
To Reproduce
Expected behavior
The library should pick up the file defined in the HOSTALIASES variable
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)
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
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
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
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
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
Using it out of the box one gets:
panic: open /etc/hosts: permission denied
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:
Expected behavior
New lines should not add extra characters, also considering we can't have lines with infinite length
Also we should use strings.TrimPrefix()
instead of the actual curLine.Trimed[1:]
to remove the '#' prefix
Originally posted by @areYouLazy in #6 (comment)
Describe the bug
After a Comment/Uncomment action the raw version of the line is outdated
To Reproduce
Steps to reproduce the behavior:
Expected behavior
line.Raw should output the correct representation of the line
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:
Expected behavior
As per deletion-by-ip, deletion should occur even without empty lines at the end of the file
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
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 {}
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.