| Age | Commit message (Collapse) | Author |
|
With help of spdxconv tool [1], we able to bulk update all files license
and copyright format to comply with SPDX formats.
[1] https://kilabit.info/project/spdxconv/
|
|
Go 1.22 now support for-range on numeric value.
|
|
|
|
Putting "html" under "net" package make no sense.
Another reason is to make the package flat under "lib/" directory.
|
|
HTTP request now implicitly create request with context.
Any false positive related to not closing HTTP response body has been
annotated with "nolint:bodyclose".
In the example code, use consistent "// Output:" comment format, by
prefixing with single space.
Any comment on code now also prefixing with single space.
An error returned without variables now use [errors.New] instead of
[fmt.Errorf].
Any error returned using [fmt.Errorf] now wrapped using "%w" instead of
"%s".
Also, replace error checking using [errors.Is] or [errors.As], instead
of using equal/not-equal operator.
Any statement like "x = x OP y" now replaced with "x OP= y".
Also, swap statement is simplified using "x, y = y, x".
Any switch statement with single case now replaced with if-condition.
Any call to defer on function or program that call [os.Exit], now
replaced by calling the deferred function directly.
Any if-else condition now replaced with switch statement, if possible.
|
|
Instead of annotating the lines that caught by linters, fix it to comply
with the recommendations.
This causes several breaking changes, especially related to naming,
* api/slack: [Message.IconUrl] become [Message.IconURL]
* lib/dns: DefaultSoaMinumumTtl become DefaultSoaMinimumTTL
* lib/email: [Message.SetBodyHtml] become [Message.SetBodyHTML]
* lib/http: [Client.GenerateHttpRequest] become
[Client.GenerateHTTPRequest]
* lib/http: [ClientOptions.ServerUrl] become [ClientOptions.ServerURL]
* lib/http: [EndpointRequest.HttpWriter] become
[EndpointRequest.HTTPWriter]
* lib/http: [EndpointRequest.HttpRequest] become
[EndpointRequest.HTTPRequest]
* lib/http: [ServerOptions.EnableIndexHtml] become
[ServerOptions.EnableIndexHTML]
* lib/http: [SSEConn.HttpRequest] become [SSEConn.HTTPRequest]
* lib/smtp: [ClientOptions.ServerUrl] become [ClientOptions.ServerURL]
* lib/ssh/sftp: [FileAttrs.SetUid] become [FileAttrs.SetUID]
* lib/ssh/sftp: [FileAttrs.Uid] become [FileAttrs.UID]
|
|
There are several reasons that why we move from github.com.
First, related to the name of package.
We accidentally name the package with "share" a common word in English
that does not reflect the content of repository.
By moving to other repository, we can rename it to better and unique
name, in this "pakakeh.go".
Pakakeh is Minang word for tools, and ".go" suffix indicate that the
repository related to Go programming language.
Second, supporting open source.
The new repository is hosted under sourcehut.org, the founder is known
to support open source, and all their services are licensed under AGPL,
unlike GitHub that are closed sources.
Third, regarding GitHub CoPilot.
The GitHub Terms of Service [1], allow any public content that are hosted
there granted them to parse the content.
On one side, GitHub helps and flourish the open source, but on another
side have an issues regarding scraping the copyleft license [2].
[1]: https://docs.github.com/en/site-policy/github-terms/github-terms-of-service#4-license-grant-to-us
[2]: https://githubcopilotinvestigation.com
|
|
There are some reports that I disagree with revive, in example, code
should not declare the type after variables.
In my opinion, on some cases, declaring the type make the code more
readable and explicit.
Since I did not want to add new configuration file, we changes it and
follow revive for now.
|
|
The Timeout field in net.Dialer sometimes does not have any effect.
In the for-loop, we expect that each Dial at least consume 100 ms
before returning an error.
Turns out, on several occasion, the loop run too quickly, less than the
passed timeout.
This is probably because the listening address has not been
active yet and we run it in the same machine, the OS (or Go?) return
immediately without waiting for timeout.
|
|
The Read method read packet from raw connection.
If the conn parameter is nil it will return [net.ErrClosed].
The bufsize parameter set the size of buffer for each read operation,
default to 1024 if not set or invalid (less than 0 or greater than
65535).
The timeout parameter set how long to wait for data before considering
it as failed.
If its not set, less or equal to 0, it will wait forever.
If no data received and timeout is set, it will return [ErrReadTimeout].
If there is data received and connection closed at the same time, it will
return the data first without error.
The subsequent Read will return empty packet with [ErrClosed].
Signed-off-by: Shulhan <ms@kilabit.info>
|
|
The WriteTo should return int64 not int.
|
|
The realignment reduce the cost of the following struct,
* ResolvConf: from 96 to 56 bytes (-40)
* struct in TestResolvConf_Init: from 56 to 48 bytes (-8)
|
|
Previously, the Pool's WaitRead and WaitReadEVent methods return list of
file descriptor (fd) and keeps the fd in the pool.
In case we want to process the returned fd concurrently, by running it
in different goroutine, the next call WaitRead may return the same fd
if its goroutine not fast enought to read from fd.
This changes fix this issue by removing list of fd from poll and set the
fd flag to blocking mode again after returning it from WaitRead or
WaitReadEvent.
This changes also remove the ReregisterRead and ReregisterEvent methods
since it is not applicable anymore.
|
|
The PollEvent contains file descriptor and the underlying event
based on OS, unix.EpollEvent on Linux or unix.Kevent_t on BSD.
The Poll interface provides two APIs to works with PollEvent,
WaitReadEvents that return list of PollEvent ready for read, and
ReregisterEvent to register the event back to poll (only for Linux).
|
|
In case the user of poll changes the fd flags to block for reading
or writing and forgot to set it non-block again, this may cause an issue
on the poll.
|
|
The maxQueue define the number of events that can be read from poll at
one time.
Using 128 seems to small for high throughput networks.
Increasing this number also increase the memory consumed by process.
Maybe later we can export this function as option when creating poll.
|
|
WaitAlive try to connect to network at address until timeout reached.
If connection cannot established it will return an error.
Unlike [net.DialTimeout], this function will retry not returning an error
immediately if the address has not ready yet.
|
|
This is to prevent non-exported functions, type, or variables being used
in example.
|
|
The lib/io#Reader will be deprecated and replaced with lib/bytes#Parser
in the future.
|
|
The WriteTo method write the ResolvConf as text.
|
|
Previously, PopulateQuery only add the passed dname if the number of dots
is greater than 0.
After inspecting the result from dig and getenv, the dots seems does not
affect the query.
For example, if we have A record for domain "kilabit", both of those tools
query name "kilabit" without adding local domain or domain in search.
|
|
Instead of using bytes.Replace, three times, iterate the plain text
manually to clean up the white and multiple spaces.
Benchmark result,
name old time/op new time/op delta
Sanitize-8 4.27µs ±10% 2.64µs ±13% -38.21% (p=0.000 n=10+10)
name old alloc/op new alloc/op delta
Sanitize-8 4.84kB ± 0% 4.45kB ± 0% -7.94% (p=0.000 n=10+10)
name old allocs/op new allocs/op delta
Sanitize-8 13.0 ± 0% 6.0 ± 0% -53.85% (p=0.000 n=10+10)
|
|
Since the sanitize package only contains HTML function, and the html
package already exist, we move the function into html package.
|
|
While at it, minimize allocation by using the input []byte as
output.
|
|
Given an input string, The NormalizeForID normalize it to HTML ID.
The normalization follow Mozilla specification [1] rules,
- it must not contain whitespace (spaces, tabs etc.),
- only ASCII letters, digits, '_', and '-' should be used, and
- it should start with a letter.
An empty string is equal to "_".
Any other unknown characters will be replaced with '_'.
If the input does not start with letter, it will be prefixed with
'_', unless it start with '_'.
[1] https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/id.
|
|
|
|
Given a domain name to be resolved, the PopulateQuery generate
list of names to be queried based on registered Domain and Search
in the resolv.conf file.
The domain name itself will be on top of the list if its contains any
dot.
|
|
Using pointer to slice on method or function is not a Go idiom.
It is created when I still new to Go.
|
|
Previously, the test.Assert and test.AssertBench functions has the
boolean parameter to print the stack trace of test in case its not equal.
Since this parameter is not mandatory and its usually always set to
"true", we remove them from function signature to simplify the call
to Assert and AssertBench.
|
|
Previously, if the address is an IP address the returned value is empty,
for example "127.0.0.1" will return empty host but with non-nil IP and
port.
This changes always return the host either as host name (the same as
paremeter) or valid IP address.
|
|
|
|
|
|
|
|
The NodeIterator have the method Next() that will return the first child
or the next sibling of current node, iteratively from top to bottom.
|
|
The x/net/html package currently only provide bare raw functionalities
to iterate tree, there is no check for empty node, and no function to
get attribute by name without looping it manually.
This package extends the package by adding methods to get node's attribute
by name, get the first non-empty child, and get the next non-empty sibling.
|
|
|
|
|
|
|
|
|
|
While at it, add copyright information.
|
|
This is the first implementation of (almost) generic polling.
The Poll currently only support the Read events from now, because the
most common use case is for handling multiple socket without using
goroutines.
|
|
This library previously part of bytes package. To make it bytes package
consistent (only working with slice of byte), we move all ASCII related
constants, variables, and functions into new package.
|
|
The valid syntax to suppress linter warnings is "//nolint:<name>" with
no space between comment and "nolint" and between ":". Also, we move the
placement of nolint directive to the top of statements for multiple
nolint in the same scope.
While at it, fix and supress some linter warnings.
|
|
This function only useful for expanding SPF macro "i" or when generating
query for DNS PTR.
|
|
Currently, the standard library does not provide a function to check if IP
is IPv4 or IPv6. This is a naive implementation that check IP version
based on dot or colon.
|
|
Fully Qualified Domain Name (FQDN) is a domain name that have two or
more labels.
|
|
Previously, if parameter address in ParseIPPort is hostname instead of
IP address it will return an error.
This commit change the return value to hostname without any error. So,
instead of error it will return the hostname in address.
This changes affect dns library when creating NewTCPClient and
NewUDPClient.
|
|
Most of the warnings caused by update to linter which cause global
variables declared with grouping "( ... )" and that has been suppressed,
are become false-positive again.
|
|
|
|
|